| author | |
| committer | |
| log | 573bb77ab6f4f00753bb257314d8115cbaac17ae |
| tree | 4f0738c27a8ff75d7d25217dd8a92662fb93c564 |
| parent | 787e755a2f36660b5bc22f2a3a5d051a8c34445f |
4 files changed, 54 insertions(+), 0 deletions(-)
test/link.zig+4| ... | ... | @@ -156,6 +156,10 @@ pub const cases = [_]Case{ |
| 156 | 156 | .build_root = "test/link/macho/pagezero", |
| 157 | 157 | .import = @import("link/macho/pagezero/build.zig"), |
| 158 | 158 | }, |
| 159 | .{ | |
| 160 | .build_root = "test/link/macho/reexports", | |
| 161 | .import = @import("link/macho/reexports/build.zig"), | |
| 162 | }, | |
| 159 | 163 | .{ |
| 160 | 164 | .build_root = "test/link/macho/search_strategy", |
| 161 | 165 | .import = @import("link/macho/search_strategy/build.zig"), |
test/link/macho/reexports/a.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | const x: i32 = 42; | |
| 2 | export fn foo() i32 { | |
| 3 | return x; | |
| 4 | } | |
| 5 | comptime { | |
| 6 | @export(foo, .{ .name = "bar", .linkage = .Strong }); | |
| 7 | } |
test/link/macho/reexports/build.zig created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub const requires_symlinks = true; | |
| 4 | ||
| 5 | pub fn build(b: *std.Build) void { | |
| 6 | const test_step = b.step("test", "Test it"); | |
| 7 | b.default_step = test_step; | |
| 8 | ||
| 9 | add(b, test_step, .Debug); | |
| 10 | add(b, test_step, .ReleaseFast); | |
| 11 | add(b, test_step, .ReleaseSmall); | |
| 12 | add(b, test_step, .ReleaseSafe); | |
| 13 | } | |
| 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | |
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | |
| 17 | ||
| 18 | const lib = b.addStaticLibrary(.{ | |
| 19 | .name = "a", | |
| 20 | .root_source_file = .{ .path = "a.zig" }, | |
| 21 | .optimize = optimize, | |
| 22 | .target = target, | |
| 23 | }); | |
| 24 | ||
| 25 | const exe = b.addExecutable(.{ | |
| 26 | .name = "test", | |
| 27 | .optimize = optimize, | |
| 28 | .target = target, | |
| 29 | }); | |
| 30 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 31 | exe.linkLibrary(lib); | |
| 32 | exe.linkLibC(); | |
| 33 | ||
| 34 | const run = b.addRunArtifact(exe); | |
| 35 | run.skip_foreign_checks = true; | |
| 36 | run.expectExitCode(0); | |
| 37 | test_step.dependOn(&run.step); | |
| 38 | } |
test/link/macho/reexports/main.c created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | extern int foo(); | |
| 2 | extern int bar(); | |
| 3 | int main() { | |
| 4 | return bar() - foo(); | |
| 5 | } |