authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-28 15:10:56-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-29 05:15:35-04:00
log20ade4ce7f4e738344dbf370d5df769d2a979908
tree986fb2597b8931405fe3dbf5a84d2ba0cafc4229
parentf133bcba9f75562c324cced5385356ac2e08ae43

tests: change some x86_64 backend targets to pic for more coverage


1 files changed, 11 insertions(+), 2 deletions(-)

test/tests.zig+11-2
......@@ -28,6 +28,7 @@ const TestTarget = struct {
2828 single_threaded: ?bool = null,
2929 use_llvm: ?bool = null,
3030 use_lld: ?bool = null,
31 force_pic: ?bool = null,
3132};
3233
3334const test_targets = blk: {
......@@ -103,6 +104,7 @@ const test_targets = blk: {
103104 },
104105 .use_llvm = false,
105106 .use_lld = false,
107 .force_pic = true,
106108 },
107109 .{
108110 .target = .{
......@@ -494,6 +496,7 @@ const CAbiTarget = struct {
494496 target: CrossTarget = .{},
495497 use_llvm: ?bool = null,
496498 use_lld: ?bool = null,
499 force_pic: ?bool = null,
497500 c_defines: []const []const u8 = &.{},
498501};
499502
......@@ -536,6 +539,7 @@ const c_abi_targets = [_]CAbiTarget{
536539 },
537540 .use_llvm = false,
538541 .use_lld = false,
542 .force_pic = true,
539543 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
540544 },
541545 .{
......@@ -1118,6 +1122,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
11181122 .use_lld = test_target.use_lld,
11191123 .zig_lib_dir = .{ .path = "lib" },
11201124 });
1125 these_tests.force_pic = test_target.force_pic;
11211126 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
11221127 const backend_suffix = if (test_target.use_llvm == true)
11231128 "-llvm"
......@@ -1128,6 +1133,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
11281133 else
11291134 "";
11301135 const use_lld = if (test_target.use_lld == false) "-no-lld" else "";
1136 const use_pic = if (test_target.force_pic == true) "-pic" else "";
11311137
11321138 these_tests.addIncludePath(.{ .path = "test" });
11331139
......@@ -1136,7 +1142,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
11361142 these_tests.stack_size = 2 * 1024 * 1024;
11371143 }
11381144
1139 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}", .{
1145 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}", .{
11401146 options.name,
11411147 triple_txt,
11421148 model_txt,
......@@ -1145,6 +1151,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
11451151 single_threaded_suffix,
11461152 backend_suffix,
11471153 use_lld,
1154 use_pic,
11481155 });
11491156
11501157 if (test_target.target.ofmt == std.Target.ObjectFormat.c) {
......@@ -1240,7 +1247,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
12401247 }
12411248
12421249 const test_step = b.addTest(.{
1243 .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}", .{
1250 .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}{s}", .{
12441251 c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"),
12451252 c_abi_target.target.getCpuModel().name,
12461253 @tagName(optimize_mode),
......@@ -1253,6 +1260,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
12531260 else
12541261 "",
12551262 if (c_abi_target.use_lld == false) "-no-lld" else "",
1263 if (c_abi_target.force_pic == true) "-pic" else "",
12561264 }),
12571265 .root_source_file = .{ .path = "test/c_abi/main.zig" },
12581266 .target = c_abi_target.target,
......@@ -1261,6 +1269,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
12611269 .use_llvm = c_abi_target.use_llvm,
12621270 .use_lld = c_abi_target.use_lld,
12631271 });
1272 test_step.force_pic = c_abi_target.force_pic;
12641273 if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) {
12651274 // TODO NativeTargetInfo insists on dynamically linking musl
12661275 // for some reason?