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 {...@@ -700,9 +700,7 @@ pub const Abi = enum {
700700
701 pub fn default(arch: Cpu.Arch, os: Os) Abi {701 pub fn default(arch: Cpu.Arch, os: Os) Abi {
702 return if (arch.isWasm()) .musl else switch (os.tag) {702 return if (arch.isWasm()) .musl else switch (os.tag) {
703 .freestanding,703 .freestanding, .other => switch (arch) {
704 .other,
705 => switch (arch) {
706 // Soft float is usually a sane default for freestanding.704 // Soft float is usually a sane default for freestanding.
707 .arm,705 .arm,
708 .armeb,706 .armeb,
...@@ -716,14 +714,32 @@ pub const Abi = enum {...@@ -716,14 +714,32 @@ pub const Abi = enum {
716 => .eabi,714 => .eabi,
717 else => .none,715 else => .none,
718 },716 },
719 .aix,717 .aix => if (arch == .powerpc) .eabihf else .none,
720 => if (arch == .powerpc) .eabihf else .none,718 .haiku => switch (arch) {
721 .linux,719 .arm,
722 .wasi,720 .thumb,
723 .emscripten,721 .powerpc,
724 => .musl,722 => .eabihf,
725 .rtems,723 else => .none,
726 => switch (arch) {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) {
727 .arm,743 .arm,
728 .armeb,744 .armeb,
729 .thumb,745 .thumb,
...@@ -735,37 +751,33 @@ pub const Abi = enum {...@@ -735,37 +751,33 @@ pub const Abi = enum {
735 => .eabihf,751 => .eabihf,
736 else => .none,752 else => .none,
737 },753 },
738 .hurd,754 .freebsd => switch (arch) {
739 .windows,
740 => .gnu,
741 .freebsd,
742 => switch (arch) {
743 .arm,755 .arm,
744 .armeb,756 .armeb,
745 .thumb,757 .thumb,
746 .thumbeb,758 .thumbeb,
747 .powerpc,759 .powerpc,
748 => .eabihf,760 => .eabihf,
761 // Soft float tends to be more common for MIPS.
749 .mips,762 .mips,
750 .mipsel,763 .mipsel,
751 => .eabi,764 => .eabi,
752 else => .none,765 else => .none,
753 },766 },
754 .netbsd,767 .netbsd => switch (arch) {
755 => switch (arch) {
756 .arm,768 .arm,
757 .armeb,769 .armeb,
758 .thumb,770 .thumb,
759 .thumbeb,771 .thumbeb,
760 .powerpc,772 .powerpc,
761 => .eabihf,773 => .eabihf,
774 // Soft float tends to be more common for MIPS.
762 .mips,775 .mips,
763 .mipsel,776 .mipsel,
764 => .eabi,777 => .eabi,
765 else => .none,778 else => .none,
766 },779 },
767 .openbsd,780 .openbsd => switch (arch) {
768 => switch (arch) {
769 .arm,781 .arm,
770 .thumb,782 .thumb,
771 => .eabi,783 => .eabi,
...@@ -773,18 +785,16 @@ pub const Abi = enum {...@@ -773,18 +785,16 @@ pub const Abi = enum {
773 => .eabihf,785 => .eabihf,
774 else => .none,786 else => .none,
775 },787 },
776 .ios,788 .ios => if (arch == .x86_64) .macabi else .none,
777 => if (arch == .x86_64) .macabi else .none,789 .tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
778 .tvos,790 .windows => .gnu,
779 .visionos,791 .uefi => .msvc,
780 => if (arch == .x86_64) .simulator else .none,792 .wasi, .emscripten => .musl,
781 .uefi,793
782 => .msvc,
783 .contiki,794 .contiki,
784 .elfiamcu,795 .elfiamcu,
785 .fuchsia,796 .fuchsia,
786 .hermit,797 .hermit,
787 .haiku,
788 .plan9,798 .plan9,
789 .serenity,799 .serenity,
790 .zos,800 .zos,
...@@ -792,7 +802,6 @@ pub const Abi = enum {...@@ -792,7 +802,6 @@ pub const Abi = enum {
792 .bridgeos,802 .bridgeos,
793 .driverkit,803 .driverkit,
794 .macos,804 .macos,
795 .watchos,
796 .illumos,805 .illumos,
797 .solaris,806 .solaris,
798 .ps3,807 .ps3,