macho: add smoke test for re-exports in static libs

This commit is contained in:
Jakub Konka 2023-08-16 12:19:34 +02:00
parent 787e755a2f
commit 573bb77ab6
4 changed files with 54 additions and 0 deletions

View File

@ -156,6 +156,10 @@ pub const cases = [_]Case{
.build_root = "test/link/macho/pagezero",
.import = @import("link/macho/pagezero/build.zig"),
},
.{
.build_root = "test/link/macho/reexports",
.import = @import("link/macho/reexports/build.zig"),
},
.{
.build_root = "test/link/macho/search_strategy",
.import = @import("link/macho/search_strategy/build.zig"),

View File

@ -0,0 +1,7 @@
const x: i32 = 42;
export fn foo() i32 {
return x;
}
comptime {
@export(foo, .{ .name = "bar", .linkage = .Strong });
}

View File

@ -0,0 +1,38 @@
const std = @import("std");
pub const requires_symlinks = true;
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;
add(b, test_step, .Debug);
add(b, test_step, .ReleaseFast);
add(b, test_step, .ReleaseSmall);
add(b, test_step, .ReleaseSafe);
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
const target: std.zig.CrossTarget = .{ .os_tag = .macos };
const lib = b.addStaticLibrary(.{
.name = "a",
.root_source_file = .{ .path = "a.zig" },
.optimize = optimize,
.target = target,
});
const exe = b.addExecutable(.{
.name = "test",
.optimize = optimize,
.target = target,
});
exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
exe.linkLibrary(lib);
exe.linkLibC();
const run = b.addRunArtifact(exe);
run.skip_foreign_checks = true;
run.expectExitCode(0);
test_step.dependOn(&run.step);
}

View File

@ -0,0 +1,5 @@
extern int foo();
extern int bar();
int main() {
return bar() - foo();
}