Skip to content

Commit

Permalink
std.Target: Make Abi.default() more smarter.
Browse files Browse the repository at this point in the history
This builds on 221bd82 with more research I did
for test/llvm_targets.zig.
  • Loading branch information
alexrp committed Oct 17, 2024
1 parent 8504e1f commit ff594ea
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,7 @@ pub const Abi = enum {

pub fn default(arch: Cpu.Arch, os: Os) Abi {
return if (arch.isWasm()) .musl else switch (os.tag) {
.freestanding,
.other,
=> switch (arch) {
.freestanding, .other => switch (arch) {
// Soft float is usually a sane default for freestanding.
.arm,
.armeb,
Expand All @@ -716,14 +714,32 @@ pub const Abi = enum {
=> .eabi,
else => .none,
},
.aix,
=> if (arch == .powerpc) .eabihf else .none,
.linux,
.wasi,
.emscripten,
=> .musl,
.rtems,
=> switch (arch) {
.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,
else => .musl,
},
.rtems => switch (arch) {
.arm,
.armeb,
.thumb,
Expand All @@ -735,64 +751,57 @@ pub const Abi = enum {
=> .eabihf,
else => .none,
},
.hurd,
.windows,
=> .gnu,
.freebsd,
=> switch (arch) {
.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) {
.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) {
.openbsd => switch (arch) {
.arm,
.thumb,
=> .eabi,
.powerpc,
=> .eabihf,
else => .none,
},
.ios,
=> if (arch == .x86_64) .macabi else .none,
.tvos,
.visionos,
=> if (arch == .x86_64) .simulator else .none,
.uefi,
=> .msvc,
.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,
.haiku,
.plan9,
.serenity,
.zos,
.dragonfly,
.bridgeos,
.driverkit,
.macos,
.watchos,
.illumos,
.solaris,
.ps3,
Expand Down

0 comments on commit ff594ea

Please sign in to comment.