| ... | @@ -28,6 +28,7 @@ const TestTarget = struct { | ... | @@ -28,6 +28,7 @@ const TestTarget = struct { |
| 28 | single_threaded: ?bool = null, | 28 | single_threaded: ?bool = null, |
| 29 | use_llvm: ?bool = null, | 29 | use_llvm: ?bool = null, |
| 30 | use_lld: ?bool = null, | 30 | use_lld: ?bool = null, |
| | 31 | force_pic: ?bool = null, |
| 31 | }; | 32 | }; |
| 32 | | 33 | |
| 33 | const test_targets = blk: { | 34 | const test_targets = blk: { |
| ... | @@ -103,6 +104,7 @@ const test_targets = blk: { | ... | @@ -103,6 +104,7 @@ const test_targets = blk: { |
| 103 | }, | 104 | }, |
| 104 | .use_llvm = false, | 105 | .use_llvm = false, |
| 105 | .use_lld = false, | 106 | .use_lld = false, |
| | 107 | .force_pic = true, |
| 106 | }, | 108 | }, |
| 107 | .{ | 109 | .{ |
| 108 | .target = .{ | 110 | .target = .{ |
| ... | @@ -494,6 +496,7 @@ const CAbiTarget = struct { | ... | @@ -494,6 +496,7 @@ const CAbiTarget = struct { |
| 494 | target: CrossTarget = .{}, | 496 | target: CrossTarget = .{}, |
| 495 | use_llvm: ?bool = null, | 497 | use_llvm: ?bool = null, |
| 496 | use_lld: ?bool = null, | 498 | use_lld: ?bool = null, |
| | 499 | force_pic: ?bool = null, |
| 497 | c_defines: []const []const u8 = &.{}, | 500 | c_defines: []const []const u8 = &.{}, |
| 498 | }; | 501 | }; |
| 499 | | 502 | |
| ... | @@ -536,6 +539,7 @@ const c_abi_targets = [_]CAbiTarget{ | ... | @@ -536,6 +539,7 @@ const c_abi_targets = [_]CAbiTarget{ |
| 536 | }, | 539 | }, |
| 537 | .use_llvm = false, | 540 | .use_llvm = false, |
| 538 | .use_lld = false, | 541 | .use_lld = false, |
| | 542 | .force_pic = true, |
| 539 | .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"}, | 543 | .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"}, |
| 540 | }, | 544 | }, |
| 541 | .{ | 545 | .{ |
| ... | @@ -1118,6 +1122,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -1118,6 +1122,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1118 | .use_lld = test_target.use_lld, | 1122 | .use_lld = test_target.use_lld, |
| 1119 | .zig_lib_dir = .{ .path = "lib" }, | 1123 | .zig_lib_dir = .{ .path = "lib" }, |
| 1120 | }); | 1124 | }); |
| | 1125 | these_tests.force_pic = test_target.force_pic; |
| 1121 | const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; | 1126 | const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; |
| 1122 | const backend_suffix = if (test_target.use_llvm == true) | 1127 | const backend_suffix = if (test_target.use_llvm == true) |
| 1123 | "-llvm" | 1128 | "-llvm" |
| ... | @@ -1128,6 +1133,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -1128,6 +1133,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1128 | else | 1133 | else |
| 1129 | ""; | 1134 | ""; |
| 1130 | const use_lld = if (test_target.use_lld == false) "-no-lld" else ""; | 1135 | const use_lld = if (test_target.use_lld == false) "-no-lld" else ""; |
| | 1136 | const use_pic = if (test_target.force_pic == true) "-pic" else ""; |
| 1131 | | 1137 | |
| 1132 | these_tests.addIncludePath(.{ .path = "test" }); | 1138 | these_tests.addIncludePath(.{ .path = "test" }); |
| 1133 | | 1139 | |
| ... | @@ -1136,7 +1142,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -1136,7 +1142,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1136 | these_tests.stack_size = 2 * 1024 * 1024; | 1142 | these_tests.stack_size = 2 * 1024 * 1024; |
| 1137 | } | 1143 | } |
| 1138 | | 1144 | |
| 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}", .{ |
| 1140 | options.name, | 1146 | options.name, |
| 1141 | triple_txt, | 1147 | triple_txt, |
| 1142 | model_txt, | 1148 | model_txt, |
| ... | @@ -1145,6 +1151,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -1145,6 +1151,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1145 | single_threaded_suffix, | 1151 | single_threaded_suffix, |
| 1146 | backend_suffix, | 1152 | backend_suffix, |
| 1147 | use_lld, | 1153 | use_lld, |
| | 1154 | use_pic, |
| 1148 | }); | 1155 | }); |
| 1149 | | 1156 | |
| 1150 | if (test_target.target.ofmt == std.Target.ObjectFormat.c) { | 1157 | 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 | ... | @@ -1240,7 +1247,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 1240 | } | 1247 | } |
| 1241 | | 1248 | |
| 1242 | const test_step = b.addTest(.{ | 1249 | 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}", .{ |
| 1244 | c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"), | 1251 | c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"), |
| 1245 | c_abi_target.target.getCpuModel().name, | 1252 | c_abi_target.target.getCpuModel().name, |
| 1246 | @tagName(optimize_mode), | 1253 | @tagName(optimize_mode), |
| ... | @@ -1253,6 +1260,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S | ... | @@ -1253,6 +1260,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 1253 | else | 1260 | else |
| 1254 | "", | 1261 | "", |
| 1255 | if (c_abi_target.use_lld == false) "-no-lld" else "", | 1262 | if (c_abi_target.use_lld == false) "-no-lld" else "", |
| | 1263 | if (c_abi_target.force_pic == true) "-pic" else "", |
| 1256 | }), | 1264 | }), |
| 1257 | .root_source_file = .{ .path = "test/c_abi/main.zig" }, | 1265 | .root_source_file = .{ .path = "test/c_abi/main.zig" }, |
| 1258 | .target = c_abi_target.target, | 1266 | .target = c_abi_target.target, |
| ... | @@ -1261,6 +1269,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S | ... | @@ -1261,6 +1269,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 1261 | .use_llvm = c_abi_target.use_llvm, | 1269 | .use_llvm = c_abi_target.use_llvm, |
| 1262 | .use_lld = c_abi_target.use_lld, | 1270 | .use_lld = c_abi_target.use_lld, |
| 1263 | }); | 1271 | }); |
| | 1272 | test_step.force_pic = c_abi_target.force_pic; |
| 1264 | if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) { | 1273 | if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) { |
| 1265 | // TODO NativeTargetInfo insists on dynamically linking musl | 1274 | // TODO NativeTargetInfo insists on dynamically linking musl |
| 1266 | // for some reason? | 1275 | // for some reason? |