add standalone tests for the new linker bug fixes

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.
This commit is contained in:
Jakub Konka 2021-12-14 23:58:17 +01:00
parent 3ff05b79b9
commit bd926e5ea0
7 changed files with 55 additions and 0 deletions

View File

@ -34,6 +34,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
cases.addBuildFile("test/standalone/link_frameworks/build.zig", .{
.requires_macos_sdk = true,
});
cases.addBuildFile("test/standalone/link_common_symbols_alignment/build.zig", .{});
if (builtin.os.tag == .macos) {
cases.addBuildFile("test/standalone/link_import_tls_dylib/build.zig", .{});
}
cases.addBuildFile("test/standalone/issue_339/build.zig", .{});
cases.addBuildFile("test/standalone/issue_8550/build.zig", .{});
cases.addBuildFile("test/standalone/issue_794/build.zig", .{});

View File

@ -0,0 +1,2 @@
int foo;
__attribute__((aligned(4096))) int bar;

View File

@ -0,0 +1,16 @@
const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const lib_a = b.addStaticLibrary("a", null);
lib_a.addCSourceFiles(&.{"a.c"}, &.{"-fcommon"});
lib_a.setBuildMode(mode);
const test_exe = b.addTest("main.zig");
test_exe.setBuildMode(mode);
test_exe.linkLibrary(lib_a);
const test_step = b.step("test", "Test it");
test_step.dependOn(&test_exe.step);
}

View File

@ -0,0 +1,9 @@
const std = @import("std");
extern var foo: i32;
extern var bar: i32;
test {
try std.testing.expect(@ptrToInt(&foo) % 4 == 0);
try std.testing.expect(@ptrToInt(&bar) % 4096 == 0);
}

View File

@ -0,0 +1 @@
_Thread_local int a;

View File

@ -0,0 +1,16 @@
const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const lib = b.addSharedLibrary("a", null, b.version(1, 0, 0));
lib.setBuildMode(mode);
lib.addCSourceFile("a.c", &.{});
const test_exe = b.addTest("main.zig");
test_exe.setBuildMode(mode);
test_exe.linkLibrary(lib);
const test_step = b.step("test", "Test it");
test_step.dependOn(&test_exe.step);
}

View File

@ -0,0 +1,7 @@
const std = @import("std");
extern threadlocal var a: i32;
test {
try std.testing.expect(a == 0);
}