authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-15 16:48:44-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-15 16:48:44-07:00
loge17297102a14620c8d53a3d1f4137314880a28ce
tree3e30f4bfa2ea9db5f28e7b11cc80bc5313ed00b0
parent8c4031fd87c385ede55834130cb05a1ac04b07ac
parentd91e75f5cacebd80f574993160839f8af21a5984

Merge branch 'kubkon-enable-stage2-macos-tests'

closes #6661

3 files changed, 32 insertions(+), 18 deletions(-)

lib/std/target.zig+20-14
...@@ -483,6 +483,16 @@ pub const Target = struct {...@@ -483,6 +483,16 @@ pub const Target = struct {
483 else => false,483 else => false,
484 };484 };
485 }485 }
486
487 pub fn floatAbi(abi: Abi) FloatAbi {
488 return switch (abi) {
489 .gnueabihf,
490 .eabihf,
491 .musleabihf,
492 => .hard,
493 else => .soft,
494 };
495 }
486 };496 };
487497
488 pub const ObjectFormat = enum {498 pub const ObjectFormat = enum {
...@@ -1259,13 +1269,7 @@ pub const Target = struct {...@@ -1259,13 +1269,7 @@ pub const Target = struct {
1259 };1269 };
12601270
1261 pub fn getFloatAbi(self: Target) FloatAbi {1271 pub fn getFloatAbi(self: Target) FloatAbi {
1262 return switch (self.abi) {1272 return self.abi.floatAbi();
1263 .gnueabihf,
1264 .eabihf,
1265 .musleabihf,
1266 => .hard,
1267 else => .soft,
1268 };
1269 }1273 }
12701274
1271 pub fn hasDynamicLinker(self: Target) bool {1275 pub fn hasDynamicLinker(self: Target) bool {
...@@ -1336,12 +1340,12 @@ pub const Target = struct {...@@ -1336,12 +1340,12 @@ pub const Target = struct {
1336 const print = S.print;1340 const print = S.print;
1337 const copy = S.copy;1341 const copy = S.copy;
13381342
1339 if (self.isAndroid()) {1343 if (self.abi == .android) {
1340 const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else "";1344 const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else "";
1341 return print(&result, "/system/bin/linker{}", .{suffix});1345 return print(&result, "/system/bin/linker{}", .{suffix});
1342 }1346 }
13431347
1344 if (self.isMusl()) {1348 if (self.abi.isMusl()) {
1345 const is_arm = switch (self.cpu.arch) {1349 const is_arm = switch (self.cpu.arch) {
1346 .arm, .armeb, .thumb, .thumbeb => true,1350 .arm, .armeb, .thumb, .thumbeb => true,
1347 else => false,1351 else => false,
...@@ -1351,7 +1355,7 @@ pub const Target = struct {...@@ -1351,7 +1355,7 @@ pub const Target = struct {
1351 .armeb, .thumbeb => "armeb",1355 .armeb, .thumbeb => "armeb",
1352 else => |arch| @tagName(arch),1356 else => |arch| @tagName(arch),
1353 };1357 };
1354 const arch_suffix = if (is_arm and self.getFloatAbi() == .hard) "hf" else "";1358 const arch_suffix = if (is_arm and self.abi.floatAbi() == .hard) "hf" else "";
1355 return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix });1359 return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix });
1356 }1360 }
13571361
...@@ -1373,7 +1377,7 @@ pub const Target = struct {...@@ -1373,7 +1377,7 @@ pub const Target = struct {
1373 .armeb,1377 .armeb,
1374 .thumb,1378 .thumb,
1375 .thumbeb,1379 .thumbeb,
1376 => return copy(&result, switch (self.getFloatAbi()) {1380 => return copy(&result, switch (self.abi.floatAbi()) {
1377 .hard => "/lib/ld-linux-armhf.so.3",1381 .hard => "/lib/ld-linux-armhf.so.3",
1378 else => "/lib/ld-linux.so.3",1382 else => "/lib/ld-linux.so.3",
1379 }),1383 }),
...@@ -1444,13 +1448,15 @@ pub const Target = struct {...@@ -1444,13 +1448,15 @@ pub const Target = struct {
1444 => return result,1448 => return result,
1445 },1449 },
14461450
1447 // Operating systems in this list have been verified as not having a standard
1448 // dynamic linker path.
1449 .freestanding,
1450 .ios,1451 .ios,
1451 .tvos,1452 .tvos,
1452 .watchos,1453 .watchos,
1453 .macos,1454 .macos,
1455 => return copy(&result, "/usr/lib/dyld"),
1456
1457 // Operating systems in this list have been verified as not having a standard
1458 // dynamic linker path.
1459 .freestanding,
1454 .uefi,1460 .uefi,
1455 .windows,1461 .windows,
1456 .emscripten,1462 .emscripten,
lib/std/zig/cross_target.zig+9-1
...@@ -606,12 +606,20 @@ pub const CrossTarget = struct {...@@ -606,12 +606,20 @@ pub const CrossTarget = struct {
606 const os_match = os_tag == Target.current.os.tag;606 const os_match = os_tag == Target.current.os.tag;
607607
608 // If the OS and CPU arch match, the binary can be considered native.608 // If the OS and CPU arch match, the binary can be considered native.
609 // TODO additionally match the CPU features. This `getExternalExecutor` function should
610 // be moved to std.Target and match any chosen target against the native target.
609 if (os_match and cpu_arch == Target.current.cpu.arch) {611 if (os_match and cpu_arch == Target.current.cpu.arch) {
610 // However, we also need to verify that the dynamic linker path is valid.612 // However, we also need to verify that the dynamic linker path is valid.
611 // TODO Until that is implemented, we prevent returning `.native` when the OS is non-native.
612 if (self.os_tag == null) {613 if (self.os_tag == null) {
613 return .native;614 return .native;
614 }615 }
616 // TODO here we call toTarget, a deprecated function, because of the above TODO about moving
617 // this code to std.Target.
618 const opt_dl = self.dynamic_linker.get() orelse self.toTarget().standardDynamicLinkerPath().get();
619 if (opt_dl) |dl| blk: {
620 std.fs.cwd().access(dl, .{}) catch break :blk;
621 return .native;
622 }
615 }623 }
616624
617 // If the OS matches, we can use QEMU to emulate a foreign architecture.625 // If the OS matches, we can use QEMU to emulate a foreign architecture.
test/stage2/test.zig+3-3
...@@ -145,7 +145,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -145,7 +145,7 @@ pub fn addCases(ctx: *TestContext) !void {
145 }145 }
146146
147 {147 {
148 var case = ctx.exe("hello world", macosx_x64);148 var case = ctx.exe("hello world with updates", macosx_x64);
149 case.addError("", &[_][]const u8{":1:1: error: no entry point found"});149 case.addError("", &[_][]const u8{":1:1: error: no entry point found"});
150150
151 // Incorrect return type151 // Incorrect return type
...@@ -183,7 +183,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -183,7 +183,7 @@ pub fn addCases(ctx: *TestContext) !void {
183 \\ );183 \\ );
184 \\ unreachable;184 \\ unreachable;
185 \\}185 \\}
186 ,186 ,
187 "Hello, World!\n",187 "Hello, World!\n",
188 );188 );
189 // Now change the message only189 // Now change the message only
...@@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {
993 \\ );993 \\ );
994 \\ unreachable;994 \\ unreachable;
995 \\}995 \\}
996 ,996 ,
997 "Hello, World!\n",997 "Hello, World!\n",
998 );998 );
999 try case.files.append(.{999 try case.files.append(.{