mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Compilation: Pass hard/soft float flags to Clang as appropriate.
This commit is contained in:
parent
70c92331c7
commit
77c8f4b671
@ -5484,6 +5484,9 @@ pub fn addCCArgs(
|
||||
const is_enabled = target.cpu.features.isEnabled(index);
|
||||
|
||||
if (feature.llvm_name) |llvm_name| {
|
||||
// We communicate float ABI to Clang through the dedicated options further down.
|
||||
if (std.mem.eql(u8, llvm_name, "soft-float")) continue;
|
||||
|
||||
argv.appendSliceAssumeCapacity(&[_][]const u8{ "-Xclang", "-target-feature", "-Xclang" });
|
||||
const plus_or_minus = "-+"[@intFromBool(is_enabled)];
|
||||
const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name });
|
||||
@ -5705,10 +5708,6 @@ pub fn addCCArgs(
|
||||
if (target.cpu.model.llvm_name) |llvm_name| {
|
||||
try argv.append(try std.fmt.allocPrint(arena, "-march={s}", .{llvm_name}));
|
||||
}
|
||||
|
||||
if (std.Target.mips.featureSetHas(target.cpu.features, .soft_float)) {
|
||||
try argv.append("-msoft-float");
|
||||
}
|
||||
},
|
||||
else => {
|
||||
// TODO
|
||||
@ -5751,6 +5750,21 @@ pub fn addCCArgs(
|
||||
try argv.append(try std.fmt.allocPrint(arena, "-mabi={s}", .{mabi}));
|
||||
}
|
||||
|
||||
// We might want to support -mfloat-abi=softfp for Arm and CSKY here in the future.
|
||||
if (target_util.clangSupportsFloatAbiArg(target)) {
|
||||
const fabi = @tagName(target.floatAbi());
|
||||
|
||||
try argv.append(switch (target.cpu.arch) {
|
||||
// For whatever reason, Clang doesn't support `-mfloat-abi` for s390x.
|
||||
.s390x => try std.fmt.allocPrint(arena, "-m{s}-float", .{fabi}),
|
||||
else => try std.fmt.allocPrint(arena, "-mfloat-abi={s}", .{fabi}),
|
||||
});
|
||||
}
|
||||
|
||||
if (target_util.clangSupportsNoImplicitFloatArg(target) and target.floatAbi() == .soft) {
|
||||
try argv.append("-mno-implicit-float");
|
||||
}
|
||||
|
||||
if (out_dep_path) |p| {
|
||||
try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", p });
|
||||
}
|
||||
|
||||
@ -339,6 +339,48 @@ pub fn clangAssemblerSupportsMcpuArg(target: std.Target) bool {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn clangSupportsFloatAbiArg(target: std.Target) bool {
|
||||
return switch (target.cpu.arch) {
|
||||
.arm,
|
||||
.armeb,
|
||||
.thumb,
|
||||
.thumbeb,
|
||||
.csky,
|
||||
.mips,
|
||||
.mipsel,
|
||||
.mips64,
|
||||
.mips64el,
|
||||
.powerpc,
|
||||
.powerpcle,
|
||||
.powerpc64,
|
||||
.powerpc64le,
|
||||
.s390x,
|
||||
.sparc,
|
||||
.sparc64,
|
||||
=> true,
|
||||
// We use the target triple for LoongArch.
|
||||
.loongarch32, .loongarch64 => false,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn clangSupportsNoImplicitFloatArg(target: std.Target) bool {
|
||||
return switch (target.cpu.arch) {
|
||||
.aarch64,
|
||||
.aarch64_be,
|
||||
.arm,
|
||||
.armeb,
|
||||
.thumb,
|
||||
.thumbeb,
|
||||
.riscv32,
|
||||
.riscv64,
|
||||
.x86,
|
||||
.x86_64,
|
||||
=> true,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn needUnwindTables(target: std.Target) bool {
|
||||
return target.os.tag == .windows or target.isDarwin() or std.debug.Dwarf.abi.supportsUnwinding(target);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user