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

@@ -244,18 +244,7 @@ pub const Object = struct {
// TODO handle float ABI better- it should depend on the ABI portion of std.Target
const float_abi: llvm.ABIType = .Default;
// TODO a way to override this as part of std.Target ABI?
const abi_name: ?[*:0]const u8 = switch (options.target.cpu.arch) {
.riscv32 => switch (options.target.os.tag) {
.linux => "ilp32d",
else => "ilp32",
},
.riscv64 => switch (options.target.os.tag) {
.linux => "lp64d",
else => "lp64",
},
else => null,
};
const abi_name: ?[*:0]const u8 = if (options.target_abi) |t| @tagName(t) else null;
const target_machine = llvm.TargetMachine.create(
target,