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 {
483483 else => false,
484484 };
485485 }
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 }
486496 };
487497
488498 pub const ObjectFormat = enum {
......@@ -1259,13 +1269,7 @@ pub const Target = struct {
12591269 };
12601270
12611271 pub fn getFloatAbi(self: Target) FloatAbi {
1262 return switch (self.abi) {
1263 .gnueabihf,
1264 .eabihf,
1265 .musleabihf,
1266 => .hard,
1267 else => .soft,
1268 };
1272 return self.abi.floatAbi();
12691273 }
12701274
12711275 pub fn hasDynamicLinker(self: Target) bool {
......@@ -1336,12 +1340,12 @@ pub const Target = struct {
13361340 const print = S.print;
13371341 const copy = S.copy;
13381342
1339 if (self.isAndroid()) {
1343 if (self.abi == .android) {
13401344 const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else "";
13411345 return print(&result, "/system/bin/linker{}", .{suffix});
13421346 }
13431347
1344 if (self.isMusl()) {
1348 if (self.abi.isMusl()) {
13451349 const is_arm = switch (self.cpu.arch) {
13461350 .arm, .armeb, .thumb, .thumbeb => true,
13471351 else => false,
......@@ -1351,7 +1355,7 @@ pub const Target = struct {
13511355 .armeb, .thumbeb => "armeb",
13521356 else => |arch| @tagName(arch),
13531357 };
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 "";
13551359 return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix });
13561360 }
13571361
......@@ -1373,7 +1377,7 @@ pub const Target = struct {
13731377 .armeb,
13741378 .thumb,
13751379 .thumbeb,
1376 => return copy(&result, switch (self.getFloatAbi()) {
1380 => return copy(&result, switch (self.abi.floatAbi()) {
13771381 .hard => "/lib/ld-linux-armhf.so.3",
13781382 else => "/lib/ld-linux.so.3",
13791383 }),
......@@ -1444,13 +1448,15 @@ pub const Target = struct {
14441448 => return result,
14451449 },
14461450
1447 // Operating systems in this list have been verified as not having a standard
1448 // dynamic linker path.
1449 .freestanding,
14501451 .ios,
14511452 .tvos,
14521453 .watchos,
14531454 .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,
14541460 .uefi,
14551461 .windows,
14561462 .emscripten,
lib/std/zig/cross_target.zig+9-1
......@@ -606,12 +606,20 @@ pub const CrossTarget = struct {
606606 const os_match = os_tag == Target.current.os.tag;
607607
608608 // 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.
609611 if (os_match and cpu_arch == Target.current.cpu.arch) {
610612 // 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.
612613 if (self.os_tag == null) {
613614 return .native;
614615 }
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 }
615623 }
616624
617625 // 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 {
145145 }
146146
147147 {
148 var case = ctx.exe("hello world", macosx_x64);
148 var case = ctx.exe("hello world with updates", macosx_x64);
149149 case.addError("", &[_][]const u8{":1:1: error: no entry point found"});
150150
151151 // Incorrect return type
......@@ -183,7 +183,7 @@ pub fn addCases(ctx: *TestContext) !void {
183183 \\ );
184184 \\ unreachable;
185185 \\}
186 ,
186 ,
187187 "Hello, World!\n",
188188 );
189189 // Now change the message only
......@@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {
993993 \\ );
994994 \\ unreachable;
995995 \\}
996 ,
996 ,
997997 "Hello, World!\n",
998998 );
999999 try case.files.append(.{