authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-15 11:34:47+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log933231868ab37c67af53ab67aaf1355b5f50413a
tree4220e9773c7d8c8ed0bc70478774e97500a6936c
parent7dc6900018f78d7514926853d35087d5b205109f

test/link/macho: test re-exports in zig


1 files changed, 30 insertions(+), 0 deletions(-)

test/link/macho.zig+30
...@@ -28,6 +28,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {...@@ -28,6 +28,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
28 macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target }));28 macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target }));
29 macho_step.dependOn(testNoExportsDylib(b, .{ .target = default_target }));29 macho_step.dependOn(testNoExportsDylib(b, .{ .target = default_target }));
30 macho_step.dependOn(testPagezeroSize(b, .{ .target = default_target }));30 macho_step.dependOn(testPagezeroSize(b, .{ .target = default_target }));
31 macho_step.dependOn(testReexportsZig(b, .{ .target = default_target }));
31 macho_step.dependOn(testRelocatable(b, .{ .target = default_target }));32 macho_step.dependOn(testRelocatable(b, .{ .target = default_target }));
32 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));33 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));
33 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));34 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
...@@ -897,6 +898,35 @@ fn testPagezeroSize(b: *Build, opts: Options) *Step {...@@ -897,6 +898,35 @@ fn testPagezeroSize(b: *Build, opts: Options) *Step {
897 return test_step;898 return test_step;
898}899}
899900
901fn testReexportsZig(b: *Build, opts: Options) *Step {
902 const test_step = addTestStep(b, "macho-reexports-zig", opts);
903
904 const lib = addStaticLibrary(b, opts, .{ .name = "a", .zig_source_bytes =
905 \\const x: i32 = 42;
906 \\export fn foo() i32 {
907 \\ return x;
908 \\}
909 \\comptime {
910 \\ @export(foo, .{ .name = "bar", .linkage = .Strong });
911 \\}
912 });
913
914 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
915 \\extern int foo();
916 \\extern int bar();
917 \\int main() {
918 \\ return bar() - foo();
919 \\}
920 });
921 exe.linkLibrary(lib);
922
923 const run = addRunArtifact(exe);
924 run.expectExitCode(0);
925 test_step.dependOn(&run.step);
926
927 return test_step;
928}
929
900fn testRelocatable(b: *Build, opts: Options) *Step {930fn testRelocatable(b: *Build, opts: Options) *Step {
901 const test_step = addTestStep(b, "macho-relocatable", opts);931 const test_step = addTestStep(b, "macho-relocatable", opts);
902932