Commit 3c7f030a60
Changed files (2)
lib
std
lib/std/zig/cross_target.zig
@@ -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);
lib/std/target.zig
@@ -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();
}