mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
commit
e17297102a
@ -483,6 +483,16 @@ pub const Target = struct {
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn floatAbi(abi: Abi) FloatAbi {
|
||||
return switch (abi) {
|
||||
.gnueabihf,
|
||||
.eabihf,
|
||||
.musleabihf,
|
||||
=> .hard,
|
||||
else => .soft,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const ObjectFormat = enum {
|
||||
@ -1259,13 +1269,7 @@ pub const Target = struct {
|
||||
};
|
||||
|
||||
pub fn getFloatAbi(self: Target) FloatAbi {
|
||||
return switch (self.abi) {
|
||||
.gnueabihf,
|
||||
.eabihf,
|
||||
.musleabihf,
|
||||
=> .hard,
|
||||
else => .soft,
|
||||
};
|
||||
return self.abi.floatAbi();
|
||||
}
|
||||
|
||||
pub fn hasDynamicLinker(self: Target) bool {
|
||||
@ -1336,12 +1340,12 @@ pub const Target = struct {
|
||||
const print = S.print;
|
||||
const copy = S.copy;
|
||||
|
||||
if (self.isAndroid()) {
|
||||
if (self.abi == .android) {
|
||||
const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else "";
|
||||
return print(&result, "/system/bin/linker{}", .{suffix});
|
||||
}
|
||||
|
||||
if (self.isMusl()) {
|
||||
if (self.abi.isMusl()) {
|
||||
const is_arm = switch (self.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => true,
|
||||
else => false,
|
||||
@ -1351,7 +1355,7 @@ pub const Target = struct {
|
||||
.armeb, .thumbeb => "armeb",
|
||||
else => |arch| @tagName(arch),
|
||||
};
|
||||
const arch_suffix = if (is_arm and self.getFloatAbi() == .hard) "hf" else "";
|
||||
const arch_suffix = if (is_arm and self.abi.floatAbi() == .hard) "hf" else "";
|
||||
return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix });
|
||||
}
|
||||
|
||||
@ -1373,7 +1377,7 @@ pub const Target = struct {
|
||||
.armeb,
|
||||
.thumb,
|
||||
.thumbeb,
|
||||
=> return copy(&result, switch (self.getFloatAbi()) {
|
||||
=> return copy(&result, switch (self.abi.floatAbi()) {
|
||||
.hard => "/lib/ld-linux-armhf.so.3",
|
||||
else => "/lib/ld-linux.so.3",
|
||||
}),
|
||||
@ -1444,13 +1448,15 @@ pub const Target = struct {
|
||||
=> return result,
|
||||
},
|
||||
|
||||
// Operating systems in this list have been verified as not having a standard
|
||||
// dynamic linker path.
|
||||
.freestanding,
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.macos,
|
||||
=> return copy(&result, "/usr/lib/dyld"),
|
||||
|
||||
// Operating systems in this list have been verified as not having a standard
|
||||
// dynamic linker path.
|
||||
.freestanding,
|
||||
.uefi,
|
||||
.windows,
|
||||
.emscripten,
|
||||
|
||||
@ -606,12 +606,20 @@ pub const CrossTarget = struct {
|
||||
const os_match = os_tag == Target.current.os.tag;
|
||||
|
||||
// If the OS and CPU arch match, the binary can be considered native.
|
||||
// TODO additionally match the CPU features. This `getExternalExecutor` function should
|
||||
// be moved to std.Target and match any chosen target against the native target.
|
||||
if (os_match and cpu_arch == Target.current.cpu.arch) {
|
||||
// However, we also need to verify that the dynamic linker path is valid.
|
||||
// TODO Until that is implemented, we prevent returning `.native` when the OS is non-native.
|
||||
if (self.os_tag == null) {
|
||||
return .native;
|
||||
}
|
||||
// TODO here we call toTarget, a deprecated function, because of the above TODO about moving
|
||||
// this code to std.Target.
|
||||
const opt_dl = self.dynamic_linker.get() orelse self.toTarget().standardDynamicLinkerPath().get();
|
||||
if (opt_dl) |dl| blk: {
|
||||
std.fs.cwd().access(dl, .{}) catch break :blk;
|
||||
return .native;
|
||||
}
|
||||
}
|
||||
|
||||
// If the OS matches, we can use QEMU to emulate a foreign architecture.
|
||||
|
||||
@ -145,7 +145,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
}
|
||||
|
||||
{
|
||||
var case = ctx.exe("hello world", macosx_x64);
|
||||
var case = ctx.exe("hello world with updates", macosx_x64);
|
||||
case.addError("", &[_][]const u8{":1:1: error: no entry point found"});
|
||||
|
||||
// Incorrect return type
|
||||
@ -183,7 +183,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ );
|
||||
\\ unreachable;
|
||||
\\}
|
||||
,
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
// Now change the message only
|
||||
@ -993,7 +993,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ );
|
||||
\\ unreachable;
|
||||
\\}
|
||||
,
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
try case.files.append(.{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user