| author | |
| committer | |
| log | bd926e5ea0f9b27677a270a4e8253b6a6f77379c |
| tree | 463e9a1c77ad8cf0d9dce57ee4dbb47b9c62c0d8 |
| parent | 3ff05b79b94f46c0c3f75c7b54a2b0a66840cdf8 |
This is just a temp addition until I figure out how to tweak
the stage2 test harness to add the ability to test the linker too.7 files changed, 55 insertions(+), 0 deletions(-)
test/standalone.zig+4| ... | @@ -34,6 +34,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void { | ... | @@ -34,6 +34,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 34 | cases.addBuildFile("test/standalone/link_frameworks/build.zig", .{ | 34 | cases.addBuildFile("test/standalone/link_frameworks/build.zig", .{ |
| 35 | .requires_macos_sdk = true, | 35 | .requires_macos_sdk = true, |
| 36 | }); | 36 | }); |
| 37 | cases.addBuildFile("test/standalone/link_common_symbols_alignment/build.zig", .{}); | ||
| 38 | if (builtin.os.tag == .macos) { | ||
| 39 | cases.addBuildFile("test/standalone/link_import_tls_dylib/build.zig", .{}); | ||
| 40 | } | ||
| 37 | cases.addBuildFile("test/standalone/issue_339/build.zig", .{}); | 41 | cases.addBuildFile("test/standalone/issue_339/build.zig", .{}); |
| 38 | cases.addBuildFile("test/standalone/issue_8550/build.zig", .{}); | 42 | cases.addBuildFile("test/standalone/issue_8550/build.zig", .{}); |
| 39 | cases.addBuildFile("test/standalone/issue_794/build.zig", .{}); | 43 | cases.addBuildFile("test/standalone/issue_794/build.zig", .{}); |
test/standalone/link_common_symbols_alignment/a.c created+2| ... | @@ -0,0 +1,2 @@ | ||
| 1 | int foo; | ||
| 2 | __attribute__((aligned(4096))) int bar; | ||
test/standalone/link_common_symbols_alignment/build.zig created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | const Builder = @import("std").build.Builder; | ||
| 2 | |||
| 3 | pub fn build(b: *Builder) void { | ||
| 4 | const mode = b.standardReleaseOptions(); | ||
| 5 | |||
| 6 | const lib_a = b.addStaticLibrary("a", null); | ||
| 7 | lib_a.addCSourceFiles(&.{"a.c"}, &.{"-fcommon"}); | ||
| 8 | lib_a.setBuildMode(mode); | ||
| 9 | |||
| 10 | const test_exe = b.addTest("main.zig"); | ||
| 11 | test_exe.setBuildMode(mode); | ||
| 12 | test_exe.linkLibrary(lib_a); | ||
| 13 | |||
| 14 | const test_step = b.step("test", "Test it"); | ||
| 15 | test_step.dependOn(&test_exe.step); | ||
| 16 | } | ||
test/standalone/link_common_symbols_alignment/main.zig created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | extern var foo: i32; | ||
| 4 | extern var bar: i32; | ||
| 5 | |||
| 6 | test { | ||
| 7 | try std.testing.expect(@ptrToInt(&foo) % 4 == 0); | ||
| 8 | try std.testing.expect(@ptrToInt(&bar) % 4096 == 0); | ||
| 9 | } | ||
test/standalone/link_import_tls_dylib/a.c created+1| ... | @@ -0,0 +1 @@ | ||
| 1 | _Thread_local int a; | ||
test/standalone/link_import_tls_dylib/build.zig created+16| ... | @@ -0,0 +1,16 @@ | ||
| 1 | const Builder = @import("std").build.Builder; | ||
| 2 | |||
| 3 | pub fn build(b: *Builder) void { | ||
| 4 | const mode = b.standardReleaseOptions(); | ||
| 5 | |||
| 6 | const lib = b.addSharedLibrary("a", null, b.version(1, 0, 0)); | ||
| 7 | lib.setBuildMode(mode); | ||
| 8 | lib.addCSourceFile("a.c", &.{}); | ||
| 9 | |||
| 10 | const test_exe = b.addTest("main.zig"); | ||
| 11 | test_exe.setBuildMode(mode); | ||
| 12 | test_exe.linkLibrary(lib); | ||
| 13 | |||
| 14 | const test_step = b.step("test", "Test it"); | ||
| 15 | test_step.dependOn(&test_exe.step); | ||
| 16 | } | ||
test/standalone/link_import_tls_dylib/main.zig created+7| ... | @@ -0,0 +1,7 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | extern threadlocal var a: i32; | ||
| 4 | |||
| 5 | test { | ||
| 6 | try std.testing.expect(a == 0); | ||
| 7 | } | ||