nonegnugnuabin32gnuabi64gnueabignueabihfgnuf32gnusfgnux32gnuilp32code16eabieabihfilp32androidandroideabimuslmuslabin32muslabi64musleabimusleabihfmuslx32msvcitaniumcygnussimulatormacabiohosohoseabipub fn default(arch: Cpu.Arch, os: Os) Abi {
return switch (os.tag) {
.freestanding, .other => switch (arch) {
// Soft float is usually a sane default for freestanding.
.arm,
.armeb,
.thumb,
.thumbeb,
.csky,
.mips,
.mipsel,
.powerpc,
.powerpcle,
=> .eabi,
else => .none,
},
.aix => if (arch == .powerpc) .eabihf else .none,
.haiku => switch (arch) {
.arm,
.thumb,
.powerpc,
=> .eabihf,
else => .none,
},
.hurd => .gnu,
.linux => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
.powerpcle,
=> .musleabihf,
// Soft float tends to be more common for CSKY and MIPS.
.csky,
=> .gnueabi, // No musl support.
.mips,
.mipsel,
=> .musleabi,
.mips64,
.mips64el,
=> .muslabi64,
else => .musl,
},
.rtems => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.mips,
.mipsel,
=> .eabi,
.powerpc,
=> .eabihf,
else => .none,
},
.freebsd => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
=> .eabihf,
// Soft float tends to be more common for MIPS.
.mips,
.mipsel,
=> .eabi,
else => .none,
},
.netbsd => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
=> .eabihf,
// Soft float tends to be more common for MIPS.
.mips,
.mipsel,
=> .eabi,
else => .none,
},
.openbsd => switch (arch) {
.arm,
.thumb,
=> .eabi,
.powerpc,
=> .eabihf,
else => .none,
},
.ios => if (arch == .x86_64) .macabi else .none,
.tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
.windows => .gnu,
.uefi => .msvc,
.wasi, .emscripten => .musl,
.contiki,
.elfiamcu,
.fuchsia,
.hermit,
.plan9,
.serenity,
.zos,
.dragonfly,
.driverkit,
.macos,
.illumos,
.solaris,
.ps3,
.ps4,
.ps5,
.amdhsa,
.amdpal,
.cuda,
.mesa3d,
.nvcl,
.opencl,
.opengl,
.vulkan,
=> .none,
};
}pub inline fn isGnu(abi: Abi) boolabi: Abipub inline fn isGnu(abi: Abi) bool {
return switch (abi) {
.gnu,
.gnuabin32,
.gnuabi64,
.gnueabi,
.gnueabihf,
.gnuf32,
.gnusf,
.gnux32,
.gnuilp32,
=> true,
else => false,
};
}pub inline fn isMusl(abi: Abi) boolabi: Abipub inline fn isMusl(abi: Abi) bool {
return switch (abi) {
.musl,
.muslabin32,
.muslabi64,
.musleabi,
.musleabihf,
.muslx32,
=> true,
else => abi.isOpenHarmony(),
};
}pub inline fn isOpenHarmony(abi: Abi) boolabi: Abipub inline fn isOpenHarmony(abi: Abi) bool {
return switch (abi) {
.ohos, .ohoseabi => true,
else => false,
};
}pub const Abi = enum {
none,
gnu,
gnuabin32,
gnuabi64,
gnueabi,
gnueabihf,
gnuf32,
gnusf,
gnux32,
gnuilp32,
code16,
eabi,
eabihf,
ilp32,
android,
androideabi,
musl,
muslabin32,
muslabi64,
musleabi,
musleabihf,
muslx32,
msvc,
itanium,
cygnus,
simulator,
macabi,
ohos,
ohoseabi,
// LLVM tags deliberately omitted:
// - amplification
// - anyhit
// - callable
// - closesthit
// - compute
// - coreclr
// - domain
// - geometry
// - gnuf64
// - hull
// - intersection
// - library
// - mesh
// - miss
// - pixel
// - raygeneration
// - vertex
pub fn default(arch: Cpu.Arch, os: Os) Abi {
return switch (os.tag) {
.freestanding, .other => switch (arch) {
// Soft float is usually a sane default for freestanding.
.arm,
.armeb,
.thumb,
.thumbeb,
.csky,
.mips,
.mipsel,
.powerpc,
.powerpcle,
=> .eabi,
else => .none,
},
.aix => if (arch == .powerpc) .eabihf else .none,
.haiku => switch (arch) {
.arm,
.thumb,
.powerpc,
=> .eabihf,
else => .none,
},
.hurd => .gnu,
.linux => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
.powerpcle,
=> .musleabihf,
// Soft float tends to be more common for CSKY and MIPS.
.csky,
=> .gnueabi, // No musl support.
.mips,
.mipsel,
=> .musleabi,
.mips64,
.mips64el,
=> .muslabi64,
else => .musl,
},
.rtems => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.mips,
.mipsel,
=> .eabi,
.powerpc,
=> .eabihf,
else => .none,
},
.freebsd => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
=> .eabihf,
// Soft float tends to be more common for MIPS.
.mips,
.mipsel,
=> .eabi,
else => .none,
},
.netbsd => switch (arch) {
.arm,
.armeb,
.thumb,
.thumbeb,
.powerpc,
=> .eabihf,
// Soft float tends to be more common for MIPS.
.mips,
.mipsel,
=> .eabi,
else => .none,
},
.openbsd => switch (arch) {
.arm,
.thumb,
=> .eabi,
.powerpc,
=> .eabihf,
else => .none,
},
.ios => if (arch == .x86_64) .macabi else .none,
.tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
.windows => .gnu,
.uefi => .msvc,
.wasi, .emscripten => .musl,
.contiki,
.elfiamcu,
.fuchsia,
.hermit,
.plan9,
.serenity,
.zos,
.dragonfly,
.driverkit,
.macos,
.illumos,
.solaris,
.ps3,
.ps4,
.ps5,
.amdhsa,
.amdpal,
.cuda,
.mesa3d,
.nvcl,
.opencl,
.opengl,
.vulkan,
=> .none,
};
}
pub inline fn isGnu(abi: Abi) bool {
return switch (abi) {
.gnu,
.gnuabin32,
.gnuabi64,
.gnueabi,
.gnueabihf,
.gnuf32,
.gnusf,
.gnux32,
.gnuilp32,
=> true,
else => false,
};
}
pub inline fn isMusl(abi: Abi) bool {
return switch (abi) {
.musl,
.muslabin32,
.muslabi64,
.musleabi,
.musleabihf,
.muslx32,
=> true,
else => abi.isOpenHarmony(),
};
}
pub inline fn isOpenHarmony(abi: Abi) bool {
return switch (abi) {
.ohos, .ohoseabi => true,
else => false,
};
}
pub inline fn isAndroid(abi: Abi) bool {
return switch (abi) {
.android, .androideabi => true,
else => false,
};
}
pub const Float = enum {
hard,
soft,
};
pub inline fn float(abi: Abi) Float {
return switch (abi) {
.androideabi,
.eabi,
.gnueabi,
.musleabi,
.gnusf,
.ohoseabi,
=> .soft,
else => .hard,
};
}
}