authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-07 06:14:10+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-07 06:14:10+02:00
log20e03beaef021b729279edd2063e30f9befb9f38
treeb18178c581e5f7006c65d5b058db064b14d23cc3
parentcc79cc9f55acd68d03ff7f7abf39508f3e954f3a
parent221bd829bcb4318be941a93029b9c12d8317845d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21611 from alexrp/target-abi-default

`std.Target`: Rewrite `Abi.default()` to have better defaults across the board.

2 files changed, 96 insertions(+), 35 deletions(-)

lib/std/Target.zig+95-34
......@@ -701,50 +701,111 @@ pub const Abi = enum {
701701 pub fn default(arch: Cpu.Arch, os: Os) Abi {
702702 return if (arch.isWasm()) .musl else switch (os.tag) {
703703 .freestanding,
704 .dragonfly,
705 .ps3,
706 .zos,
707 .rtems,
708 .aix,
709 .cuda,
710 .nvcl,
711 .amdhsa,
712 .ps4,
713 .ps5,
714 .elfiamcu,
715 .mesa3d,
716 .contiki,
717 .amdpal,
718 .hermit,
719704 .other,
720 => .eabi,
721 .openbsd,
722 .freebsd,
723 .fuchsia,
724 .netbsd,
725 .hurd,
726 .haiku,
727 .windows,
728 => .gnu,
729 .uefi => .msvc,
705 => switch (arch) {
706 // Soft float is usually a sane default for freestanding.
707 .arm,
708 .armeb,
709 .thumb,
710 .thumbeb,
711 .csky,
712 .mips,
713 .mipsel,
714 .powerpc,
715 .powerpcle,
716 => .eabi,
717 else => .none,
718 },
719 .aix,
720 => if (arch == .powerpc) .eabihf else .none,
730721 .linux,
731722 .wasi,
732723 .emscripten,
733724 => .musl,
734 .bridgeos,
735 .opencl,
736 .opengl,
737 .vulkan,
738 .plan9, // TODO specify abi
739 .macos,
725 .rtems,
726 => switch (arch) {
727 .arm,
728 .armeb,
729 .thumb,
730 .thumbeb,
731 .mips,
732 .mipsel,
733 => .eabi,
734 .powerpc,
735 => .eabihf,
736 else => .none,
737 },
738 .hurd,
739 .windows,
740 => .gnu,
741 .freebsd,
742 => switch (arch) {
743 .arm,
744 .armeb,
745 .thumb,
746 .thumbeb,
747 .powerpc,
748 => .eabihf,
749 .mips,
750 .mipsel,
751 => .eabi,
752 else => .none,
753 },
754 .netbsd,
755 => switch (arch) {
756 .arm,
757 .armeb,
758 .thumb,
759 .thumbeb,
760 .powerpc,
761 => .eabihf,
762 .mips,
763 .mipsel,
764 => .eabi,
765 else => .none,
766 },
767 .openbsd,
768 => switch (arch) {
769 .arm,
770 .thumb,
771 => .eabi,
772 .powerpc,
773 => .eabihf,
774 else => .none,
775 },
740776 .ios,
777 => if (arch == .x86_64) .macabi else .none,
741778 .tvos,
742 .watchos,
743779 .visionos,
780 => if (arch == .x86_64) .simulator else .none,
781 .uefi,
782 => .msvc,
783 .contiki,
784 .elfiamcu,
785 .fuchsia,
786 .hermit,
787 .haiku,
788 .plan9,
789 .serenity,
790 .zos,
791 .dragonfly,
792 .bridgeos,
744793 .driverkit,
745 .solaris,
794 .macos,
795 .watchos,
746796 .illumos,
747 .serenity,
797 .solaris,
798 .ps3,
799 .ps4,
800 .ps5,
801 .amdhsa,
802 .amdpal,
803 .cuda,
804 .mesa3d,
805 .nvcl,
806 .opencl,
807 .opengl,
808 .vulkan,
748809 => .none,
749810 };
750811 }
test/llvm_targets.zig+1-1
......@@ -185,7 +185,7 @@ const targets = [_]std.Target.Query{
185185 .{ .cpu_arch = .nvptx64, .os_tag = .cuda, .abi = .none },
186186 .{ .cpu_arch = .nvptx64, .os_tag = .nvcl, .abi = .none },
187187
188 .{ .cpu_arch = .powerpc, .os_tag = .aix, .abi = .eabi },
188 .{ .cpu_arch = .powerpc, .os_tag = .aix, .abi = .eabihf },
189189 .{ .cpu_arch = .powerpc, .os_tag = .freebsd, .abi = .eabi },
190190 .{ .cpu_arch = .powerpc, .os_tag = .freebsd, .abi = .eabihf },
191191 .{ .cpu_arch = .powerpc, .os_tag = .freestanding, .abi = .eabi },