mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
macho: add smoke test for re-exports in static libs
This commit is contained in:
parent
787e755a2f
commit
573bb77ab6
@ -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"),
|
||||
|
7
test/link/macho/reexports/a.zig
Normal file
7
test/link/macho/reexports/a.zig
Normal file
@ -0,0 +1,7 @@
|
||||
const x: i32 = 42;
|
||||
export fn foo() i32 {
|
||||
return x;
|
||||
}
|
||||
comptime {
|
||||
@export(foo, .{ .name = "bar", .linkage = .Strong });
|
||||
}
|
38
test/link/macho/reexports/build.zig
Normal file
38
test/link/macho/reexports/build.zig
Normal 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);
|
||||
}
|
5
test/link/macho/reexports/main.c
Normal file
5
test/link/macho/reexports/main.c
Normal file
@ -0,0 +1,5 @@
|
||||
extern int foo();
|
||||
extern int bar();
|
||||
int main() {
|
||||
return bar() - foo();
|
||||
}
|
Loading…
Reference in New Issue
Block a user