mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
add CrossTarget.getObjectFormat
closes #4588 thanks Michaël Larouche for the suggested fix
This commit is contained in:
parent
7e6b68a534
commit
3c7f030a60
2 changed files with 12 additions and 4 deletions
|
|
@ -1014,18 +1014,22 @@ pub const Target = struct {
|
|||
return libPrefix_cpu_arch_abi(self.cpu.arch, self.abi);
|
||||
}
|
||||
|
||||
pub fn getObjectFormat(self: Target) ObjectFormat {
|
||||
if (self.os.tag == .windows or self.os.tag == .uefi) {
|
||||
pub fn getObjectFormatSimple(os_tag: Os.Tag, cpu_arch: Cpu.Arch) ObjectFormat {
|
||||
if (os_tag == .windows or os_tag == .uefi) {
|
||||
return .coff;
|
||||
} else if (self.isDarwin()) {
|
||||
} else if (os_tag.isDarwin()) {
|
||||
return .macho;
|
||||
}
|
||||
if (self.cpu.arch.isWasm()) {
|
||||
if (cpu_arch.isWasm()) {
|
||||
return .wasm;
|
||||
}
|
||||
return .elf;
|
||||
}
|
||||
|
||||
pub fn getObjectFormat(self: Target) ObjectFormat {
|
||||
return getObjectFormatSimple(self.os.tag, self.cpu.arch);
|
||||
}
|
||||
|
||||
pub fn isMinGW(self: Target) bool {
|
||||
return self.os.tag == .windows and self.isGnu();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -645,6 +645,10 @@ pub const CrossTarget = struct {
|
|||
self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };
|
||||
}
|
||||
|
||||
pub fn getObjectFormat(self: CrossTarget) ObjectFormat {
|
||||
return Target.getObjectFormatSimple(self.getOsTag(), self.getCpuArch());
|
||||
}
|
||||
|
||||
fn updateCpuFeatures(self: CrossTarget, set: *Target.Cpu.Feature.Set) void {
|
||||
set.removeFeatureSet(self.cpu_features_sub);
|
||||
set.addFeatureSet(self.cpu_features_add);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue