2019-11-07 06:14:15 +08:00
|
|
|
// const builtin = @import("builtin");
|
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-24 06:43:24 +08:00
|
|
|
|
2018-11-13 21:08:37 +08:00
|
|
|
pub const FloatAbi = enum {
|
2018-07-18 12:34:42 +08:00
|
|
|
Hard,
|
|
|
|
Soft,
|
|
|
|
SoftFp,
|
|
|
|
};
|
|
|
|
|
2019-11-07 06:14:15 +08:00
|
|
|
// pub const Cross = struct {
|
|
|
|
// arch: Target.Arch,
|
|
|
|
// os: Target.Os,
|
|
|
|
// abi: Target.Abi,
|
|
|
|
// object_format: builtin.ObjectFormat,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// pub fn getObjectFormat(self: Target) builtin.ObjectFormat {
|
|
|
|
// return switch (self) {
|
|
|
|
// .Native => builtin.object_format,
|
|
|
|
// .Cross => |t| t.object_format,
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
|
|
|
|
/// TODO expose the arch and subarch separately
|
|
|
|
pub fn isArmOrThumb(self: Target) bool {
|
|
|
|
return switch (self.getArch()) {
|
|
|
|
.arm,
|
|
|
|
.armeb,
|
|
|
|
.aarch64,
|
|
|
|
.aarch64_be,
|
|
|
|
.thumb,
|
|
|
|
.thumbeb,
|
|
|
|
=> true,
|
|
|
|
else => false,
|
2018-07-17 08:52:50 +08:00
|
|
|
};
|
2019-11-07 06:14:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn getFloatAbi(self: Target) FloatAbi {
|
|
|
|
return switch (self.getAbi()) {
|
|
|
|
.gnueabihf,
|
|
|
|
.eabihf,
|
|
|
|
.musleabihf,
|
|
|
|
=> .Hard,
|
|
|
|
else => .Soft,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn getDynamicLinkerPath(self: Target) ?[]const u8 {
|
|
|
|
const env = self.getAbi();
|
|
|
|
const arch = self.getArch();
|
|
|
|
const os = self.getOs();
|
|
|
|
switch (os) {
|
|
|
|
.freebsd => {
|
|
|
|
return "/libexec/ld-elf.so.1";
|
|
|
|
},
|
|
|
|
.linux => {
|
|
|
|
switch (env) {
|
|
|
|
.android => {
|
|
|
|
if (is64bit(self)) {
|
|
|
|
return "/system/bin/linker64";
|
|
|
|
} else {
|
|
|
|
return "/system/bin/linker";
|
|
|
|
}
|
2018-07-19 12:08:47 +08:00
|
|
|
},
|
2019-11-07 06:14:15 +08:00
|
|
|
.gnux32 => {
|
|
|
|
if (arch == .x86_64) {
|
|
|
|
return "/libx32/ld-linux-x32.so.2";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.musl,
|
|
|
|
.musleabi,
|
|
|
|
.musleabihf,
|
|
|
|
=> {
|
|
|
|
if (arch == .x86_64) {
|
|
|
|
return "/lib/ld-musl-x86_64.so.1";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
else => {},
|
|
|
|
}
|
|
|
|
switch (arch) {
|
|
|
|
.i386,
|
|
|
|
.sparc,
|
|
|
|
.sparcel,
|
|
|
|
=> return "/lib/ld-linux.so.2",
|
|
|
|
|
|
|
|
.aarch64 => return "/lib/ld-linux-aarch64.so.1",
|
|
|
|
|
|
|
|
.aarch64_be => return "/lib/ld-linux-aarch64_be.so.1",
|
|
|
|
|
|
|
|
.arm,
|
|
|
|
.thumb,
|
|
|
|
=> return switch (getFloatAbi(self)) {
|
|
|
|
.Hard => return "/lib/ld-linux-armhf.so.3",
|
|
|
|
else => return "/lib/ld-linux.so.3",
|
2018-07-19 12:08:47 +08:00
|
|
|
},
|
|
|
|
|
2019-11-07 06:14:15 +08:00
|
|
|
.armeb,
|
|
|
|
.thumbeb,
|
|
|
|
=> return switch (getFloatAbi(self)) {
|
|
|
|
.Hard => return "/lib/ld-linux-armhf.so.3",
|
|
|
|
else => return "/lib/ld-linux.so.3",
|
|
|
|
},
|
2018-07-24 05:38:03 +08:00
|
|
|
|
2019-11-07 06:14:15 +08:00
|
|
|
.mips,
|
|
|
|
.mipsel,
|
|
|
|
.mips64,
|
|
|
|
.mips64el,
|
|
|
|
=> return null,
|
|
|
|
|
|
|
|
.powerpc => return "/lib/ld.so.1",
|
|
|
|
.powerpc64 => return "/lib64/ld64.so.2",
|
|
|
|
.powerpc64le => return "/lib64/ld64.so.2",
|
|
|
|
.s390x => return "/lib64/ld64.so.1",
|
|
|
|
.sparcv9 => return "/lib64/ld-linux.so.2",
|
|
|
|
.x86_64 => return "/lib64/ld-linux-x86-64.so.2",
|
|
|
|
|
|
|
|
.arc,
|
|
|
|
.avr,
|
|
|
|
.bpfel,
|
|
|
|
.bpfeb,
|
|
|
|
.hexagon,
|
|
|
|
.msp430,
|
|
|
|
.r600,
|
|
|
|
.amdgcn,
|
|
|
|
.riscv32,
|
|
|
|
.riscv64,
|
|
|
|
.tce,
|
|
|
|
.tcele,
|
|
|
|
.xcore,
|
|
|
|
.nvptx,
|
|
|
|
.nvptx64,
|
|
|
|
.le32,
|
|
|
|
.le64,
|
|
|
|
.amdil,
|
|
|
|
.amdil64,
|
|
|
|
.hsail,
|
|
|
|
.hsail64,
|
|
|
|
.spir,
|
|
|
|
.spir64,
|
|
|
|
.kalimba,
|
|
|
|
.shave,
|
|
|
|
.lanai,
|
|
|
|
.wasm32,
|
|
|
|
.wasm64,
|
|
|
|
.renderscript32,
|
|
|
|
.renderscript64,
|
|
|
|
.aarch64_32,
|
|
|
|
=> return null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
else => return null,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn getDarwinArchString(self: Target) []const u8 {
|
|
|
|
const arch = self.getArch();
|
|
|
|
switch (arch) {
|
|
|
|
.aarch64 => return "arm64",
|
|
|
|
.thumb,
|
|
|
|
.arm,
|
|
|
|
=> return "arm",
|
|
|
|
.powerpc => return "ppc",
|
|
|
|
.powerpc64 => return "ppc64",
|
|
|
|
.powerpc64le => return "ppc64le",
|
|
|
|
else => return @tagName(arch),
|
|
|
|
}
|
|
|
|
}
|