default mabi based on RISC-V extensions and -mabi build option

The target abi can also be set in build.zig via LibExeObjStep.target_abi

The value passed in is checked that it is a valid value in
std.Target.TargetAbi

The target abi is also validated against the target cpu
This commit is contained in:
vole-dev
2021-10-30 10:30:28 -05:00
committed by Andrew Kelley
parent 84704ef43e
commit ff38f56040
15 changed files with 141 additions and 31 deletions

View File

@@ -9487,9 +9487,8 @@ static void init(CodeGen *g) {
// TODO handle float ABI better- it should depend on the ABI portion of std.Target
ZigLLVMABIType float_abi = ZigLLVMABITypeDefault;
// TODO a way to override this as part of std.Target ABI?
const char *abi_name = nullptr;
if (target_is_riscv(g->zig_target)) {
const char *abi_name = g->zig_target->llvm_target_abi;
if (abi_name == nullptr && target_is_riscv(g->zig_target)) {
// RISC-V Linux defaults to ilp32d/lp64d
if (g->zig_target->os == OsLinux) {
abi_name = (g->zig_target->arch == ZigLLVM_riscv32) ? "ilp32d" : "lp64d";