authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-17 18:59:24+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-18 00:10:43+02:00
logff594eae49104c009ddfc13a6f7d82e1ec1a68f4
treec929dff4793a68593b4bf9c40d4d50e22a8a2724
parent8504e1f550ba697f29fd72f181d9009ebad09501

std.Target: Make Abi.default() more smarter.

This builds on 221bd829bcb4318be941a93029b9c12d8317845d with more research I did for test/llvm_targets.zig.

1 files changed, 38 insertions(+), 29 deletions(-)

lib/std/Target.zig+38-29
......@@ -700,9 +700,7 @@ pub const Abi = enum {
700700
701701 pub fn default(arch: Cpu.Arch, os: Os) Abi {
702702 return if (arch.isWasm()) .musl else switch (os.tag) {
703 .freestanding,
704 .other,
705 => switch (arch) {
703 .freestanding, .other => switch (arch) {
706704 // Soft float is usually a sane default for freestanding.
707705 .arm,
708706 .armeb,
......@@ -716,14 +714,32 @@ pub const Abi = enum {
716714 => .eabi,
717715 else => .none,
718716 },
719 .aix,
720 => if (arch == .powerpc) .eabihf else .none,
721 .linux,
722 .wasi,
723 .emscripten,
724 => .musl,
725 .rtems,
726 => switch (arch) {
717 .aix => if (arch == .powerpc) .eabihf else .none,
718 .haiku => switch (arch) {
719 .arm,
720 .thumb,
721 .powerpc,
722 => .eabihf,
723 else => .none,
724 },
725 .hurd => .gnu,
726 .linux => switch (arch) {
727 .arm,
728 .armeb,
729 .thumb,
730 .thumbeb,
731 .powerpc,
732 .powerpcle,
733 => .musleabihf,
734 // Soft float tends to be more common for CSKY and MIPS.
735 .csky,
736 => .gnueabi, // No musl support.
737 .mips,
738 .mipsel,
739 => .musleabi,
740 else => .musl,
741 },
742 .rtems => switch (arch) {
727743 .arm,
728744 .armeb,
729745 .thumb,
......@@ -735,37 +751,33 @@ pub const Abi = enum {
735751 => .eabihf,
736752 else => .none,
737753 },
738 .hurd,
739 .windows,
740 => .gnu,
741 .freebsd,
742 => switch (arch) {
754 .freebsd => switch (arch) {
743755 .arm,
744756 .armeb,
745757 .thumb,
746758 .thumbeb,
747759 .powerpc,
748760 => .eabihf,
761 // Soft float tends to be more common for MIPS.
749762 .mips,
750763 .mipsel,
751764 => .eabi,
752765 else => .none,
753766 },
754 .netbsd,
755 => switch (arch) {
767 .netbsd => switch (arch) {
756768 .arm,
757769 .armeb,
758770 .thumb,
759771 .thumbeb,
760772 .powerpc,
761773 => .eabihf,
774 // Soft float tends to be more common for MIPS.
762775 .mips,
763776 .mipsel,
764777 => .eabi,
765778 else => .none,
766779 },
767 .openbsd,
768 => switch (arch) {
780 .openbsd => switch (arch) {
769781 .arm,
770782 .thumb,
771783 => .eabi,
......@@ -773,18 +785,16 @@ pub const Abi = enum {
773785 => .eabihf,
774786 else => .none,
775787 },
776 .ios,
777 => if (arch == .x86_64) .macabi else .none,
778 .tvos,
779 .visionos,
780 => if (arch == .x86_64) .simulator else .none,
781 .uefi,
782 => .msvc,
788 .ios => if (arch == .x86_64) .macabi else .none,
789 .tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
790 .windows => .gnu,
791 .uefi => .msvc,
792 .wasi, .emscripten => .musl,
793
783794 .contiki,
784795 .elfiamcu,
785796 .fuchsia,
786797 .hermit,
787 .haiku,
788798 .plan9,
789799 .serenity,
790800 .zos,
......@@ -792,7 +802,6 @@ pub const Abi = enum {
792802 .bridgeos,
793803 .driverkit,
794804 .macos,
795 .watchos,
796805 .illumos,
797806 .solaris,
798807 .ps3,