| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | | pub fn addCases(ctx: *@import("tests.zig").LinkContext) void { |
| 1 | pub fn addCases(ctx: *LinkContext) void { |
| 2 | 2 | if (ctx.includeTest("exports-static")) |prefix| { |
| 3 | 3 | const lib = ctx.addLibrary(.static, .{ |
| 4 | 4 | .name = "lib", |
| ... | ... | @@ -23,8 +23,46 @@ pub fn addCases(ctx: *@import("tests.zig").LinkContext) void { |
| 23 | 23 | }, .{}); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | if (ctx.includeTest("emit-static-lib")) |prefix| { |
| 27 | const obj1 = ctx.addObject(.{ |
| 28 | .name = "obj1", |
| 29 | .use_llvm = true, |
| 30 | .use_lld = true, |
| 31 | .c_source_bytes = |
| 32 | \\int foo1 = 1; |
| 33 | \\int foo2 = 2; |
| 34 | \\int fooBar() { |
| 35 | \\ return foo1 + foo2; |
| 36 | \\} |
| 37 | , |
| 38 | }); |
| 39 | const obj2 = ctx.addObject(.{ |
| 40 | .name = "this_is_a_long_name", |
| 41 | .zig_source_bytes = |
| 42 | \\fn weakFoo() callconv(.c) usize { |
| 43 | \\ return 42; |
| 44 | \\} |
| 45 | \\export var strong_foo: usize = 100; |
| 46 | \\comptime { |
| 47 | \\ @export(&weakFoo, .{ .name = "weakFoo", .linkage = .weak }); |
| 48 | \\ @export(&strong_foo, .{ .name = "strong_foo_alias", .linkage = .strong }); |
| 49 | \\} |
| 50 | , |
| 51 | }); |
| 26 | 52 | |
| 53 | const lib = ctx.addLibrary(.static, .{ .name = "lib" }); |
| 54 | lib.root_module.addObject(obj1); |
| 55 | lib.root_module.addObject(obj2); |
| 27 | 56 | |
| 57 | ctx.verifyObjdump(prefix, lib, &.{ |
| 58 | "-s", |
| 59 | "--elements=file-type", |
| 60 | "--symbols", |
| 61 | "--only-symbol=foo", |
| 62 | "--only-symbol=Foo", |
| 63 | }, .{}); |
| 64 | } |
| 28 | 65 | } |
| 29 | 66 | |
| 67 | const LinkContext = @import("tests.zig").LinkContext; |
| 30 | 68 | const std = @import("std"); |