From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_target/src/abi/call/csky.rs | 38 ++- compiler/rustc_target/src/abi/call/x86.rs | 3 +- compiler/rustc_target/src/abi/mod.rs | 117 ++++++- compiler/rustc_target/src/asm/csky.rs | 6 +- compiler/rustc_target/src/lib.rs | 2 + .../rustc_target/src/spec/aarch64_apple_darwin.rs | 27 -- .../rustc_target/src/spec/aarch64_apple_ios.rs | 37 --- .../src/spec/aarch64_apple_ios_macabi.rs | 34 -- .../rustc_target/src/spec/aarch64_apple_ios_sim.rs | 37 --- .../rustc_target/src/spec/aarch64_apple_tvos.rs | 19 -- .../src/spec/aarch64_apple_watchos_sim.rs | 34 -- .../src/spec/aarch64_be_unknown_linux_gnu.rs | 18 - .../src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs | 21 -- .../src/spec/aarch64_be_unknown_netbsd.rs | 17 - compiler/rustc_target/src/spec/aarch64_fuchsia.rs | 1 - .../src/spec/aarch64_kmc_solid_asp3.rs | 19 -- .../rustc_target/src/spec/aarch64_linux_android.rs | 26 -- .../spec/aarch64_nintendo_switch_freestanding.rs | 26 -- ...4_nintendo_switch_freestanding_linker_script.ld | 78 ----- .../src/spec/aarch64_pc_windows_gnullvm.rs | 16 - .../src/spec/aarch64_pc_windows_msvc.rs | 15 - .../src/spec/aarch64_unknown_freebsd.rs | 19 -- .../src/spec/aarch64_unknown_fuchsia.rs | 18 - .../src/spec/aarch64_unknown_hermit.rs | 15 - .../src/spec/aarch64_unknown_linux_gnu.rs | 24 -- .../src/spec/aarch64_unknown_linux_gnu_ilp32.rs | 17 - .../src/spec/aarch64_unknown_linux_musl.rs | 21 -- .../src/spec/aarch64_unknown_linux_ohos.rs | 28 -- .../src/spec/aarch64_unknown_netbsd.rs | 16 - .../rustc_target/src/spec/aarch64_unknown_none.rs | 32 -- .../src/spec/aarch64_unknown_none_softfloat.rs | 30 -- .../src/spec/aarch64_unknown_nto_qnx_710.rs | 30 -- .../src/spec/aarch64_unknown_openbsd.rs | 15 - .../rustc_target/src/spec/aarch64_unknown_redox.rs | 15 - .../rustc_target/src/spec/aarch64_unknown_teeos.rs | 16 - .../rustc_target/src/spec/aarch64_unknown_uefi.rs | 21 -- .../src/spec/aarch64_uwp_windows_msvc.rs | 15 - .../rustc_target/src/spec/aarch64_wrs_vxworks.rs | 15 - compiler/rustc_target/src/spec/abi.rs | 341 ------------------- compiler/rustc_target/src/spec/abi/mod.rs | 341 +++++++++++++++++++ compiler/rustc_target/src/spec/aix_base.rs | 32 -- compiler/rustc_target/src/spec/android_base.rs | 16 - compiler/rustc_target/src/spec/apple/tests.rs | 38 --- compiler/rustc_target/src/spec/apple_base.rs | 356 -------------------- .../src/spec/arm64_32_apple_watchos.rs | 30 -- .../rustc_target/src/spec/arm_linux_androideabi.rs | 18 - .../src/spec/arm_unknown_linux_gnueabi.rs | 18 - .../src/spec/arm_unknown_linux_gnueabihf.rs | 18 - .../src/spec/arm_unknown_linux_musleabi.rs | 22 -- .../src/spec/arm_unknown_linux_musleabihf.rs | 22 -- .../src/spec/armeb_unknown_linux_gnueabi.rs | 20 -- .../rustc_target/src/spec/armebv7r_none_eabi.rs | 26 -- .../rustc_target/src/spec/armebv7r_none_eabihf.rs | 27 -- compiler/rustc_target/src/spec/armv4t_none_eabi.rs | 49 --- .../src/spec/armv4t_unknown_linux_gnueabi.rs | 20 -- .../rustc_target/src/spec/armv5te_none_eabi.rs | 41 --- .../src/spec/armv5te_unknown_linux_gnueabi.rs | 19 -- .../src/spec/armv5te_unknown_linux_musleabi.rs | 23 -- .../src/spec/armv5te_unknown_linux_uclibceabi.rs | 19 -- .../rustc_target/src/spec/armv6_unknown_freebsd.rs | 20 -- .../src/spec/armv6_unknown_netbsd_eabihf.rs | 19 -- .../rustc_target/src/spec/armv6k_nintendo_3ds.rs | 36 -- .../src/spec/armv7_linux_androideabi.rs | 27 -- .../src/spec/armv7_sony_vita_newlibeabihf.rs | 41 --- .../rustc_target/src/spec/armv7_unknown_freebsd.rs | 19 -- .../src/spec/armv7_unknown_linux_gnueabi.rs | 21 -- .../src/spec/armv7_unknown_linux_gnueabihf.rs | 21 -- .../src/spec/armv7_unknown_linux_musleabi.rs | 26 -- .../src/spec/armv7_unknown_linux_musleabihf.rs | 25 -- .../src/spec/armv7_unknown_linux_ohos.rs | 24 -- .../src/spec/armv7_unknown_linux_uclibceabi.rs | 23 -- .../src/spec/armv7_unknown_linux_uclibceabihf.rs | 24 -- .../src/spec/armv7_unknown_netbsd_eabihf.rs | 19 -- .../src/spec/armv7_wrs_vxworks_eabihf.rs | 17 - .../src/spec/armv7a_kmc_solid_asp3_eabi.rs | 19 -- .../src/spec/armv7a_kmc_solid_asp3_eabihf.rs | 19 -- compiler/rustc_target/src/spec/armv7a_none_eabi.rs | 40 --- .../rustc_target/src/spec/armv7a_none_eabihf.rs | 32 -- .../rustc_target/src/spec/armv7k_apple_watchos.rs | 30 -- compiler/rustc_target/src/spec/armv7r_none_eabi.rs | 25 -- .../rustc_target/src/spec/armv7r_none_eabihf.rs | 26 -- compiler/rustc_target/src/spec/armv7s_apple_ios.rs | 17 - .../src/spec/asmjs_unknown_emscripten.rs | 7 - compiler/rustc_target/src/spec/avr_gnu_base.rs | 368 --------------------- .../src/spec/avr_unknown_gnu_atmega328.rs | 5 - compiler/rustc_target/src/spec/base/aix.rs | 32 ++ compiler/rustc_target/src/spec/base/android.rs | 16 + compiler/rustc_target/src/spec/base/apple/mod.rs | 356 ++++++++++++++++++++ compiler/rustc_target/src/spec/base/apple/tests.rs | 38 +++ compiler/rustc_target/src/spec/base/avr_gnu.rs | 368 +++++++++++++++++++++ compiler/rustc_target/src/spec/base/bpf.rs | 29 ++ compiler/rustc_target/src/spec/base/dragonfly.rs | 14 + compiler/rustc_target/src/spec/base/freebsd.rs | 15 + compiler/rustc_target/src/spec/base/fuchsia.rs | 43 +++ compiler/rustc_target/src/spec/base/haiku.rs | 11 + compiler/rustc_target/src/spec/base/hermit.rs | 15 + compiler/rustc_target/src/spec/base/hurd.rs | 15 + compiler/rustc_target/src/spec/base/hurd_gnu.rs | 5 + compiler/rustc_target/src/spec/base/illumos.rs | 59 ++++ compiler/rustc_target/src/spec/base/l4re.rs | 14 + compiler/rustc_target/src/spec/base/linux.rs | 21 ++ compiler/rustc_target/src/spec/base/linux_gnu.rs | 5 + compiler/rustc_target/src/spec/base/linux_musl.rs | 16 + compiler/rustc_target/src/spec/base/linux_ohos.rs | 12 + .../rustc_target/src/spec/base/linux_uclibc.rs | 5 + compiler/rustc_target/src/spec/base/mod.rs | 37 +++ compiler/rustc_target/src/spec/base/msvc.rs | 26 ++ compiler/rustc_target/src/spec/base/netbsd.rs | 16 + compiler/rustc_target/src/spec/base/nto_qnx.rs | 18 + compiler/rustc_target/src/spec/base/openbsd.rs | 16 + compiler/rustc_target/src/spec/base/redox.rs | 17 + compiler/rustc_target/src/spec/base/solaris.rs | 16 + compiler/rustc_target/src/spec/base/solid.rs | 12 + compiler/rustc_target/src/spec/base/teeos.rs | 28 ++ compiler/rustc_target/src/spec/base/thumb.rs | 59 ++++ compiler/rustc_target/src/spec/base/uefi_msvc.rs | 52 +++ .../src/spec/base/unikraft_linux_musl.rs | 15 + compiler/rustc_target/src/spec/base/vxworks.rs | 21 ++ compiler/rustc_target/src/spec/base/wasm.rs | 135 ++++++++ compiler/rustc_target/src/spec/base/windows_gnu.rs | 108 ++++++ .../rustc_target/src/spec/base/windows_gnullvm.rs | 47 +++ .../rustc_target/src/spec/base/windows_msvc.rs | 34 ++ .../rustc_target/src/spec/base/windows_uwp_gnu.rs | 35 ++ .../rustc_target/src/spec/base/windows_uwp_msvc.rs | 11 + compiler/rustc_target/src/spec/bpf_base.rs | 29 -- .../rustc_target/src/spec/bpfeb_unknown_none.rs | 12 - .../rustc_target/src/spec/bpfel_unknown_none.rs | 12 - compiler/rustc_target/src/spec/crt_objects.rs | 38 --- .../src/spec/csky_unknown_linux_gnuabiv2.rs | 20 -- compiler/rustc_target/src/spec/dragonfly_base.rs | 14 - compiler/rustc_target/src/spec/freebsd_base.rs | 15 - compiler/rustc_target/src/spec/fuchsia_base.rs | 43 --- compiler/rustc_target/src/spec/haiku_base.rs | 11 - compiler/rustc_target/src/spec/hermit_base.rs | 15 - .../src/spec/hexagon_unknown_linux_musl.rs | 29 -- compiler/rustc_target/src/spec/hurd_base.rs | 15 - compiler/rustc_target/src/spec/hurd_gnu_base.rs | 5 - compiler/rustc_target/src/spec/i386_apple_ios.rs | 23 -- .../src/spec/i386_unknown_linux_gnu.rs | 8 - .../src/spec/i486_unknown_linux_gnu.rs | 8 - .../rustc_target/src/spec/i586_pc_nto_qnx700.rs | 24 -- .../rustc_target/src/spec/i586_pc_windows_msvc.rs | 8 - .../src/spec/i586_unknown_linux_gnu.rs | 8 - .../src/spec/i586_unknown_linux_musl.rs | 8 - .../rustc_target/src/spec/i686_apple_darwin.rs | 27 -- .../rustc_target/src/spec/i686_linux_android.rs | 25 -- .../rustc_target/src/spec/i686_pc_windows_gnu.rs | 27 -- .../src/spec/i686_pc_windows_gnullvm.rs | 26 -- .../rustc_target/src/spec/i686_pc_windows_msvc.rs | 32 -- .../rustc_target/src/spec/i686_unknown_freebsd.rs | 19 -- .../rustc_target/src/spec/i686_unknown_haiku.rs | 19 -- .../rustc_target/src/spec/i686_unknown_hurd_gnu.rs | 19 -- .../src/spec/i686_unknown_linux_gnu.rs | 20 -- .../src/spec/i686_unknown_linux_musl.rs | 33 -- .../rustc_target/src/spec/i686_unknown_netbsd.rs | 19 -- .../rustc_target/src/spec/i686_unknown_openbsd.rs | 19 -- .../rustc_target/src/spec/i686_unknown_uefi.rs | 89 ----- .../rustc_target/src/spec/i686_uwp_windows_gnu.rs | 26 -- .../rustc_target/src/spec/i686_uwp_windows_msvc.rs | 17 - compiler/rustc_target/src/spec/i686_wrs_vxworks.rs | 19 -- compiler/rustc_target/src/spec/illumos_base.rs | 59 ---- compiler/rustc_target/src/spec/l4re_base.rs | 14 - compiler/rustc_target/src/spec/linux_base.rs | 21 -- compiler/rustc_target/src/spec/linux_gnu_base.rs | 5 - compiler/rustc_target/src/spec/linux_musl_base.rs | 16 - compiler/rustc_target/src/spec/linux_ohos_base.rs | 12 - .../rustc_target/src/spec/linux_uclibc_base.rs | 5 - .../src/spec/loongarch64_unknown_linux_gnu.rs | 17 - .../src/spec/loongarch64_unknown_none.rs | 23 -- .../src/spec/loongarch64_unknown_none_softfloat.rs | 24 -- .../src/spec/m68k_unknown_linux_gnu.rs | 16 - .../src/spec/mips64_openwrt_linux_musl.rs | 26 -- .../src/spec/mips64_unknown_linux_gnuabi64.rs | 22 -- .../src/spec/mips64_unknown_linux_muslabi64.rs | 22 -- .../src/spec/mips64el_unknown_linux_gnuabi64.rs | 20 -- .../src/spec/mips64el_unknown_linux_muslabi64.rs | 16 - .../src/spec/mips_unknown_linux_gnu.rs | 20 -- .../src/spec/mips_unknown_linux_musl.rs | 17 - .../src/spec/mips_unknown_linux_uclibc.rs | 20 -- compiler/rustc_target/src/spec/mipsel_sony_psp.rs | 36 -- .../src/spec/mipsel_sony_psp_linker_script.ld | 45 --- compiler/rustc_target/src/spec/mipsel_sony_psx.rs | 37 --- .../src/spec/mipsel_unknown_linux_gnu.rs | 19 -- .../src/spec/mipsel_unknown_linux_musl.rs | 16 - .../src/spec/mipsel_unknown_linux_uclibc.rs | 19 -- .../rustc_target/src/spec/mipsel_unknown_none.rs | 26 -- .../src/spec/mipsisa32r6_unknown_linux_gnu.rs | 20 -- .../src/spec/mipsisa32r6el_unknown_linux_gnu.rs | 19 -- .../src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs | 22 -- .../spec/mipsisa64r6el_unknown_linux_gnuabi64.rs | 20 -- compiler/rustc_target/src/spec/mod.rs | 359 ++++++++++++++++---- compiler/rustc_target/src/spec/msp430_none_elf.rs | 59 ---- compiler/rustc_target/src/spec/msvc_base.rs | 26 -- compiler/rustc_target/src/spec/netbsd_base.rs | 16 - compiler/rustc_target/src/spec/nto_qnx_base.rs | 18 - .../rustc_target/src/spec/nvptx64_nvidia_cuda.rs | 52 --- compiler/rustc_target/src/spec/openbsd_base.rs | 16 - .../rustc_target/src/spec/powerpc64_ibm_aix.rs | 18 - .../src/spec/powerpc64_unknown_freebsd.rs | 18 - .../src/spec/powerpc64_unknown_linux_gnu.rs | 18 - .../src/spec/powerpc64_unknown_linux_musl.rs | 18 - .../src/spec/powerpc64_unknown_openbsd.rs | 18 - .../rustc_target/src/spec/powerpc64_wrs_vxworks.rs | 18 - .../src/spec/powerpc64le_unknown_freebsd.rs | 17 - .../src/spec/powerpc64le_unknown_linux_gnu.rs | 17 - .../src/spec/powerpc64le_unknown_linux_musl.rs | 17 - .../src/spec/powerpc_unknown_freebsd.rs | 26 -- .../src/spec/powerpc_unknown_linux_gnu.rs | 17 - .../src/spec/powerpc_unknown_linux_gnuspe.rs | 22 -- .../src/spec/powerpc_unknown_linux_musl.rs | 17 - .../src/spec/powerpc_unknown_netbsd.rs | 17 - .../src/spec/powerpc_unknown_openbsd.rs | 17 - .../rustc_target/src/spec/powerpc_wrs_vxworks.rs | 17 - .../src/spec/powerpc_wrs_vxworks_spe.rs | 23 -- compiler/rustc_target/src/spec/redox_base.rs | 17 - .../src/spec/riscv32gc_unknown_linux_gnu.rs | 18 - .../src/spec/riscv32gc_unknown_linux_musl.rs | 18 - .../src/spec/riscv32i_unknown_none_elf.rs | 23 -- .../src/spec/riscv32im_unknown_none_elf.rs | 24 -- .../src/spec/riscv32imac_esp_espidf.rs | 31 -- .../src/spec/riscv32imac_unknown_none_elf.rs | 23 -- .../src/spec/riscv32imac_unknown_xous_elf.rs | 22 -- .../rustc_target/src/spec/riscv32imc_esp_espidf.rs | 34 -- .../src/spec/riscv32imc_unknown_none_elf.rs | 24 -- .../rustc_target/src/spec/riscv64_linux_android.rs | 19 -- .../src/spec/riscv64gc_unknown_freebsd.rs | 18 - .../src/spec/riscv64gc_unknown_fuchsia.rs | 19 -- .../src/spec/riscv64gc_unknown_hermit.rs | 20 -- .../src/spec/riscv64gc_unknown_linux_gnu.rs | 18 - .../src/spec/riscv64gc_unknown_linux_musl.rs | 18 - .../src/spec/riscv64gc_unknown_netbsd.rs | 19 -- .../src/spec/riscv64gc_unknown_none_elf.rs | 29 -- .../src/spec/riscv64gc_unknown_openbsd.rs | 18 - .../src/spec/riscv64imac_unknown_none_elf.rs | 26 -- .../src/spec/s390x_unknown_linux_gnu.rs | 26 -- .../src/spec/s390x_unknown_linux_musl.rs | 27 -- compiler/rustc_target/src/spec/solaris_base.rs | 16 - compiler/rustc_target/src/spec/solid_base.rs | 13 - .../src/spec/sparc64_unknown_linux_gnu.rs | 17 - .../src/spec/sparc64_unknown_netbsd.rs | 17 - .../src/spec/sparc64_unknown_openbsd.rs | 18 - .../src/spec/sparc_unknown_linux_gnu.rs | 18 - .../src/spec/sparc_unknown_none_elf.rs | 27 -- .../rustc_target/src/spec/sparcv9_sun_solaris.rs | 24 -- .../src/spec/targets/aarch64_apple_darwin.rs | 27 ++ .../src/spec/targets/aarch64_apple_ios.rs | 37 +++ .../src/spec/targets/aarch64_apple_ios_macabi.rs | 34 ++ .../src/spec/targets/aarch64_apple_ios_sim.rs | 37 +++ .../src/spec/targets/aarch64_apple_tvos.rs | 19 ++ .../src/spec/targets/aarch64_apple_tvos_sim.rs | 31 ++ .../src/spec/targets/aarch64_apple_watchos_sim.rs | 34 ++ .../spec/targets/aarch64_be_unknown_linux_gnu.rs | 18 + .../targets/aarch64_be_unknown_linux_gnu_ilp32.rs | 21 ++ .../src/spec/targets/aarch64_be_unknown_netbsd.rs | 17 + .../src/spec/targets/aarch64_fuchsia.rs | 1 + .../src/spec/targets/aarch64_kmc_solid_asp3.rs | 19 ++ .../src/spec/targets/aarch64_linux_android.rs | 26 ++ .../aarch64_nintendo_switch_freestanding.rs | 26 ++ ...4_nintendo_switch_freestanding_linker_script.ld | 78 +++++ .../src/spec/targets/aarch64_pc_windows_gnullvm.rs | 16 + .../src/spec/targets/aarch64_pc_windows_msvc.rs | 15 + .../src/spec/targets/aarch64_unknown_freebsd.rs | 19 ++ .../src/spec/targets/aarch64_unknown_fuchsia.rs | 18 + .../src/spec/targets/aarch64_unknown_hermit.rs | 15 + .../src/spec/targets/aarch64_unknown_linux_gnu.rs | 24 ++ .../targets/aarch64_unknown_linux_gnu_ilp32.rs | 17 + .../src/spec/targets/aarch64_unknown_linux_musl.rs | 21 ++ .../src/spec/targets/aarch64_unknown_linux_ohos.rs | 27 ++ .../src/spec/targets/aarch64_unknown_netbsd.rs | 16 + .../src/spec/targets/aarch64_unknown_none.rs | 32 ++ .../spec/targets/aarch64_unknown_none_softfloat.rs | 30 ++ .../spec/targets/aarch64_unknown_nto_qnx_710.rs | 29 ++ .../src/spec/targets/aarch64_unknown_openbsd.rs | 15 + .../src/spec/targets/aarch64_unknown_redox.rs | 15 + .../src/spec/targets/aarch64_unknown_teeos.rs | 16 + .../src/spec/targets/aarch64_unknown_uefi.rs | 20 ++ .../src/spec/targets/aarch64_uwp_windows_msvc.rs | 15 + .../src/spec/targets/aarch64_wrs_vxworks.rs | 15 + .../src/spec/targets/arm64_32_apple_watchos.rs | 30 ++ .../src/spec/targets/arm_linux_androideabi.rs | 18 + .../src/spec/targets/arm_unknown_linux_gnueabi.rs | 18 + .../spec/targets/arm_unknown_linux_gnueabihf.rs | 18 + .../src/spec/targets/arm_unknown_linux_musleabi.rs | 22 ++ .../spec/targets/arm_unknown_linux_musleabihf.rs | 22 ++ .../spec/targets/armeb_unknown_linux_gnueabi.rs | 20 ++ .../src/spec/targets/armebv7r_none_eabi.rs | 26 ++ .../src/spec/targets/armebv7r_none_eabihf.rs | 27 ++ .../src/spec/targets/armv4t_none_eabi.rs | 49 +++ .../spec/targets/armv4t_unknown_linux_gnueabi.rs | 20 ++ .../src/spec/targets/armv5te_none_eabi.rs | 41 +++ .../spec/targets/armv5te_unknown_linux_gnueabi.rs | 19 ++ .../spec/targets/armv5te_unknown_linux_musleabi.rs | 23 ++ .../targets/armv5te_unknown_linux_uclibceabi.rs | 19 ++ .../src/spec/targets/armv6_unknown_freebsd.rs | 20 ++ .../spec/targets/armv6_unknown_netbsd_eabihf.rs | 19 ++ .../src/spec/targets/armv6k_nintendo_3ds.rs | 36 ++ .../src/spec/targets/armv7_linux_androideabi.rs | 27 ++ .../spec/targets/armv7_sony_vita_newlibeabihf.rs | 41 +++ .../src/spec/targets/armv7_unknown_freebsd.rs | 19 ++ .../spec/targets/armv7_unknown_linux_gnueabi.rs | 21 ++ .../spec/targets/armv7_unknown_linux_gnueabihf.rs | 21 ++ .../spec/targets/armv7_unknown_linux_musleabi.rs | 26 ++ .../spec/targets/armv7_unknown_linux_musleabihf.rs | 25 ++ .../src/spec/targets/armv7_unknown_linux_ohos.rs | 24 ++ .../spec/targets/armv7_unknown_linux_uclibceabi.rs | 23 ++ .../targets/armv7_unknown_linux_uclibceabihf.rs | 24 ++ .../spec/targets/armv7_unknown_netbsd_eabihf.rs | 19 ++ .../src/spec/targets/armv7_wrs_vxworks_eabihf.rs | 17 + .../src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs | 19 ++ .../spec/targets/armv7a_kmc_solid_asp3_eabihf.rs | 19 ++ .../src/spec/targets/armv7a_none_eabi.rs | 40 +++ .../src/spec/targets/armv7a_none_eabihf.rs | 32 ++ .../src/spec/targets/armv7k_apple_watchos.rs | 30 ++ .../src/spec/targets/armv7r_none_eabi.rs | 25 ++ .../src/spec/targets/armv7r_none_eabihf.rs | 26 ++ .../src/spec/targets/armv7s_apple_ios.rs | 17 + .../src/spec/targets/asmjs_unknown_emscripten.rs | 7 + .../src/spec/targets/avr_unknown_gnu_atmega328.rs | 5 + .../src/spec/targets/bpfeb_unknown_none.rs | 12 + .../src/spec/targets/bpfel_unknown_none.rs | 12 + .../spec/targets/csky_unknown_linux_gnuabiv2.rs | 20 ++ .../spec/targets/csky_unknown_linux_gnuabiv2hf.rs | 21 ++ .../src/spec/targets/hexagon_unknown_linux_musl.rs | 29 ++ .../src/spec/targets/i386_apple_ios.rs | 23 ++ .../src/spec/targets/i386_unknown_linux_gnu.rs | 8 + .../src/spec/targets/i486_unknown_linux_gnu.rs | 8 + .../src/spec/targets/i586_pc_nto_qnx700.rs | 23 ++ .../src/spec/targets/i586_pc_windows_msvc.rs | 8 + .../src/spec/targets/i586_unknown_linux_gnu.rs | 8 + .../src/spec/targets/i586_unknown_linux_musl.rs | 8 + .../src/spec/targets/i586_unknown_netbsd.rs | 18 + .../src/spec/targets/i686_apple_darwin.rs | 27 ++ .../src/spec/targets/i686_linux_android.rs | 25 ++ .../src/spec/targets/i686_pc_windows_gnu.rs | 27 ++ .../src/spec/targets/i686_pc_windows_gnullvm.rs | 26 ++ .../src/spec/targets/i686_pc_windows_msvc.rs | 32 ++ .../src/spec/targets/i686_unknown_freebsd.rs | 19 ++ .../src/spec/targets/i686_unknown_haiku.rs | 19 ++ .../src/spec/targets/i686_unknown_hurd_gnu.rs | 19 ++ .../src/spec/targets/i686_unknown_linux_gnu.rs | 20 ++ .../src/spec/targets/i686_unknown_linux_musl.rs | 33 ++ .../src/spec/targets/i686_unknown_netbsd.rs | 19 ++ .../src/spec/targets/i686_unknown_openbsd.rs | 19 ++ .../src/spec/targets/i686_unknown_uefi.rs | 89 +++++ .../src/spec/targets/i686_uwp_windows_gnu.rs | 26 ++ .../src/spec/targets/i686_uwp_windows_msvc.rs | 17 + .../src/spec/targets/i686_wrs_vxworks.rs | 19 ++ .../spec/targets/loongarch64_unknown_linux_gnu.rs | 17 + .../src/spec/targets/loongarch64_unknown_none.rs | 23 ++ .../targets/loongarch64_unknown_none_softfloat.rs | 24 ++ .../src/spec/targets/m68k_unknown_linux_gnu.rs | 16 + .../src/spec/targets/mips64_openwrt_linux_musl.rs | 26 ++ .../spec/targets/mips64_unknown_linux_gnuabi64.rs | 22 ++ .../spec/targets/mips64_unknown_linux_muslabi64.rs | 22 ++ .../targets/mips64el_unknown_linux_gnuabi64.rs | 20 ++ .../targets/mips64el_unknown_linux_muslabi64.rs | 16 + .../src/spec/targets/mips_unknown_linux_gnu.rs | 20 ++ .../src/spec/targets/mips_unknown_linux_musl.rs | 17 + .../src/spec/targets/mips_unknown_linux_uclibc.rs | 20 ++ .../src/spec/targets/mipsel_sony_psp.rs | 36 ++ .../spec/targets/mipsel_sony_psp_linker_script.ld | 45 +++ .../src/spec/targets/mipsel_sony_psx.rs | 37 +++ .../src/spec/targets/mipsel_unknown_linux_gnu.rs | 19 ++ .../src/spec/targets/mipsel_unknown_linux_musl.rs | 16 + .../spec/targets/mipsel_unknown_linux_uclibc.rs | 19 ++ .../src/spec/targets/mipsel_unknown_netbsd.rs | 21 ++ .../src/spec/targets/mipsel_unknown_none.rs | 26 ++ .../spec/targets/mipsisa32r6_unknown_linux_gnu.rs | 20 ++ .../targets/mipsisa32r6el_unknown_linux_gnu.rs | 19 ++ .../targets/mipsisa64r6_unknown_linux_gnuabi64.rs | 22 ++ .../mipsisa64r6el_unknown_linux_gnuabi64.rs | 20 ++ .../src/spec/targets/msp430_none_elf.rs | 59 ++++ .../src/spec/targets/nvptx64_nvidia_cuda.rs | 52 +++ .../src/spec/targets/powerpc64_ibm_aix.rs | 18 + .../src/spec/targets/powerpc64_unknown_freebsd.rs | 18 + .../spec/targets/powerpc64_unknown_linux_gnu.rs | 18 + .../spec/targets/powerpc64_unknown_linux_musl.rs | 18 + .../src/spec/targets/powerpc64_unknown_openbsd.rs | 18 + .../src/spec/targets/powerpc64_wrs_vxworks.rs | 18 + .../spec/targets/powerpc64le_unknown_freebsd.rs | 17 + .../spec/targets/powerpc64le_unknown_linux_gnu.rs | 17 + .../spec/targets/powerpc64le_unknown_linux_musl.rs | 17 + .../src/spec/targets/powerpc_unknown_freebsd.rs | 26 ++ .../src/spec/targets/powerpc_unknown_linux_gnu.rs | 17 + .../spec/targets/powerpc_unknown_linux_gnuspe.rs | 22 ++ .../src/spec/targets/powerpc_unknown_linux_musl.rs | 17 + .../src/spec/targets/powerpc_unknown_netbsd.rs | 17 + .../src/spec/targets/powerpc_unknown_openbsd.rs | 17 + .../src/spec/targets/powerpc_wrs_vxworks.rs | 17 + .../src/spec/targets/powerpc_wrs_vxworks_spe.rs | 23 ++ .../spec/targets/riscv32gc_unknown_linux_gnu.rs | 18 + .../spec/targets/riscv32gc_unknown_linux_musl.rs | 18 + .../src/spec/targets/riscv32i_unknown_none_elf.rs | 23 ++ .../src/spec/targets/riscv32im_unknown_none_elf.rs | 24 ++ .../src/spec/targets/riscv32imac_esp_espidf.rs | 31 ++ .../spec/targets/riscv32imac_unknown_none_elf.rs | 23 ++ .../spec/targets/riscv32imac_unknown_xous_elf.rs | 22 ++ .../src/spec/targets/riscv32imc_esp_espidf.rs | 34 ++ .../spec/targets/riscv32imc_unknown_none_elf.rs | 24 ++ .../src/spec/targets/riscv64_linux_android.rs | 19 ++ .../src/spec/targets/riscv64gc_unknown_freebsd.rs | 18 + .../src/spec/targets/riscv64gc_unknown_fuchsia.rs | 19 ++ .../src/spec/targets/riscv64gc_unknown_hermit.rs | 20 ++ .../spec/targets/riscv64gc_unknown_linux_gnu.rs | 18 + .../spec/targets/riscv64gc_unknown_linux_musl.rs | 18 + .../src/spec/targets/riscv64gc_unknown_netbsd.rs | 19 ++ .../src/spec/targets/riscv64gc_unknown_none_elf.rs | 28 ++ .../src/spec/targets/riscv64gc_unknown_openbsd.rs | 18 + .../spec/targets/riscv64imac_unknown_none_elf.rs | 26 ++ .../src/spec/targets/s390x_unknown_linux_gnu.rs | 26 ++ .../src/spec/targets/s390x_unknown_linux_musl.rs | 27 ++ .../src/spec/targets/sparc64_unknown_linux_gnu.rs | 17 + .../src/spec/targets/sparc64_unknown_netbsd.rs | 17 + .../src/spec/targets/sparc64_unknown_openbsd.rs | 18 + .../src/spec/targets/sparc_unknown_linux_gnu.rs | 18 + .../src/spec/targets/sparc_unknown_none_elf.rs | 27 ++ .../src/spec/targets/sparcv9_sun_solaris.rs | 24 ++ .../src/spec/targets/thumbv4t_none_eabi.rs | 59 ++++ .../src/spec/targets/thumbv5te_none_eabi.rs | 41 +++ .../src/spec/targets/thumbv6m_none_eabi.rs | 25 ++ .../src/spec/targets/thumbv7a_pc_windows_msvc.rs | 28 ++ .../src/spec/targets/thumbv7a_uwp_windows_msvc.rs | 18 + .../src/spec/targets/thumbv7em_none_eabi.rs | 27 ++ .../src/spec/targets/thumbv7em_none_eabihf.rs | 36 ++ .../src/spec/targets/thumbv7m_none_eabi.rs | 18 + .../spec/targets/thumbv7neon_linux_androideabi.rs | 26 ++ .../targets/thumbv7neon_unknown_linux_gnueabihf.rs | 23 ++ .../thumbv7neon_unknown_linux_musleabihf.rs | 29 ++ .../src/spec/targets/thumbv8m_base_none_eabi.rs | 21 ++ .../src/spec/targets/thumbv8m_main_none_eabi.rs | 19 ++ .../src/spec/targets/thumbv8m_main_none_eabihf.rs | 25 ++ .../src/spec/targets/wasm32_unknown_emscripten.rs | 35 ++ .../src/spec/targets/wasm32_unknown_unknown.rs | 55 +++ .../rustc_target/src/spec/targets/wasm32_wasi.rs | 119 +++++++ .../spec/targets/wasm32_wasi_preview1_threads.rs | 133 ++++++++ .../src/spec/targets/wasm64_unknown_unknown.rs | 47 +++ .../src/spec/targets/x86_64_apple_darwin.rs | 26 ++ .../src/spec/targets/x86_64_apple_ios.rs | 21 ++ .../src/spec/targets/x86_64_apple_ios_macabi.rs | 24 ++ .../src/spec/targets/x86_64_apple_tvos.rs | 18 + .../src/spec/targets/x86_64_apple_watchos_sim.rs | 30 ++ .../spec/targets/x86_64_fortanix_unknown_sgx.rs | 83 +++++ .../src/spec/targets/x86_64_fuchsia.rs | 1 + .../src/spec/targets/x86_64_linux_android.rs | 24 ++ .../src/spec/targets/x86_64_pc_nto_qnx710.rs | 22 ++ .../src/spec/targets/x86_64_pc_solaris.rs | 21 ++ .../src/spec/targets/x86_64_pc_windows_gnu.rs | 24 ++ .../src/spec/targets/x86_64_pc_windows_gnullvm.rs | 19 ++ .../src/spec/targets/x86_64_pc_windows_msvc.rs | 17 + .../src/spec/targets/x86_64_sun_solaris.rs | 20 ++ .../src/spec/targets/x86_64_unikraft_linux_musl.rs | 19 ++ .../src/spec/targets/x86_64_unknown_dragonfly.rs | 19 ++ .../src/spec/targets/x86_64_unknown_freebsd.rs | 22 ++ .../src/spec/targets/x86_64_unknown_fuchsia.rs | 19 ++ .../src/spec/targets/x86_64_unknown_haiku.rs | 21 ++ .../src/spec/targets/x86_64_unknown_hermit.rs | 19 ++ .../src/spec/targets/x86_64_unknown_illumos.rs | 21 ++ .../src/spec/targets/x86_64_unknown_l4re_uclibc.rs | 18 + .../src/spec/targets/x86_64_unknown_linux_gnu.rs | 27 ++ .../spec/targets/x86_64_unknown_linux_gnux32.rs | 24 ++ .../src/spec/targets/x86_64_unknown_linux_musl.rs | 26 ++ .../src/spec/targets/x86_64_unknown_linux_ohos.rs | 26 ++ .../src/spec/targets/x86_64_unknown_netbsd.rs | 27 ++ .../src/spec/targets/x86_64_unknown_none.rs | 38 +++ .../src/spec/targets/x86_64_unknown_openbsd.rs | 20 ++ .../src/spec/targets/x86_64_unknown_redox.rs | 19 ++ .../src/spec/targets/x86_64_unknown_uefi.rs | 41 +++ .../src/spec/targets/x86_64_uwp_windows_gnu.rs | 23 ++ .../src/spec/targets/x86_64_uwp_windows_msvc.rs | 17 + .../src/spec/targets/x86_64_wrs_vxworks.rs | 20 ++ .../src/spec/targets/x86_64h_apple_darwin.rs | 44 +++ compiler/rustc_target/src/spec/teeos_base.rs | 29 -- compiler/rustc_target/src/spec/tests/tests_impl.rs | 2 +- compiler/rustc_target/src/spec/thumb_base.rs | 59 ---- .../rustc_target/src/spec/thumbv4t_none_eabi.rs | 59 ---- .../rustc_target/src/spec/thumbv5te_none_eabi.rs | 41 --- .../rustc_target/src/spec/thumbv6m_none_eabi.rs | 25 -- .../src/spec/thumbv7a_pc_windows_msvc.rs | 28 -- .../src/spec/thumbv7a_uwp_windows_msvc.rs | 18 - .../rustc_target/src/spec/thumbv7em_none_eabi.rs | 27 -- .../rustc_target/src/spec/thumbv7em_none_eabihf.rs | 36 -- .../rustc_target/src/spec/thumbv7m_none_eabi.rs | 18 - .../src/spec/thumbv7neon_linux_androideabi.rs | 26 -- .../spec/thumbv7neon_unknown_linux_gnueabihf.rs | 23 -- .../spec/thumbv7neon_unknown_linux_musleabihf.rs | 29 -- .../src/spec/thumbv8m_base_none_eabi.rs | 21 -- .../src/spec/thumbv8m_main_none_eabi.rs | 19 -- .../src/spec/thumbv8m_main_none_eabihf.rs | 25 -- compiler/rustc_target/src/spec/uefi_msvc_base.rs | 52 --- .../src/spec/unikraft_linux_musl_base.rs | 15 - compiler/rustc_target/src/spec/vxworks_base.rs | 21 -- .../src/spec/wasm32_unknown_emscripten.rs | 34 -- .../src/spec/wasm32_unknown_unknown.rs | 55 --- compiler/rustc_target/src/spec/wasm32_wasi.rs | 118 ------- .../src/spec/wasm32_wasi_preview1_threads.rs | 134 -------- .../src/spec/wasm64_unknown_unknown.rs | 47 --- compiler/rustc_target/src/spec/wasm_base.rs | 133 -------- compiler/rustc_target/src/spec/windows_gnu_base.rs | 107 ------ .../rustc_target/src/spec/windows_gnullvm_base.rs | 47 --- .../rustc_target/src/spec/windows_msvc_base.rs | 34 -- .../rustc_target/src/spec/windows_uwp_gnu_base.rs | 35 -- .../rustc_target/src/spec/windows_uwp_msvc_base.rs | 11 - .../rustc_target/src/spec/x86_64_apple_darwin.rs | 26 -- compiler/rustc_target/src/spec/x86_64_apple_ios.rs | 21 -- .../src/spec/x86_64_apple_ios_macabi.rs | 24 -- .../rustc_target/src/spec/x86_64_apple_tvos.rs | 18 - .../src/spec/x86_64_apple_watchos_sim.rs | 30 -- .../src/spec/x86_64_fortanix_unknown_sgx.rs | 83 ----- compiler/rustc_target/src/spec/x86_64_fuchsia.rs | 1 - .../rustc_target/src/spec/x86_64_linux_android.rs | 22 -- .../rustc_target/src/spec/x86_64_pc_nto_qnx710.rs | 23 -- .../rustc_target/src/spec/x86_64_pc_solaris.rs | 21 -- .../rustc_target/src/spec/x86_64_pc_windows_gnu.rs | 24 -- .../src/spec/x86_64_pc_windows_gnullvm.rs | 19 -- .../src/spec/x86_64_pc_windows_msvc.rs | 17 - .../rustc_target/src/spec/x86_64_sun_solaris.rs | 20 -- .../src/spec/x86_64_unikraft_linux_musl.rs | 19 -- .../src/spec/x86_64_unknown_dragonfly.rs | 19 -- .../src/spec/x86_64_unknown_freebsd.rs | 22 -- .../src/spec/x86_64_unknown_fuchsia.rs | 19 -- .../rustc_target/src/spec/x86_64_unknown_haiku.rs | 21 -- .../rustc_target/src/spec/x86_64_unknown_hermit.rs | 19 -- .../src/spec/x86_64_unknown_illumos.rs | 21 -- .../src/spec/x86_64_unknown_l4re_uclibc.rs | 18 - .../src/spec/x86_64_unknown_linux_gnu.rs | 27 -- .../src/spec/x86_64_unknown_linux_gnux32.rs | 24 -- .../src/spec/x86_64_unknown_linux_musl.rs | 26 -- .../src/spec/x86_64_unknown_linux_ohos.rs | 26 -- .../rustc_target/src/spec/x86_64_unknown_netbsd.rs | 25 -- .../rustc_target/src/spec/x86_64_unknown_none.rs | 38 --- .../src/spec/x86_64_unknown_openbsd.rs | 20 -- .../rustc_target/src/spec/x86_64_unknown_redox.rs | 19 -- .../rustc_target/src/spec/x86_64_unknown_uefi.rs | 38 --- .../src/spec/x86_64_uwp_windows_gnu.rs | 23 -- .../src/spec/x86_64_uwp_windows_msvc.rs | 17 - .../rustc_target/src/spec/x86_64_wrs_vxworks.rs | 20 -- .../rustc_target/src/spec/x86_64h_apple_darwin.rs | 44 --- 537 files changed, 8169 insertions(+), 7721 deletions(-) delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_darwin.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_ios.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_tvos.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_apple_watchos_sim.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_fuchsia.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_linux_android.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding_linker_script.ld delete mode 100644 compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_fuchsia.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_nto_qnx_710.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_redox.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_teeos.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs delete mode 100644 compiler/rustc_target/src/spec/abi.rs create mode 100644 compiler/rustc_target/src/spec/abi/mod.rs delete mode 100644 compiler/rustc_target/src/spec/aix_base.rs delete mode 100644 compiler/rustc_target/src/spec/android_base.rs delete mode 100644 compiler/rustc_target/src/spec/apple/tests.rs delete mode 100644 compiler/rustc_target/src/spec/apple_base.rs delete mode 100644 compiler/rustc_target/src/spec/arm64_32_apple_watchos.rs delete mode 100644 compiler/rustc_target/src/spec/arm_linux_androideabi.rs delete mode 100644 compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs delete mode 100644 compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs delete mode 100644 compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs delete mode 100644 compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armeb_unknown_linux_gnueabi.rs delete mode 100644 compiler/rustc_target/src/spec/armebv7r_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv4t_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv5te_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_linux_androideabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7a_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7a_none_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7k_apple_watchos.rs delete mode 100644 compiler/rustc_target/src/spec/armv7r_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7r_none_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/armv7s_apple_ios.rs delete mode 100644 compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs delete mode 100644 compiler/rustc_target/src/spec/avr_gnu_base.rs delete mode 100644 compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs create mode 100644 compiler/rustc_target/src/spec/base/aix.rs create mode 100644 compiler/rustc_target/src/spec/base/android.rs create mode 100644 compiler/rustc_target/src/spec/base/apple/mod.rs create mode 100644 compiler/rustc_target/src/spec/base/apple/tests.rs create mode 100644 compiler/rustc_target/src/spec/base/avr_gnu.rs create mode 100644 compiler/rustc_target/src/spec/base/bpf.rs create mode 100644 compiler/rustc_target/src/spec/base/dragonfly.rs create mode 100644 compiler/rustc_target/src/spec/base/freebsd.rs create mode 100644 compiler/rustc_target/src/spec/base/fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/base/haiku.rs create mode 100644 compiler/rustc_target/src/spec/base/hermit.rs create mode 100644 compiler/rustc_target/src/spec/base/hurd.rs create mode 100644 compiler/rustc_target/src/spec/base/hurd_gnu.rs create mode 100644 compiler/rustc_target/src/spec/base/illumos.rs create mode 100644 compiler/rustc_target/src/spec/base/l4re.rs create mode 100644 compiler/rustc_target/src/spec/base/linux.rs create mode 100644 compiler/rustc_target/src/spec/base/linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/base/linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/base/linux_ohos.rs create mode 100644 compiler/rustc_target/src/spec/base/linux_uclibc.rs create mode 100644 compiler/rustc_target/src/spec/base/mod.rs create mode 100644 compiler/rustc_target/src/spec/base/msvc.rs create mode 100644 compiler/rustc_target/src/spec/base/netbsd.rs create mode 100644 compiler/rustc_target/src/spec/base/nto_qnx.rs create mode 100644 compiler/rustc_target/src/spec/base/openbsd.rs create mode 100644 compiler/rustc_target/src/spec/base/redox.rs create mode 100644 compiler/rustc_target/src/spec/base/solaris.rs create mode 100644 compiler/rustc_target/src/spec/base/solid.rs create mode 100644 compiler/rustc_target/src/spec/base/teeos.rs create mode 100644 compiler/rustc_target/src/spec/base/thumb.rs create mode 100644 compiler/rustc_target/src/spec/base/uefi_msvc.rs create mode 100644 compiler/rustc_target/src/spec/base/unikraft_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/base/vxworks.rs create mode 100644 compiler/rustc_target/src/spec/base/wasm.rs create mode 100644 compiler/rustc_target/src/spec/base/windows_gnu.rs create mode 100644 compiler/rustc_target/src/spec/base/windows_gnullvm.rs create mode 100644 compiler/rustc_target/src/spec/base/windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/base/windows_uwp_gnu.rs create mode 100644 compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/bpf_base.rs delete mode 100644 compiler/rustc_target/src/spec/bpfeb_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/bpfel_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/csky_unknown_linux_gnuabiv2.rs delete mode 100644 compiler/rustc_target/src/spec/dragonfly_base.rs delete mode 100644 compiler/rustc_target/src/spec/freebsd_base.rs delete mode 100644 compiler/rustc_target/src/spec/fuchsia_base.rs delete mode 100644 compiler/rustc_target/src/spec/haiku_base.rs delete mode 100644 compiler/rustc_target/src/spec/hermit_base.rs delete mode 100644 compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/hurd_base.rs delete mode 100644 compiler/rustc_target/src/spec/hurd_gnu_base.rs delete mode 100644 compiler/rustc_target/src/spec/i386_apple_ios.rs delete mode 100644 compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i586_pc_nto_qnx700.rs delete mode 100644 compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/i686_apple_darwin.rs delete mode 100644 compiler/rustc_target/src/spec/i686_linux_android.rs delete mode 100644 compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs delete mode 100644 compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_haiku.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_uefi.rs delete mode 100644 compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/i686_wrs_vxworks.rs delete mode 100644 compiler/rustc_target/src/spec/illumos_base.rs delete mode 100644 compiler/rustc_target/src/spec/l4re_base.rs delete mode 100644 compiler/rustc_target/src/spec/linux_base.rs delete mode 100644 compiler/rustc_target/src/spec/linux_gnu_base.rs delete mode 100644 compiler/rustc_target/src/spec/linux_musl_base.rs delete mode 100644 compiler/rustc_target/src/spec/linux_ohos_base.rs delete mode 100644 compiler/rustc_target/src/spec/linux_uclibc_base.rs delete mode 100644 compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/loongarch64_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/loongarch64_unknown_none_softfloat.rs delete mode 100644 compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs delete mode 100644 compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs delete mode 100644 compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs delete mode 100644 compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs delete mode 100644 compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_sony_psp.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld delete mode 100644 compiler/rustc_target/src/spec/mipsel_sony_psx.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs delete mode 100644 compiler/rustc_target/src/spec/mipsel_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs delete mode 100644 compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs delete mode 100644 compiler/rustc_target/src/spec/msp430_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/msvc_base.rs delete mode 100644 compiler/rustc_target/src/spec/netbsd_base.rs delete mode 100644 compiler/rustc_target/src/spec/nto_qnx_base.rs delete mode 100644 compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs delete mode 100644 compiler/rustc_target/src/spec/openbsd_base.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs delete mode 100644 compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs delete mode 100644 compiler/rustc_target/src/spec/redox_base.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32imac_esp_espidf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64_linux_android.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_hermit.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64gc_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/solaris_base.rs delete mode 100644 compiler/rustc_target/src/spec/solid_base.rs delete mode 100644 compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/sparc_unknown_none_elf.rs delete mode 100644 compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding_linker_script.ld create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx_710.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7k_apple_watchos.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs create mode 100644 compiler/rustc_target/src/spec/targets/asmjs_unknown_emscripten.rs create mode 100644 compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs create mode 100644 compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs create mode 100644 compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs create mode 100644 compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/i386_apple_ios.rs create mode 100644 compiler/rustc_target/src/spec/targets/i386_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i486_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs create mode 100644 compiler/rustc_target/src/spec/targets/i586_pc_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_linux_android.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs create mode 100644 compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_sony_psp_linker_script.ld create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs create mode 100644 compiler/rustc_target/src/spec/targets/msp430_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs create mode 100644 compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs create mode 100644 compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs create mode 100644 compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs create mode 100644 compiler/rustc_target/src/spec/targets/wasm32_wasi.rs create mode 100644 compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs create mode 100644 compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx710.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_sun_solaris.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs delete mode 100644 compiler/rustc_target/src/spec/teeos_base.rs delete mode 100644 compiler/rustc_target/src/spec/thumb_base.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs delete mode 100644 compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/uefi_msvc_base.rs delete mode 100644 compiler/rustc_target/src/spec/unikraft_linux_musl_base.rs delete mode 100644 compiler/rustc_target/src/spec/vxworks_base.rs delete mode 100644 compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs delete mode 100644 compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs delete mode 100644 compiler/rustc_target/src/spec/wasm32_wasi.rs delete mode 100644 compiler/rustc_target/src/spec/wasm32_wasi_preview1_threads.rs delete mode 100644 compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs delete mode 100644 compiler/rustc_target/src/spec/wasm_base.rs delete mode 100644 compiler/rustc_target/src/spec/windows_gnu_base.rs delete mode 100644 compiler/rustc_target/src/spec/windows_gnullvm_base.rs delete mode 100644 compiler/rustc_target/src/spec/windows_msvc_base.rs delete mode 100644 compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs delete mode 100644 compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_apple_darwin.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_apple_ios.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_apple_tvos.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_fuchsia.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_linux_android.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_pc_nto_qnx710.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_pc_solaris.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_sun_solaris.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unikraft_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_fuchsia.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_none.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_redox.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64h_apple_darwin.rs (limited to 'compiler/rustc_target/src') diff --git a/compiler/rustc_target/src/abi/call/csky.rs b/compiler/rustc_target/src/abi/call/csky.rs index bbe95fa20..706493b0a 100644 --- a/compiler/rustc_target/src/abi/call/csky.rs +++ b/compiler/rustc_target/src/abi/call/csky.rs @@ -1,17 +1,39 @@ -// See https://github.com/llvm/llvm-project/blob/d85b94bf0080dcd780656c0f5e6342800720eba9/llvm/lib/Target/CSKY/CSKYCallingConv.td -use crate::abi::call::{ArgAbi, FnAbi}; +// Reference: CSKY ABI Manual +// https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1695027452256/T-HEAD_800_Series_ABI_Standards_Manual.pdf +// +// Reference: Clang CSKY lowering code +// https://github.com/llvm/llvm-project/blob/4a074f32a6914f2a8d7215d78758c24942dddc3d/clang/lib/CodeGen/Targets/CSKY.cpp#L76-L162 -fn classify_ret(ret: &mut ArgAbi<'_, Ty>) { - if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 { - ret.make_indirect(); +use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform}; + +fn classify_ret(arg: &mut ArgAbi<'_, Ty>) { + // For return type, aggregate which <= 2*XLen will be returned in registers. + // Otherwise, aggregate will be returned indirectly. + if arg.layout.is_aggregate() { + let total = arg.layout.size; + if total.bits() > 64 { + arg.make_indirect(); + } else if total.bits() > 32 { + arg.cast_to(Uniform { unit: Reg::i32(), total }); + } else { + arg.cast_to(Reg::i32()); + } } else { - ret.extend_integer_width_to(32); + arg.extend_integer_width_to(32); } } fn classify_arg(arg: &mut ArgAbi<'_, Ty>) { - if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 { - arg.make_indirect(); + // For argument type, the first 4*XLen parts of aggregate will be passed + // in registers, and the rest will be passed in stack. + // So we can coerce to integers directly and let backend handle it correctly. + if arg.layout.is_aggregate() { + let total = arg.layout.size; + if total.bits() > 32 { + arg.cast_to(Uniform { unit: Reg::i32(), total }); + } else { + arg.cast_to(Reg::i32()); + } } else { arg.extend_integer_width_to(32); } diff --git a/compiler/rustc_target/src/abi/call/x86.rs b/compiler/rustc_target/src/abi/call/x86.rs index afa1b70ef..c27f1e6dd 100644 --- a/compiler/rustc_target/src/abi/call/x86.rs +++ b/compiler/rustc_target/src/abi/call/x86.rs @@ -72,7 +72,8 @@ where // - For backwards compatibility, arguments with natural alignment > 4 are still passed // on stack (via `byval`). For example, this includes `double`, `int64_t`, // and structs containing them, provided they lack an explicit alignment attribute. - assert!(arg.layout.align.abi >= max_repr_align, + assert!( + arg.layout.align.abi >= max_repr_align, "abi alignment {:?} less than requested alignment {max_repr_align:?}", arg.layout.align.abi, ); diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 74fe98920..b00567e87 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -1,3 +1,4 @@ +use rustc_data_structures::intern::Interned; pub use Integer::*; pub use Primitive::*; @@ -18,6 +19,111 @@ impl ToJson for Endian { } } +rustc_index::newtype_index! { + /// The *source-order* index of a field in a variant. + /// + /// This is how most code after type checking refers to fields, rather than + /// using names (as names have hygiene complications and more complex lookup). + /// + /// Particularly for `repr(Rust)` types, this may not be the same as *layout* order. + /// (It is for `repr(C)` `struct`s, however.) + /// + /// For example, in the following types, + /// ```rust + /// # enum Never {} + /// # #[repr(u16)] + /// enum Demo1 { + /// Variant0 { a: Never, b: i32 } = 100, + /// Variant1 { c: u8, d: u64 } = 10, + /// } + /// struct Demo2 { e: u8, f: u16, g: u8 } + /// ``` + /// `b` is `FieldIdx(1)` in `VariantIdx(0)`, + /// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and + /// `f` is `FieldIdx(1)` in `VariantIdx(0)`. + #[derive(HashStable_Generic)] + pub struct FieldIdx {} +} + +rustc_index::newtype_index! { + /// The *source-order* index of a variant in a type. + /// + /// For enums, these are always `0..variant_count`, regardless of any + /// custom discriminants that may have been defined, and including any + /// variants that may end up uninhabited due to field types. (Some of the + /// variants may not be present in a monomorphized ABI [`Variants`], but + /// those skipped variants are always counted when determining the *index*.) + /// + /// `struct`s, `tuples`, and `unions`s are considered to have a single variant + /// with variant index zero, aka [`FIRST_VARIANT`]. + #[derive(HashStable_Generic)] + pub struct VariantIdx { + /// Equivalent to `VariantIdx(0)`. + const FIRST_VARIANT = 0; + } +} +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)] +#[rustc_pass_by_value] +pub struct Layout<'a>(pub Interned<'a, LayoutS>); + +impl<'a> fmt::Debug for Layout<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // See comment on `::fmt` above. + self.0.0.fmt(f) + } +} + +impl<'a> Deref for Layout<'a> { + type Target = &'a LayoutS; + fn deref(&self) -> &&'a LayoutS { + &self.0.0 + } +} + +impl<'a> Layout<'a> { + pub fn fields(self) -> &'a FieldsShape { + &self.0.0.fields + } + + pub fn variants(self) -> &'a Variants { + &self.0.0.variants + } + + pub fn abi(self) -> Abi { + self.0.0.abi + } + + pub fn largest_niche(self) -> Option { + self.0.0.largest_niche + } + + pub fn align(self) -> AbiAndPrefAlign { + self.0.0.align + } + + pub fn size(self) -> Size { + self.0.0.size + } + + pub fn max_repr_align(self) -> Option { + self.0.0.max_repr_align + } + + pub fn unadjusted_abi_align(self) -> Align { + self.0.0.unadjusted_abi_align + } + + /// Whether the layout is from a type that implements [`std::marker::PointerLike`]. + /// + /// Currently, that means that the type is pointer-sized, pointer-aligned, + /// and has a scalar ABI. + pub fn is_pointer_like(self, data_layout: &TargetDataLayout) -> bool { + self.size() == data_layout.pointer_size + && self.align().abi == data_layout.pointer_align.abi + && matches!(self.abi(), Abi::Scalar(..)) + } +} + /// The layout of a type, alongside the type itself. /// Provides various type traversal APIs (e.g., recursing into fields). /// @@ -42,8 +148,8 @@ impl<'a, Ty: fmt::Display> fmt::Debug for TyAndLayout<'a, Ty> { } impl<'a, Ty> Deref for TyAndLayout<'a, Ty> { - type Target = &'a LayoutS; - fn deref(&self) -> &&'a LayoutS { + type Target = &'a LayoutS; + fn deref(&self) -> &&'a LayoutS { &self.layout.0.0 } } @@ -144,14 +250,17 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { Ty::is_transparent(self) } - pub fn offset_of_subfield(self, cx: &C, indices: impl Iterator) -> Size + pub fn offset_of_subfield(self, cx: &C, indices: I) -> Size where Ty: TyAbiInterface<'a, C>, + I: Iterator, { let mut layout = self; let mut offset = Size::ZERO; - for index in indices { + for (variant, field) in indices { + layout = layout.for_variant(cx, variant); + let index = field.index(); offset += layout.fields.offset(index); layout = layout.field(cx, index); assert!( diff --git a/compiler/rustc_target/src/asm/csky.rs b/compiler/rustc_target/src/asm/csky.rs index 6f0e7f799..db3d81060 100644 --- a/compiler/rustc_target/src/asm/csky.rs +++ b/compiler/rustc_target/src/asm/csky.rs @@ -64,9 +64,9 @@ def_regs! { r20: reg = ["r20","t4"],// feature high-register r21: reg = ["r21","t5"],// feature high-register r22: reg = ["r22","t6"],// feature high-register - r23: reg = ["r23","t7", "fp"],// feature high-register - r24: reg = ["r24","t8", "sop"],// feature high-register - r25: reg = ["r25","t9","tp", "bsp"],// feature high-register + r23: reg = ["r23","t7"],// feature high-register + r24: reg = ["r24","t8"],// feature high-register + r25: reg = ["r25","t9"],// feature high-register f0: freg = ["fr0","vr0"], f1: freg = ["fr1","vr1"], f2: freg = ["fr2","vr2"], diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index e838e1113..9c5ce8894 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -8,6 +8,8 @@ //! LLVM. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] +#![cfg_attr(not(bootstrap), doc(rust_logo))] +#![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![feature(assert_matches)] #![feature(associated_type_bounds)] #![feature(exhaustive_patterns)] diff --git a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs deleted file mode 100644 index 9ac732351..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_darwin.rs +++ /dev/null @@ -1,27 +0,0 @@ -use super::apple_base::{macos_llvm_target, opts, Arch}; -use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Arm64; - let mut base = opts("macos", arch); - base.cpu = "apple-m1".into(); - base.max_atomic_width = Some(128); - - // FIXME: The leak sanitizer currently fails the tests, see #88132. - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; - - Target { - // Clang automatically chooses a more specific target based on - // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work - // correctly, we do too. - llvm_target: macos_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - mcount: "\u{1}mcount".into(), - frame_pointer: FramePointer::NonLeaf, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios.rs deleted file mode 100644 index e9edfd287..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs +++ /dev/null @@ -1,37 +0,0 @@ -use super::apple_base::{ios_llvm_target, opts, Arch}; -use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Arm64; - let mut base = opts("ios", arch); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; - - Target { - // Clang automatically chooses a more specific target based on - // IPHONEOS_DEPLOYMENT_TARGET. - // This is required for the target to pick the right - // MACH-O commands, so we do too. - llvm_target: ios_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - frame_pointer: FramePointer::NonLeaf, - // Taken from a clang build on Xcode 11.4.1. - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - arm64-apple-ios11.0.0\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs deleted file mode 100644 index b29ab14e7..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs +++ /dev/null @@ -1,34 +0,0 @@ -use super::apple_base::{opts, Arch}; -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - let llvm_target = "arm64-apple-ios14.0-macabi"; - - let arch = Arch::Arm64_macabi; - let mut base = opts("ios", arch); - base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD; - - Target { - llvm_target: llvm_target.into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - frame_pointer: FramePointer::NonLeaf, - // Taken from a clang build on Xcode 11.4.1. - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - arm64-apple-ios-macabi\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -Os\0" - .into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs deleted file mode 100644 index 6e2d62b6e..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs +++ /dev/null @@ -1,37 +0,0 @@ -use super::apple_base::{ios_sim_llvm_target, opts, Arch}; -use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Arm64_sim; - let mut base = opts("ios", arch); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; - - Target { - // Clang automatically chooses a more specific target based on - // IPHONEOS_DEPLOYMENT_TARGET. - // This is required for the simulator target to pick the right - // MACH-O commands, so we do too. - llvm_target: ios_sim_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - frame_pointer: FramePointer::NonLeaf, - // Taken from a clang build on Xcode 11.4.1. - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - arm64-apple-ios14.0-simulator\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs b/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs deleted file mode 100644 index f7cdfa71c..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_tvos.rs +++ /dev/null @@ -1,19 +0,0 @@ -use super::apple_base::{opts, tvos_llvm_target, Arch}; -use crate::spec::{FramePointer, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Arm64; - Target { - llvm_target: tvos_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - frame_pointer: FramePointer::NonLeaf, - ..opts("tvos", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/aarch64_apple_watchos_sim.rs deleted file mode 100644 index e4af4127c..000000000 --- a/compiler/rustc_target/src/spec/aarch64_apple_watchos_sim.rs +++ /dev/null @@ -1,34 +0,0 @@ -use super::apple_base::{opts, watchos_sim_llvm_target, Arch}; -use crate::spec::{FramePointer, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Arm64_sim; - Target { - // Clang automatically chooses a more specific target based on - // WATCHOS_DEPLOYMENT_TARGET. - // This is required for the simulator target to pick the right - // MACH-O commands, so we do too. - llvm_target: watchos_sim_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - frame_pointer: FramePointer::NonLeaf, - // Taken from a clang build on Xcode 11.4.1. - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - arm64-apple-watchos5.0-simulator\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..opts("watchos", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs deleted file mode 100644 index b84783c0a..000000000 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64_be-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a,+outline-atomics".into(), - max_atomic_width: Some(128), - mcount: "\u{1}_mcount".into(), - endian: Endian::Big, - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs deleted file mode 100644 index a24e0119f..000000000 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.max_atomic_width = Some(128); - - Target { - llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - abi: "ilp32".into(), - features: "+v8a,+outline-atomics".into(), - mcount: "\u{1}_mcount".into(), - endian: Endian::Big, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs deleted file mode 100644 index 98ae05974..000000000 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64_be-unknown-netbsd".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - mcount: "__mcount".into(), - max_atomic_width: Some(128), - endian: Endian::Big, - ..super::netbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_fuchsia.rs b/compiler/rustc_target/src/spec/aarch64_fuchsia.rs deleted file mode 100644 index ddecbb1a8..000000000 --- a/compiler/rustc_target/src/spec/aarch64_fuchsia.rs +++ /dev/null @@ -1 +0,0 @@ -pub use crate::spec::aarch64_unknown_fuchsia::target; diff --git a/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs b/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs deleted file mode 100644 index 437fd6015..000000000 --- a/compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs +++ /dev/null @@ -1,19 +0,0 @@ -use super::{RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let base = super::solid_base::opts("asp3"); - Target { - llvm_target: "aarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - linker: Some("aarch64-kmc-elf-gcc".into()), - features: "+v8a,+neon,+fp-armv8".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(128), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/aarch64_linux_android.rs deleted file mode 100644 index 071b727b3..000000000 --- a/compiler/rustc_target/src/spec/aarch64_linux_android.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a -// for target ABI requirements. - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-linux-android".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - max_atomic_width: Some(128), - // As documented in https://developer.android.com/ndk/guides/cpu-features.html - // the neon (ASIMD) and FP must exist on all android aarch64 targets. - features: "+v8a,+neon,+fp-armv8".into(), - supported_sanitizers: SanitizerSet::CFI - | SanitizerSet::HWADDRESS - | SanitizerSet::MEMTAG - | SanitizerSet::SHADOWCALLSTACK - | SanitizerSet::ADDRESS, - supports_xray: true, - ..super::android_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs deleted file mode 100644 index e271bdc8a..000000000 --- a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs +++ /dev/null @@ -1,26 +0,0 @@ -use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, Target, TargetOptions}; - -const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding_linker_script.ld"); - -/// A base target for Nintendo Switch devices using a pure LLVM toolchain. -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - link_script: Some(LINKER_SCRIPT.into()), - os: "horizon".into(), - max_atomic_width: Some(128), - panic_strategy: PanicStrategy::Abort, - position_independent_executables: true, - dynamic_linking: true, - relro_level: RelroLevel::Off, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding_linker_script.ld b/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding_linker_script.ld deleted file mode 100644 index f3441e659..000000000 --- a/compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding_linker_script.ld +++ /dev/null @@ -1,78 +0,0 @@ -OUTPUT_FORMAT(elf64-littleaarch64) -OUTPUT_ARCH(aarch64) -ENTRY(_start) - -PHDRS -{ - text PT_LOAD FLAGS(5); - rodata PT_LOAD FLAGS(4); - data PT_LOAD FLAGS(6); - bss PT_LOAD FLAGS(6); - dynamic PT_DYNAMIC; -} - -SECTIONS -{ - . = 0; - - .text : ALIGN(0x1000) { - HIDDEN(__text_start = .); - KEEP(*(.text.jmp)) - - . = 0x80; - - *(.text .text.*) - *(.plt .plt.*) - } - - /* Read-only sections */ - - . = ALIGN(0x1000); - - .module_name : { *(.module_name) } :rodata - - .rodata : { *(.rodata .rodata.*) } :rodata - .hash : { *(.hash) } - .dynsym : { *(.dynsym .dynsym.*) } - .dynstr : { *(.dynstr .dynstr.*) } - .rela.dyn : { *(.rela.dyn) } - - .eh_frame : { - HIDDEN(__eh_frame_start = .); - *(.eh_frame .eh_frame.*) - HIDDEN(__eh_frame_end = .); - } - - .eh_frame_hdr : { - HIDDEN(__eh_frame_hdr_start = .); - *(.eh_frame_hdr .eh_frame_hdr.*) - HIDDEN(__eh_frame_hdr_end = .); - } - - /* Read-write sections */ - - . = ALIGN(0x1000); - - .data : { - *(.data .data.*) - *(.got .got.*) - *(.got.plt .got.plt.*) - } :data - - .dynamic : { - HIDDEN(__dynamic_start = .); - *(.dynamic) - } - - /* BSS section */ - - . = ALIGN(0x1000); - - .bss : { - HIDDEN(__bss_start = .); - *(.bss .bss.*) - *(COMMON) - . = ALIGN(8); - HIDDEN(__bss_end = .); - } :bss -} diff --git a/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs deleted file mode 100644 index cf1d7ca11..000000000 --- a/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_gnullvm_base::opts(); - base.max_atomic_width = Some(128); - base.features = "+v8a,+neon,+fp-armv8".into(); - base.linker = Some("aarch64-w64-mingw32-clang".into()); - - Target { - llvm_target: "aarch64-pc-windows-gnu".into(), - pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs deleted file mode 100644 index 56b76bc7a..000000000 --- a/compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_msvc_base::opts(); - base.max_atomic_width = Some(128); - base.features = "+v8a,+neon,+fp-armv8".into(); - - Target { - llvm_target: "aarch64-pc-windows-msvc".into(), - pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs deleted file mode 100644 index 84fa9814b..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-freebsd".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - max_atomic_width: Some(128), - supported_sanitizers: SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::MEMORY - | SanitizerSet::THREAD, - ..super::freebsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/aarch64_unknown_fuchsia.rs deleted file mode 100644 index a5683fa73..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_fuchsia.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-fuchsia".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - max_atomic_width: Some(128), - supported_sanitizers: SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::SHADOWCALLSTACK, - ..super::fuchsia_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs b/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs deleted file mode 100644 index 2414867be..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-hermit".into(), - pointer_width: 64, - arch: "aarch64".into(), - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - options: TargetOptions { - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), - max_atomic_width: Some(128), - ..super::hermit_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs deleted file mode 100644 index da2460894..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a,+outline-atomics".into(), - mcount: "\u{1}_mcount".into(), - max_atomic_width: Some(128), - supported_sanitizers: SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::MEMTAG - | SanitizerSet::THREAD - | SanitizerSet::HWADDRESS, - supports_xray: true, - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs deleted file mode 100644 index ad9df53c2..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-linux-gnu_ilp32".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - abi: "ilp32".into(), - features: "+v8a,+outline-atomics".into(), - max_atomic_width: Some(128), - mcount: "\u{1}_mcount".into(), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs deleted file mode 100644 index 523eb6bd2..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.max_atomic_width = Some(128); - base.supports_xray = true; - base.features = "+v8a".into(); - base.supported_sanitizers = SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - - Target { - llvm_target: "aarch64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs deleted file mode 100644 index c8f3db00e..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -use super::SanitizerSet; - -pub fn target() -> Target { - let mut base = super::linux_ohos_base::opts(); - base.max_atomic_width = Some(128); - - Target { - // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. - llvm_target: "aarch64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+reserve-x18".into(), - mcount: "\u{1}_mcount".into(), - supported_sanitizers: SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::MEMTAG - | SanitizerSet::THREAD - | SanitizerSet::HWADDRESS, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs deleted file mode 100644 index a58b64d3d..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-netbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - mcount: "__mcount".into(), - max_atomic_width: Some(128), - ..super::netbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none.rs deleted file mode 100644 index be27302f7..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_none.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Generic AArch64 target for bare-metal code - Floating point enabled -// -// Can be used in conjunction with the `target-feature` and -// `target-cpu` compiler flags to opt-in more hardware-specific -// features. -// -// For example, `-C target-cpu=cortex-a53`. - -use super::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetOptions, -}; - -pub fn target() -> Target { - let opts = TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), - supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(128), - panic_strategy: PanicStrategy::Abort, - ..Default::default() - }; - Target { - llvm_target: "aarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs deleted file mode 100644 index 9dfa1f268..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_none_softfloat.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Generic AArch64 target for bare-metal code - Floating point disabled -// -// Can be used in conjunction with the `target-feature` and -// `target-cpu` compiler flags to opt-in more hardware-specific -// features. -// -// For example, `-C target-cpu=cortex-a53`. - -use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let opts = TargetOptions { - abi: "softfloat".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - features: "+v8a,+strict-align,-neon,-fp-armv8".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(128), - panic_strategy: PanicStrategy::Abort, - ..Default::default() - }; - Target { - llvm_target: "aarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_nto_qnx_710.rs b/compiler/rustc_target/src/spec/aarch64_unknown_nto_qnx_710.rs deleted file mode 100644 index 630642dcd..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_nto_qnx_710.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::nto_qnx_base; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-unknown".into(), - pointer_width: 64, - // from: https://llvm.org/docs/LangRef.html#data-layout - // e = little endian - // m:e = ELF mangling: Private symbols get a .L prefix - // i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32 - // i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32 - // i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64 - // i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128 - // n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently. - // S128 = 128 bits are the natural alignment of the stack in bits. - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - max_atomic_width: Some(128), - pre_link_args: TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-Vgcc_ntoaarch64le_cxx"], - ), - env: "nto71".into(), - ..nto_qnx_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs deleted file mode 100644 index 224e31af2..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-openbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - max_atomic_width: Some(128), - ..super::openbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs b/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs deleted file mode 100644 index 5650162cd..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_redox.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::redox_base::opts(); - base.max_atomic_width = Some(128); - base.features = "+v8a".into(); - - Target { - llvm_target: "aarch64-unknown-redox".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_teeos.rs b/compiler/rustc_target/src/spec/aarch64_unknown_teeos.rs deleted file mode 100644 index 64a7dc681..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_teeos.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::teeos_base::opts(); - base.features = "+strict-align,+neon,+fp-armv8".into(); - base.max_atomic_width = Some(128); - base.linker = Some("aarch64-linux-gnu-ld".into()); - - Target { - llvm_target: "aarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs deleted file mode 100644 index 82fb01556..000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_uefi.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This defines the aarch64 target for UEFI systems as described in the UEFI specification. See the -// uefi-base module for generic UEFI options. - -use super::uefi_msvc_base; -use crate::spec::{LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = uefi_msvc_base::opts(); - - base.max_atomic_width = Some(128); - base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/machine:arm64"]); - base.features = "+v8a".into(); - - Target { - llvm_target: "aarch64-unknown-windows".into(), - pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs deleted file mode 100644 index d39442d91..000000000 --- a/compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_uwp_msvc_base::opts(); - base.max_atomic_width = Some(128); - base.features = "+v8a".into(); - - Target { - llvm_target: "aarch64-pc-windows-msvc".into(), - pointer_width: 64, - data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs deleted file mode 100644 index 7e2af4c7a..000000000 --- a/compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "aarch64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a".into(), - max_atomic_width: Some(128), - ..super::vxworks_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs deleted file mode 100644 index a99cccd42..000000000 --- a/compiler/rustc_target/src/spec/abi.rs +++ /dev/null @@ -1,341 +0,0 @@ -use std::fmt; - -use rustc_macros::HashStable_Generic; -use rustc_span::symbol::sym; -use rustc_span::{Span, Symbol}; - -#[cfg(test)] -mod tests; - -#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)] -#[derive(HashStable_Generic, Encodable, Decodable)] -pub enum Abi { - // Some of the ABIs come first because every time we add a new ABI, we have to re-bless all the - // hashing tests. These are used in many places, so giving them stable values reduces test - // churn. The specific values are meaningless. - Rust, - C { - unwind: bool, - }, - Cdecl { - unwind: bool, - }, - Stdcall { - unwind: bool, - }, - Fastcall { - unwind: bool, - }, - Vectorcall { - unwind: bool, - }, - Thiscall { - unwind: bool, - }, - Aapcs { - unwind: bool, - }, - Win64 { - unwind: bool, - }, - SysV64 { - unwind: bool, - }, - PtxKernel, - Msp430Interrupt, - X86Interrupt, - AmdGpuKernel, - EfiApi, - AvrInterrupt, - AvrNonBlockingInterrupt, - CCmseNonSecureCall, - Wasm, - System { - unwind: bool, - }, - RustIntrinsic, - RustCall, - PlatformIntrinsic, - Unadjusted, - /// For things unlikely to be called, where reducing register pressure in - /// `extern "Rust"` callers is worth paying extra cost in the callee. - /// Stronger than just `#[cold]` because `fn` pointers might be incompatible. - RustCold, - RiscvInterruptM, - RiscvInterruptS, -} - -impl Abi { - pub fn supports_varargs(self) -> bool { - // * C and Cdecl obviously support varargs. - // * C can be based on Aapcs, SysV64 or Win64, so they must support varargs. - // * EfiApi is based on Win64 or C, so it also supports it. - // - // * Stdcall does not, because it would be impossible for the callee to clean - // up the arguments. (callee doesn't know how many arguments are there) - // * Same for Fastcall, Vectorcall and Thiscall. - // * System can become Stdcall, so is also a no-no. - // * Other calling conventions are related to hardware or the compiler itself. - match self { - Self::C { .. } - | Self::Cdecl { .. } - | Self::Aapcs { .. } - | Self::Win64 { .. } - | Self::SysV64 { .. } - | Self::EfiApi => true, - _ => false, - } - } -} - -#[derive(Copy, Clone)] -pub struct AbiData { - abi: Abi, - - /// Name of this ABI as we like it called. - name: &'static str, -} - -#[allow(non_upper_case_globals)] -const AbiDatas: &[AbiData] = &[ - AbiData { abi: Abi::Rust, name: "Rust" }, - AbiData { abi: Abi::C { unwind: false }, name: "C" }, - AbiData { abi: Abi::C { unwind: true }, name: "C-unwind" }, - AbiData { abi: Abi::Cdecl { unwind: false }, name: "cdecl" }, - AbiData { abi: Abi::Cdecl { unwind: true }, name: "cdecl-unwind" }, - AbiData { abi: Abi::Stdcall { unwind: false }, name: "stdcall" }, - AbiData { abi: Abi::Stdcall { unwind: true }, name: "stdcall-unwind" }, - AbiData { abi: Abi::Fastcall { unwind: false }, name: "fastcall" }, - AbiData { abi: Abi::Fastcall { unwind: true }, name: "fastcall-unwind" }, - AbiData { abi: Abi::Vectorcall { unwind: false }, name: "vectorcall" }, - AbiData { abi: Abi::Vectorcall { unwind: true }, name: "vectorcall-unwind" }, - AbiData { abi: Abi::Thiscall { unwind: false }, name: "thiscall" }, - AbiData { abi: Abi::Thiscall { unwind: true }, name: "thiscall-unwind" }, - AbiData { abi: Abi::Aapcs { unwind: false }, name: "aapcs" }, - AbiData { abi: Abi::Aapcs { unwind: true }, name: "aapcs-unwind" }, - AbiData { abi: Abi::Win64 { unwind: false }, name: "win64" }, - AbiData { abi: Abi::Win64 { unwind: true }, name: "win64-unwind" }, - AbiData { abi: Abi::SysV64 { unwind: false }, name: "sysv64" }, - AbiData { abi: Abi::SysV64 { unwind: true }, name: "sysv64-unwind" }, - AbiData { abi: Abi::PtxKernel, name: "ptx-kernel" }, - AbiData { abi: Abi::Msp430Interrupt, name: "msp430-interrupt" }, - AbiData { abi: Abi::X86Interrupt, name: "x86-interrupt" }, - AbiData { abi: Abi::AmdGpuKernel, name: "amdgpu-kernel" }, - AbiData { abi: Abi::EfiApi, name: "efiapi" }, - AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" }, - AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" }, - AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" }, - AbiData { abi: Abi::Wasm, name: "wasm" }, - AbiData { abi: Abi::System { unwind: false }, name: "system" }, - AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" }, - AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, - AbiData { abi: Abi::RustCall, name: "rust-call" }, - AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" }, - AbiData { abi: Abi::Unadjusted, name: "unadjusted" }, - AbiData { abi: Abi::RustCold, name: "rust-cold" }, - AbiData { abi: Abi::RiscvInterruptM, name: "riscv-interrupt-m" }, - AbiData { abi: Abi::RiscvInterruptS, name: "riscv-interrupt-s" }, -]; - -#[derive(Copy, Clone, Debug)] -pub enum AbiUnsupported { - Unrecognized, - Reason { explain: &'static str }, -} - -/// Returns the ABI with the given name (if any). -pub fn lookup(name: &str) -> Result { - AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi).ok_or_else(|| match name { - "riscv-interrupt" => AbiUnsupported::Reason { - explain: "please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively", - }, - "riscv-interrupt-u" => AbiUnsupported::Reason { - explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314", - }, - - _ => AbiUnsupported::Unrecognized, - - }) -} - -pub fn all_names() -> Vec<&'static str> { - AbiDatas.iter().map(|d| d.name).collect() -} - -pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> { - AbiDatas - .iter() - .map(|d| d.name) - .filter(|name| is_enabled(features, span, name).is_ok()) - .collect() -} - -pub enum AbiDisabled { - Unstable { feature: Symbol, explain: &'static str }, - Unrecognized, -} - -pub fn is_enabled( - features: &rustc_feature::Features, - span: Span, - name: &str, -) -> Result<(), AbiDisabled> { - let s = is_stable(name); - if let Err(AbiDisabled::Unstable { feature, .. }) = s { - if features.enabled(feature) || span.allows_unstable(feature) { - return Ok(()); - } - } - s -} - -pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { - match name { - // Stable - "Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind" - | "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind" - | "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall" - | "thiscall-unwind" => Ok(()), - "rust-intrinsic" => Err(AbiDisabled::Unstable { - feature: sym::intrinsics, - explain: "intrinsics are subject to change", - }), - "platform-intrinsic" => Err(AbiDisabled::Unstable { - feature: sym::platform_intrinsics, - explain: "platform intrinsics are experimental and possibly buggy", - }), - "vectorcall" => Err(AbiDisabled::Unstable { - feature: sym::abi_vectorcall, - explain: "vectorcall is experimental and subject to change", - }), - "vectorcall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::abi_vectorcall, - explain: "vectorcall-unwind ABI is experimental and subject to change", - }), - "rust-call" => Err(AbiDisabled::Unstable { - feature: sym::unboxed_closures, - explain: "rust-call ABI is subject to change", - }), - "rust-cold" => Err(AbiDisabled::Unstable { - feature: sym::rust_cold_cc, - explain: "rust-cold is experimental and subject to change", - }), - "ptx-kernel" => Err(AbiDisabled::Unstable { - feature: sym::abi_ptx, - explain: "PTX ABIs are experimental and subject to change", - }), - "unadjusted" => Err(AbiDisabled::Unstable { - feature: sym::abi_unadjusted, - explain: "unadjusted ABI is an implementation detail and perma-unstable", - }), - "msp430-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_msp430_interrupt, - explain: "msp430-interrupt ABI is experimental and subject to change", - }), - "x86-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_x86_interrupt, - explain: "x86-interrupt ABI is experimental and subject to change", - }), - "amdgpu-kernel" => Err(AbiDisabled::Unstable { - feature: sym::abi_amdgpu_kernel, - explain: "amdgpu-kernel ABI is experimental and subject to change", - }), - "avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_avr_interrupt, - explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change", - }), - "riscv-interrupt-m" | "riscv-interrupt-s" => Err(AbiDisabled::Unstable { - feature: sym::abi_riscv_interrupt, - explain: "riscv-interrupt ABIs are experimental and subject to change", - }), - "C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable { - feature: sym::abi_c_cmse_nonsecure_call, - explain: "C-cmse-nonsecure-call ABI is experimental and subject to change", - }), - "wasm" => Err(AbiDisabled::Unstable { - feature: sym::wasm_abi, - explain: "wasm ABI is experimental and subject to change", - }), - _ => Err(AbiDisabled::Unrecognized), - } -} - -impl Abi { - /// Default ABI chosen for `extern fn` declarations without an explicit ABI. - pub const FALLBACK: Abi = Abi::C { unwind: false }; - - #[inline] - pub fn index(self) -> usize { - // N.B., this ordering MUST match the AbiDatas array above. - // (This is ensured by the test indices_are_correct().) - use Abi::*; - let i = match self { - // Cross-platform ABIs - Rust => 0, - C { unwind: false } => 1, - C { unwind: true } => 2, - // Platform-specific ABIs - Cdecl { unwind: false } => 3, - Cdecl { unwind: true } => 4, - Stdcall { unwind: false } => 5, - Stdcall { unwind: true } => 6, - Fastcall { unwind: false } => 7, - Fastcall { unwind: true } => 8, - Vectorcall { unwind: false } => 9, - Vectorcall { unwind: true } => 10, - Thiscall { unwind: false } => 11, - Thiscall { unwind: true } => 12, - Aapcs { unwind: false } => 13, - Aapcs { unwind: true } => 14, - Win64 { unwind: false } => 15, - Win64 { unwind: true } => 16, - SysV64 { unwind: false } => 17, - SysV64 { unwind: true } => 18, - PtxKernel => 19, - Msp430Interrupt => 20, - X86Interrupt => 21, - AmdGpuKernel => 22, - EfiApi => 23, - AvrInterrupt => 24, - AvrNonBlockingInterrupt => 25, - CCmseNonSecureCall => 26, - Wasm => 27, - // Cross-platform ABIs - System { unwind: false } => 28, - System { unwind: true } => 29, - RustIntrinsic => 30, - RustCall => 31, - PlatformIntrinsic => 32, - Unadjusted => 33, - RustCold => 34, - RiscvInterruptM => 35, - RiscvInterruptS => 36, - }; - debug_assert!( - AbiDatas - .iter() - .enumerate() - .find(|(_, AbiData { abi, .. })| *abi == self) - .map(|(index, _)| index) - .expect("abi variant has associated data") - == i, - "Abi index did not match `AbiDatas` ordering" - ); - i - } - - #[inline] - pub fn data(self) -> &'static AbiData { - &AbiDatas[self.index()] - } - - pub fn name(self) -> &'static str { - self.data().name - } -} - -impl fmt::Display for Abi { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "\"{}\"", self.name()) - } -} diff --git a/compiler/rustc_target/src/spec/abi/mod.rs b/compiler/rustc_target/src/spec/abi/mod.rs new file mode 100644 index 000000000..4c1f0c01a --- /dev/null +++ b/compiler/rustc_target/src/spec/abi/mod.rs @@ -0,0 +1,341 @@ +use std::fmt; + +use rustc_macros::HashStable_Generic; +use rustc_span::symbol::sym; +use rustc_span::{Span, Symbol}; + +#[cfg(test)] +mod tests; + +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug)] +#[derive(HashStable_Generic, Encodable, Decodable)] +pub enum Abi { + // Some of the ABIs come first because every time we add a new ABI, we have to re-bless all the + // hashing tests. These are used in many places, so giving them stable values reduces test + // churn. The specific values are meaningless. + Rust, + C { + unwind: bool, + }, + Cdecl { + unwind: bool, + }, + Stdcall { + unwind: bool, + }, + Fastcall { + unwind: bool, + }, + Vectorcall { + unwind: bool, + }, + Thiscall { + unwind: bool, + }, + Aapcs { + unwind: bool, + }, + Win64 { + unwind: bool, + }, + SysV64 { + unwind: bool, + }, + PtxKernel, + Msp430Interrupt, + X86Interrupt, + AmdGpuKernel, + EfiApi, + AvrInterrupt, + AvrNonBlockingInterrupt, + CCmseNonSecureCall, + Wasm, + System { + unwind: bool, + }, + RustIntrinsic, + RustCall, + PlatformIntrinsic, + Unadjusted, + /// For things unlikely to be called, where reducing register pressure in + /// `extern "Rust"` callers is worth paying extra cost in the callee. + /// Stronger than just `#[cold]` because `fn` pointers might be incompatible. + RustCold, + RiscvInterruptM, + RiscvInterruptS, +} + +impl Abi { + pub fn supports_varargs(self) -> bool { + // * C and Cdecl obviously support varargs. + // * C can be based on Aapcs, SysV64 or Win64, so they must support varargs. + // * EfiApi is based on Win64 or C, so it also supports it. + // + // * Stdcall does not, because it would be impossible for the callee to clean + // up the arguments. (callee doesn't know how many arguments are there) + // * Same for Fastcall, Vectorcall and Thiscall. + // * System can become Stdcall, so is also a no-no. + // * Other calling conventions are related to hardware or the compiler itself. + match self { + Self::C { .. } + | Self::Cdecl { .. } + | Self::Aapcs { .. } + | Self::Win64 { .. } + | Self::SysV64 { .. } + | Self::EfiApi => true, + _ => false, + } + } +} + +#[derive(Copy, Clone)] +pub struct AbiData { + abi: Abi, + + /// Name of this ABI as we like it called. + name: &'static str, +} + +#[allow(non_upper_case_globals)] +const AbiDatas: &[AbiData] = &[ + AbiData { abi: Abi::Rust, name: "Rust" }, + AbiData { abi: Abi::C { unwind: false }, name: "C" }, + AbiData { abi: Abi::C { unwind: true }, name: "C-unwind" }, + AbiData { abi: Abi::Cdecl { unwind: false }, name: "cdecl" }, + AbiData { abi: Abi::Cdecl { unwind: true }, name: "cdecl-unwind" }, + AbiData { abi: Abi::Stdcall { unwind: false }, name: "stdcall" }, + AbiData { abi: Abi::Stdcall { unwind: true }, name: "stdcall-unwind" }, + AbiData { abi: Abi::Fastcall { unwind: false }, name: "fastcall" }, + AbiData { abi: Abi::Fastcall { unwind: true }, name: "fastcall-unwind" }, + AbiData { abi: Abi::Vectorcall { unwind: false }, name: "vectorcall" }, + AbiData { abi: Abi::Vectorcall { unwind: true }, name: "vectorcall-unwind" }, + AbiData { abi: Abi::Thiscall { unwind: false }, name: "thiscall" }, + AbiData { abi: Abi::Thiscall { unwind: true }, name: "thiscall-unwind" }, + AbiData { abi: Abi::Aapcs { unwind: false }, name: "aapcs" }, + AbiData { abi: Abi::Aapcs { unwind: true }, name: "aapcs-unwind" }, + AbiData { abi: Abi::Win64 { unwind: false }, name: "win64" }, + AbiData { abi: Abi::Win64 { unwind: true }, name: "win64-unwind" }, + AbiData { abi: Abi::SysV64 { unwind: false }, name: "sysv64" }, + AbiData { abi: Abi::SysV64 { unwind: true }, name: "sysv64-unwind" }, + AbiData { abi: Abi::PtxKernel, name: "ptx-kernel" }, + AbiData { abi: Abi::Msp430Interrupt, name: "msp430-interrupt" }, + AbiData { abi: Abi::X86Interrupt, name: "x86-interrupt" }, + AbiData { abi: Abi::AmdGpuKernel, name: "amdgpu-kernel" }, + AbiData { abi: Abi::EfiApi, name: "efiapi" }, + AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" }, + AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" }, + AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" }, + AbiData { abi: Abi::Wasm, name: "wasm" }, + AbiData { abi: Abi::System { unwind: false }, name: "system" }, + AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" }, + AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, + AbiData { abi: Abi::RustCall, name: "rust-call" }, + AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" }, + AbiData { abi: Abi::Unadjusted, name: "unadjusted" }, + AbiData { abi: Abi::RustCold, name: "rust-cold" }, + AbiData { abi: Abi::RiscvInterruptM, name: "riscv-interrupt-m" }, + AbiData { abi: Abi::RiscvInterruptS, name: "riscv-interrupt-s" }, +]; + +#[derive(Copy, Clone, Debug)] +pub enum AbiUnsupported { + Unrecognized, + Reason { explain: &'static str }, +} + +/// Returns the ABI with the given name (if any). +pub fn lookup(name: &str) -> Result { + AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi).ok_or_else(|| match name { + "riscv-interrupt" => AbiUnsupported::Reason { + explain: "please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively", + }, + "riscv-interrupt-u" => AbiUnsupported::Reason { + explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314", + }, + + _ => AbiUnsupported::Unrecognized, + + }) +} + +pub fn all_names() -> Vec<&'static str> { + AbiDatas.iter().map(|d| d.name).collect() +} + +pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> { + AbiDatas + .iter() + .map(|d| d.name) + .filter(|name| is_enabled(features, span, name).is_ok()) + .collect() +} + +pub enum AbiDisabled { + Unstable { feature: Symbol, explain: &'static str }, + Unrecognized, +} + +pub fn is_enabled( + features: &rustc_feature::Features, + span: Span, + name: &str, +) -> Result<(), AbiDisabled> { + let s = is_stable(name); + if let Err(AbiDisabled::Unstable { feature, .. }) = s { + if features.active(feature) || span.allows_unstable(feature) { + return Ok(()); + } + } + s +} + +pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { + match name { + // Stable + "Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind" + | "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind" + | "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall" + | "thiscall-unwind" => Ok(()), + "rust-intrinsic" => Err(AbiDisabled::Unstable { + feature: sym::intrinsics, + explain: "intrinsics are subject to change", + }), + "platform-intrinsic" => Err(AbiDisabled::Unstable { + feature: sym::platform_intrinsics, + explain: "platform intrinsics are experimental and possibly buggy", + }), + "vectorcall" => Err(AbiDisabled::Unstable { + feature: sym::abi_vectorcall, + explain: "vectorcall is experimental and subject to change", + }), + "vectorcall-unwind" => Err(AbiDisabled::Unstable { + feature: sym::abi_vectorcall, + explain: "vectorcall-unwind ABI is experimental and subject to change", + }), + "rust-call" => Err(AbiDisabled::Unstable { + feature: sym::unboxed_closures, + explain: "rust-call ABI is subject to change", + }), + "rust-cold" => Err(AbiDisabled::Unstable { + feature: sym::rust_cold_cc, + explain: "rust-cold is experimental and subject to change", + }), + "ptx-kernel" => Err(AbiDisabled::Unstable { + feature: sym::abi_ptx, + explain: "PTX ABIs are experimental and subject to change", + }), + "unadjusted" => Err(AbiDisabled::Unstable { + feature: sym::abi_unadjusted, + explain: "unadjusted ABI is an implementation detail and perma-unstable", + }), + "msp430-interrupt" => Err(AbiDisabled::Unstable { + feature: sym::abi_msp430_interrupt, + explain: "msp430-interrupt ABI is experimental and subject to change", + }), + "x86-interrupt" => Err(AbiDisabled::Unstable { + feature: sym::abi_x86_interrupt, + explain: "x86-interrupt ABI is experimental and subject to change", + }), + "amdgpu-kernel" => Err(AbiDisabled::Unstable { + feature: sym::abi_amdgpu_kernel, + explain: "amdgpu-kernel ABI is experimental and subject to change", + }), + "avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable { + feature: sym::abi_avr_interrupt, + explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change", + }), + "riscv-interrupt-m" | "riscv-interrupt-s" => Err(AbiDisabled::Unstable { + feature: sym::abi_riscv_interrupt, + explain: "riscv-interrupt ABIs are experimental and subject to change", + }), + "C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable { + feature: sym::abi_c_cmse_nonsecure_call, + explain: "C-cmse-nonsecure-call ABI is experimental and subject to change", + }), + "wasm" => Err(AbiDisabled::Unstable { + feature: sym::wasm_abi, + explain: "wasm ABI is experimental and subject to change", + }), + _ => Err(AbiDisabled::Unrecognized), + } +} + +impl Abi { + /// Default ABI chosen for `extern fn` declarations without an explicit ABI. + pub const FALLBACK: Abi = Abi::C { unwind: false }; + + #[inline] + pub fn index(self) -> usize { + // N.B., this ordering MUST match the AbiDatas array above. + // (This is ensured by the test indices_are_correct().) + use Abi::*; + let i = match self { + // Cross-platform ABIs + Rust => 0, + C { unwind: false } => 1, + C { unwind: true } => 2, + // Platform-specific ABIs + Cdecl { unwind: false } => 3, + Cdecl { unwind: true } => 4, + Stdcall { unwind: false } => 5, + Stdcall { unwind: true } => 6, + Fastcall { unwind: false } => 7, + Fastcall { unwind: true } => 8, + Vectorcall { unwind: false } => 9, + Vectorcall { unwind: true } => 10, + Thiscall { unwind: false } => 11, + Thiscall { unwind: true } => 12, + Aapcs { unwind: false } => 13, + Aapcs { unwind: true } => 14, + Win64 { unwind: false } => 15, + Win64 { unwind: true } => 16, + SysV64 { unwind: false } => 17, + SysV64 { unwind: true } => 18, + PtxKernel => 19, + Msp430Interrupt => 20, + X86Interrupt => 21, + AmdGpuKernel => 22, + EfiApi => 23, + AvrInterrupt => 24, + AvrNonBlockingInterrupt => 25, + CCmseNonSecureCall => 26, + Wasm => 27, + // Cross-platform ABIs + System { unwind: false } => 28, + System { unwind: true } => 29, + RustIntrinsic => 30, + RustCall => 31, + PlatformIntrinsic => 32, + Unadjusted => 33, + RustCold => 34, + RiscvInterruptM => 35, + RiscvInterruptS => 36, + }; + debug_assert!( + AbiDatas + .iter() + .enumerate() + .find(|(_, AbiData { abi, .. })| *abi == self) + .map(|(index, _)| index) + .expect("abi variant has associated data") + == i, + "Abi index did not match `AbiDatas` ordering" + ); + i + } + + #[inline] + pub fn data(self) -> &'static AbiData { + &AbiDatas[self.index()] + } + + pub fn name(self) -> &'static str { + self.data().name + } +} + +impl fmt::Display for Abi { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "\"{}\"", self.name()) + } +} diff --git a/compiler/rustc_target/src/spec/aix_base.rs b/compiler/rustc_target/src/spec/aix_base.rs deleted file mode 100644 index c71c4ba2c..000000000 --- a/compiler/rustc_target/src/spec/aix_base.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - abi: "vec-extabi".into(), - code_model: Some(CodeModel::Small), - cpu: "pwr7".into(), - os: "aix".into(), - vendor: "ibm".into(), - dynamic_linking: true, - endian: Endian::Big, - executables: true, - archive_format: "aix_big".into(), - families: cvs!["unix"], - has_rpath: false, - has_thread_local: true, - crt_static_respected: true, - linker_flavor: LinkerFlavor::Unix(Cc::No), - linker: Some("ld".into()), - eh_frame_header: false, - is_like_aix: true, - default_dwarf_version: 3, - function_sections: true, - pre_link_objects: crt_objects::new(&[ - (LinkOutputKind::DynamicNoPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]), - (LinkOutputKind::DynamicPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]), - ]), - dll_suffix: ".a".into(), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/android_base.rs b/compiler/rustc_target/src/spec/android_base.rs deleted file mode 100644 index 9c1df1a06..000000000 --- a/compiler/rustc_target/src/spec/android_base.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{SanitizerSet, TargetOptions}; - -pub fn opts() -> TargetOptions { - let mut base = super::linux_base::opts(); - base.os = "android".into(); - base.is_like_android = true; - base.default_dwarf_version = 2; - base.has_thread_local = false; - base.supported_sanitizers = SanitizerSet::ADDRESS; - // This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867 - // for context. (At that time, there was no `-C force-unwind-tables`, so the only solution - // was to always emit `uwtable`). - base.default_uwtable = true; - base.crt_static_respected = true; - base -} diff --git a/compiler/rustc_target/src/spec/apple/tests.rs b/compiler/rustc_target/src/spec/apple/tests.rs deleted file mode 100644 index 3b23ddadc..000000000 --- a/compiler/rustc_target/src/spec/apple/tests.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::spec::{ - aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin, - x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim, -}; - -#[test] -fn simulator_targets_set_abi() { - let all_sim_targets = [ - x86_64_apple_ios::target(), - x86_64_apple_tvos::target(), - x86_64_apple_watchos_sim::target(), - aarch64_apple_ios_sim::target(), - // Note: There is currently no ARM64 tvOS simulator target - aarch64_apple_watchos_sim::target(), - ]; - - for target in all_sim_targets { - assert_eq!(target.abi, "sim") - } -} - -#[test] -fn macos_link_environment_unmodified() { - let all_macos_targets = [ - aarch64_apple_darwin::target(), - i686_apple_darwin::target(), - x86_64_apple_darwin::target(), - ]; - - for target in all_macos_targets { - // macOS targets should only remove information for cross-compiling, but never - // for the host. - assert_eq!( - target.link_env_remove, - crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"], - ); - } -} diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs deleted file mode 100644 index 7a666eea4..000000000 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ /dev/null @@ -1,356 +0,0 @@ -use std::{borrow::Cow, env}; - -use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs}; -use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, Target, TargetOptions}; - -#[cfg(test)] -#[path = "apple/tests.rs"] -mod tests; - -use Arch::*; -#[allow(non_camel_case_types)] -#[derive(Copy, Clone)] -pub enum Arch { - Armv7k, - Armv7s, - Arm64, - Arm64_32, - I386, - I686, - X86_64, - X86_64h, - X86_64_sim, - X86_64_macabi, - Arm64_macabi, - Arm64_sim, -} - -impl Arch { - pub fn target_name(self) -> &'static str { - match self { - Armv7k => "armv7k", - Armv7s => "armv7s", - Arm64 | Arm64_macabi | Arm64_sim => "arm64", - Arm64_32 => "arm64_32", - I386 => "i386", - I686 => "i686", - X86_64 | X86_64_sim | X86_64_macabi => "x86_64", - X86_64h => "x86_64h", - } - } - - pub fn target_arch(self) -> Cow<'static, str> { - Cow::Borrowed(match self { - Armv7k | Armv7s => "arm", - Arm64 | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64", - I386 | I686 => "x86", - X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64", - }) - } - - fn target_abi(self) -> &'static str { - match self { - Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "", - X86_64_macabi | Arm64_macabi => "macabi", - // x86_64-apple-ios is a simulator target, even though it isn't - // declared that way in the target like the other ones... - Arm64_sim | X86_64_sim => "sim", - } - } - - fn target_cpu(self) -> &'static str { - match self { - Armv7k => "cortex-a8", - Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher. - Arm64 => "apple-a7", - Arm64_32 => "apple-s4", - // Only macOS 10.12+ is supported, which means - // all x86_64/x86 CPUs must be running at least penryn - // https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82 - I386 | I686 => "penryn", - X86_64 | X86_64_sim => "penryn", - X86_64_macabi => "penryn", - // Note: `core-avx2` is slightly more advanced than `x86_64h`, see - // comments (and disabled features) in `x86_64h_apple_darwin` for - // details. It is a higher baseline then `penryn` however. - X86_64h => "core-avx2", - Arm64_macabi => "apple-a12", - Arm64_sim => "apple-a12", - } - } -} - -fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs { - let platform_name: StaticCow = match abi { - "sim" => format!("{os}-simulator").into(), - "macabi" => "mac-catalyst".into(), - _ => os.into(), - }; - - let platform_version: StaticCow = match os { - "ios" => ios_lld_platform_version(), - "tvos" => tvos_lld_platform_version(), - "watchos" => watchos_lld_platform_version(), - "macos" => macos_lld_platform_version(arch), - _ => unreachable!(), - } - .into(); - - let arch = arch.target_name(); - - let mut args = TargetOptions::link_args( - LinkerFlavor::Darwin(Cc::No, Lld::No), - &["-arch", arch, "-platform_version"], - ); - super::add_link_args_iter( - &mut args, - LinkerFlavor::Darwin(Cc::No, Lld::No), - [platform_name, platform_version.clone(), platform_version].into_iter(), - ); - if abi != "macabi" { - super::add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]); - } - - args -} - -pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { - let abi = arch.target_abi(); - - TargetOptions { - abi: abi.into(), - os: os.into(), - cpu: arch.target_cpu().into(), - link_env_remove: link_env_remove(arch, os), - vendor: "apple".into(), - linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No), - // macOS has -dead_strip, which doesn't rely on function_sections - function_sections: false, - dynamic_linking: true, - pre_link_args: pre_link_args(os, arch, abi), - families: cvs!["unix"], - is_like_osx: true, - // LLVM notes that macOS 10.11+ and iOS 9+ default - // to v4, so we do the same. - // https://github.com/llvm/llvm-project/blob/378778a0d10c2f8d5df8ceff81f95b6002984a4b/clang/lib/Driver/ToolChains/Darwin.cpp#L1203 - default_dwarf_version: 4, - frame_pointer: FramePointer::Always, - has_rpath: true, - dll_suffix: ".dylib".into(), - archive_format: "darwin".into(), - // Thread locals became available with iOS 8 and macOS 10.7, - // and both are far below our minimum. - has_thread_local: true, - abi_return_struct_as_int: true, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - - debuginfo_kind: DebuginfoKind::DwarfDsym, - // The historical default for macOS targets is to run `dsymutil` which - // generates a packed version of debuginfo split from the main file. - split_debuginfo: SplitDebuginfo::Packed, - supported_split_debuginfo: Cow::Borrowed(&[ - SplitDebuginfo::Packed, - SplitDebuginfo::Unpacked, - SplitDebuginfo::Off, - ]), - - // This environment variable is pretty magical but is intended for - // producing deterministic builds. This was first discovered to be used - // by the `ar` tool as a way to control whether or not mtime entries in - // the archive headers were set to zero or not. It appears that - // eventually the linker got updated to do the same thing and now reads - // this environment variable too in recent versions. - // - // For some more info see the commentary on #47086 - link_env: Cow::Borrowed(&[(Cow::Borrowed("ZERO_AR_DATE"), Cow::Borrowed("1"))]), - - ..Default::default() - } -} - -pub fn sdk_version(platform: u32) -> Option<(u32, u32)> { - // NOTE: These values are from an arbitrary point in time but shouldn't make it into the final - // binary since the final link command will have the current SDK version passed to it. - match platform { - object::macho::PLATFORM_MACOS => Some((13, 1)), - object::macho::PLATFORM_IOS - | object::macho::PLATFORM_IOSSIMULATOR - | object::macho::PLATFORM_TVOS - | object::macho::PLATFORM_TVOSSIMULATOR - | object::macho::PLATFORM_MACCATALYST => Some((16, 2)), - object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)), - _ => None, - } -} - -pub fn platform(target: &Target) -> Option { - Some(match (&*target.os, &*target.abi) { - ("macos", _) => object::macho::PLATFORM_MACOS, - ("ios", "macabi") => object::macho::PLATFORM_MACCATALYST, - ("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR, - ("ios", _) => object::macho::PLATFORM_IOS, - ("watchos", "sim") => object::macho::PLATFORM_WATCHOSSIMULATOR, - ("watchos", _) => object::macho::PLATFORM_WATCHOS, - ("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR, - ("tvos", _) => object::macho::PLATFORM_TVOS, - _ => return None, - }) -} - -pub fn deployment_target(target: &Target) -> Option<(u32, u32)> { - let (major, minor) = match &*target.os { - "macos" => { - // This does not need to be specific. It just needs to handle x86 vs M1. - let arch = if target.arch == "x86" || target.arch == "x86_64" { X86_64 } else { Arm64 }; - macos_deployment_target(arch) - } - "ios" => match &*target.abi { - "macabi" => mac_catalyst_deployment_target(), - _ => ios_deployment_target(), - }, - "watchos" => watchos_deployment_target(), - "tvos" => tvos_deployment_target(), - _ => return None, - }; - - Some((major, minor)) -} - -fn from_set_deployment_target(var_name: &str) -> Option<(u32, u32)> { - let deployment_target = env::var(var_name).ok()?; - let (unparsed_major, unparsed_minor) = deployment_target.split_once('.')?; - let (major, minor) = (unparsed_major.parse().ok()?, unparsed_minor.parse().ok()?); - - Some((major, minor)) -} - -fn macos_default_deployment_target(arch: Arch) -> (u32, u32) { - match arch { - // Note: Arm64_sim is not included since macOS has no simulator. - Arm64 | Arm64_macabi => (11, 0), - _ => (10, 12), - } -} - -fn macos_deployment_target(arch: Arch) -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("MACOSX_DEPLOYMENT_TARGET") - .unwrap_or_else(|| macos_default_deployment_target(arch)) -} - -fn macos_lld_platform_version(arch: Arch) -> String { - let (major, minor) = macos_deployment_target(arch); - format!("{major}.{minor}") -} - -pub fn macos_llvm_target(arch: Arch) -> String { - let (major, minor) = macos_deployment_target(arch); - format!("{}-apple-macosx{}.{}.0", arch.target_name(), major, minor) -} - -fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow]> { - // Apple platforms only officially support macOS as a host for any compilation. - // - // If building for macOS, we go ahead and remove any erroneous environment state - // that's only applicable to cross-OS compilation. Always leave anything for the - // host OS alone though. - if os == "macos" { - let mut env_remove = Vec::with_capacity(2); - // Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which - // may occur when we're linking a custom build script while targeting iOS for example. - if let Ok(sdkroot) = env::var("SDKROOT") { - if sdkroot.contains("iPhoneOS.platform") - || sdkroot.contains("iPhoneSimulator.platform") - || sdkroot.contains("AppleTVOS.platform") - || sdkroot.contains("AppleTVSimulator.platform") - || sdkroot.contains("WatchOS.platform") - || sdkroot.contains("WatchSimulator.platform") - { - env_remove.push("SDKROOT".into()) - } - } - // Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at - // "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", - // although this is apparently ignored when using the linker at "/usr/bin/ld". - env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); - env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); - env_remove.into() - } else { - // Otherwise if cross-compiling for a different OS/SDK, remove any part - // of the linking environment that's wrong and reversed. - match arch { - Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim | X86_64h - | Arm64_sim => { - cvs!["MACOSX_DEPLOYMENT_TARGET"] - } - X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], - } - } -} - -fn ios_deployment_target() -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) -} - -fn mac_catalyst_deployment_target() -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((14, 0)) -} - -pub fn ios_llvm_target(arch: Arch) -> String { - // Modern iOS tooling extracts information about deployment target - // from LC_BUILD_VERSION. This load command will only be emitted when - // we build with a version specific `llvm_target`, with the version - // set high enough. Luckily one LC_BUILD_VERSION is enough, for Xcode - // to pick it up (since std and core are still built with the fallback - // of version 7.0 and hence emit the old LC_IPHONE_MIN_VERSION). - let (major, minor) = ios_deployment_target(); - format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor) -} - -fn ios_lld_platform_version() -> String { - let (major, minor) = ios_deployment_target(); - format!("{major}.{minor}") -} - -pub fn ios_sim_llvm_target(arch: Arch) -> String { - let (major, minor) = ios_deployment_target(); - format!("{}-apple-ios{}.{}.0-simulator", arch.target_name(), major, minor) -} - -fn tvos_deployment_target() -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) -} - -fn tvos_lld_platform_version() -> String { - let (major, minor) = tvos_deployment_target(); - format!("{major}.{minor}") -} - -pub fn tvos_llvm_target(arch: Arch) -> String { - let (major, minor) = tvos_deployment_target(); - format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor) -} - -pub fn tvos_sim_llvm_target(arch: Arch) -> String { - let (major, minor) = tvos_deployment_target(); - format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor) -} - -fn watchos_deployment_target() -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. - from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0)) -} - -fn watchos_lld_platform_version() -> String { - let (major, minor) = watchos_deployment_target(); - format!("{major}.{minor}") -} - -pub fn watchos_sim_llvm_target(arch: Arch) -> String { - let (major, minor) = watchos_deployment_target(); - format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor) -} diff --git a/compiler/rustc_target/src/spec/arm64_32_apple_watchos.rs b/compiler/rustc_target/src/spec/arm64_32_apple_watchos.rs deleted file mode 100644 index c757ed45e..000000000 --- a/compiler/rustc_target/src/spec/arm64_32_apple_watchos.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::apple_base::{opts, Arch}; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let base = opts("watchos", Arch::Arm64_32); - Target { - llvm_target: "arm64_32-apple-watchos".into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128".into(), - arch: "aarch64".into(), - options: TargetOptions { - features: "+v8a,+neon,+fp-armv8,+apple-a7".into(), - max_atomic_width: Some(128), - forces_embed_bitcode: true, - dynamic_linking: false, - position_independent_executables: true, - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - arm64_32-apple-watchos5.0.0\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs b/compiler/rustc_target/src/spec/arm_linux_androideabi.rs deleted file mode 100644 index bbf1fa315..000000000 --- a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "arm-linux-androideabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - // https://developer.android.com/ndk/guides/abis.html#armeabi - features: "+strict-align,+v5te".into(), - supported_sanitizers: SanitizerSet::ADDRESS, - max_atomic_width: Some(32), - ..super::android_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs deleted file mode 100644 index 400030ca0..000000000 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabi.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "arm-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+strict-align,+v6".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs deleted file mode 100644 index 6228fb15a..000000000 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_gnueabihf.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "arm-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - features: "+strict-align,+v6,+vfp2,-d32".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs deleted file mode 100644 index 3ef441d6a..000000000 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabi.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it - // to determine the calling convention and float ABI, and it doesn't - // support the "musleabi" value. - llvm_target: "arm-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - // Most of these settings are copied from the arm_unknown_linux_gnueabi - // target. - features: "+strict-align,+v6".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs deleted file mode 100644 index eb6660d4c..000000000 --- a/compiler/rustc_target/src/spec/arm_unknown_linux_musleabihf.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - // It's important we use "gnueabihf" and not "musleabihf" here. LLVM - // uses it to determine the calling convention and float ABI, and it - // doesn't support the "musleabihf" value. - llvm_target: "arm-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // Most of these settings are copied from the arm_unknown_linux_gnueabihf - // target. - features: "+strict-align,+v6,+vfp2,-d32".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armeb_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armeb_unknown_linux_gnueabi.rs deleted file mode 100644 index 1d66515a7..000000000 --- a/compiler/rustc_target/src/spec/armeb_unknown_linux_gnueabi.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armeb-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+strict-align,+v8,+crc".into(), - endian: Endian::Big, - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs deleted file mode 100644 index 446efa90d..000000000 --- a/compiler/rustc_target/src/spec/armebv7r_none_eabi.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Targets the Big endian Cortex-R4/R5 processor (ARMv7-R) - -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armebv7r-none-eabi".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - endian: Endian::Big, - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - max_atomic_width: Some(64), - emit_debug_gdb_scripts: false, - // GCC defaults to 8 for arm-none here. - c_enum_min_bits: Some(8), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs deleted file mode 100644 index 0c9e99ff8..000000000 --- a/compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Targets the Cortex-R4F/R5F processor (ARMv7-R) - -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armebv7r-none-eabihf".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - endian: Endian::Big, - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - features: "+vfp3,-d32,-fp16".into(), - max_atomic_width: Some(64), - emit_debug_gdb_scripts: false, - // GCC defaults to 8 for arm-none here. - c_enum_min_bits: Some(8), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv4t_none_eabi.rs b/compiler/rustc_target/src/spec/armv4t_none_eabi.rs deleted file mode 100644 index 44fdd3178..000000000 --- a/compiler/rustc_target/src/spec/armv4t_none_eabi.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! Targets the ARMv4T, with code as `a32` code by default. -//! -//! Primarily of use for the GBA, but usable with other devices too. -//! -//! Please ping @Lokathor if changes are needed. -//! -//! **Important:** This target profile **does not** specify a linker script. You -//! just get the default link script when you build a binary for this target. -//! The default link script is very likely wrong, so you should use -//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. - -use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv4t-none-eabi".into(), - pointer_width: 32, - arch: "arm".into(), - /* Data layout args are '-' separated: - * little endian - * stack is 64-bit aligned (EABI) - * pointers are 32-bit - * i64 must be 64-bit aligned (EABI) - * mangle names with ELF style - * native integers are 32-bit - * All other elements are default - */ - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - options: TargetOptions { - abi: "eabi".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], - // Force-enable 32-bit atomics, which allows the use of atomic load/store only. - // The resulting atomics are ABI incompatible with atomics backed by libatomic. - features: "+soft-float,+strict-align,+atomics-32".into(), - main_needs_argc_argv: false, - atomic_cas: false, - has_thumb_interworking: true, - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - // From thumb_base, rust-lang/rust#44993. - emit_debug_gdb_scripts: false, - // From thumb_base, GCC gives enums a minimum of 8 bits on no-os targets. - c_enum_min_bits: Some(8), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs deleted file mode 100644 index cffebcc95..000000000 --- a/compiler/rustc_target/src/spec/armv4t_unknown_linux_gnueabi.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv4t-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+soft-float,+strict-align".into(), - // Atomic operations provided by compiler-builtins - max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - has_thumb_interworking: true, - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv5te_none_eabi.rs b/compiler/rustc_target/src/spec/armv5te_none_eabi.rs deleted file mode 100644 index dfd27b654..000000000 --- a/compiler/rustc_target/src/spec/armv5te_none_eabi.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Targets the ARMv5TE, with code as `a32` code by default. - -use crate::spec::{cvs, FramePointer, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv5te-none-eabi".into(), - pointer_width: 32, - arch: "arm".into(), - /* Data layout args are '-' separated: - * little endian - * stack is 64-bit aligned (EABI) - * pointers are 32-bit - * i64 must be 64-bit aligned (EABI) - * mangle names with ELF style - * native integers are 32-bit - * All other elements are default - */ - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - - options: TargetOptions { - abi: "eabi".into(), - // extra args passed to the external assembler (assuming `arm-none-eabi-as`): - // * activate t32/a32 interworking - // * use arch ARMv5TE - // * use little-endian - asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",], - // minimum extra features, these cannot be disabled via -C - // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. - // The resulting atomics are ABI incompatible with atomics backed by libatomic. - features: "+soft-float,+strict-align,+atomics-32".into(), - frame_pointer: FramePointer::MayOmit, - main_needs_argc_argv: false, - // don't have atomic compare-and-swap - atomic_cas: false, - has_thumb_interworking: true, - - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs deleted file mode 100644 index b94056310..000000000 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_gnueabi.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv5te-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+soft-float,+strict-align".into(), - // Atomic operations provided by compiler-builtins - max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".into(), - has_thumb_interworking: true, - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs deleted file mode 100644 index 2530971b5..000000000 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_musleabi.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - // FIXME: this comment below does not seem applicable? - // It's important we use "gnueabihf" and not "musleabihf" here. LLVM - // uses it to determine the calling convention and float ABI, and LLVM - // doesn't support the "musleabihf" value. - llvm_target: "armv5te-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+soft-float,+strict-align".into(), - // Atomic operations provided by compiler-builtins - max_atomic_width: Some(32), - mcount: "\u{1}mcount".into(), - has_thumb_interworking: true, - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs deleted file mode 100644 index a51be10a3..000000000 --- a/compiler/rustc_target/src/spec/armv5te_unknown_linux_uclibceabi.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv5te-unknown-linux-uclibcgnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+soft-float,+strict-align".into(), - // Atomic operations provided by compiler-builtins - max_atomic_width: Some(32), - mcount: "\u{1}__gnu_mcount_nc".into(), - has_thumb_interworking: true, - ..super::linux_uclibc_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs deleted file mode 100644 index 4a8aa3157..000000000 --- a/compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv6-unknown-freebsd-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), - features: "+v6,+vfp2,-d32".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - ..super::freebsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs deleted file mode 100644 index 6e26f686f..000000000 --- a/compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv6-unknown-netbsdelf-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), - features: "+v6,+vfp2,-d32".into(), - max_atomic_width: Some(64), - mcount: "__mcount".into(), - ..super::netbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs deleted file mode 100644 index 23f4a5abf..000000000 --- a/compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; - -/// A base target for Nintendo 3DS devices using the devkitARM toolchain. -/// -/// Requires the devkitARM toolchain for 3DS targets on the host system. - -pub fn target() -> Target { - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-specs=3dsx.specs", "-mtune=mpcore", "-mfloat-abi=hard", "-mtp=soft"], - ); - - Target { - llvm_target: "armv6k-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - os: "horizon".into(), - env: "newlib".into(), - vendor: "nintendo".into(), - abi: "eabihf".into(), - cpu: "mpcore".into(), - families: cvs!["unix"], - linker: Some("arm-none-eabi-gcc".into()), - relocation_model: RelocModel::Static, - features: "+vfp2".into(), - pre_link_args, - exe_suffix: ".elf".into(), - no_default_libraries: false, - has_thread_local: true, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs deleted file mode 100644 index 402e0fd92..000000000 --- a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; - -// This target if is for the baseline of the Android v7a ABI -// in thumb mode. It's named armv7-* instead of thumbv7-* -// for historical reasons. See the thumbv7neon variant for -// enabling NEON. - -// See https://developer.android.com/ndk/guides/abis.html#v7a -// for target ABI requirements. - -pub fn target() -> Target { - let mut base = super::android_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]); - Target { - llvm_target: "armv7-none-linux-android".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(), - supported_sanitizers: SanitizerSet::ADDRESS, - max_atomic_width: Some(64), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs b/compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs deleted file mode 100644 index 62c936036..000000000 --- a/compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; - -/// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib). -/// -/// Requires the VITASDK toolchain on the host system. - -pub fn target() -> Target { - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-Wl,-q", "-Wl,--pic-veneer"], - ); - - Target { - llvm_target: "thumbv7a-vita-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - os: "vita".into(), - endian: Endian::Little, - c_int_width: "32".into(), - env: "newlib".into(), - vendor: "sony".into(), - abi: "eabihf".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), - no_default_libraries: false, - cpu: "cortex-a9".into(), - families: cvs!["unix"], - linker: Some("arm-vita-eabi-gcc".into()), - relocation_model: RelocModel::Static, - features: "+v7,+neon,+vfp3,+thumb2,+thumb-mode".into(), - pre_link_args, - exe_suffix: ".elf".into(), - has_thumb_interworking: true, - max_atomic_width: Some(64), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs deleted file mode 100644 index bc37b62de..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-freebsd-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - ..super::freebsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs deleted file mode 100644 index 73ae212a7..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or -// hardfloat. - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+v7,+thumb2,+soft-float,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs deleted file mode 100644 index e39ea49a0..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for glibc Linux on ARMv7 without NEON or -// thumb-mode. See the thumbv7neon variant for enabling both. - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}__gnu_mcount_nc".into(), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs deleted file mode 100644 index 7dae85773..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for musl Linux on ARMv7 without thumb-mode, NEON or -// hardfloat. - -pub fn target() -> Target { - // Most of these settings are copied from the armv7_unknown_linux_gnueabi - // target. - Target { - // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it - // to determine the calling convention and float ABI, and it doesn't - // support the "musleabi" value. - llvm_target: "armv7-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - features: "+v7,+thumb2,+soft-float,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs deleted file mode 100644 index ba83964bf..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for musl Linux on ARMv7 without thumb-mode or NEON. - -pub fn target() -> Target { - Target { - // It's important we use "gnueabihf" and not "musleabihf" here. LLVM - // uses it to determine the calling convention and float ABI, and LLVM - // doesn't support the "musleabihf" value. - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - // Most of these settings are copied from the armv7_unknown_linux_gnueabihf - // target. - options: TargetOptions { - abi: "eabihf".into(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs deleted file mode 100644 index e9b0bda68..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for OpenHarmony on ARMv7 Linux with thumb-mode, but no NEON or -// hardfloat. - -pub fn target() -> Target { - // Most of these settings are copied from the armv7_unknown_linux_musleabi - // target. - Target { - // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. - llvm_target: "armv7-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - features: "+v7,+thumb2,+soft-float,-neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_ohos_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs deleted file mode 100644 index 171f67070..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabi.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for uclibc Linux on ARMv7 without NEON, -// thumb-mode or hardfloat. - -pub fn target() -> Target { - let base = super::linux_uclibc_base::opts(); - Target { - llvm_target: "armv7-unknown-linux-gnueabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - features: "+v7,+thumb2,+soft-float,-neon".into(), - cpu: "generic".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - abi: "eabi".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs deleted file mode 100644 index d3e95a657..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_uclibceabihf.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for uclibc Linux on ARMv7 without NEON or -// thumb-mode. See the thumbv7neon variant for enabling both. - -pub fn target() -> Target { - let base = super::linux_uclibc_base::opts(); - Target { - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - cpu: "generic".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - abi: "eabihf".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs deleted file mode 100644 index c89ae2483..000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-netbsdelf-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - mcount: "__mcount".into(), - ..super::netbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs deleted file mode 100644 index c1ab90172..000000000 --- a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - max_atomic_width: Some(64), - ..super::vxworks_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs deleted file mode 100644 index b49dc650b..000000000 --- a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabi.rs +++ /dev/null @@ -1,19 +0,0 @@ -use super::{RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let base = super::solid_base::opts("asp3"); - Target { - llvm_target: "armv7a-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - linker: Some("arm-kmc-eabi-gcc".into()), - features: "+v7,+soft-float,+thumb2,-neon".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(64), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs b/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs deleted file mode 100644 index 7d30238e8..000000000 --- a/compiler/rustc_target/src/spec/armv7a_kmc_solid_asp3_eabihf.rs +++ /dev/null @@ -1,19 +0,0 @@ -use super::{RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let base = super::solid_base::opts("asp3"); - Target { - llvm_target: "armv7a-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - linker: Some("arm-kmc-eabi-gcc".into()), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(64), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs b/compiler/rustc_target/src/spec/armv7a_none_eabi.rs deleted file mode 100644 index d59de86a2..000000000 --- a/compiler/rustc_target/src/spec/armv7a_none_eabi.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Generic ARMv7-A target for bare-metal code - floating point disabled -// -// This is basically the `armv7-unknown-linux-gnueabi` target with some changes -// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64` -// targets: -// -// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned -// memory access is disabled on boot on these cores -// - linker changed to LLD. rationale: C is not strictly needed to build -// bare-metal binaries (the `gcc` linker has the advantage that it knows where C -// libraries and crt*.o are but it's not much of an advantage here); LLD is also -// faster -// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets -// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic -// linking. rationale: matches `thumb` targets - -use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let opts = TargetOptions { - abi: "eabi".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(64), - panic_strategy: PanicStrategy::Abort, - emit_debug_gdb_scripts: false, - c_enum_min_bits: Some(8), - ..Default::default() - }; - Target { - llvm_target: "armv7a-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs deleted file mode 100644 index c134f3e09..000000000 --- a/compiler/rustc_target/src/spec/armv7a_none_eabihf.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Generic ARMv7-A target for bare-metal code - floating point enabled (assumes -// FPU is present and emits FPU instructions) -// -// This is basically the `armv7-unknown-linux-gnueabihf` target with some -// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal -// `thumb` & `aarch64` targets. - -use super::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let opts = TargetOptions { - abi: "eabihf".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(), - relocation_model: RelocModel::Static, - disable_redzone: true, - max_atomic_width: Some(64), - panic_strategy: PanicStrategy::Abort, - emit_debug_gdb_scripts: false, - // GCC defaults to 8 for arm-none here. - c_enum_min_bits: Some(8), - ..Default::default() - }; - Target { - llvm_target: "armv7a-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/armv7k_apple_watchos.rs b/compiler/rustc_target/src/spec/armv7k_apple_watchos.rs deleted file mode 100644 index 6e1d00d1f..000000000 --- a/compiler/rustc_target/src/spec/armv7k_apple_watchos.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::apple_base::{opts, Arch}; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Armv7k; - Target { - llvm_target: "armv7k-apple-watchos".into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+v7,+vfp4,+neon".into(), - max_atomic_width: Some(64), - forces_embed_bitcode: true, - dynamic_linking: false, - position_independent_executables: true, - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - armv7k-apple-watchos3.0.0\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..opts("watchos", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs b/compiler/rustc_target/src/spec/armv7r_none_eabi.rs deleted file mode 100644 index 68b252798..000000000 --- a/compiler/rustc_target/src/spec/armv7r_none_eabi.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R) - -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv7r-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - max_atomic_width: Some(64), - emit_debug_gdb_scripts: false, - // GCC defaults to 8 for arm-none here. - c_enum_min_bits: Some(8), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs deleted file mode 100644 index 909765a31..000000000 --- a/compiler/rustc_target/src/spec/armv7r_none_eabihf.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R) - -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "armv7r-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabihf".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - features: "+vfp3,-d32,-fp16".into(), - max_atomic_width: Some(64), - emit_debug_gdb_scripts: false, - // GCC defaults to 8 for arm-none here. - c_enum_min_bits: Some(8), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs b/compiler/rustc_target/src/spec/armv7s_apple_ios.rs deleted file mode 100644 index be7f8542c..000000000 --- a/compiler/rustc_target/src/spec/armv7s_apple_ios.rs +++ /dev/null @@ -1,17 +0,0 @@ -use super::apple_base::{ios_llvm_target, opts, Arch}; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::Armv7s; - Target { - llvm_target: ios_llvm_target(arch).into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), - arch: arch.target_arch(), - options: TargetOptions { - features: "+v7,+vfp4,+neon".into(), - max_atomic_width: Some(64), - ..opts("ios", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs b/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs deleted file mode 100644 index f492c3451..000000000 --- a/compiler/rustc_target/src/spec/asmjs_unknown_emscripten.rs +++ /dev/null @@ -1,7 +0,0 @@ -use super::{wasm32_unknown_emscripten, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut target = wasm32_unknown_emscripten::target(); - target.add_post_link_args(LinkerFlavor::EmCc, &["-sWASM=0", "--memory-init-file", "0"]); - target -} diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs deleted file mode 100644 index cd324c94b..000000000 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ /dev/null @@ -1,368 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; -use object::elf; - -/// A base target for AVR devices using the GNU toolchain. -/// -/// Requires GNU avr-gcc and avr-binutils on the host system. -/// FIXME: Remove the second parameter when const string concatenation is possible. -pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target { - Target { - arch: "avr".into(), - data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(), - llvm_target: "avr-unknown-unknown".into(), - pointer_width: 16, - options: TargetOptions { - c_int_width: "16".into(), - cpu: target_cpu.into(), - exe_suffix: ".elf".into(), - - linker: Some("avr-gcc".into()), - eh_frame_header: false, - pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[mmcu]), - late_link_args: TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-lgcc"], - ), - max_atomic_width: Some(16), - atomic_cas: false, - relocation_model: RelocModel::Static, - ..TargetOptions::default() - }, - } -} - -/// Resolve the value of the EF_AVR_ARCH field for AVR ELF files, given the -/// name of the target CPU / MCU. -/// -/// In ELF files using the AVR architecture, the lower 7 bits of the e_flags -/// field is a code that identifies the "ISA revision" of the object code. -/// -/// This flag is generally set by AVR compilers in their output ELF files, -/// and linkers like avr-ld check this flag in all of their input files to -/// make sure they are compiled with the same ISA revision. -pub fn ef_avr_arch(target_cpu: &str) -> u32 { - // Adapted from llvm-project/llvm/lib/target/AVR/AVRDevices.td - match target_cpu { - // Generic MCUs - "avr1" => elf::EF_AVR_ARCH_AVR1, - "avr2" => elf::EF_AVR_ARCH_AVR2, - "avr25" => elf::EF_AVR_ARCH_AVR25, - "avr3" => elf::EF_AVR_ARCH_AVR3, - "avr31" => elf::EF_AVR_ARCH_AVR31, - "avr35" => elf::EF_AVR_ARCH_AVR35, - "avr4" => elf::EF_AVR_ARCH_AVR4, - "avr5" => elf::EF_AVR_ARCH_AVR5, - "avr51" => elf::EF_AVR_ARCH_AVR51, - "avr6" => elf::EF_AVR_ARCH_AVR6, - "avrxmega1" => elf::EF_AVR_ARCH_XMEGA1, - "avrxmega2" => elf::EF_AVR_ARCH_XMEGA2, - "avrxmega3" => elf::EF_AVR_ARCH_XMEGA3, - "avrxmega4" => elf::EF_AVR_ARCH_XMEGA4, - "avrxmega5" => elf::EF_AVR_ARCH_XMEGA5, - "avrxmega6" => elf::EF_AVR_ARCH_XMEGA6, - "avrxmega7" => elf::EF_AVR_ARCH_XMEGA7, - "avrtiny" => elf::EF_AVR_ARCH_AVRTINY, - - // Specific MCUs - "at90s1200" => elf::EF_AVR_ARCH_AVR1, - "attiny11" => elf::EF_AVR_ARCH_AVR1, - "attiny12" => elf::EF_AVR_ARCH_AVR1, - "attiny15" => elf::EF_AVR_ARCH_AVR1, - "attiny28" => elf::EF_AVR_ARCH_AVR1, - "at90s2313" => elf::EF_AVR_ARCH_AVR2, - "at90s2323" => elf::EF_AVR_ARCH_AVR2, - "at90s2333" => elf::EF_AVR_ARCH_AVR2, - "at90s2343" => elf::EF_AVR_ARCH_AVR2, - "attiny22" => elf::EF_AVR_ARCH_AVR2, - "attiny26" => elf::EF_AVR_ARCH_AVR2, - "at86rf401" => elf::EF_AVR_ARCH_AVR25, - "at90s4414" => elf::EF_AVR_ARCH_AVR2, - "at90s4433" => elf::EF_AVR_ARCH_AVR2, - "at90s4434" => elf::EF_AVR_ARCH_AVR2, - "at90s8515" => elf::EF_AVR_ARCH_AVR2, - "at90c8534" => elf::EF_AVR_ARCH_AVR2, - "at90s8535" => elf::EF_AVR_ARCH_AVR2, - "ata5272" => elf::EF_AVR_ARCH_AVR25, - "ata6616c" => elf::EF_AVR_ARCH_AVR25, - "attiny13" => elf::EF_AVR_ARCH_AVR25, - "attiny13a" => elf::EF_AVR_ARCH_AVR25, - "attiny2313" => elf::EF_AVR_ARCH_AVR25, - "attiny2313a" => elf::EF_AVR_ARCH_AVR25, - "attiny24" => elf::EF_AVR_ARCH_AVR25, - "attiny24a" => elf::EF_AVR_ARCH_AVR25, - "attiny4313" => elf::EF_AVR_ARCH_AVR25, - "attiny44" => elf::EF_AVR_ARCH_AVR25, - "attiny44a" => elf::EF_AVR_ARCH_AVR25, - "attiny84" => elf::EF_AVR_ARCH_AVR25, - "attiny84a" => elf::EF_AVR_ARCH_AVR25, - "attiny25" => elf::EF_AVR_ARCH_AVR25, - "attiny45" => elf::EF_AVR_ARCH_AVR25, - "attiny85" => elf::EF_AVR_ARCH_AVR25, - "attiny261" => elf::EF_AVR_ARCH_AVR25, - "attiny261a" => elf::EF_AVR_ARCH_AVR25, - "attiny441" => elf::EF_AVR_ARCH_AVR25, - "attiny461" => elf::EF_AVR_ARCH_AVR25, - "attiny461a" => elf::EF_AVR_ARCH_AVR25, - "attiny841" => elf::EF_AVR_ARCH_AVR25, - "attiny861" => elf::EF_AVR_ARCH_AVR25, - "attiny861a" => elf::EF_AVR_ARCH_AVR25, - "attiny87" => elf::EF_AVR_ARCH_AVR25, - "attiny43u" => elf::EF_AVR_ARCH_AVR25, - "attiny48" => elf::EF_AVR_ARCH_AVR25, - "attiny88" => elf::EF_AVR_ARCH_AVR25, - "attiny828" => elf::EF_AVR_ARCH_AVR25, - "at43usb355" => elf::EF_AVR_ARCH_AVR3, - "at76c711" => elf::EF_AVR_ARCH_AVR3, - "atmega103" => elf::EF_AVR_ARCH_AVR31, - "at43usb320" => elf::EF_AVR_ARCH_AVR31, - "attiny167" => elf::EF_AVR_ARCH_AVR35, - "at90usb82" => elf::EF_AVR_ARCH_AVR35, - "at90usb162" => elf::EF_AVR_ARCH_AVR35, - "ata5505" => elf::EF_AVR_ARCH_AVR35, - "ata6617c" => elf::EF_AVR_ARCH_AVR35, - "ata664251" => elf::EF_AVR_ARCH_AVR35, - "atmega8u2" => elf::EF_AVR_ARCH_AVR35, - "atmega16u2" => elf::EF_AVR_ARCH_AVR35, - "atmega32u2" => elf::EF_AVR_ARCH_AVR35, - "attiny1634" => elf::EF_AVR_ARCH_AVR35, - "atmega8" => elf::EF_AVR_ARCH_AVR4, - "ata6289" => elf::EF_AVR_ARCH_AVR4, - "atmega8a" => elf::EF_AVR_ARCH_AVR4, - "ata6285" => elf::EF_AVR_ARCH_AVR4, - "ata6286" => elf::EF_AVR_ARCH_AVR4, - "ata6612c" => elf::EF_AVR_ARCH_AVR4, - "atmega48" => elf::EF_AVR_ARCH_AVR4, - "atmega48a" => elf::EF_AVR_ARCH_AVR4, - "atmega48pa" => elf::EF_AVR_ARCH_AVR4, - "atmega48pb" => elf::EF_AVR_ARCH_AVR4, - "atmega48p" => elf::EF_AVR_ARCH_AVR4, - "atmega88" => elf::EF_AVR_ARCH_AVR4, - "atmega88a" => elf::EF_AVR_ARCH_AVR4, - "atmega88p" => elf::EF_AVR_ARCH_AVR4, - "atmega88pa" => elf::EF_AVR_ARCH_AVR4, - "atmega88pb" => elf::EF_AVR_ARCH_AVR4, - "atmega8515" => elf::EF_AVR_ARCH_AVR4, - "atmega8535" => elf::EF_AVR_ARCH_AVR4, - "atmega8hva" => elf::EF_AVR_ARCH_AVR4, - "at90pwm1" => elf::EF_AVR_ARCH_AVR4, - "at90pwm2" => elf::EF_AVR_ARCH_AVR4, - "at90pwm2b" => elf::EF_AVR_ARCH_AVR4, - "at90pwm3" => elf::EF_AVR_ARCH_AVR4, - "at90pwm3b" => elf::EF_AVR_ARCH_AVR4, - "at90pwm81" => elf::EF_AVR_ARCH_AVR4, - "ata5702m322" => elf::EF_AVR_ARCH_AVR5, - "ata5782" => elf::EF_AVR_ARCH_AVR5, - "ata5790" => elf::EF_AVR_ARCH_AVR5, - "ata5790n" => elf::EF_AVR_ARCH_AVR5, - "ata5791" => elf::EF_AVR_ARCH_AVR5, - "ata5795" => elf::EF_AVR_ARCH_AVR5, - "ata5831" => elf::EF_AVR_ARCH_AVR5, - "ata6613c" => elf::EF_AVR_ARCH_AVR5, - "ata6614q" => elf::EF_AVR_ARCH_AVR5, - "ata8210" => elf::EF_AVR_ARCH_AVR5, - "ata8510" => elf::EF_AVR_ARCH_AVR5, - "atmega16" => elf::EF_AVR_ARCH_AVR5, - "atmega16a" => elf::EF_AVR_ARCH_AVR5, - "atmega161" => elf::EF_AVR_ARCH_AVR5, - "atmega162" => elf::EF_AVR_ARCH_AVR5, - "atmega163" => elf::EF_AVR_ARCH_AVR5, - "atmega164a" => elf::EF_AVR_ARCH_AVR5, - "atmega164p" => elf::EF_AVR_ARCH_AVR5, - "atmega164pa" => elf::EF_AVR_ARCH_AVR5, - "atmega165" => elf::EF_AVR_ARCH_AVR5, - "atmega165a" => elf::EF_AVR_ARCH_AVR5, - "atmega165p" => elf::EF_AVR_ARCH_AVR5, - "atmega165pa" => elf::EF_AVR_ARCH_AVR5, - "atmega168" => elf::EF_AVR_ARCH_AVR5, - "atmega168a" => elf::EF_AVR_ARCH_AVR5, - "atmega168p" => elf::EF_AVR_ARCH_AVR5, - "atmega168pa" => elf::EF_AVR_ARCH_AVR5, - "atmega168pb" => elf::EF_AVR_ARCH_AVR5, - "atmega169" => elf::EF_AVR_ARCH_AVR5, - "atmega169a" => elf::EF_AVR_ARCH_AVR5, - "atmega169p" => elf::EF_AVR_ARCH_AVR5, - "atmega169pa" => elf::EF_AVR_ARCH_AVR5, - "atmega32" => elf::EF_AVR_ARCH_AVR5, - "atmega32a" => elf::EF_AVR_ARCH_AVR5, - "atmega323" => elf::EF_AVR_ARCH_AVR5, - "atmega324a" => elf::EF_AVR_ARCH_AVR5, - "atmega324p" => elf::EF_AVR_ARCH_AVR5, - "atmega324pa" => elf::EF_AVR_ARCH_AVR5, - "atmega324pb" => elf::EF_AVR_ARCH_AVR5, - "atmega325" => elf::EF_AVR_ARCH_AVR5, - "atmega325a" => elf::EF_AVR_ARCH_AVR5, - "atmega325p" => elf::EF_AVR_ARCH_AVR5, - "atmega325pa" => elf::EF_AVR_ARCH_AVR5, - "atmega3250" => elf::EF_AVR_ARCH_AVR5, - "atmega3250a" => elf::EF_AVR_ARCH_AVR5, - "atmega3250p" => elf::EF_AVR_ARCH_AVR5, - "atmega3250pa" => elf::EF_AVR_ARCH_AVR5, - "atmega328" => elf::EF_AVR_ARCH_AVR5, - "atmega328p" => elf::EF_AVR_ARCH_AVR5, - "atmega328pb" => elf::EF_AVR_ARCH_AVR5, - "atmega329" => elf::EF_AVR_ARCH_AVR5, - "atmega329a" => elf::EF_AVR_ARCH_AVR5, - "atmega329p" => elf::EF_AVR_ARCH_AVR5, - "atmega329pa" => elf::EF_AVR_ARCH_AVR5, - "atmega3290" => elf::EF_AVR_ARCH_AVR5, - "atmega3290a" => elf::EF_AVR_ARCH_AVR5, - "atmega3290p" => elf::EF_AVR_ARCH_AVR5, - "atmega3290pa" => elf::EF_AVR_ARCH_AVR5, - "atmega406" => elf::EF_AVR_ARCH_AVR5, - "atmega64" => elf::EF_AVR_ARCH_AVR5, - "atmega64a" => elf::EF_AVR_ARCH_AVR5, - "atmega640" => elf::EF_AVR_ARCH_AVR5, - "atmega644" => elf::EF_AVR_ARCH_AVR5, - "atmega644a" => elf::EF_AVR_ARCH_AVR5, - "atmega644p" => elf::EF_AVR_ARCH_AVR5, - "atmega644pa" => elf::EF_AVR_ARCH_AVR5, - "atmega645" => elf::EF_AVR_ARCH_AVR5, - "atmega645a" => elf::EF_AVR_ARCH_AVR5, - "atmega645p" => elf::EF_AVR_ARCH_AVR5, - "atmega649" => elf::EF_AVR_ARCH_AVR5, - "atmega649a" => elf::EF_AVR_ARCH_AVR5, - "atmega649p" => elf::EF_AVR_ARCH_AVR5, - "atmega6450" => elf::EF_AVR_ARCH_AVR5, - "atmega6450a" => elf::EF_AVR_ARCH_AVR5, - "atmega6450p" => elf::EF_AVR_ARCH_AVR5, - "atmega6490" => elf::EF_AVR_ARCH_AVR5, - "atmega6490a" => elf::EF_AVR_ARCH_AVR5, - "atmega6490p" => elf::EF_AVR_ARCH_AVR5, - "atmega64rfr2" => elf::EF_AVR_ARCH_AVR5, - "atmega644rfr2" => elf::EF_AVR_ARCH_AVR5, - "atmega16hva" => elf::EF_AVR_ARCH_AVR5, - "atmega16hva2" => elf::EF_AVR_ARCH_AVR5, - "atmega16hvb" => elf::EF_AVR_ARCH_AVR5, - "atmega16hvbrevb" => elf::EF_AVR_ARCH_AVR5, - "atmega32hvb" => elf::EF_AVR_ARCH_AVR5, - "atmega32hvbrevb" => elf::EF_AVR_ARCH_AVR5, - "atmega64hve" => elf::EF_AVR_ARCH_AVR5, - "atmega64hve2" => elf::EF_AVR_ARCH_AVR5, - "at90can32" => elf::EF_AVR_ARCH_AVR5, - "at90can64" => elf::EF_AVR_ARCH_AVR5, - "at90pwm161" => elf::EF_AVR_ARCH_AVR5, - "at90pwm216" => elf::EF_AVR_ARCH_AVR5, - "at90pwm316" => elf::EF_AVR_ARCH_AVR5, - "atmega32c1" => elf::EF_AVR_ARCH_AVR5, - "atmega64c1" => elf::EF_AVR_ARCH_AVR5, - "atmega16m1" => elf::EF_AVR_ARCH_AVR5, - "atmega32m1" => elf::EF_AVR_ARCH_AVR5, - "atmega64m1" => elf::EF_AVR_ARCH_AVR5, - "atmega16u4" => elf::EF_AVR_ARCH_AVR5, - "atmega32u4" => elf::EF_AVR_ARCH_AVR5, - "atmega32u6" => elf::EF_AVR_ARCH_AVR5, - "at90usb646" => elf::EF_AVR_ARCH_AVR5, - "at90usb647" => elf::EF_AVR_ARCH_AVR5, - "at90scr100" => elf::EF_AVR_ARCH_AVR5, - "at94k" => elf::EF_AVR_ARCH_AVR5, - "m3000" => elf::EF_AVR_ARCH_AVR5, - "atmega128" => elf::EF_AVR_ARCH_AVR51, - "atmega128a" => elf::EF_AVR_ARCH_AVR51, - "atmega1280" => elf::EF_AVR_ARCH_AVR51, - "atmega1281" => elf::EF_AVR_ARCH_AVR51, - "atmega1284" => elf::EF_AVR_ARCH_AVR51, - "atmega1284p" => elf::EF_AVR_ARCH_AVR51, - "atmega128rfa1" => elf::EF_AVR_ARCH_AVR51, - "atmega128rfr2" => elf::EF_AVR_ARCH_AVR51, - "atmega1284rfr2" => elf::EF_AVR_ARCH_AVR51, - "at90can128" => elf::EF_AVR_ARCH_AVR51, - "at90usb1286" => elf::EF_AVR_ARCH_AVR51, - "at90usb1287" => elf::EF_AVR_ARCH_AVR51, - "atmega2560" => elf::EF_AVR_ARCH_AVR6, - "atmega2561" => elf::EF_AVR_ARCH_AVR6, - "atmega256rfr2" => elf::EF_AVR_ARCH_AVR6, - "atmega2564rfr2" => elf::EF_AVR_ARCH_AVR6, - "atxmega16a4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega16a4u" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega16c4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega16d4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32a4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32a4u" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32c3" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32c4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32d3" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32d4" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega32e5" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega16e5" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega8e5" => elf::EF_AVR_ARCH_XMEGA2, - "atxmega64a3" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64a3u" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64a4u" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64b1" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64b3" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64c3" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64d3" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64d4" => elf::EF_AVR_ARCH_XMEGA4, - "atxmega64a1" => elf::EF_AVR_ARCH_XMEGA5, - "atxmega64a1u" => elf::EF_AVR_ARCH_XMEGA5, - "atxmega128a3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128a3u" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128b1" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128b3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128c3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128d3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128d4" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega192a3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega192a3u" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega192c3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega192d3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256a3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256a3u" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256a3b" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256a3bu" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256c3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega256d3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega384c3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega384d3" => elf::EF_AVR_ARCH_XMEGA6, - "atxmega128a1" => elf::EF_AVR_ARCH_XMEGA7, - "atxmega128a1u" => elf::EF_AVR_ARCH_XMEGA7, - "atxmega128a4u" => elf::EF_AVR_ARCH_XMEGA7, - "attiny4" => elf::EF_AVR_ARCH_AVRTINY, - "attiny5" => elf::EF_AVR_ARCH_AVRTINY, - "attiny9" => elf::EF_AVR_ARCH_AVRTINY, - "attiny10" => elf::EF_AVR_ARCH_AVRTINY, - "attiny20" => elf::EF_AVR_ARCH_AVRTINY, - "attiny40" => elf::EF_AVR_ARCH_AVRTINY, - "attiny102" => elf::EF_AVR_ARCH_AVRTINY, - "attiny104" => elf::EF_AVR_ARCH_AVRTINY, - "attiny202" => elf::EF_AVR_ARCH_XMEGA3, - "attiny402" => elf::EF_AVR_ARCH_XMEGA3, - "attiny204" => elf::EF_AVR_ARCH_XMEGA3, - "attiny404" => elf::EF_AVR_ARCH_XMEGA3, - "attiny804" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1604" => elf::EF_AVR_ARCH_XMEGA3, - "attiny406" => elf::EF_AVR_ARCH_XMEGA3, - "attiny806" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1606" => elf::EF_AVR_ARCH_XMEGA3, - "attiny807" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1607" => elf::EF_AVR_ARCH_XMEGA3, - "attiny212" => elf::EF_AVR_ARCH_XMEGA3, - "attiny412" => elf::EF_AVR_ARCH_XMEGA3, - "attiny214" => elf::EF_AVR_ARCH_XMEGA3, - "attiny414" => elf::EF_AVR_ARCH_XMEGA3, - "attiny814" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1614" => elf::EF_AVR_ARCH_XMEGA3, - "attiny416" => elf::EF_AVR_ARCH_XMEGA3, - "attiny816" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1616" => elf::EF_AVR_ARCH_XMEGA3, - "attiny3216" => elf::EF_AVR_ARCH_XMEGA3, - "attiny417" => elf::EF_AVR_ARCH_XMEGA3, - "attiny817" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1617" => elf::EF_AVR_ARCH_XMEGA3, - "attiny3217" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1624" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1626" => elf::EF_AVR_ARCH_XMEGA3, - "attiny1627" => elf::EF_AVR_ARCH_XMEGA3, - "atmega808" => elf::EF_AVR_ARCH_XMEGA3, - "atmega809" => elf::EF_AVR_ARCH_XMEGA3, - "atmega1608" => elf::EF_AVR_ARCH_XMEGA3, - "atmega1609" => elf::EF_AVR_ARCH_XMEGA3, - "atmega3208" => elf::EF_AVR_ARCH_XMEGA3, - "atmega3209" => elf::EF_AVR_ARCH_XMEGA3, - "atmega4808" => elf::EF_AVR_ARCH_XMEGA3, - "atmega4809" => elf::EF_AVR_ARCH_XMEGA3, - - // Unknown target CPU => Unspecified/generic code - _ => 0, - } -} diff --git a/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs b/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs deleted file mode 100644 index 6c16b03cc..000000000 --- a/compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - super::avr_gnu_base::target("atmega328", "-mmcu=atmega328") -} diff --git a/compiler/rustc_target/src/spec/base/aix.rs b/compiler/rustc_target/src/spec/base/aix.rs new file mode 100644 index 000000000..c71c4ba2c --- /dev/null +++ b/compiler/rustc_target/src/spec/base/aix.rs @@ -0,0 +1,32 @@ +use crate::abi::Endian; +use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + abi: "vec-extabi".into(), + code_model: Some(CodeModel::Small), + cpu: "pwr7".into(), + os: "aix".into(), + vendor: "ibm".into(), + dynamic_linking: true, + endian: Endian::Big, + executables: true, + archive_format: "aix_big".into(), + families: cvs!["unix"], + has_rpath: false, + has_thread_local: true, + crt_static_respected: true, + linker_flavor: LinkerFlavor::Unix(Cc::No), + linker: Some("ld".into()), + eh_frame_header: false, + is_like_aix: true, + default_dwarf_version: 3, + function_sections: true, + pre_link_objects: crt_objects::new(&[ + (LinkOutputKind::DynamicNoPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]), + (LinkOutputKind::DynamicPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]), + ]), + dll_suffix: ".a".into(), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/android.rs b/compiler/rustc_target/src/spec/base/android.rs new file mode 100644 index 000000000..af15c16a5 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/android.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, SanitizerSet, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut base = base::linux::opts(); + base.os = "android".into(); + base.is_like_android = true; + base.default_dwarf_version = 2; + base.has_thread_local = false; + base.supported_sanitizers = SanitizerSet::ADDRESS; + // This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867 + // for context. (At that time, there was no `-C force-unwind-tables`, so the only solution + // was to always emit `uwtable`). + base.default_uwtable = true; + base.crt_static_respected = true; + base +} diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs new file mode 100644 index 000000000..99e64503e --- /dev/null +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -0,0 +1,356 @@ +use std::{borrow::Cow, env}; + +use crate::spec::{add_link_args, add_link_args_iter}; +use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs}; +use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, Target, TargetOptions}; + +#[cfg(test)] +mod tests; + +use Arch::*; +#[allow(non_camel_case_types)] +#[derive(Copy, Clone)] +pub enum Arch { + Armv7k, + Armv7s, + Arm64, + Arm64_32, + I386, + I686, + X86_64, + X86_64h, + X86_64_sim, + X86_64_macabi, + Arm64_macabi, + Arm64_sim, +} + +impl Arch { + pub fn target_name(self) -> &'static str { + match self { + Armv7k => "armv7k", + Armv7s => "armv7s", + Arm64 | Arm64_macabi | Arm64_sim => "arm64", + Arm64_32 => "arm64_32", + I386 => "i386", + I686 => "i686", + X86_64 | X86_64_sim | X86_64_macabi => "x86_64", + X86_64h => "x86_64h", + } + } + + pub fn target_arch(self) -> Cow<'static, str> { + Cow::Borrowed(match self { + Armv7k | Armv7s => "arm", + Arm64 | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64", + I386 | I686 => "x86", + X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64", + }) + } + + fn target_abi(self) -> &'static str { + match self { + Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "", + X86_64_macabi | Arm64_macabi => "macabi", + // x86_64-apple-ios is a simulator target, even though it isn't + // declared that way in the target like the other ones... + Arm64_sim | X86_64_sim => "sim", + } + } + + fn target_cpu(self) -> &'static str { + match self { + Armv7k => "cortex-a8", + Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher. + Arm64 => "apple-a7", + Arm64_32 => "apple-s4", + // Only macOS 10.12+ is supported, which means + // all x86_64/x86 CPUs must be running at least penryn + // https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82 + I386 | I686 => "penryn", + X86_64 | X86_64_sim => "penryn", + X86_64_macabi => "penryn", + // Note: `core-avx2` is slightly more advanced than `x86_64h`, see + // comments (and disabled features) in `x86_64h_apple_darwin` for + // details. It is a higher baseline then `penryn` however. + X86_64h => "core-avx2", + Arm64_macabi => "apple-a12", + Arm64_sim => "apple-a12", + } + } +} + +fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs { + let platform_name: StaticCow = match abi { + "sim" => format!("{os}-simulator").into(), + "macabi" => "mac-catalyst".into(), + _ => os.into(), + }; + + let platform_version: StaticCow = match os { + "ios" => ios_lld_platform_version(), + "tvos" => tvos_lld_platform_version(), + "watchos" => watchos_lld_platform_version(), + "macos" => macos_lld_platform_version(arch), + _ => unreachable!(), + } + .into(); + + let arch = arch.target_name(); + + let mut args = TargetOptions::link_args( + LinkerFlavor::Darwin(Cc::No, Lld::No), + &["-arch", arch, "-platform_version"], + ); + add_link_args_iter( + &mut args, + LinkerFlavor::Darwin(Cc::No, Lld::No), + [platform_name, platform_version.clone(), platform_version].into_iter(), + ); + if abi != "macabi" { + add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]); + } + + args +} + +pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { + let abi = arch.target_abi(); + + TargetOptions { + abi: abi.into(), + os: os.into(), + cpu: arch.target_cpu().into(), + link_env_remove: link_env_remove(arch, os), + vendor: "apple".into(), + linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No), + // macOS has -dead_strip, which doesn't rely on function_sections + function_sections: false, + dynamic_linking: true, + pre_link_args: pre_link_args(os, arch, abi), + families: cvs!["unix"], + is_like_osx: true, + // LLVM notes that macOS 10.11+ and iOS 9+ default + // to v4, so we do the same. + // https://github.com/llvm/llvm-project/blob/378778a0d10c2f8d5df8ceff81f95b6002984a4b/clang/lib/Driver/ToolChains/Darwin.cpp#L1203 + default_dwarf_version: 4, + frame_pointer: FramePointer::Always, + has_rpath: true, + dll_suffix: ".dylib".into(), + archive_format: "darwin".into(), + // Thread locals became available with iOS 8 and macOS 10.7, + // and both are far below our minimum. + has_thread_local: true, + abi_return_struct_as_int: true, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + + debuginfo_kind: DebuginfoKind::DwarfDsym, + // The historical default for macOS targets is to run `dsymutil` which + // generates a packed version of debuginfo split from the main file. + split_debuginfo: SplitDebuginfo::Packed, + supported_split_debuginfo: Cow::Borrowed(&[ + SplitDebuginfo::Packed, + SplitDebuginfo::Unpacked, + SplitDebuginfo::Off, + ]), + + // This environment variable is pretty magical but is intended for + // producing deterministic builds. This was first discovered to be used + // by the `ar` tool as a way to control whether or not mtime entries in + // the archive headers were set to zero or not. It appears that + // eventually the linker got updated to do the same thing and now reads + // this environment variable too in recent versions. + // + // For some more info see the commentary on #47086 + link_env: Cow::Borrowed(&[(Cow::Borrowed("ZERO_AR_DATE"), Cow::Borrowed("1"))]), + + ..Default::default() + } +} + +pub fn sdk_version(platform: u32) -> Option<(u32, u32)> { + // NOTE: These values are from an arbitrary point in time but shouldn't make it into the final + // binary since the final link command will have the current SDK version passed to it. + match platform { + object::macho::PLATFORM_MACOS => Some((13, 1)), + object::macho::PLATFORM_IOS + | object::macho::PLATFORM_IOSSIMULATOR + | object::macho::PLATFORM_TVOS + | object::macho::PLATFORM_TVOSSIMULATOR + | object::macho::PLATFORM_MACCATALYST => Some((16, 2)), + object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)), + _ => None, + } +} + +pub fn platform(target: &Target) -> Option { + Some(match (&*target.os, &*target.abi) { + ("macos", _) => object::macho::PLATFORM_MACOS, + ("ios", "macabi") => object::macho::PLATFORM_MACCATALYST, + ("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR, + ("ios", _) => object::macho::PLATFORM_IOS, + ("watchos", "sim") => object::macho::PLATFORM_WATCHOSSIMULATOR, + ("watchos", _) => object::macho::PLATFORM_WATCHOS, + ("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR, + ("tvos", _) => object::macho::PLATFORM_TVOS, + _ => return None, + }) +} + +pub fn deployment_target(target: &Target) -> Option<(u32, u32)> { + let (major, minor) = match &*target.os { + "macos" => { + // This does not need to be specific. It just needs to handle x86 vs M1. + let arch = if target.arch == "x86" || target.arch == "x86_64" { X86_64 } else { Arm64 }; + macos_deployment_target(arch) + } + "ios" => match &*target.abi { + "macabi" => mac_catalyst_deployment_target(), + _ => ios_deployment_target(), + }, + "watchos" => watchos_deployment_target(), + "tvos" => tvos_deployment_target(), + _ => return None, + }; + + Some((major, minor)) +} + +fn from_set_deployment_target(var_name: &str) -> Option<(u32, u32)> { + let deployment_target = env::var(var_name).ok()?; + let (unparsed_major, unparsed_minor) = deployment_target.split_once('.')?; + let (major, minor) = (unparsed_major.parse().ok()?, unparsed_minor.parse().ok()?); + + Some((major, minor)) +} + +fn macos_default_deployment_target(arch: Arch) -> (u32, u32) { + match arch { + // Note: Arm64_sim is not included since macOS has no simulator. + Arm64 | Arm64_macabi => (11, 0), + _ => (10, 12), + } +} + +fn macos_deployment_target(arch: Arch) -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("MACOSX_DEPLOYMENT_TARGET") + .unwrap_or_else(|| macos_default_deployment_target(arch)) +} + +fn macos_lld_platform_version(arch: Arch) -> String { + let (major, minor) = macos_deployment_target(arch); + format!("{major}.{minor}") +} + +pub fn macos_llvm_target(arch: Arch) -> String { + let (major, minor) = macos_deployment_target(arch); + format!("{}-apple-macosx{}.{}.0", arch.target_name(), major, minor) +} + +fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow]> { + // Apple platforms only officially support macOS as a host for any compilation. + // + // If building for macOS, we go ahead and remove any erroneous environment state + // that's only applicable to cross-OS compilation. Always leave anything for the + // host OS alone though. + if os == "macos" { + let mut env_remove = Vec::with_capacity(2); + // Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which + // may occur when we're linking a custom build script while targeting iOS for example. + if let Ok(sdkroot) = env::var("SDKROOT") { + if sdkroot.contains("iPhoneOS.platform") + || sdkroot.contains("iPhoneSimulator.platform") + || sdkroot.contains("AppleTVOS.platform") + || sdkroot.contains("AppleTVSimulator.platform") + || sdkroot.contains("WatchOS.platform") + || sdkroot.contains("WatchSimulator.platform") + { + env_remove.push("SDKROOT".into()) + } + } + // Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at + // "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", + // although this is apparently ignored when using the linker at "/usr/bin/ld". + env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); + env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); + env_remove.into() + } else { + // Otherwise if cross-compiling for a different OS/SDK, remove any part + // of the linking environment that's wrong and reversed. + match arch { + Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim | X86_64h + | Arm64_sim => { + cvs!["MACOSX_DEPLOYMENT_TARGET"] + } + X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], + } + } +} + +fn ios_deployment_target() -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) +} + +fn mac_catalyst_deployment_target() -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((14, 0)) +} + +pub fn ios_llvm_target(arch: Arch) -> String { + // Modern iOS tooling extracts information about deployment target + // from LC_BUILD_VERSION. This load command will only be emitted when + // we build with a version specific `llvm_target`, with the version + // set high enough. Luckily one LC_BUILD_VERSION is enough, for Xcode + // to pick it up (since std and core are still built with the fallback + // of version 7.0 and hence emit the old LC_IPHONE_MIN_VERSION). + let (major, minor) = ios_deployment_target(); + format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor) +} + +fn ios_lld_platform_version() -> String { + let (major, minor) = ios_deployment_target(); + format!("{major}.{minor}") +} + +pub fn ios_sim_llvm_target(arch: Arch) -> String { + let (major, minor) = ios_deployment_target(); + format!("{}-apple-ios{}.{}.0-simulator", arch.target_name(), major, minor) +} + +fn tvos_deployment_target() -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) +} + +fn tvos_lld_platform_version() -> String { + let (major, minor) = tvos_deployment_target(); + format!("{major}.{minor}") +} + +pub fn tvos_llvm_target(arch: Arch) -> String { + let (major, minor) = tvos_deployment_target(); + format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor) +} + +pub fn tvos_sim_llvm_target(arch: Arch) -> String { + let (major, minor) = tvos_deployment_target(); + format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor) +} + +fn watchos_deployment_target() -> (u32, u32) { + // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. + from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0)) +} + +fn watchos_lld_platform_version() -> String { + let (major, minor) = watchos_deployment_target(); + format!("{major}.{minor}") +} + +pub fn watchos_sim_llvm_target(arch: Arch) -> String { + let (major, minor) = watchos_deployment_target(); + format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor) +} diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs new file mode 100644 index 000000000..f13058ebc --- /dev/null +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -0,0 +1,38 @@ +use crate::spec::targets::{ + aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin, + x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim, +}; + +#[test] +fn simulator_targets_set_abi() { + let all_sim_targets = [ + x86_64_apple_ios::target(), + x86_64_apple_tvos::target(), + x86_64_apple_watchos_sim::target(), + aarch64_apple_ios_sim::target(), + // Note: There is currently no ARM64 tvOS simulator target + aarch64_apple_watchos_sim::target(), + ]; + + for target in all_sim_targets { + assert_eq!(target.abi, "sim") + } +} + +#[test] +fn macos_link_environment_unmodified() { + let all_macos_targets = [ + aarch64_apple_darwin::target(), + i686_apple_darwin::target(), + x86_64_apple_darwin::target(), + ]; + + for target in all_macos_targets { + // macOS targets should only remove information for cross-compiling, but never + // for the host. + assert_eq!( + target.link_env_remove, + crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"], + ); + } +} diff --git a/compiler/rustc_target/src/spec/base/avr_gnu.rs b/compiler/rustc_target/src/spec/base/avr_gnu.rs new file mode 100644 index 000000000..cd324c94b --- /dev/null +++ b/compiler/rustc_target/src/spec/base/avr_gnu.rs @@ -0,0 +1,368 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; +use object::elf; + +/// A base target for AVR devices using the GNU toolchain. +/// +/// Requires GNU avr-gcc and avr-binutils on the host system. +/// FIXME: Remove the second parameter when const string concatenation is possible. +pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target { + Target { + arch: "avr".into(), + data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(), + llvm_target: "avr-unknown-unknown".into(), + pointer_width: 16, + options: TargetOptions { + c_int_width: "16".into(), + cpu: target_cpu.into(), + exe_suffix: ".elf".into(), + + linker: Some("avr-gcc".into()), + eh_frame_header: false, + pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[mmcu]), + late_link_args: TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-lgcc"], + ), + max_atomic_width: Some(16), + atomic_cas: false, + relocation_model: RelocModel::Static, + ..TargetOptions::default() + }, + } +} + +/// Resolve the value of the EF_AVR_ARCH field for AVR ELF files, given the +/// name of the target CPU / MCU. +/// +/// In ELF files using the AVR architecture, the lower 7 bits of the e_flags +/// field is a code that identifies the "ISA revision" of the object code. +/// +/// This flag is generally set by AVR compilers in their output ELF files, +/// and linkers like avr-ld check this flag in all of their input files to +/// make sure they are compiled with the same ISA revision. +pub fn ef_avr_arch(target_cpu: &str) -> u32 { + // Adapted from llvm-project/llvm/lib/target/AVR/AVRDevices.td + match target_cpu { + // Generic MCUs + "avr1" => elf::EF_AVR_ARCH_AVR1, + "avr2" => elf::EF_AVR_ARCH_AVR2, + "avr25" => elf::EF_AVR_ARCH_AVR25, + "avr3" => elf::EF_AVR_ARCH_AVR3, + "avr31" => elf::EF_AVR_ARCH_AVR31, + "avr35" => elf::EF_AVR_ARCH_AVR35, + "avr4" => elf::EF_AVR_ARCH_AVR4, + "avr5" => elf::EF_AVR_ARCH_AVR5, + "avr51" => elf::EF_AVR_ARCH_AVR51, + "avr6" => elf::EF_AVR_ARCH_AVR6, + "avrxmega1" => elf::EF_AVR_ARCH_XMEGA1, + "avrxmega2" => elf::EF_AVR_ARCH_XMEGA2, + "avrxmega3" => elf::EF_AVR_ARCH_XMEGA3, + "avrxmega4" => elf::EF_AVR_ARCH_XMEGA4, + "avrxmega5" => elf::EF_AVR_ARCH_XMEGA5, + "avrxmega6" => elf::EF_AVR_ARCH_XMEGA6, + "avrxmega7" => elf::EF_AVR_ARCH_XMEGA7, + "avrtiny" => elf::EF_AVR_ARCH_AVRTINY, + + // Specific MCUs + "at90s1200" => elf::EF_AVR_ARCH_AVR1, + "attiny11" => elf::EF_AVR_ARCH_AVR1, + "attiny12" => elf::EF_AVR_ARCH_AVR1, + "attiny15" => elf::EF_AVR_ARCH_AVR1, + "attiny28" => elf::EF_AVR_ARCH_AVR1, + "at90s2313" => elf::EF_AVR_ARCH_AVR2, + "at90s2323" => elf::EF_AVR_ARCH_AVR2, + "at90s2333" => elf::EF_AVR_ARCH_AVR2, + "at90s2343" => elf::EF_AVR_ARCH_AVR2, + "attiny22" => elf::EF_AVR_ARCH_AVR2, + "attiny26" => elf::EF_AVR_ARCH_AVR2, + "at86rf401" => elf::EF_AVR_ARCH_AVR25, + "at90s4414" => elf::EF_AVR_ARCH_AVR2, + "at90s4433" => elf::EF_AVR_ARCH_AVR2, + "at90s4434" => elf::EF_AVR_ARCH_AVR2, + "at90s8515" => elf::EF_AVR_ARCH_AVR2, + "at90c8534" => elf::EF_AVR_ARCH_AVR2, + "at90s8535" => elf::EF_AVR_ARCH_AVR2, + "ata5272" => elf::EF_AVR_ARCH_AVR25, + "ata6616c" => elf::EF_AVR_ARCH_AVR25, + "attiny13" => elf::EF_AVR_ARCH_AVR25, + "attiny13a" => elf::EF_AVR_ARCH_AVR25, + "attiny2313" => elf::EF_AVR_ARCH_AVR25, + "attiny2313a" => elf::EF_AVR_ARCH_AVR25, + "attiny24" => elf::EF_AVR_ARCH_AVR25, + "attiny24a" => elf::EF_AVR_ARCH_AVR25, + "attiny4313" => elf::EF_AVR_ARCH_AVR25, + "attiny44" => elf::EF_AVR_ARCH_AVR25, + "attiny44a" => elf::EF_AVR_ARCH_AVR25, + "attiny84" => elf::EF_AVR_ARCH_AVR25, + "attiny84a" => elf::EF_AVR_ARCH_AVR25, + "attiny25" => elf::EF_AVR_ARCH_AVR25, + "attiny45" => elf::EF_AVR_ARCH_AVR25, + "attiny85" => elf::EF_AVR_ARCH_AVR25, + "attiny261" => elf::EF_AVR_ARCH_AVR25, + "attiny261a" => elf::EF_AVR_ARCH_AVR25, + "attiny441" => elf::EF_AVR_ARCH_AVR25, + "attiny461" => elf::EF_AVR_ARCH_AVR25, + "attiny461a" => elf::EF_AVR_ARCH_AVR25, + "attiny841" => elf::EF_AVR_ARCH_AVR25, + "attiny861" => elf::EF_AVR_ARCH_AVR25, + "attiny861a" => elf::EF_AVR_ARCH_AVR25, + "attiny87" => elf::EF_AVR_ARCH_AVR25, + "attiny43u" => elf::EF_AVR_ARCH_AVR25, + "attiny48" => elf::EF_AVR_ARCH_AVR25, + "attiny88" => elf::EF_AVR_ARCH_AVR25, + "attiny828" => elf::EF_AVR_ARCH_AVR25, + "at43usb355" => elf::EF_AVR_ARCH_AVR3, + "at76c711" => elf::EF_AVR_ARCH_AVR3, + "atmega103" => elf::EF_AVR_ARCH_AVR31, + "at43usb320" => elf::EF_AVR_ARCH_AVR31, + "attiny167" => elf::EF_AVR_ARCH_AVR35, + "at90usb82" => elf::EF_AVR_ARCH_AVR35, + "at90usb162" => elf::EF_AVR_ARCH_AVR35, + "ata5505" => elf::EF_AVR_ARCH_AVR35, + "ata6617c" => elf::EF_AVR_ARCH_AVR35, + "ata664251" => elf::EF_AVR_ARCH_AVR35, + "atmega8u2" => elf::EF_AVR_ARCH_AVR35, + "atmega16u2" => elf::EF_AVR_ARCH_AVR35, + "atmega32u2" => elf::EF_AVR_ARCH_AVR35, + "attiny1634" => elf::EF_AVR_ARCH_AVR35, + "atmega8" => elf::EF_AVR_ARCH_AVR4, + "ata6289" => elf::EF_AVR_ARCH_AVR4, + "atmega8a" => elf::EF_AVR_ARCH_AVR4, + "ata6285" => elf::EF_AVR_ARCH_AVR4, + "ata6286" => elf::EF_AVR_ARCH_AVR4, + "ata6612c" => elf::EF_AVR_ARCH_AVR4, + "atmega48" => elf::EF_AVR_ARCH_AVR4, + "atmega48a" => elf::EF_AVR_ARCH_AVR4, + "atmega48pa" => elf::EF_AVR_ARCH_AVR4, + "atmega48pb" => elf::EF_AVR_ARCH_AVR4, + "atmega48p" => elf::EF_AVR_ARCH_AVR4, + "atmega88" => elf::EF_AVR_ARCH_AVR4, + "atmega88a" => elf::EF_AVR_ARCH_AVR4, + "atmega88p" => elf::EF_AVR_ARCH_AVR4, + "atmega88pa" => elf::EF_AVR_ARCH_AVR4, + "atmega88pb" => elf::EF_AVR_ARCH_AVR4, + "atmega8515" => elf::EF_AVR_ARCH_AVR4, + "atmega8535" => elf::EF_AVR_ARCH_AVR4, + "atmega8hva" => elf::EF_AVR_ARCH_AVR4, + "at90pwm1" => elf::EF_AVR_ARCH_AVR4, + "at90pwm2" => elf::EF_AVR_ARCH_AVR4, + "at90pwm2b" => elf::EF_AVR_ARCH_AVR4, + "at90pwm3" => elf::EF_AVR_ARCH_AVR4, + "at90pwm3b" => elf::EF_AVR_ARCH_AVR4, + "at90pwm81" => elf::EF_AVR_ARCH_AVR4, + "ata5702m322" => elf::EF_AVR_ARCH_AVR5, + "ata5782" => elf::EF_AVR_ARCH_AVR5, + "ata5790" => elf::EF_AVR_ARCH_AVR5, + "ata5790n" => elf::EF_AVR_ARCH_AVR5, + "ata5791" => elf::EF_AVR_ARCH_AVR5, + "ata5795" => elf::EF_AVR_ARCH_AVR5, + "ata5831" => elf::EF_AVR_ARCH_AVR5, + "ata6613c" => elf::EF_AVR_ARCH_AVR5, + "ata6614q" => elf::EF_AVR_ARCH_AVR5, + "ata8210" => elf::EF_AVR_ARCH_AVR5, + "ata8510" => elf::EF_AVR_ARCH_AVR5, + "atmega16" => elf::EF_AVR_ARCH_AVR5, + "atmega16a" => elf::EF_AVR_ARCH_AVR5, + "atmega161" => elf::EF_AVR_ARCH_AVR5, + "atmega162" => elf::EF_AVR_ARCH_AVR5, + "atmega163" => elf::EF_AVR_ARCH_AVR5, + "atmega164a" => elf::EF_AVR_ARCH_AVR5, + "atmega164p" => elf::EF_AVR_ARCH_AVR5, + "atmega164pa" => elf::EF_AVR_ARCH_AVR5, + "atmega165" => elf::EF_AVR_ARCH_AVR5, + "atmega165a" => elf::EF_AVR_ARCH_AVR5, + "atmega165p" => elf::EF_AVR_ARCH_AVR5, + "atmega165pa" => elf::EF_AVR_ARCH_AVR5, + "atmega168" => elf::EF_AVR_ARCH_AVR5, + "atmega168a" => elf::EF_AVR_ARCH_AVR5, + "atmega168p" => elf::EF_AVR_ARCH_AVR5, + "atmega168pa" => elf::EF_AVR_ARCH_AVR5, + "atmega168pb" => elf::EF_AVR_ARCH_AVR5, + "atmega169" => elf::EF_AVR_ARCH_AVR5, + "atmega169a" => elf::EF_AVR_ARCH_AVR5, + "atmega169p" => elf::EF_AVR_ARCH_AVR5, + "atmega169pa" => elf::EF_AVR_ARCH_AVR5, + "atmega32" => elf::EF_AVR_ARCH_AVR5, + "atmega32a" => elf::EF_AVR_ARCH_AVR5, + "atmega323" => elf::EF_AVR_ARCH_AVR5, + "atmega324a" => elf::EF_AVR_ARCH_AVR5, + "atmega324p" => elf::EF_AVR_ARCH_AVR5, + "atmega324pa" => elf::EF_AVR_ARCH_AVR5, + "atmega324pb" => elf::EF_AVR_ARCH_AVR5, + "atmega325" => elf::EF_AVR_ARCH_AVR5, + "atmega325a" => elf::EF_AVR_ARCH_AVR5, + "atmega325p" => elf::EF_AVR_ARCH_AVR5, + "atmega325pa" => elf::EF_AVR_ARCH_AVR5, + "atmega3250" => elf::EF_AVR_ARCH_AVR5, + "atmega3250a" => elf::EF_AVR_ARCH_AVR5, + "atmega3250p" => elf::EF_AVR_ARCH_AVR5, + "atmega3250pa" => elf::EF_AVR_ARCH_AVR5, + "atmega328" => elf::EF_AVR_ARCH_AVR5, + "atmega328p" => elf::EF_AVR_ARCH_AVR5, + "atmega328pb" => elf::EF_AVR_ARCH_AVR5, + "atmega329" => elf::EF_AVR_ARCH_AVR5, + "atmega329a" => elf::EF_AVR_ARCH_AVR5, + "atmega329p" => elf::EF_AVR_ARCH_AVR5, + "atmega329pa" => elf::EF_AVR_ARCH_AVR5, + "atmega3290" => elf::EF_AVR_ARCH_AVR5, + "atmega3290a" => elf::EF_AVR_ARCH_AVR5, + "atmega3290p" => elf::EF_AVR_ARCH_AVR5, + "atmega3290pa" => elf::EF_AVR_ARCH_AVR5, + "atmega406" => elf::EF_AVR_ARCH_AVR5, + "atmega64" => elf::EF_AVR_ARCH_AVR5, + "atmega64a" => elf::EF_AVR_ARCH_AVR5, + "atmega640" => elf::EF_AVR_ARCH_AVR5, + "atmega644" => elf::EF_AVR_ARCH_AVR5, + "atmega644a" => elf::EF_AVR_ARCH_AVR5, + "atmega644p" => elf::EF_AVR_ARCH_AVR5, + "atmega644pa" => elf::EF_AVR_ARCH_AVR5, + "atmega645" => elf::EF_AVR_ARCH_AVR5, + "atmega645a" => elf::EF_AVR_ARCH_AVR5, + "atmega645p" => elf::EF_AVR_ARCH_AVR5, + "atmega649" => elf::EF_AVR_ARCH_AVR5, + "atmega649a" => elf::EF_AVR_ARCH_AVR5, + "atmega649p" => elf::EF_AVR_ARCH_AVR5, + "atmega6450" => elf::EF_AVR_ARCH_AVR5, + "atmega6450a" => elf::EF_AVR_ARCH_AVR5, + "atmega6450p" => elf::EF_AVR_ARCH_AVR5, + "atmega6490" => elf::EF_AVR_ARCH_AVR5, + "atmega6490a" => elf::EF_AVR_ARCH_AVR5, + "atmega6490p" => elf::EF_AVR_ARCH_AVR5, + "atmega64rfr2" => elf::EF_AVR_ARCH_AVR5, + "atmega644rfr2" => elf::EF_AVR_ARCH_AVR5, + "atmega16hva" => elf::EF_AVR_ARCH_AVR5, + "atmega16hva2" => elf::EF_AVR_ARCH_AVR5, + "atmega16hvb" => elf::EF_AVR_ARCH_AVR5, + "atmega16hvbrevb" => elf::EF_AVR_ARCH_AVR5, + "atmega32hvb" => elf::EF_AVR_ARCH_AVR5, + "atmega32hvbrevb" => elf::EF_AVR_ARCH_AVR5, + "atmega64hve" => elf::EF_AVR_ARCH_AVR5, + "atmega64hve2" => elf::EF_AVR_ARCH_AVR5, + "at90can32" => elf::EF_AVR_ARCH_AVR5, + "at90can64" => elf::EF_AVR_ARCH_AVR5, + "at90pwm161" => elf::EF_AVR_ARCH_AVR5, + "at90pwm216" => elf::EF_AVR_ARCH_AVR5, + "at90pwm316" => elf::EF_AVR_ARCH_AVR5, + "atmega32c1" => elf::EF_AVR_ARCH_AVR5, + "atmega64c1" => elf::EF_AVR_ARCH_AVR5, + "atmega16m1" => elf::EF_AVR_ARCH_AVR5, + "atmega32m1" => elf::EF_AVR_ARCH_AVR5, + "atmega64m1" => elf::EF_AVR_ARCH_AVR5, + "atmega16u4" => elf::EF_AVR_ARCH_AVR5, + "atmega32u4" => elf::EF_AVR_ARCH_AVR5, + "atmega32u6" => elf::EF_AVR_ARCH_AVR5, + "at90usb646" => elf::EF_AVR_ARCH_AVR5, + "at90usb647" => elf::EF_AVR_ARCH_AVR5, + "at90scr100" => elf::EF_AVR_ARCH_AVR5, + "at94k" => elf::EF_AVR_ARCH_AVR5, + "m3000" => elf::EF_AVR_ARCH_AVR5, + "atmega128" => elf::EF_AVR_ARCH_AVR51, + "atmega128a" => elf::EF_AVR_ARCH_AVR51, + "atmega1280" => elf::EF_AVR_ARCH_AVR51, + "atmega1281" => elf::EF_AVR_ARCH_AVR51, + "atmega1284" => elf::EF_AVR_ARCH_AVR51, + "atmega1284p" => elf::EF_AVR_ARCH_AVR51, + "atmega128rfa1" => elf::EF_AVR_ARCH_AVR51, + "atmega128rfr2" => elf::EF_AVR_ARCH_AVR51, + "atmega1284rfr2" => elf::EF_AVR_ARCH_AVR51, + "at90can128" => elf::EF_AVR_ARCH_AVR51, + "at90usb1286" => elf::EF_AVR_ARCH_AVR51, + "at90usb1287" => elf::EF_AVR_ARCH_AVR51, + "atmega2560" => elf::EF_AVR_ARCH_AVR6, + "atmega2561" => elf::EF_AVR_ARCH_AVR6, + "atmega256rfr2" => elf::EF_AVR_ARCH_AVR6, + "atmega2564rfr2" => elf::EF_AVR_ARCH_AVR6, + "atxmega16a4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega16a4u" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega16c4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega16d4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32a4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32a4u" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32c3" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32c4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32d3" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32d4" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega32e5" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega16e5" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega8e5" => elf::EF_AVR_ARCH_XMEGA2, + "atxmega64a3" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64a3u" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64a4u" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64b1" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64b3" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64c3" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64d3" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64d4" => elf::EF_AVR_ARCH_XMEGA4, + "atxmega64a1" => elf::EF_AVR_ARCH_XMEGA5, + "atxmega64a1u" => elf::EF_AVR_ARCH_XMEGA5, + "atxmega128a3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128a3u" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128b1" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128b3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128c3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128d3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128d4" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega192a3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega192a3u" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega192c3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega192d3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256a3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256a3u" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256a3b" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256a3bu" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256c3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega256d3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega384c3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega384d3" => elf::EF_AVR_ARCH_XMEGA6, + "atxmega128a1" => elf::EF_AVR_ARCH_XMEGA7, + "atxmega128a1u" => elf::EF_AVR_ARCH_XMEGA7, + "atxmega128a4u" => elf::EF_AVR_ARCH_XMEGA7, + "attiny4" => elf::EF_AVR_ARCH_AVRTINY, + "attiny5" => elf::EF_AVR_ARCH_AVRTINY, + "attiny9" => elf::EF_AVR_ARCH_AVRTINY, + "attiny10" => elf::EF_AVR_ARCH_AVRTINY, + "attiny20" => elf::EF_AVR_ARCH_AVRTINY, + "attiny40" => elf::EF_AVR_ARCH_AVRTINY, + "attiny102" => elf::EF_AVR_ARCH_AVRTINY, + "attiny104" => elf::EF_AVR_ARCH_AVRTINY, + "attiny202" => elf::EF_AVR_ARCH_XMEGA3, + "attiny402" => elf::EF_AVR_ARCH_XMEGA3, + "attiny204" => elf::EF_AVR_ARCH_XMEGA3, + "attiny404" => elf::EF_AVR_ARCH_XMEGA3, + "attiny804" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1604" => elf::EF_AVR_ARCH_XMEGA3, + "attiny406" => elf::EF_AVR_ARCH_XMEGA3, + "attiny806" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1606" => elf::EF_AVR_ARCH_XMEGA3, + "attiny807" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1607" => elf::EF_AVR_ARCH_XMEGA3, + "attiny212" => elf::EF_AVR_ARCH_XMEGA3, + "attiny412" => elf::EF_AVR_ARCH_XMEGA3, + "attiny214" => elf::EF_AVR_ARCH_XMEGA3, + "attiny414" => elf::EF_AVR_ARCH_XMEGA3, + "attiny814" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1614" => elf::EF_AVR_ARCH_XMEGA3, + "attiny416" => elf::EF_AVR_ARCH_XMEGA3, + "attiny816" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1616" => elf::EF_AVR_ARCH_XMEGA3, + "attiny3216" => elf::EF_AVR_ARCH_XMEGA3, + "attiny417" => elf::EF_AVR_ARCH_XMEGA3, + "attiny817" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1617" => elf::EF_AVR_ARCH_XMEGA3, + "attiny3217" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1624" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1626" => elf::EF_AVR_ARCH_XMEGA3, + "attiny1627" => elf::EF_AVR_ARCH_XMEGA3, + "atmega808" => elf::EF_AVR_ARCH_XMEGA3, + "atmega809" => elf::EF_AVR_ARCH_XMEGA3, + "atmega1608" => elf::EF_AVR_ARCH_XMEGA3, + "atmega1609" => elf::EF_AVR_ARCH_XMEGA3, + "atmega3208" => elf::EF_AVR_ARCH_XMEGA3, + "atmega3209" => elf::EF_AVR_ARCH_XMEGA3, + "atmega4808" => elf::EF_AVR_ARCH_XMEGA3, + "atmega4809" => elf::EF_AVR_ARCH_XMEGA3, + + // Unknown target CPU => Unspecified/generic code + _ => 0, + } +} diff --git a/compiler/rustc_target/src/spec/base/bpf.rs b/compiler/rustc_target/src/spec/base/bpf.rs new file mode 100644 index 000000000..4d03747d0 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/bpf.rs @@ -0,0 +1,29 @@ +use crate::abi::Endian; +use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, TargetOptions}; + +pub fn opts(endian: Endian) -> TargetOptions { + TargetOptions { + allow_asm: true, + endian, + linker_flavor: LinkerFlavor::Bpf, + atomic_cas: false, + dynamic_linking: true, + no_builtins: true, + panic_strategy: PanicStrategy::Abort, + position_independent_executables: true, + // Disable MergeFunctions since: + // - older kernels don't support bpf-to-bpf calls + // - on newer kernels, userspace still needs to relocate before calling + // BPF_PROG_LOAD and not all BPF libraries do that yet + merge_functions: MergeFunctions::Disabled, + obj_is_bitcode: true, + requires_lto: false, + singlethread: true, + // When targeting the `v3` cpu in llvm, 32-bit atomics are also supported. + // But making this value change based on the target cpu can be mostly confusing + // and would require a bit of a refactor. + min_atomic_width: Some(64), + max_atomic_width: Some(64), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/dragonfly.rs b/compiler/rustc_target/src/spec/base/dragonfly.rs new file mode 100644 index 000000000..de2be7817 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/dragonfly.rs @@ -0,0 +1,14 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "dragonfly".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + default_dwarf_version: 2, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/freebsd.rs b/compiler/rustc_target/src/spec/base/freebsd.rs new file mode 100644 index 000000000..8c141aaae --- /dev/null +++ b/compiler/rustc_target/src/spec/base/freebsd.rs @@ -0,0 +1,15 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "freebsd".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + abi_return_struct_as_int: true, + default_dwarf_version: 2, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/fuchsia.rs b/compiler/rustc_target/src/spec/base/fuchsia.rs new file mode 100644 index 000000000..4c2775850 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/fuchsia.rs @@ -0,0 +1,43 @@ +use crate::spec::{crt_objects, cvs, Cc, LinkOutputKind, LinkerFlavor, Lld, TargetOptions}; + +pub fn opts() -> TargetOptions { + // This mirrors the linker options provided by clang. We presume lld for + // now. When using clang as the linker it will supply these options for us, + // so we only list them for ld/lld. + // + // https://github.com/llvm/llvm-project/blob/db9322b2066c55254e7691efeab863f43bfcc084/clang/lib/Driver/ToolChains/Fuchsia.cpp#L31 + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &[ + "--build-id", + "--hash-style=gnu", + "-z", + "max-page-size=4096", + "-z", + "now", + "-z", + "rodynamic", + "-z", + "separate-loadable-segments", + "--pack-dyn-relocs=relr", + ], + ); + + TargetOptions { + os: "fuchsia".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + dynamic_linking: true, + families: cvs!["unix"], + pre_link_args, + pre_link_objects: crt_objects::new(&[ + (LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]), + (LinkOutputKind::DynamicPicExe, &["Scrt1.o"]), + (LinkOutputKind::StaticNoPicExe, &["Scrt1.o"]), + (LinkOutputKind::StaticPicExe, &["Scrt1.o"]), + ]), + position_independent_executables: true, + has_thread_local: true, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/haiku.rs b/compiler/rustc_target/src/spec/base/haiku.rs new file mode 100644 index 000000000..8ab874410 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/haiku.rs @@ -0,0 +1,11 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "haiku".into(), + dynamic_linking: true, + families: cvs!["unix"], + relro_level: RelroLevel::Full, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/hermit.rs b/compiler/rustc_target/src/spec/base/hermit.rs new file mode 100644 index 000000000..c6e98fc1a --- /dev/null +++ b/compiler/rustc_target/src/spec/base/hermit.rs @@ -0,0 +1,15 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "hermit".into(), + linker: Some("rust-lld".into()), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + tls_model: TlsModel::InitialExec, + position_independent_executables: true, + static_position_independent_executables: true, + has_thread_local: true, + panic_strategy: PanicStrategy::Abort, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/hurd.rs b/compiler/rustc_target/src/spec/base/hurd.rs new file mode 100644 index 000000000..76f8223c0 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/hurd.rs @@ -0,0 +1,15 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "hurd".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + has_thread_local: true, + crt_static_respected: true, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/hurd_gnu.rs b/compiler/rustc_target/src/spec/base/hurd_gnu.rs new file mode 100644 index 000000000..3501dbdea --- /dev/null +++ b/compiler/rustc_target/src/spec/base/hurd_gnu.rs @@ -0,0 +1,5 @@ +use crate::spec::{base, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { env: "gnu".into(), ..base::hurd::opts() } +} diff --git a/compiler/rustc_target/src/spec/base/illumos.rs b/compiler/rustc_target/src/spec/base/illumos.rs new file mode 100644 index 000000000..e63e78975 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/illumos.rs @@ -0,0 +1,59 @@ +use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, TargetOptions}; + +pub fn opts() -> TargetOptions { + let late_link_args = TargetOptions::link_args( + LinkerFlavor::Unix(Cc::Yes), + &[ + // The illumos libc contains a stack unwinding implementation, as + // does libgcc_s. The latter implementation includes several + // additional symbols that are not always in base libc. To force + // the consistent use of just one unwinder, we ensure libc appears + // after libgcc_s in the NEEDED list for the resultant binary by + // ignoring any attempts to add it as a dynamic dependency until the + // very end. + // FIXME: This should be replaced by a more complete and generic + // mechanism for controlling the order of library arguments passed + // to the linker. + "-lc", + // LLVM will insert calls to the stack protector functions + // "__stack_chk_fail" and "__stack_chk_guard" into code in native + // object files. Some platforms include these symbols directly in + // libc, but at least historically these have been provided in + // libssp.so on illumos and Solaris systems. + "-lssp", + ], + ); + + TargetOptions { + os: "illumos".into(), + dynamic_linking: true, + has_rpath: true, + families: cvs!["unix"], + is_like_solaris: true, + linker_flavor: LinkerFlavor::Unix(Cc::Yes), + limit_rdylib_exports: false, // Linker doesn't support this + frame_pointer: FramePointer::Always, + eh_frame_header: false, + late_link_args, + + // While we support ELF TLS, rust requires a way to register + // cleanup handlers (in C, this would be something along the lines of: + // void register_callback(void (*fn)(void *), void *arg); + // (see src/libstd/sys/unix/fast_thread_local.rs) that is currently + // missing in illumos. For now at least, we must fallback to using + // pthread_{get,set}specific. + //has_thread_local: true, + + // FIXME: Currently, rust is invoking cc to link, which ends up + // causing these to get included twice. We should eventually transition + // to having rustc invoke ld directly, in which case these will need to + // be uncommented. + // + // We want XPG6 behavior from libc and libm. See standards(5) + //pre_link_objects_exe: vec![ + // "/usr/lib/amd64/values-Xc.o".into(), + // "/usr/lib/amd64/values-xpg6.o".into(), + //], + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/l4re.rs b/compiler/rustc_target/src/spec/base/l4re.rs new file mode 100644 index 000000000..3a4d83fad --- /dev/null +++ b/compiler/rustc_target/src/spec/base/l4re.rs @@ -0,0 +1,14 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "l4re".into(), + env: "uclibc".into(), + linker_flavor: LinkerFlavor::Unix(Cc::No), + panic_strategy: PanicStrategy::Abort, + linker: Some("l4-bender".into()), + families: cvs!["unix"], + relocation_model: RelocModel::Static, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/linux.rs b/compiler/rustc_target/src/spec/base/linux.rs new file mode 100644 index 000000000..df8e84812 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/linux.rs @@ -0,0 +1,21 @@ +use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions}; +use std::borrow::Cow; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "linux".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + has_thread_local: true, + crt_static_respected: true, + supported_split_debuginfo: Cow::Borrowed(&[ + SplitDebuginfo::Packed, + SplitDebuginfo::Unpacked, + SplitDebuginfo::Off, + ]), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/linux_gnu.rs b/compiler/rustc_target/src/spec/base/linux_gnu.rs new file mode 100644 index 000000000..3491277c4 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/linux_gnu.rs @@ -0,0 +1,5 @@ +use crate::spec::{base, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { env: "gnu".into(), ..base::linux::opts() } +} diff --git a/compiler/rustc_target/src/spec/base/linux_musl.rs b/compiler/rustc_target/src/spec/base/linux_musl.rs new file mode 100644 index 000000000..5117cadbe --- /dev/null +++ b/compiler/rustc_target/src/spec/base/linux_musl.rs @@ -0,0 +1,16 @@ +use crate::spec::crt_objects; +use crate::spec::{base, LinkSelfContainedDefault, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut base = base::linux::opts(); + + base.env = "musl".into(); + base.pre_link_objects_self_contained = crt_objects::pre_musl_self_contained(); + base.post_link_objects_self_contained = crt_objects::post_musl_self_contained(); + base.link_self_contained = LinkSelfContainedDefault::InferredForMusl; + + // These targets statically link libc by default + base.crt_static_default = true; + + base +} diff --git a/compiler/rustc_target/src/spec/base/linux_ohos.rs b/compiler/rustc_target/src/spec/base/linux_ohos.rs new file mode 100644 index 000000000..273e6a98d --- /dev/null +++ b/compiler/rustc_target/src/spec/base/linux_ohos.rs @@ -0,0 +1,12 @@ +use crate::spec::{base, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut base = base::linux::opts(); + + base.env = "ohos".into(); + base.crt_static_default = false; + base.force_emulated_tls = true; + base.has_thread_local = false; + + base +} diff --git a/compiler/rustc_target/src/spec/base/linux_uclibc.rs b/compiler/rustc_target/src/spec/base/linux_uclibc.rs new file mode 100644 index 000000000..540344e9e --- /dev/null +++ b/compiler/rustc_target/src/spec/base/linux_uclibc.rs @@ -0,0 +1,5 @@ +use crate::spec::{base, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { env: "uclibc".into(), ..base::linux::opts() } +} diff --git a/compiler/rustc_target/src/spec/base/mod.rs b/compiler/rustc_target/src/spec/base/mod.rs new file mode 100644 index 000000000..d137aaa53 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/mod.rs @@ -0,0 +1,37 @@ +pub(crate) mod aix; +pub(crate) mod android; +pub(crate) mod apple; +pub(crate) mod avr_gnu; +pub(crate) mod bpf; +pub(crate) mod dragonfly; +pub(crate) mod freebsd; +pub(crate) mod fuchsia; +pub(crate) mod haiku; +pub(crate) mod hermit; +pub(crate) mod hurd; +pub(crate) mod hurd_gnu; +pub(crate) mod illumos; +pub(crate) mod l4re; +pub(crate) mod linux; +pub(crate) mod linux_gnu; +pub(crate) mod linux_musl; +pub(crate) mod linux_ohos; +pub(crate) mod linux_uclibc; +pub(crate) mod msvc; +pub(crate) mod netbsd; +pub(crate) mod nto_qnx; +pub(crate) mod openbsd; +pub(crate) mod redox; +pub(crate) mod solaris; +pub(crate) mod solid; +pub(crate) mod teeos; +pub(crate) mod thumb; +pub(crate) mod uefi_msvc; +pub(crate) mod unikraft_linux_musl; +pub(crate) mod vxworks; +pub(crate) mod wasm; +pub(crate) mod windows_gnu; +pub(crate) mod windows_gnullvm; +pub(crate) mod windows_msvc; +pub(crate) mod windows_uwp_gnu; +pub(crate) mod windows_uwp_msvc; diff --git a/compiler/rustc_target/src/spec/base/msvc.rs b/compiler/rustc_target/src/spec/base/msvc.rs new file mode 100644 index 000000000..efe949a4e --- /dev/null +++ b/compiler/rustc_target/src/spec/base/msvc.rs @@ -0,0 +1,26 @@ +use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; +use std::borrow::Cow; + +pub fn opts() -> TargetOptions { + // Suppress the verbose logo and authorship debugging output, which would needlessly + // clog any log files. + let pre_link_args = TargetOptions::link_args(LinkerFlavor::Msvc(Lld::No), &["/NOLOGO"]); + + TargetOptions { + linker_flavor: LinkerFlavor::Msvc(Lld::No), + dll_tls_export: false, + is_like_windows: true, + is_like_msvc: true, + pre_link_args, + abi_return_struct_as_int: true, + emit_debug_gdb_scripts: false, + + // Currently this is the only supported method of debuginfo on MSVC + // where `*.pdb` files show up next to the final artifact. + split_debuginfo: SplitDebuginfo::Packed, + supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Packed]), + debuginfo_kind: DebuginfoKind::Pdb, + + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/netbsd.rs b/compiler/rustc_target/src/spec/base/netbsd.rs new file mode 100644 index 000000000..be94ea234 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/netbsd.rs @@ -0,0 +1,16 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "netbsd".into(), + dynamic_linking: true, + families: cvs!["unix"], + no_default_libraries: false, + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + use_ctors_section: true, + default_dwarf_version: 2, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/nto_qnx.rs b/compiler/rustc_target/src/spec/base/nto_qnx.rs new file mode 100644 index 000000000..f1405e9b4 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/nto_qnx.rs @@ -0,0 +1,18 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + crt_static_respected: true, + dynamic_linking: true, + executables: true, + families: cvs!["unix"], + has_rpath: true, + has_thread_local: false, + linker: Some("qcc".into()), + os: "nto".into(), + position_independent_executables: true, + static_position_independent_executables: true, + relro_level: RelroLevel::Full, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/openbsd.rs b/compiler/rustc_target/src/spec/base/openbsd.rs new file mode 100644 index 000000000..e7db14e05 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/openbsd.rs @@ -0,0 +1,16 @@ +use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "openbsd".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + abi_return_struct_as_int: true, + position_independent_executables: true, + frame_pointer: FramePointer::Always, // FIXME 43575: should be MayOmit... + relro_level: RelroLevel::Full, + default_dwarf_version: 2, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/redox.rs b/compiler/rustc_target/src/spec/base/redox.rs new file mode 100644 index 000000000..468fe4785 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/redox.rs @@ -0,0 +1,17 @@ +use crate::spec::{cvs, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "redox".into(), + env: "relibc".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + position_independent_executables: true, + relro_level: RelroLevel::Full, + has_thread_local: true, + crt_static_default: true, + crt_static_respected: true, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/solaris.rs b/compiler/rustc_target/src/spec/base/solaris.rs new file mode 100644 index 000000000..f97cdb4fb --- /dev/null +++ b/compiler/rustc_target/src/spec/base/solaris.rs @@ -0,0 +1,16 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "solaris".into(), + dynamic_linking: true, + has_rpath: true, + families: cvs!["unix"], + is_like_solaris: true, + linker_flavor: LinkerFlavor::Unix(Cc::Yes), + limit_rdylib_exports: false, // Linker doesn't support this + eh_frame_header: false, + + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/solid.rs b/compiler/rustc_target/src/spec/base/solid.rs new file mode 100644 index 000000000..ce4a88690 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/solid.rs @@ -0,0 +1,12 @@ +use crate::spec::{FramePointer, TargetOptions}; + +pub fn opts(kernel: &str) -> TargetOptions { + TargetOptions { + os: format!("solid_{kernel}").into(), + vendor: "kmc".into(), + executables: false, + frame_pointer: FramePointer::NonLeaf, + has_thread_local: true, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/teeos.rs b/compiler/rustc_target/src/spec/base/teeos.rs new file mode 100644 index 000000000..38d0a6d73 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/teeos.rs @@ -0,0 +1,28 @@ +use crate::spec::{add_link_args, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions}; + +pub fn opts() -> TargetOptions { + let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"]; + let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"]; + + let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args); + add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args); + + TargetOptions { + os: "teeos".into(), + vendor: "unknown".into(), + dynamic_linking: true, + linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), + // rpath hardcodes -Wl, so it can't be used together with ld.lld. + // C TAs also don't support rpath, so this is fine. + has_rpath: false, + // Note: Setting has_thread_local to true causes an error when + // loading / dyn-linking the TA + has_thread_local: false, + position_independent_executables: true, + relro_level: RelroLevel::Full, + crt_static_respected: true, + pre_link_args, + panic_strategy: PanicStrategy::Abort, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/thumb.rs b/compiler/rustc_target/src/spec/base/thumb.rs new file mode 100644 index 000000000..0decfecb4 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/thumb.rs @@ -0,0 +1,59 @@ +// These `thumbv*` targets cover the ARM Cortex-M family of processors which are widely used in +// microcontrollers. Namely, all these processors: +// +// - Cortex-M0 +// - Cortex-M0+ +// - Cortex-M1 +// - Cortex-M3 +// - Cortex-M4(F) +// - Cortex-M7(F) +// - Cortex-M23 +// - Cortex-M33 +// +// We have opted for these instead of one target per processor (e.g., `cortex-m0`, `cortex-m3`, +// etc) because the differences between some processors like the cortex-m0 and cortex-m1 are almost +// nonexistent from the POV of codegen so it doesn't make sense to have separate targets for them. +// And if differences exist between two processors under the same target, rustc flags can be used to +// optimize for one processor or the other. +// +// Also, we have not chosen a single target (`arm-none-eabi`) like GCC does because this makes +// difficult to integrate Rust code and C code. Targeting the Cortex-M4 requires different gcc flags +// than the ones you would use for the Cortex-M0 and with a single target it'd be impossible to +// differentiate one processor from the other. +// +// About arm vs thumb in the name. The Cortex-M devices only support the Thumb instruction set, +// which is more compact (higher code density), and not the ARM instruction set. That's why LLVM +// triples use thumb instead of arm. We follow suit because having thumb in the name let us +// differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of +// build scripts / gcc flags. + +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions}; + +pub fn opts() -> TargetOptions { + // See rust-lang/rfcs#1645 for a discussion about these defaults + TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + // In most cases, LLD is good enough + linker: Some("rust-lld".into()), + // Because these devices have very little resources having an unwinder is too onerous so we + // default to "abort" because the "unwind" strategy is very rare. + panic_strategy: PanicStrategy::Abort, + // Similarly, one almost always never wants to use relocatable code because of the extra + // costs it involves. + relocation_model: RelocModel::Static, + // When this section is added a volatile load to its start address is also generated. This + // volatile load is a footgun as it can end up loading an invalid memory address, depending + // on how the user set up their linker scripts. This section adds pretty printer for stuff + // like std::Vec, which is not that used in no-std context, so it's best to left it out + // until we figure a way to add the pretty printers without requiring a volatile load cf. + // rust-lang/rust#44993. + emit_debug_gdb_scripts: false, + // LLVM is eager to trash the link register when calling `noreturn` functions, which + // breaks debugging. Preserve LR by default to prevent that from happening. + frame_pointer: FramePointer::Always, + // ARM supports multiple ABIs for enums, the linux one matches the default of 32 here + // but any arm-none or thumb-none target will be defaulted to 8 on GCC. + c_enum_min_bits: Some(8), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/uefi_msvc.rs b/compiler/rustc_target/src/spec/base/uefi_msvc.rs new file mode 100644 index 000000000..e8acd6078 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/uefi_msvc.rs @@ -0,0 +1,52 @@ +// This defines a base target-configuration for native UEFI systems. The UEFI specification has +// quite detailed sections on the ABI of all the supported target architectures. In almost all +// cases it simply follows what Microsoft Windows does. Hence, whenever in doubt, see the MSDN +// documentation. +// UEFI uses COFF/PE32+ format for binaries. All binaries must be statically linked. No dynamic +// linker is supported. As native to COFF, binaries are position-dependent, but will be relocated +// by the loader if the pre-chosen memory location is already in use. +// UEFI forbids running code on anything but the boot-CPU. No interrupts are allowed other than +// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all +// code runs in the same environment, no process separation is supported. + +use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut base = base::msvc::opts(); + + base.add_pre_link_args( + LinkerFlavor::Msvc(Lld::No), + &[ + // Non-standard subsystems have no default entry-point in PE+ files. We have to define + // one. "efi_main" seems to be a common choice amongst other implementations and the + // spec. + "/entry:efi_main", + // COFF images have a "Subsystem" field in their header, which defines what kind of + // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION, + // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION, + // which is very likely the most common option. Individual projects can override this + // with custom linker flags. + // The subsystem-type only has minor effects on the application. It defines the memory + // regions the application is loaded into (runtime-drivers need to be put into + // reserved areas), as well as whether a return from the entry-point is treated as + // exit (default for applications). + "/subsystem:efi_application", + ], + ); + + TargetOptions { + os: "uefi".into(), + linker_flavor: LinkerFlavor::Msvc(Lld::Yes), + disable_redzone: true, + exe_suffix: ".efi".into(), + allows_weak_linkage: false, + panic_strategy: PanicStrategy::Abort, + // LLVM does not emit inline assembly because the LLVM target does not get considered as… + // "Windows". + stack_probes: StackProbeType::Call, + singlethread: true, + linker: Some("rust-lld".into()), + entry_name: "efi_main".into(), + ..base + } +} diff --git a/compiler/rustc_target/src/spec/base/unikraft_linux_musl.rs b/compiler/rustc_target/src/spec/base/unikraft_linux_musl.rs new file mode 100644 index 000000000..9ccd0a1e7 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/unikraft_linux_musl.rs @@ -0,0 +1,15 @@ +use crate::spec::{cvs, PanicStrategy, RelocModel, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "linux".into(), + env: "musl".into(), + vendor: "unikraft".into(), + linker: Some("kraftld".into()), + relocation_model: RelocModel::Static, + families: cvs!["unix"], + has_thread_local: true, + panic_strategy: PanicStrategy::Abort, + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/vxworks.rs b/compiler/rustc_target/src/spec/base/vxworks.rs new file mode 100644 index 000000000..aa4784b63 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/vxworks.rs @@ -0,0 +1,21 @@ +use crate::spec::{cvs, TargetOptions}; + +pub fn opts() -> TargetOptions { + TargetOptions { + os: "vxworks".into(), + env: "gnu".into(), + vendor: "wrs".into(), + linker: Some("wr-c++".into()), + exe_suffix: ".vxe".into(), + dynamic_linking: true, + families: cvs!["unix"], + has_rpath: true, + has_thread_local: true, + crt_static_default: true, + crt_static_respected: true, + crt_static_allows_dylibs: true, + // VxWorks needs to implement this to support profiling + mcount: "_mcount".into(), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/wasm.rs b/compiler/rustc_target/src/spec/base/wasm.rs new file mode 100644 index 000000000..87ade9e58 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/wasm.rs @@ -0,0 +1,135 @@ +use crate::spec::{ + add_link_args, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, PanicStrategy, RelocModel, + TargetOptions, TlsModel, +}; + +pub fn options() -> TargetOptions { + macro_rules! args { + ($prefix:literal) => { + &[ + // By default LLD only gives us one page of stack (64k) which is a + // little small. Default to a larger stack closer to other PC platforms + // (1MB) and users can always inject their own link-args to override this. + concat!($prefix, "-z"), + concat!($prefix, "stack-size=1048576"), + // By default LLD's memory layout is: + // + // 1. First, a blank page + // 2. Next, all static data + // 3. Finally, the main stack (which grows down) + // + // This has the unfortunate consequence that on stack overflows you + // corrupt static data and can cause some exceedingly weird bugs. To + // help detect this a little sooner we instead request that the stack is + // placed before static data. + // + // This means that we'll generate slightly larger binaries as references + // to static data will take more bytes in the ULEB128 encoding, but + // stack overflow will be guaranteed to trap as it underflows instead of + // corrupting static data. + concat!($prefix, "--stack-first"), + // FIXME we probably shouldn't pass this but instead pass an explicit list + // of symbols we'll allow to be undefined. We don't currently have a + // mechanism of knowing, however, which symbols are intended to be imported + // from the environment and which are intended to be imported from other + // objects linked elsewhere. This is a coarse approximation but is sure to + // hide some bugs and frustrate someone at some point, so we should ideally + // work towards a world where we can explicitly list symbols that are + // supposed to be imported and have all other symbols generate errors if + // they remain undefined. + concat!($prefix, "--allow-undefined"), + // Rust code should never have warnings, and warnings are often + // indicative of bugs, let's prevent them. + concat!($prefix, "--fatal-warnings"), + // LLD only implements C++-like demangling, which doesn't match our own + // mangling scheme. Tell LLD to not demangle anything and leave it up to + // us to demangle these symbols later. Currently rustc does not perform + // further demangling, but tools like twiggy and wasm-bindgen are intended + // to do so. + concat!($prefix, "--no-demangle"), + ] + }; + } + + let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::WasmLld(Cc::No), args!("")); + add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,")); + + TargetOptions { + is_like_wasm: true, + families: cvs!["wasm"], + + // we allow dynamic linking, but only cdylibs. Basically we allow a + // final library artifact that exports some symbols (a wasm module) but + // we don't allow intermediate `dylib` crate types + dynamic_linking: true, + only_cdylib: true, + + // relatively self-explanatory! + exe_suffix: ".wasm".into(), + dll_prefix: "".into(), + dll_suffix: ".wasm".into(), + eh_frame_header: false, + + max_atomic_width: Some(64), + + // Unwinding doesn't work right now, so the whole target unconditionally + // defaults to panic=abort. Note that this is guaranteed to change in + // the future once unwinding is implemented. Don't rely on this as we're + // basically guaranteed to change it once WebAssembly supports + // exceptions. + panic_strategy: PanicStrategy::Abort, + + // Wasm doesn't have atomics yet, so tell LLVM that we're in a single + // threaded model which will legalize atomics to normal operations. + singlethread: true, + + // no dynamic linking, no need for default visibility! + default_hidden_visibility: true, + + // Symbol visibility takes care of this for the WebAssembly. + // Additionally the only known linker, LLD, doesn't support the script + // arguments just yet + limit_rdylib_exports: false, + + // we use the LLD shipped with the Rust toolchain by default + linker: Some("rust-lld".into()), + linker_flavor: LinkerFlavor::WasmLld(Cc::No), + + pre_link_args, + + // FIXME: Figure out cases in which WASM needs to link with a native toolchain. + // + // rust-lang/rust#104137: cannot blindly remove this without putting in + // some other way to compensate for lack of `-nostartfiles` in linker + // invocation. + link_self_contained: LinkSelfContainedDefault::True, + + // This has no effect in LLVM 8 or prior, but in LLVM 9 and later when + // PIC code is implemented this has quite a drastic effect if it stays + // at the default, `pic`. In an effort to keep wasm binaries as minimal + // as possible we're defaulting to `static` for now, but the hope is + // that eventually we can ship a `pic`-compatible standard library which + // works with `static` as well (or works with some method of generating + // non-relative calls and such later on). + relocation_model: RelocModel::Static, + + // When the atomics feature is activated then these two keys matter, + // otherwise they're basically ignored by the standard library. In this + // mode, however, the `#[thread_local]` attribute works (i.e. + // `has_thread_local`) and we need to get it to work by specifying + // `local-exec` as that's all that's implemented in LLVM today for wasm. + has_thread_local: true, + tls_model: TlsModel::LocalExec, + + // gdb scripts don't work on wasm blobs + emit_debug_gdb_scripts: false, + + // There's more discussion of this at + // https://bugs.llvm.org/show_bug.cgi?id=52442 but the general result is + // that this isn't useful for wasm and has tricky issues with + // representation, so this is disabled. + generate_arange_section: false, + + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/windows_gnu.rs b/compiler/rustc_target/src/spec/base/windows_gnu.rs new file mode 100644 index 000000000..25f02dc14 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/windows_gnu.rs @@ -0,0 +1,108 @@ +use crate::spec::LinkSelfContainedDefault; +use crate::spec::{add_link_args, crt_objects}; +use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; +use std::borrow::Cow; + +pub fn opts() -> TargetOptions { + let mut pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &[ + // Enable ASLR + "--dynamicbase", + // ASLR will rebase it anyway so leaving that option enabled only leads to confusion + "--disable-auto-image-base", + ], + ); + add_link_args( + &mut pre_link_args, + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &[ + // Tell GCC to avoid linker plugins, because we are not bundling + // them with Windows installer, and Rust does its own LTO anyways. + "-fno-use-linker-plugin", + "-Wl,--dynamicbase", + "-Wl,--disable-auto-image-base", + ], + ); + + // Order of `late_link_args*` was found through trial and error to work with various + // mingw-w64 versions (not tested on the CI). It's expected to change from time to time. + let mingw_libs = &[ + "-lmsvcrt", + "-lmingwex", + "-lmingw32", + "-lgcc", // alas, mingw* libraries above depend on libgcc + // mingw's msvcrt is a weird hybrid import library and static library. + // And it seems that the linker fails to use import symbols from msvcrt + // that are required from functions in msvcrt in certain cases. For example + // `_fmode` that is used by an implementation of `__p__fmode` in x86_64. + // The library is purposely listed twice to fix that. + // + // See https://github.com/rust-lang/rust/pull/47483 for some more details. + "-lmsvcrt", + "-luser32", + "-lkernel32", + ]; + let mut late_link_args = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs); + add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs); + // If any of our crates are dynamically linked then we need to use + // the shared libgcc_s-dw2-1.dll. This is required to support + // unwinding across DLL boundaries. + let dynamic_unwind_libs = &["-lgcc_s"]; + let mut late_link_args_dynamic = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs); + add_link_args( + &mut late_link_args_dynamic, + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + dynamic_unwind_libs, + ); + // If all of our crates are statically linked then we can get away + // with statically linking the libgcc unwinding code. This allows + // binaries to be redistributed without the libgcc_s-dw2-1.dll + // dependency, but unfortunately break unwinding across DLL + // boundaries when unwinding across FFI boundaries. + let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"]; + let mut late_link_args_static = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs); + add_link_args( + &mut late_link_args_static, + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + static_unwind_libs, + ); + + TargetOptions { + os: "windows".into(), + env: "gnu".into(), + vendor: "pc".into(), + // FIXME(#13846) this should be enabled for windows + function_sections: false, + linker: Some("gcc".into()), + dynamic_linking: true, + dll_tls_export: false, + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + families: cvs!["windows"], + is_like_windows: true, + allows_weak_linkage: false, + pre_link_args, + pre_link_objects: crt_objects::pre_mingw(), + post_link_objects: crt_objects::post_mingw(), + pre_link_objects_self_contained: crt_objects::pre_mingw_self_contained(), + post_link_objects_self_contained: crt_objects::post_mingw_self_contained(), + link_self_contained: LinkSelfContainedDefault::InferredForMingw, + late_link_args, + late_link_args_dynamic, + late_link_args_static, + abi_return_struct_as_int: true, + emit_debug_gdb_scripts: false, + requires_uwtable: true, + eh_frame_header: false, + // FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to + // output DWO, despite using DWARF, doesn't use ELF.. + debuginfo_kind: DebuginfoKind::Pdb, + supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/windows_gnullvm.rs b/compiler/rustc_target/src/spec/base/windows_gnullvm.rs new file mode 100644 index 000000000..b1d8e2be5 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/windows_gnullvm.rs @@ -0,0 +1,47 @@ +use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; +use std::borrow::Cow; + +pub fn opts() -> TargetOptions { + // We cannot use `-nodefaultlibs` because compiler-rt has to be passed + // as a path since it's not added to linker search path by the default. + // There were attempts to make it behave like libgcc (so one can just use -l) + // but LLVM maintainers rejected it: https://reviews.llvm.org/D51440 + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-nolibc", "--unwindlib=none"], + ); + // Order of `late_link_args*` does not matter with LLD. + let late_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"], + ); + + TargetOptions { + os: "windows".into(), + env: "gnu".into(), + vendor: "pc".into(), + abi: "llvm".into(), + linker: Some("clang".into()), + dynamic_linking: true, + dll_tls_export: false, + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + families: cvs!["windows"], + is_like_windows: true, + allows_weak_linkage: false, + pre_link_args, + late_link_args, + abi_return_struct_as_int: true, + emit_debug_gdb_scripts: false, + requires_uwtable: true, + eh_frame_header: false, + no_default_libraries: false, + has_thread_local: true, + // FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to + // output DWO, despite using DWARF, doesn't use ELF.. + debuginfo_kind: DebuginfoKind::Pdb, + supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/windows_msvc.rs b/compiler/rustc_target/src/spec/base/windows_msvc.rs new file mode 100644 index 000000000..e3cf97572 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/windows_msvc.rs @@ -0,0 +1,34 @@ +use crate::spec::{base, cvs, TargetOptions}; + +pub fn opts() -> TargetOptions { + let base = base::msvc::opts(); + + TargetOptions { + os: "windows".into(), + env: "msvc".into(), + vendor: "pc".into(), + dynamic_linking: true, + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + staticlib_prefix: "".into(), + staticlib_suffix: ".lib".into(), + families: cvs!["windows"], + crt_static_allows_dylibs: true, + crt_static_respected: true, + requires_uwtable: true, + // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC + // as there's been trouble in the past of linking the C++ standard + // library required by LLVM. This likely needs to happen one day, but + // in general Windows is also a more controlled environment than + // Unix, so it's not necessarily as critical that this be implemented. + // + // Note that there are also some licensing worries about statically + // linking some libraries which require a specific agreement, so it may + // not ever be possible for us to pass this flag. + no_default_libraries: false, + has_thread_local: true, + + ..base + } +} diff --git a/compiler/rustc_target/src/spec/base/windows_uwp_gnu.rs b/compiler/rustc_target/src/spec/base/windows_uwp_gnu.rs new file mode 100644 index 000000000..17256e18e --- /dev/null +++ b/compiler/rustc_target/src/spec/base/windows_uwp_gnu.rs @@ -0,0 +1,35 @@ +use crate::spec::{add_link_args, base, Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions}; + +pub fn opts() -> TargetOptions { + let base = base::windows_gnu::opts(); + + // FIXME: This should be updated for the exception machinery changes from #67502 + // and inherit from `windows_gnu_base`, at least partially. + let mingw_libs = &[ + "-lwinstorecompat", + "-lruntimeobject", + "-lsynchronization", + "-lvcruntime140_app", + "-lucrt", + "-lwindowsapp", + "-lmingwex", + "-lmingw32", + ]; + let mut late_link_args = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs); + add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs); + // Reset the flags back to empty until the FIXME above is addressed. + let late_link_args_dynamic = LinkArgs::new(); + let late_link_args_static = LinkArgs::new(); + + TargetOptions { + abi: "uwp".into(), + vendor: "uwp".into(), + limit_rdylib_exports: false, + late_link_args, + late_link_args_dynamic, + late_link_args_static, + + ..base + } +} diff --git a/compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs b/compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs new file mode 100644 index 000000000..59a761671 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs @@ -0,0 +1,11 @@ +use crate::spec::{base, LinkerFlavor, Lld, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut opts = base::windows_msvc::opts(); + + opts.abi = "uwp".into(); + opts.vendor = "uwp".into(); + opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]); + + opts +} diff --git a/compiler/rustc_target/src/spec/bpf_base.rs b/compiler/rustc_target/src/spec/bpf_base.rs deleted file mode 100644 index 4d03747d0..000000000 --- a/compiler/rustc_target/src/spec/bpf_base.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, TargetOptions}; - -pub fn opts(endian: Endian) -> TargetOptions { - TargetOptions { - allow_asm: true, - endian, - linker_flavor: LinkerFlavor::Bpf, - atomic_cas: false, - dynamic_linking: true, - no_builtins: true, - panic_strategy: PanicStrategy::Abort, - position_independent_executables: true, - // Disable MergeFunctions since: - // - older kernels don't support bpf-to-bpf calls - // - on newer kernels, userspace still needs to relocate before calling - // BPF_PROG_LOAD and not all BPF libraries do that yet - merge_functions: MergeFunctions::Disabled, - obj_is_bitcode: true, - requires_lto: false, - singlethread: true, - // When targeting the `v3` cpu in llvm, 32-bit atomics are also supported. - // But making this value change based on the target cpu can be mostly confusing - // and would require a bit of a refactor. - min_atomic_width: Some(64), - max_atomic_width: Some(64), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs b/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs deleted file mode 100644 index 174ddfa50..000000000 --- a/compiler/rustc_target/src/spec/bpfeb_unknown_none.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::spec::Target; -use crate::{abi::Endian, spec::bpf_base}; - -pub fn target() -> Target { - Target { - llvm_target: "bpfeb".into(), - data_layout: "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - pointer_width: 64, - arch: "bpf".into(), - options: bpf_base::opts(Endian::Big), - } -} diff --git a/compiler/rustc_target/src/spec/bpfel_unknown_none.rs b/compiler/rustc_target/src/spec/bpfel_unknown_none.rs deleted file mode 100644 index 7625e7b0e..000000000 --- a/compiler/rustc_target/src/spec/bpfel_unknown_none.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::spec::Target; -use crate::{abi::Endian, spec::bpf_base}; - -pub fn target() -> Target { - Target { - llvm_target: "bpfel".into(), - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - pointer_width: 64, - arch: "bpf".into(), - options: bpf_base::opts(Endian::Little), - } -} diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs index c126390f5..53f710b8f 100644 --- a/compiler/rustc_target/src/spec/crt_objects.rs +++ b/compiler/rustc_target/src/spec/crt_objects.rs @@ -40,11 +40,9 @@ //! but not gcc's. As a result rustc cannot link with C++ static libraries (#36710) //! when linking in self-contained mode. -use crate::json::{Json, ToJson}; use crate::spec::LinkOutputKind; use std::borrow::Cow; use std::collections::BTreeMap; -use std::str::FromStr; pub type CrtObjects = BTreeMap>>; @@ -123,39 +121,3 @@ pub(super) fn pre_wasi_self_contained() -> CrtObjects { pub(super) fn post_wasi_self_contained() -> CrtObjects { new(&[]) } - -/// Which logic to use to determine whether to use self-contained linking mode -/// if `-Clink-self-contained` is not specified explicitly. -#[derive(Clone, Copy, PartialEq, Hash, Debug)] -pub enum LinkSelfContainedDefault { - False, - True, - Musl, - Mingw, -} - -impl FromStr for LinkSelfContainedDefault { - type Err = (); - - fn from_str(s: &str) -> Result { - Ok(match s { - "false" => LinkSelfContainedDefault::False, - "true" | "wasm" => LinkSelfContainedDefault::True, - "musl" => LinkSelfContainedDefault::Musl, - "mingw" => LinkSelfContainedDefault::Mingw, - _ => return Err(()), - }) - } -} - -impl ToJson for LinkSelfContainedDefault { - fn to_json(&self) -> Json { - match *self { - LinkSelfContainedDefault::False => "false", - LinkSelfContainedDefault::True => "true", - LinkSelfContainedDefault::Musl => "musl", - LinkSelfContainedDefault::Mingw => "mingw", - } - .to_json() - } -} diff --git a/compiler/rustc_target/src/spec/csky_unknown_linux_gnuabiv2.rs b/compiler/rustc_target/src/spec/csky_unknown_linux_gnuabiv2.rs deleted file mode 100644 index 7d03dd26f..000000000 --- a/compiler/rustc_target/src/spec/csky_unknown_linux_gnuabiv2.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -// This target is for glibc Linux on Csky - -pub fn target() -> Target { - Target { - //https://github.com/llvm/llvm-project/blob/8b76aea8d8b1b71f6220bc2845abc749f18a19b7/clang/lib/Basic/Targets/CSKY.h - llvm_target: "csky-unknown-linux-gnuabiv2".into(), - pointer_width: 32, - data_layout: "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32-v128:32:32-a:0:32-Fi32-n32".into(), - arch: "csky".into(), - options: TargetOptions { - abi: "abiv2".into(), - features: "+2e3,+3e7,+7e10,+cache,+dsp1e2,+dspe60,+e1,+e2,+edsp,+elrw,+hard-tp,+high-registers,+hwdiv,+mp,+mp1e2,+nvic,+trust".into(), - late_link_args_static: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-l:libatomic.a"]), - max_atomic_width: Some(32), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/dragonfly_base.rs b/compiler/rustc_target/src/spec/dragonfly_base.rs deleted file mode 100644 index de2be7817..000000000 --- a/compiler/rustc_target/src/spec/dragonfly_base.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "dragonfly".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - default_dwarf_version: 2, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/freebsd_base.rs b/compiler/rustc_target/src/spec/freebsd_base.rs deleted file mode 100644 index 8c141aaae..000000000 --- a/compiler/rustc_target/src/spec/freebsd_base.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "freebsd".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - abi_return_struct_as_int: true, - default_dwarf_version: 2, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs deleted file mode 100644 index 4c2775850..000000000 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ /dev/null @@ -1,43 +0,0 @@ -use crate::spec::{crt_objects, cvs, Cc, LinkOutputKind, LinkerFlavor, Lld, TargetOptions}; - -pub fn opts() -> TargetOptions { - // This mirrors the linker options provided by clang. We presume lld for - // now. When using clang as the linker it will supply these options for us, - // so we only list them for ld/lld. - // - // https://github.com/llvm/llvm-project/blob/db9322b2066c55254e7691efeab863f43bfcc084/clang/lib/Driver/ToolChains/Fuchsia.cpp#L31 - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &[ - "--build-id", - "--hash-style=gnu", - "-z", - "max-page-size=4096", - "-z", - "now", - "-z", - "rodynamic", - "-z", - "separate-loadable-segments", - "--pack-dyn-relocs=relr", - ], - ); - - TargetOptions { - os: "fuchsia".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - dynamic_linking: true, - families: cvs!["unix"], - pre_link_args, - pre_link_objects: crt_objects::new(&[ - (LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]), - (LinkOutputKind::DynamicPicExe, &["Scrt1.o"]), - (LinkOutputKind::StaticNoPicExe, &["Scrt1.o"]), - (LinkOutputKind::StaticPicExe, &["Scrt1.o"]), - ]), - position_independent_executables: true, - has_thread_local: true, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs deleted file mode 100644 index 8ab874410..000000000 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "haiku".into(), - dynamic_linking: true, - families: cvs!["unix"], - relro_level: RelroLevel::Full, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/hermit_base.rs b/compiler/rustc_target/src/spec/hermit_base.rs deleted file mode 100644 index c6e98fc1a..000000000 --- a/compiler/rustc_target/src/spec/hermit_base.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "hermit".into(), - linker: Some("rust-lld".into()), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - tls_model: TlsModel::InitialExec, - position_independent_executables: true, - static_position_independent_executables: true, - has_thread_local: true, - panic_strategy: PanicStrategy::Abort, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs deleted file mode 100644 index 4c6ab5f5a..000000000 --- a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "hexagonv60".into(); - base.max_atomic_width = Some(32); - // FIXME: HVX length defaults are per-CPU - base.features = "-small-data,+hvx-length128b".into(); - - base.crt_static_default = false; - base.has_rpath = true; - base.linker_flavor = LinkerFlavor::Unix(Cc::Yes); - - base.c_enum_min_bits = Some(8); - - Target { - llvm_target: "hexagon-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: concat!( - "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32", - ":32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32", - ":32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048", - ":2048:2048" - ) - .into(), - arch: "hexagon".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/hurd_base.rs b/compiler/rustc_target/src/spec/hurd_base.rs deleted file mode 100644 index 76f8223c0..000000000 --- a/compiler/rustc_target/src/spec/hurd_base.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "hurd".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - has_thread_local: true, - crt_static_respected: true, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/hurd_gnu_base.rs b/compiler/rustc_target/src/spec/hurd_gnu_base.rs deleted file mode 100644 index b9cf26d93..000000000 --- a/compiler/rustc_target/src/spec/hurd_gnu_base.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::TargetOptions; - -pub fn opts() -> TargetOptions { - TargetOptions { env: "gnu".into(), ..super::hurd_base::opts() } -} diff --git a/compiler/rustc_target/src/spec/i386_apple_ios.rs b/compiler/rustc_target/src/spec/i386_apple_ios.rs deleted file mode 100644 index 581998161..000000000 --- a/compiler/rustc_target/src/spec/i386_apple_ios.rs +++ /dev/null @@ -1,23 +0,0 @@ -use super::apple_base::{ios_sim_llvm_target, opts, Arch}; -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::I386; - Target { - // Clang automatically chooses a more specific target based on - // IPHONEOS_DEPLOYMENT_TARGET. - // This is required for the target to pick the right - // MACH-O commands, so we do too. - llvm_target: ios_sim_llvm_target(arch).into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:128-n8:16:32-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { - max_atomic_width: Some(64), - stack_probes: StackProbeType::X86, - ..opts("ios", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs deleted file mode 100644 index 801a88933..000000000 --- a/compiler/rustc_target/src/spec/i386_unknown_linux_gnu.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "i386".into(); - base.llvm_target = "i386-unknown-linux-gnu".into(); - base -} diff --git a/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs deleted file mode 100644 index a11fbecc3..000000000 --- a/compiler/rustc_target/src/spec/i486_unknown_linux_gnu.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "i486".into(); - base.llvm_target = "i486-unknown-linux-gnu".into(); - base -} diff --git a/compiler/rustc_target/src/spec/i586_pc_nto_qnx700.rs b/compiler/rustc_target/src/spec/i586_pc_nto_qnx700.rs deleted file mode 100644 index 68afa7fe4..000000000 --- a/compiler/rustc_target/src/spec/i586_pc_nto_qnx700.rs +++ /dev/null @@ -1,24 +0,0 @@ -use super::nto_qnx_base; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "i586-pc-unknown".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: TargetOptions { - cpu: "pentium4".into(), - max_atomic_width: Some(64), - pre_link_args: TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-Vgcc_ntox86_cxx"], - ), - env: "nto70".into(), - stack_probes: StackProbeType::X86, - ..nto_qnx_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs deleted file mode 100644 index befb0f89f..000000000 --- a/compiler/rustc_target/src/spec/i586_pc_windows_msvc.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::i686_pc_windows_msvc::target(); - base.cpu = "pentium".into(); - base.llvm_target = "i586-pc-windows-msvc".into(); - base -} diff --git a/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs deleted file mode 100644 index b699a7af1..000000000 --- a/compiler/rustc_target/src/spec/i586_unknown_linux_gnu.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::i686_unknown_linux_gnu::target(); - base.cpu = "pentium".into(); - base.llvm_target = "i586-unknown-linux-gnu".into(); - base -} diff --git a/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs deleted file mode 100644 index 55a26eb00..000000000 --- a/compiler/rustc_target/src/spec/i586_unknown_linux_musl.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::i686_unknown_linux_musl::target(); - base.cpu = "pentium".into(); - base.llvm_target = "i586-unknown-linux-musl".into(); - base -} diff --git a/compiler/rustc_target/src/spec/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/i686_apple_darwin.rs deleted file mode 100644 index b5103d15d..000000000 --- a/compiler/rustc_target/src/spec/i686_apple_darwin.rs +++ /dev/null @@ -1,27 +0,0 @@ -use super::apple_base::{macos_llvm_target, opts, Arch}; -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - // ld64 only understands i386 and not i686 - let arch = Arch::I386; - let mut base = opts("macos", arch); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::X86; - base.frame_pointer = FramePointer::Always; - - Target { - // Clang automatically chooses a more specific target based on - // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work - // correctly, we do too. - // - // While ld64 doesn't understand i686, LLVM does. - llvm_target: macos_llvm_target(Arch::I686).into(), - pointer_width: 32, - data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:128-n8:16:32-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/i686_linux_android.rs b/compiler/rustc_target/src/spec/i686_linux_android.rs deleted file mode 100644 index c7c30c239..000000000 --- a/compiler/rustc_target/src/spec/i686_linux_android.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions}; - -// See https://developer.android.com/ndk/guides/abis.html#x86 -// for target ABI requirements. - -pub fn target() -> Target { - let mut base = super::android_base::opts(); - - base.max_atomic_width = Some(64); - - // https://developer.android.com/ndk/guides/abis.html#x86 - base.cpu = "pentiumpro".into(); - base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into(); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-linux-android".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs deleted file mode 100644 index 7a1113875..000000000 --- a/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_gnu_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.frame_pointer = FramePointer::Always; // Required for backtraces - base.linker = Some("i686-w64-mingw32-gcc".into()); - - // Mark all dynamic libraries and executables as compatible with the larger 4GiB address - // space available to x86 Windows binaries on x86_64. - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["-m", "i386pe", "--large-address-aware"], - ); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]); - - Target { - llvm_target: "i686-pc-windows-gnu".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs deleted file mode 100644 index 3154b512a..000000000 --- a/compiler/rustc_target/src/spec/i686_pc_windows_gnullvm.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_gnullvm_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.frame_pointer = FramePointer::Always; // Required for backtraces - base.linker = Some("i686-w64-mingw32-clang".into()); - - // Mark all dynamic libraries and executables as compatible with the larger 4GiB address - // space available to x86 Windows binaries on x86_64. - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["-m", "i386pe", "--large-address-aware"], - ); - - Target { - llvm_target: "i686-pc-windows-gnu".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs deleted file mode 100644 index db4c00dc6..000000000 --- a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::spec::{LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_msvc_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - - base.add_pre_link_args( - LinkerFlavor::Msvc(Lld::No), - &[ - // Mark all dynamic libraries and executables as compatible with the larger 4GiB address - // space available to x86 Windows binaries on x86_64. - "/LARGEADDRESSAWARE", - // Ensure the linker will only produce an image if it can also produce a table of - // the image's safe exception handlers. - // https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers - "/SAFESEH", - ], - ); - // Workaround for #95429 - base.has_thread_local = false; - - Target { - llvm_target: "i686-pc-windows-msvc".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:128-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs deleted file mode 100644 index 35ca78034..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_freebsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::freebsd_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-freebsd".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/i686_unknown_haiku.rs deleted file mode 100644 index e6b72336c..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_haiku.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::haiku_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-haiku".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs deleted file mode 100644 index 29f803601..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_hurd_gnu.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::hurd_gnu_base::opts(); - base.cpu = "pentiumpro".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) }; - - Target { - llvm_target: "i686-unknown-hurd-gnu".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs deleted file mode 100644 index 73e536a7e..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_linux_gnu.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.supported_sanitizers = SanitizerSet::ADDRESS; - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs deleted file mode 100644 index 3825082ba..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_linux_musl.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]); - base.stack_probes = StackProbeType::X86; - - // The unwinder used by i686-unknown-linux-musl, the LLVM libunwind - // implementation, apparently relies on frame pointers existing... somehow. - // It's not clear to me why nor where this dependency is introduced, but the - // test suite does not pass with frame pointers eliminated and it passes - // with frame pointers present. - // - // If you think that this is no longer necessary, then please feel free to - // ignore! If it still passes the test suite and the bots then sounds good - // to me. - // - // This may or may not be related to this bug: - // https://llvm.org/bugs/show_bug.cgi?id=30879 - base.frame_pointer = FramePointer::Always; - - Target { - llvm_target: "i686-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs deleted file mode 100644 index b191996c7..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_netbsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::netbsd_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-netbsdelf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: TargetOptions { mcount: "__mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs deleted file mode 100644 index 8babe5597..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_openbsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::openbsd_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-openbsd".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_uefi.rs b/compiler/rustc_target/src/spec/i686_unknown_uefi.rs deleted file mode 100644 index a2e42c5e6..000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_uefi.rs +++ /dev/null @@ -1,89 +0,0 @@ -// This defines the ia32 target for UEFI systems as described in the UEFI specification. See the -// uefi-base module for generic UEFI options. On ia32 systems -// UEFI systems always run in protected-mode, have the interrupt-controller pre-configured and -// force a single-CPU execution. -// The cdecl ABI is used. It differs from the stdcall or fastcall ABI. -// "i686-unknown-windows" is used to get the minimal subset of windows-specific features. - -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::uefi_msvc_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - - // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to - // enable these CPU features explicitly before their first use, otherwise their instructions - // will trigger an exception. Rust does not inject any code that enables AVX/MMX/SSE - // instruction sets, so this must be done by the firmware. However, existing firmware is known - // to leave these uninitialized, thus triggering exceptions if we make use of them. Which is - // why we avoid them and instead use soft-floats. This is also what GRUB and friends did so - // far. - // If you initialize FP units yourself, you can override these flags with custom linker - // arguments, thus giving you access to full MMX/SSE acceleration. - base.features = "-mmx,-sse,+soft-float".into(); - - // Use -GNU here, because of the reason below: - // Background and Problem: - // If we use i686-unknown-windows, the LLVM IA32 MSVC generates compiler intrinsic - // _alldiv, _aulldiv, _allrem, _aullrem, _allmul, which will cause undefined symbol. - // A real issue is __aulldiv() is referred by __udivdi3() - udivmod_inner!(), from - // https://github.com/rust-lang-nursery/compiler-builtins. - // As result, rust-lld generates link error finally. - // Root-cause: - // In rust\src\llvm-project\llvm\lib\Target\X86\X86ISelLowering.cpp, - // we have below code to use MSVC intrinsics. It assumes MSVC target - // will link MSVC library. But that is NOT true in UEFI environment. - // UEFI does not link any MSVC or GCC standard library. - // if (Subtarget.isTargetKnownWindowsMSVC() || - // Subtarget.isTargetWindowsItanium()) { - // // Setup Windows compiler runtime calls. - // setLibcallName(RTLIB::SDIV_I64, "_alldiv"); - // setLibcallName(RTLIB::UDIV_I64, "_aulldiv"); - // setLibcallName(RTLIB::SREM_I64, "_allrem"); - // setLibcallName(RTLIB::UREM_I64, "_aullrem"); - // setLibcallName(RTLIB::MUL_I64, "_allmul"); - // setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::X86_StdCall); - // setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::X86_StdCall); - // setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::X86_StdCall); - // setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::X86_StdCall); - // setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::X86_StdCall); - // } - // The compiler intrinsics should be implemented by compiler-builtins. - // Unfortunately, compiler-builtins has not provided those intrinsics yet. Such as: - // i386/divdi3.S - // i386/lshrdi3.S - // i386/moddi3.S - // i386/muldi3.S - // i386/udivdi3.S - // i386/umoddi3.S - // Possible solution: - // 1. Eliminate Intrinsics generation. - // 1.1 Choose different target to bypass isTargetKnownWindowsMSVC(). - // 1.2 Remove the "Setup Windows compiler runtime calls" in LLVM - // 2. Implement Intrinsics. - // We evaluated all options. - // #2 is hard because we need implement the intrinsics (_aulldiv) generated - // from the other intrinsics (__udivdi3) implementation with the same - // functionality (udivmod_inner). If we let _aulldiv() call udivmod_inner!(), - // then we are in loop. We may have to find another way to implement udivmod_inner!(). - // #1.2 may break the existing usage. - // #1.1 seems the simplest solution today. - // The IA32 -gnu calling convention is same as the one defined in UEFI specification. - // It uses cdecl, EAX/ECX/EDX as volatile register, and EAX/EDX as return value. - // We also checked the LLVM X86TargetLowering, the differences between -gnu and -msvc - // is fmodf(f32), longjmp() and TLS. None of them impacts the UEFI code. - // As a result, we choose -gnu for i686 version before those intrinsics are implemented in - // compiler-builtins. After compiler-builtins implements all required intrinsics, we may - // remove -gnu and use the default one. - Target { - llvm_target: "i686-unknown-windows-gnu".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs deleted file mode 100644 index a3e325698..000000000 --- a/compiler/rustc_target/src/spec/i686_uwp_windows_gnu.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_uwp_gnu_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.frame_pointer = FramePointer::Always; // Required for backtraces - - // Mark all dynamic libraries and executables as compatible with the larger 4GiB address - // space available to x86 Windows binaries on x86_64. - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["-m", "i386pe", "--large-address-aware"], - ); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]); - - Target { - llvm_target: "i686-pc-windows-gnu".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs deleted file mode 100644 index 4c657fe90..000000000 --- a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_uwp_msvc_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "i686-pc-windows-msvc".into(), - pointer_width: 32, - data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:128-n8:16:32-a:0:32-S32" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs deleted file mode 100644 index b5cfdfceb..000000000 --- a/compiler/rustc_target/src/spec/i686_wrs_vxworks.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::vxworks_base::opts(); - base.cpu = "pentium4".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "i686-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .into(), - arch: "x86".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/illumos_base.rs b/compiler/rustc_target/src/spec/illumos_base.rs deleted file mode 100644 index e63e78975..000000000 --- a/compiler/rustc_target/src/spec/illumos_base.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, TargetOptions}; - -pub fn opts() -> TargetOptions { - let late_link_args = TargetOptions::link_args( - LinkerFlavor::Unix(Cc::Yes), - &[ - // The illumos libc contains a stack unwinding implementation, as - // does libgcc_s. The latter implementation includes several - // additional symbols that are not always in base libc. To force - // the consistent use of just one unwinder, we ensure libc appears - // after libgcc_s in the NEEDED list for the resultant binary by - // ignoring any attempts to add it as a dynamic dependency until the - // very end. - // FIXME: This should be replaced by a more complete and generic - // mechanism for controlling the order of library arguments passed - // to the linker. - "-lc", - // LLVM will insert calls to the stack protector functions - // "__stack_chk_fail" and "__stack_chk_guard" into code in native - // object files. Some platforms include these symbols directly in - // libc, but at least historically these have been provided in - // libssp.so on illumos and Solaris systems. - "-lssp", - ], - ); - - TargetOptions { - os: "illumos".into(), - dynamic_linking: true, - has_rpath: true, - families: cvs!["unix"], - is_like_solaris: true, - linker_flavor: LinkerFlavor::Unix(Cc::Yes), - limit_rdylib_exports: false, // Linker doesn't support this - frame_pointer: FramePointer::Always, - eh_frame_header: false, - late_link_args, - - // While we support ELF TLS, rust requires a way to register - // cleanup handlers (in C, this would be something along the lines of: - // void register_callback(void (*fn)(void *), void *arg); - // (see src/libstd/sys/unix/fast_thread_local.rs) that is currently - // missing in illumos. For now at least, we must fallback to using - // pthread_{get,set}specific. - //has_thread_local: true, - - // FIXME: Currently, rust is invoking cc to link, which ends up - // causing these to get included twice. We should eventually transition - // to having rustc invoke ld directly, in which case these will need to - // be uncommented. - // - // We want XPG6 behavior from libc and libm. See standards(5) - //pre_link_objects_exe: vec![ - // "/usr/lib/amd64/values-Xc.o".into(), - // "/usr/lib/amd64/values-xpg6.o".into(), - //], - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs deleted file mode 100644 index 3a4d83fad..000000000 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "l4re".into(), - env: "uclibc".into(), - linker_flavor: LinkerFlavor::Unix(Cc::No), - panic_strategy: PanicStrategy::Abort, - linker: Some("l4-bender".into()), - families: cvs!["unix"], - relocation_model: RelocModel::Static, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/linux_base.rs b/compiler/rustc_target/src/spec/linux_base.rs deleted file mode 100644 index df8e84812..000000000 --- a/compiler/rustc_target/src/spec/linux_base.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions}; -use std::borrow::Cow; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "linux".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - has_thread_local: true, - crt_static_respected: true, - supported_split_debuginfo: Cow::Borrowed(&[ - SplitDebuginfo::Packed, - SplitDebuginfo::Unpacked, - SplitDebuginfo::Off, - ]), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/linux_gnu_base.rs b/compiler/rustc_target/src/spec/linux_gnu_base.rs deleted file mode 100644 index 8d6b3f185..000000000 --- a/compiler/rustc_target/src/spec/linux_gnu_base.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::TargetOptions; - -pub fn opts() -> TargetOptions { - TargetOptions { env: "gnu".into(), ..super::linux_base::opts() } -} diff --git a/compiler/rustc_target/src/spec/linux_musl_base.rs b/compiler/rustc_target/src/spec/linux_musl_base.rs deleted file mode 100644 index 61553e71b..000000000 --- a/compiler/rustc_target/src/spec/linux_musl_base.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::crt_objects::{self, LinkSelfContainedDefault}; -use crate::spec::TargetOptions; - -pub fn opts() -> TargetOptions { - let mut base = super::linux_base::opts(); - - base.env = "musl".into(); - base.pre_link_objects_self_contained = crt_objects::pre_musl_self_contained(); - base.post_link_objects_self_contained = crt_objects::post_musl_self_contained(); - base.link_self_contained = LinkSelfContainedDefault::Musl; - - // These targets statically link libc by default - base.crt_static_default = true; - - base -} diff --git a/compiler/rustc_target/src/spec/linux_ohos_base.rs b/compiler/rustc_target/src/spec/linux_ohos_base.rs deleted file mode 100644 index 4ad4c8373..000000000 --- a/compiler/rustc_target/src/spec/linux_ohos_base.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::spec::TargetOptions; - -pub fn opts() -> TargetOptions { - let mut base = super::linux_base::opts(); - - base.env = "ohos".into(); - base.crt_static_default = false; - base.force_emulated_tls = true; - base.has_thread_local = false; - - base -} diff --git a/compiler/rustc_target/src/spec/linux_uclibc_base.rs b/compiler/rustc_target/src/spec/linux_uclibc_base.rs deleted file mode 100644 index 4ba480ffe..000000000 --- a/compiler/rustc_target/src/spec/linux_uclibc_base.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::TargetOptions; - -pub fn opts() -> TargetOptions { - TargetOptions { env: "uclibc".into(), ..super::linux_base::opts() } -} diff --git a/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs deleted file mode 100644 index db8b9c70e..000000000 --- a/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "loongarch64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), - arch: "loongarch64".into(), - options: TargetOptions { - cpu: "generic".into(), - features: "+f,+d".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/loongarch64_unknown_none.rs b/compiler/rustc_target/src/spec/loongarch64_unknown_none.rs deleted file mode 100644 index dbc96d68e..000000000 --- a/compiler/rustc_target/src/spec/loongarch64_unknown_none.rs +++ /dev/null @@ -1,23 +0,0 @@ -use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; -use super::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "loongarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), - arch: "loongarch64".into(), - options: TargetOptions { - cpu: "generic".into(), - features: "+f,+d".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - code_model: Some(CodeModel::Small), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/loongarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/loongarch64_unknown_none_softfloat.rs deleted file mode 100644 index c4d5c7bc4..000000000 --- a/compiler/rustc_target/src/spec/loongarch64_unknown_none_softfloat.rs +++ /dev/null @@ -1,24 +0,0 @@ -use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; -use super::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "loongarch64-unknown-none".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), - arch: "loongarch64".into(), - options: TargetOptions { - cpu: "generic".into(), - features: "-f,-d".into(), - abi: "softfloat".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - llvm_abiname: "lp64s".into(), - max_atomic_width: Some(64), - relocation_model: RelocModel::Static, - panic_strategy: PanicStrategy::Abort, - code_model: Some(CodeModel::Small), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs deleted file mode 100644 index 9bcd56bed..000000000 --- a/compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "M68020".into(); - base.max_atomic_width = Some(32); - - Target { - llvm_target: "m68k-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), - arch: "m68k".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs b/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs deleted file mode 100644 index 3c6ef52c6..000000000 --- a/compiler/rustc_target/src/spec/mips64_openwrt_linux_musl.rs +++ /dev/null @@ -1,26 +0,0 @@ -/// A target tuple for OpenWrt MIPS64 targets -/// -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".into(); - base.features = "+mips64r2,+soft-float".into(); - base.max_atomic_width = Some(64); - base.crt_static_default = false; - - Target { - // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64".into(), - options: TargetOptions { - abi: "abi64".into(), - endian: Endian::Big, - mcount: "_mcount".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs deleted file mode 100644 index b9df0046b..000000000 --- a/compiler/rustc_target/src/spec/mips64_unknown_linux_gnuabi64.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mips64-unknown-linux-gnuabi64".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64".into(), - options: TargetOptions { - abi: "abi64".into(), - endian: Endian::Big, - // NOTE(mips64r2) matches C toolchain - cpu: "mips64r2".into(), - features: "+mips64r2,+xgot".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs deleted file mode 100644 index 465e97a02..000000000 --- a/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".into(); - base.features = "+mips64r2".into(); - base.max_atomic_width = Some(64); - Target { - // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64".into(), - options: TargetOptions { - abi: "abi64".into(), - endian: Endian::Big, - mcount: "_mcount".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs deleted file mode 100644 index 57ad8c473..000000000 --- a/compiler/rustc_target/src/spec/mips64el_unknown_linux_gnuabi64.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mips64el-unknown-linux-gnuabi64".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64".into(), - options: TargetOptions { - abi: "abi64".into(), - // NOTE(mips64r2) matches C toolchain - cpu: "mips64r2".into(), - features: "+mips64r2,+xgot".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs deleted file mode 100644 index 75575eb7e..000000000 --- a/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "mips64r2".into(); - base.features = "+mips64r2".into(); - base.max_atomic_width = Some(64); - Target { - // LLVM doesn't recognize "muslabi64" yet. - llvm_target: "mips64el-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64".into(), - options: TargetOptions { abi: "abi64".into(), mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs deleted file mode 100644 index 8df8b0b4c..000000000 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_gnu.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mips-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - options: TargetOptions { - endian: Endian::Big, - cpu: "mips32r2".into(), - features: "+mips32r2,+fpxx,+nooddspreg".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs deleted file mode 100644 index c2846313a..000000000 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "mips32r2".into(); - base.features = "+mips32r2,+soft-float".into(); - base.max_atomic_width = Some(32); - base.crt_static_default = false; - Target { - llvm_target: "mips-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs deleted file mode 100644 index c59bb5fdd..000000000 --- a/compiler/rustc_target/src/spec/mips_unknown_linux_uclibc.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mips-unknown-linux-uclibc".into(), - pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - options: TargetOptions { - endian: Endian::Big, - cpu: "mips32r2".into(), - features: "+mips32r2,+soft-float".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_uclibc_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/mipsel_sony_psp.rs deleted file mode 100644 index 75beb91b1..000000000 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; - -// The PSP has custom linker requirements. -const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); - -pub fn target() -> Target { - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["--emit-relocs", "--nmagic"], - ); - - Target { - llvm_target: "mipsel-sony-psp".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - - options: TargetOptions { - os: "psp".into(), - vendor: "sony".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - cpu: "mips2".into(), - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - - // PSP FPU only supports single precision floats. - features: "+single-float".into(), - - // PSP does not support trap-on-condition instructions. - llvm_args: cvs!["-mno-check-zero-division"], - pre_link_args, - link_script: Some(LINKER_SCRIPT.into()), - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld b/compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld deleted file mode 100644 index 9eb35ad9f..000000000 --- a/compiler/rustc_target/src/spec/mipsel_sony_psp_linker_script.ld +++ /dev/null @@ -1,45 +0,0 @@ -ENTRY(module_start) -SECTIONS -{ - /* PRX format requires text to begin at 0 */ - .text 0 : { *(.text .text.*) } - - /* Sort stubs for convenient ordering */ - .sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) } - - /* PSP import library stub sections. Bundles together `.lib.stub.entry.*` - * sections for better `--gc-sections` support. */ - .lib.stub.top : { *(.lib.stub.top) } - .lib.stub : { *(.lib.stub) *(.lib.stub.entry.*) } - .lib.stub.btm : { *(.lib.stub.btm) } - - /* Keep these sections around, even though they may appear unused to the linker */ - .lib.ent.top : { KEEP(*(.lib.ent.top)) } - .lib.ent : { KEEP(*(.lib.ent)) } - .lib.ent.btm : { KEEP(*(.lib.ent.btm)) } - - .eh_frame_hdr : { *(.eh_frame_hdr) } - - /* Add symbols for LLVM's libunwind */ - __eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0; - __eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0; - .eh_frame : - { - __eh_frame_start = .; - KEEP(*(.eh_frame)) - __eh_frame_end = .; - } - - /* These are explicitly listed to avoid being merged into .rodata */ - .rodata.sceResident : { *(.rodata.sceResident) *(.rodata.sceResident.*) } - .rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) } - /* Sort NIDs for convenient ordering */ - .rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) } - - .rodata : { *(.rodata .rodata.*) } - .data : { *(.data .data.*) } - .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } - .bss : { *(.bss .bss.*) } - - /DISCARD/ : { *(.rel.sceStub.text .MIPS.abiflags .reginfo) } -} diff --git a/compiler/rustc_target/src/spec/mipsel_sony_psx.rs b/compiler/rustc_target/src/spec/mipsel_sony_psx.rs deleted file mode 100644 index 12a66efdd..000000000 --- a/compiler/rustc_target/src/spec/mipsel_sony_psx.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsel-sony-psx".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - - options: TargetOptions { - os: "none".into(), - env: "psx".into(), - vendor: "sony".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - cpu: "mips1".into(), - executables: true, - linker: Some("rust-lld".into()), - relocation_model: RelocModel::Static, - exe_suffix: ".exe".into(), - - // PSX doesn't natively support floats. - features: "+soft-float".into(), - - // This should be 16 bits, but LLVM incorrectly tries emitting MIPS-II SYNC instructions - // for atomic loads and stores. This crashes rustc so we have to disable the Atomic* API - // until this is fixed upstream. See https://reviews.llvm.org/D122427#3420144 for more - // info. - max_atomic_width: Some(0), - - // PSX does not support trap-on-condition instructions. - llvm_args: cvs!["-mno-check-zero-division"], - llvm_abiname: "o32".into(), - panic_strategy: PanicStrategy::Abort, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs deleted file mode 100644 index 01346e71a..000000000 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_gnu.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsel-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - - options: TargetOptions { - cpu: "mips32r2".into(), - features: "+mips32r2,+fpxx,+nooddspreg".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs deleted file mode 100644 index 0e8f1a2c8..000000000 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "mips32r2".into(); - base.features = "+mips32r2,+soft-float".into(); - base.max_atomic_width = Some(32); - base.crt_static_default = false; - Target { - llvm_target: "mipsel-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - options: TargetOptions { mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs deleted file mode 100644 index 834207458..000000000 --- a/compiler/rustc_target/src/spec/mipsel_unknown_linux_uclibc.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsel-unknown-linux-uclibc".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - - options: TargetOptions { - cpu: "mips32r2".into(), - features: "+mips32r2,+soft-float".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_uclibc_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/mipsel_unknown_none.rs deleted file mode 100644 index 43b01e7a0..000000000 --- a/compiler/rustc_target/src/spec/mipsel_unknown_none.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Bare MIPS32r2, little endian, softfloat, O32 calling convention -//! -//! Can be used for MIPS M4K core (e.g. on PIC32MX devices) - -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsel-unknown-none".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - cpu: "mips32r2".into(), - features: "+mips32r2,+soft-float,+noabicalls".into(), - max_atomic_width: Some(32), - linker: Some("rust-lld".into()), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs deleted file mode 100644 index 983a449b0..000000000 --- a/compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsisa32r6-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips32r6".into(), - options: TargetOptions { - endian: Endian::Big, - cpu: "mips32r6".into(), - features: "+mips32r6".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs deleted file mode 100644 index ec0facdfb..000000000 --- a/compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsisa32r6el-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips32r6".into(), - - options: TargetOptions { - cpu: "mips32r6".into(), - features: "+mips32r6".into(), - max_atomic_width: Some(32), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs deleted file mode 100644 index 16dd1c416..000000000 --- a/compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsisa64r6-unknown-linux-gnuabi64".into(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64r6".into(), - options: TargetOptions { - abi: "abi64".into(), - endian: Endian::Big, - // NOTE(mips64r6) matches C toolchain - cpu: "mips64r6".into(), - features: "+mips64r6".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs deleted file mode 100644 index 8d0a6aa8f..000000000 --- a/compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "mipsisa64r6el-unknown-linux-gnuabi64".into(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), - arch: "mips64r6".into(), - options: TargetOptions { - abi: "abi64".into(), - // NOTE(mips64r6) matches C toolchain - cpu: "mips64r6".into(), - features: "+mips64r6".into(), - max_atomic_width: Some(64), - mcount: "_mcount".into(), - - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 1bcb1f353..f04799482 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -38,7 +38,7 @@ use crate::abi::call::Conv; use crate::abi::{Endian, Integer, Size, TargetDataLayout, TargetDataLayoutErrors}; use crate::json::{Json, ToJson}; use crate::spec::abi::{lookup as lookup_abi, Abi}; -use crate::spec::crt_objects::{CrtObjects, LinkSelfContainedDefault}; +use crate::spec::crt_objects::CrtObjects; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_fs_util::try_canonicalize; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; @@ -57,47 +57,11 @@ use rustc_macros::HashStable_Generic; pub mod abi; pub mod crt_objects; -mod aix_base; -mod android_base; -mod apple_base; -pub use apple_base::deployment_target as current_apple_deployment_target; -pub use apple_base::platform as current_apple_platform; -pub use apple_base::sdk_version as current_apple_sdk_version; -mod avr_gnu_base; -pub use avr_gnu_base::ef_avr_arch; -mod bpf_base; -mod dragonfly_base; -mod freebsd_base; -mod fuchsia_base; -mod haiku_base; -mod hermit_base; -mod hurd_base; -mod hurd_gnu_base; -mod illumos_base; -mod l4re_base; -mod linux_base; -mod linux_gnu_base; -mod linux_musl_base; -mod linux_ohos_base; -mod linux_uclibc_base; -mod msvc_base; -mod netbsd_base; -mod nto_qnx_base; -mod openbsd_base; -mod redox_base; -mod solaris_base; -mod solid_base; -mod teeos_base; -mod thumb_base; -mod uefi_msvc_base; -mod unikraft_linux_musl_base; -mod vxworks_base; -mod wasm_base; -mod windows_gnu_base; -mod windows_gnullvm_base; -mod windows_msvc_base; -mod windows_uwp_gnu_base; -mod windows_uwp_msvc_base; +mod base; +pub use base::apple::deployment_target as current_apple_deployment_target; +pub use base::apple::platform as current_apple_platform; +pub use base::apple::sdk_version as current_apple_sdk_version; +pub use base::avr_gnu::ef_avr_arch; /// Linker is called through a C/C++ compiler. #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -164,11 +128,11 @@ pub enum LinkerFlavor { /// Linker flavors available externally through command line (`-Clinker-flavor`) /// or json target specifications. -/// FIXME: This set has accumulated historically, bring it more in line with the internal -/// linker flavors (`LinkerFlavor`). +/// This set has accumulated historically, and contains both (stable and unstable) legacy values, as +/// well as modern ones matching the internal linker flavors (`LinkerFlavor`). #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum LinkerFlavorCli { - // New (unstable) flavors, with direct counterparts in `LinkerFlavor`. + // Modern (unstable) flavors, with direct counterparts in `LinkerFlavor`. Gnu(Cc, Lld), Darwin(Cc, Lld), WasmLld(Cc), @@ -179,13 +143,11 @@ pub enum LinkerFlavorCli { Bpf, Ptx, - // Below: the legacy stable values. + // Legacy stable values Gcc, Ld, Lld(LldFlavor), Em, - BpfLinker, - PtxLinker, } impl LinkerFlavorCli { @@ -199,9 +161,7 @@ impl LinkerFlavorCli { | LinkerFlavorCli::Msvc(Lld::Yes) | LinkerFlavorCli::EmCc | LinkerFlavorCli::Bpf - | LinkerFlavorCli::Ptx - | LinkerFlavorCli::BpfLinker - | LinkerFlavorCli::PtxLinker => true, + | LinkerFlavorCli::Ptx => true, LinkerFlavorCli::Gcc | LinkerFlavorCli::Ld | LinkerFlavorCli::Lld(..) @@ -279,11 +239,10 @@ impl LinkerFlavor { LinkerFlavorCli::Lld(LldFlavor::Wasm) => LinkerFlavor::WasmLld(Cc::No), LinkerFlavorCli::Lld(LldFlavor::Link) => LinkerFlavor::Msvc(Lld::Yes), LinkerFlavorCli::Em => LinkerFlavor::EmCc, - LinkerFlavorCli::BpfLinker => LinkerFlavor::Bpf, - LinkerFlavorCli::PtxLinker => LinkerFlavor::Ptx, } } + /// Returns the corresponding backwards-compatible CLI flavor. fn to_cli(self) -> LinkerFlavorCli { match self { LinkerFlavor::Gnu(Cc::Yes, _) @@ -299,8 +258,22 @@ impl LinkerFlavor { LinkerFlavor::Msvc(Lld::Yes) => LinkerFlavorCli::Lld(LldFlavor::Link), LinkerFlavor::Msvc(..) => LinkerFlavorCli::Msvc(Lld::No), LinkerFlavor::EmCc => LinkerFlavorCli::Em, - LinkerFlavor::Bpf => LinkerFlavorCli::BpfLinker, - LinkerFlavor::Ptx => LinkerFlavorCli::PtxLinker, + LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, + LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, + } + } + + /// Returns the modern CLI flavor that is the counterpart of this flavor. + fn to_cli_counterpart(self) -> LinkerFlavorCli { + match self { + LinkerFlavor::Gnu(cc, lld) => LinkerFlavorCli::Gnu(cc, lld), + LinkerFlavor::Darwin(cc, lld) => LinkerFlavorCli::Darwin(cc, lld), + LinkerFlavor::WasmLld(cc) => LinkerFlavorCli::WasmLld(cc), + LinkerFlavor::Unix(cc) => LinkerFlavorCli::Unix(cc), + LinkerFlavor::Msvc(lld) => LinkerFlavorCli::Msvc(lld), + LinkerFlavor::EmCc => LinkerFlavorCli::EmCc, + LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, + LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -320,7 +293,6 @@ impl LinkerFlavor { LinkerFlavorCli::Ld => (Some(Cc::No), Some(Lld::No)), LinkerFlavorCli::Lld(_) => (Some(Cc::No), Some(Lld::Yes)), LinkerFlavorCli::Em => (Some(Cc::Yes), Some(Lld::Yes)), - LinkerFlavorCli::BpfLinker | LinkerFlavorCli::PtxLinker => (None, None), } } @@ -511,7 +483,7 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::Bpf) "bpf" (LinkerFlavorCli::Ptx) "ptx" - // Below: legacy stable values + // Legacy stable flavors (LinkerFlavorCli::Gcc) "gcc" (LinkerFlavorCli::Ld) "ld" (LinkerFlavorCli::Lld(LldFlavor::Ld)) "ld.lld" @@ -519,8 +491,6 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::Lld(LldFlavor::Link)) "lld-link" (LinkerFlavorCli::Lld(LldFlavor::Wasm)) "wasm-ld" (LinkerFlavorCli::Em) "em" - (LinkerFlavorCli::BpfLinker) "bpf-linker" - (LinkerFlavorCli::PtxLinker) "ptx-linker" } impl ToJson for LinkerFlavorCli { @@ -529,6 +499,203 @@ impl ToJson for LinkerFlavorCli { } } +/// The different `-Clink-self-contained` options that can be specified in a target spec: +/// - enabling or disabling in bulk +/// - some target-specific pieces of inference to determine whether to use self-contained linking +/// if `-Clink-self-contained` is not specified explicitly (e.g. on musl/mingw) +/// - explicitly enabling some of the self-contained linking components, e.g. the linker component +/// to use `rust-lld` +#[derive(Clone, Copy, PartialEq, Debug)] +pub enum LinkSelfContainedDefault { + /// The target spec explicitly enables self-contained linking. + True, + + /// The target spec explicitly disables self-contained linking. + False, + + /// The target spec requests that the self-contained mode is inferred, in the context of musl. + InferredForMusl, + + /// The target spec requests that the self-contained mode is inferred, in the context of mingw. + InferredForMingw, + + /// The target spec explicitly enables a list of self-contained linking components: e.g. for + /// targets opting into a subset of components like the CLI's `-C link-self-contained=+linker`. + WithComponents(LinkSelfContainedComponents), +} + +/// Parses a backwards-compatible `-Clink-self-contained` option string, without components. +impl FromStr for LinkSelfContainedDefault { + type Err = (); + + fn from_str(s: &str) -> Result { + Ok(match s { + "false" => LinkSelfContainedDefault::False, + "true" | "wasm" => LinkSelfContainedDefault::True, + "musl" => LinkSelfContainedDefault::InferredForMusl, + "mingw" => LinkSelfContainedDefault::InferredForMingw, + _ => return Err(()), + }) + } +} + +impl ToJson for LinkSelfContainedDefault { + fn to_json(&self) -> Json { + match *self { + LinkSelfContainedDefault::WithComponents(components) => { + // Serialize the components in a json object's `components` field, to prepare for a + // future where `crt-objects-fallback` is removed from the json specs and + // incorporated as a field here. + let mut map = BTreeMap::new(); + map.insert("components", components); + map.to_json() + } + + // Stable backwards-compatible values + LinkSelfContainedDefault::True => "true".to_json(), + LinkSelfContainedDefault::False => "false".to_json(), + LinkSelfContainedDefault::InferredForMusl => "musl".to_json(), + LinkSelfContainedDefault::InferredForMingw => "mingw".to_json(), + } + } +} + +impl LinkSelfContainedDefault { + /// Returns whether the target spec has self-contained linking explicitly disabled. Used to emit + /// errors if the user then enables it on the CLI. + pub fn is_disabled(self) -> bool { + self == LinkSelfContainedDefault::False + } + + /// Returns whether the target spec explictly requests self-contained linking, i.e. not via + /// inference. + pub fn is_linker_enabled(self) -> bool { + match self { + LinkSelfContainedDefault::True => true, + LinkSelfContainedDefault::False => false, + LinkSelfContainedDefault::WithComponents(c) => { + c.contains(LinkSelfContainedComponents::LINKER) + } + _ => false, + } + } + + /// Returns the key to use when serializing the setting to json: + /// - individual components in a `link-self-contained` object value + /// - the other variants as a backwards-compatible `crt-objects-fallback` string + fn json_key(self) -> &'static str { + match self { + LinkSelfContainedDefault::WithComponents(_) => "link-self-contained", + _ => "crt-objects-fallback", + } + } +} + +bitflags::bitflags! { + #[derive(Default)] + /// The `-C link-self-contained` components that can individually be enabled or disabled. + pub struct LinkSelfContainedComponents: u8 { + /// CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets) + const CRT_OBJECTS = 1 << 0; + /// libc static library (e.g. on `musl`, `wasi` targets) + const LIBC = 1 << 1; + /// libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets) + const UNWIND = 1 << 2; + /// Linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for `rust-lld`) + const LINKER = 1 << 3; + /// Sanitizer runtime libraries + const SANITIZERS = 1 << 4; + /// Other MinGW libs and Windows import libs + const MINGW = 1 << 5; + } +} + +impl LinkSelfContainedComponents { + /// Parses a single `-Clink-self-contained` well-known component, not a set of flags. + pub fn from_str(s: &str) -> Option { + Some(match s { + "crto" => LinkSelfContainedComponents::CRT_OBJECTS, + "libc" => LinkSelfContainedComponents::LIBC, + "unwind" => LinkSelfContainedComponents::UNWIND, + "linker" => LinkSelfContainedComponents::LINKER, + "sanitizers" => LinkSelfContainedComponents::SANITIZERS, + "mingw" => LinkSelfContainedComponents::MINGW, + _ => return None, + }) + } + + /// Return the component's name. + /// + /// Returns `None` if the bitflags aren't a singular component (but a mix of multiple flags). + pub fn as_str(self) -> Option<&'static str> { + Some(match self { + LinkSelfContainedComponents::CRT_OBJECTS => "crto", + LinkSelfContainedComponents::LIBC => "libc", + LinkSelfContainedComponents::UNWIND => "unwind", + LinkSelfContainedComponents::LINKER => "linker", + LinkSelfContainedComponents::SANITIZERS => "sanitizers", + LinkSelfContainedComponents::MINGW => "mingw", + _ => return None, + }) + } + + /// Returns an array of all the components. + fn all_components() -> [LinkSelfContainedComponents; 6] { + [ + LinkSelfContainedComponents::CRT_OBJECTS, + LinkSelfContainedComponents::LIBC, + LinkSelfContainedComponents::UNWIND, + LinkSelfContainedComponents::LINKER, + LinkSelfContainedComponents::SANITIZERS, + LinkSelfContainedComponents::MINGW, + ] + } + + /// Returns whether at least a component is enabled. + pub fn are_any_components_enabled(self) -> bool { + !self.is_empty() + } + + /// Returns whether `LinkSelfContainedComponents::LINKER` is enabled. + pub fn is_linker_enabled(self) -> bool { + self.contains(LinkSelfContainedComponents::LINKER) + } + + /// Returns whether `LinkSelfContainedComponents::CRT_OBJECTS` is enabled. + pub fn is_crt_objects_enabled(self) -> bool { + self.contains(LinkSelfContainedComponents::CRT_OBJECTS) + } +} + +impl IntoIterator for LinkSelfContainedComponents { + type Item = LinkSelfContainedComponents; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + LinkSelfContainedComponents::all_components() + .into_iter() + .filter(|&s| self.contains(s)) + .collect::>() + .into_iter() + } +} + +impl ToJson for LinkSelfContainedComponents { + fn to_json(&self) -> Json { + let components: Vec<_> = Self::all_components() + .into_iter() + .filter(|c| self.contains(*c)) + .map(|c| { + // We can unwrap because we're iterating over all the known singular components, + // not an actual set of flags where `as_str` can fail. + c.as_str().unwrap().to_owned() + }) + .collect(); + + components.to_json() + } +} + #[derive(Clone, Copy, Debug, PartialEq, Hash, Encodable, Decodable, HashStable_Generic)] pub enum PanicStrategy { Unwind, @@ -1241,14 +1408,16 @@ impl fmt::Display for StackProtector { macro_rules! supported_targets { ( $(($triple:literal, $module:ident),)+ ) => { - $(mod $module;)+ + mod targets { + $(pub(crate) mod $module;)+ + } /// List of supported targets pub const TARGETS: &[&str] = &[$($triple),+]; fn load_builtin(target: &str) -> Option { let mut t = match target { - $( $triple => $module::target(), )+ + $( $triple => targets::$module::target(), )+ _ => return None, }; t.is_builtin = true; @@ -1264,7 +1433,7 @@ macro_rules! supported_targets { $( #[test] // `#[test]` fn $module() { - tests_impl::test_target(super::$module::target()); + tests_impl::test_target(crate::spec::targets::$module::target()); } )+ } @@ -1279,6 +1448,7 @@ supported_targets! { ("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu), ("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu), ("csky-unknown-linux-gnuabiv2", csky_unknown_linux_gnuabiv2), + ("csky-unknown-linux-gnuabiv2hf", csky_unknown_linux_gnuabiv2hf), ("mips-unknown-linux-gnu", mips_unknown_linux_gnu), ("mips64-unknown-linux-gnuabi64", mips64_unknown_linux_gnuabi64), ("mips64el-unknown-linux-gnuabi64", mips64el_unknown_linux_gnuabi64), @@ -1360,7 +1530,9 @@ supported_targets! { ("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd), ("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf), ("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf), + ("i586-unknown-netbsd", i586_unknown_netbsd), ("i686-unknown-netbsd", i686_unknown_netbsd), + ("mipsel-unknown-netbsd", mipsel_unknown_netbsd), ("powerpc-unknown-netbsd", powerpc_unknown_netbsd), ("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd), ("sparc64-unknown-netbsd", sparc64_unknown_netbsd), @@ -1399,6 +1571,7 @@ supported_targets! { ("aarch64-apple-ios-macabi", aarch64_apple_ios_macabi), ("aarch64-apple-ios-sim", aarch64_apple_ios_sim), ("aarch64-apple-tvos", aarch64_apple_tvos), + ("aarch64-apple-tvos-sim", aarch64_apple_tvos_sim), ("x86_64-apple-tvos", x86_64_apple_tvos), ("armv7k-apple-watchos", armv7k_apple_watchos), @@ -1704,6 +1877,8 @@ pub struct TargetOptions { /// Same as `(pre|post)_link_objects`, but when self-contained linking mode is enabled. pub pre_link_objects_self_contained: CrtObjects, pub post_link_objects_self_contained: CrtObjects, + /// Behavior for the self-contained linking mode: inferred for some targets, or explicitly + /// enabled (in bulk, or with individual components). pub link_self_contained: LinkSelfContainedDefault, /// Linker arguments that are passed *before* any user-defined libraries. @@ -2104,7 +2279,7 @@ impl TargetOptions { } fn update_to_cli(&mut self) { - self.linker_flavor_json = self.linker_flavor.to_cli(); + self.linker_flavor_json = self.linker_flavor.to_cli_counterpart(); self.lld_flavor_json = self.linker_flavor.lld_flavor(); self.linker_is_gnu_json = self.linker_flavor.is_gnu(); for (args, args_json) in [ @@ -2114,8 +2289,10 @@ impl TargetOptions { (&self.late_link_args_static, &mut self.late_link_args_static_json), (&self.post_link_args, &mut self.post_link_args_json), ] { - *args_json = - args.iter().map(|(flavor, args)| (flavor.to_cli(), args.clone())).collect(); + *args_json = args + .iter() + .map(|(flavor, args)| (flavor.to_cli_counterpart(), args.clone())) + .collect(); } } } @@ -2658,8 +2835,43 @@ impl Target { } Ok::<(), String>(()) } ); - - ($key_name:ident = $json_name:expr, link_self_contained) => ( { + ($key_name:ident, link_self_contained_components) => ( { + // Skeleton of what needs to be parsed: + // + // ``` + // $name: { + // "components": [ + // + // ] + // } + // ``` + let name = (stringify!($key_name)).replace("_", "-"); + if let Some(o) = obj.remove(&name) { + if let Some(o) = o.as_object() { + let component_array = o.get("components") + .ok_or_else(|| format!("{name}: expected a \ + JSON object with a `components` field."))?; + let component_array = component_array.as_array() + .ok_or_else(|| format!("{name}.components: expected a JSON array"))?; + let mut components = LinkSelfContainedComponents::empty(); + for s in component_array { + components |= match s.as_str() { + Some(s) => { + LinkSelfContainedComponents::from_str(s) + .ok_or_else(|| format!("unknown \ + `-Clink-self-contained` component: {s}"))? + }, + _ => return Err(format!("not a string: {:?}", s)), + }; + } + base.$key_name = LinkSelfContainedDefault::WithComponents(components); + } else { + incorrect_type.push(name) + } + } + Ok::<(), String>(()) + } ); + ($key_name:ident = $json_name:expr, link_self_contained_backwards_compatible) => ( { let name = $json_name; obj.remove(name).and_then(|o| o.as_str().and_then(|s| { match s.parse::() { @@ -2812,7 +3024,13 @@ impl Target { key!(post_link_objects = "post-link-objects", link_objects); key!(pre_link_objects_self_contained = "pre-link-objects-fallback", link_objects); key!(post_link_objects_self_contained = "post-link-objects-fallback", link_objects); - key!(link_self_contained = "crt-objects-fallback", link_self_contained)?; + // Deserializes the backwards-compatible variants of `-Clink-self-contained` + key!( + link_self_contained = "crt-objects-fallback", + link_self_contained_backwards_compatible + )?; + // Deserializes the components variant of `-Clink-self-contained` + key!(link_self_contained, link_self_contained_components)?; key!(pre_link_args_json = "pre-link-args", link_args); key!(late_link_args_json = "late-link-args", link_args); key!(late_link_args_dynamic_json = "late-link-args-dynamic", link_args); @@ -3068,7 +3286,6 @@ impl ToJson for Target { target_option_val!(post_link_objects); target_option_val!(pre_link_objects_self_contained, "pre-link-objects-fallback"); target_option_val!(post_link_objects_self_contained, "post-link-objects-fallback"); - target_option_val!(link_self_contained, "crt-objects-fallback"); target_option_val!(link_args - pre_link_args_json, "pre-link-args"); target_option_val!(link_args - late_link_args_json, "late-link-args"); target_option_val!(link_args - late_link_args_dynamic_json, "late-link-args-dynamic"); @@ -3165,6 +3382,10 @@ impl ToJson for Target { d.insert("default-adjusted-cabi".into(), Abi::name(abi).to_json()); } + // Serializing `-Clink-self-contained` needs a dynamic key to support the + // backwards-compatible variants. + d.insert(self.link_self_contained.json_key().into(), self.link_self_contained.to_json()); + Json::Object(d) } } diff --git a/compiler/rustc_target/src/spec/msp430_none_elf.rs b/compiler/rustc_target/src/spec/msp430_none_elf.rs deleted file mode 100644 index 251fd2a0a..000000000 --- a/compiler/rustc_target/src/spec/msp430_none_elf.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "msp430-none-elf".into(), - pointer_width: 16, - data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".into(), - arch: "msp430".into(), - - options: TargetOptions { - c_int_width: "16".into(), - - // The LLVM backend currently can't generate object files. To - // workaround this LLVM generates assembly files which then we feed - // to gcc to get object files. For this reason we have a hard - // dependency on this specific gcc. - asm_args: cvs!["-mcpu=msp430"], - linker: Some("msp430-elf-gcc".into()), - linker_flavor: LinkerFlavor::Unix(Cc::Yes), - - // There are no atomic CAS instructions available in the MSP430 - // instruction set, and the LLVM backend doesn't currently support - // compiler fences so the Atomic* API is missing on this target. - // When the LLVM backend gains support for compile fences uncomment - // the `singlethread: true` line and set `max_atomic_width` to - // `Some(16)`. - max_atomic_width: Some(0), - atomic_cas: false, - // singlethread: true, - - // Because these devices have very little resources having an - // unwinder is too onerous so we default to "abort" because the - // "unwind" strategy is very rare. - panic_strategy: PanicStrategy::Abort, - - // Similarly, one almost always never wants to use relocatable - // code because of the extra costs it involves. - relocation_model: RelocModel::Static, - - // Right now we invoke an external assembler and this isn't - // compatible with multiple codegen units, and plus we probably - // don't want to invoke that many gcc instances. - default_codegen_units: Some(1), - - // Since MSP430 doesn't meaningfully support faulting on illegal - // instructions, LLVM generates a call to abort() function instead - // of a trap instruction. Such calls are 4 bytes long, and that is - // too much overhead for such small target. - trap_unreachable: false, - - // See the thumb_base.rs file for an explanation of this value - emit_debug_gdb_scripts: false, - - eh_frame_header: false, - - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/msvc_base.rs b/compiler/rustc_target/src/spec/msvc_base.rs deleted file mode 100644 index efe949a4e..000000000 --- a/compiler/rustc_target/src/spec/msvc_base.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; -use std::borrow::Cow; - -pub fn opts() -> TargetOptions { - // Suppress the verbose logo and authorship debugging output, which would needlessly - // clog any log files. - let pre_link_args = TargetOptions::link_args(LinkerFlavor::Msvc(Lld::No), &["/NOLOGO"]); - - TargetOptions { - linker_flavor: LinkerFlavor::Msvc(Lld::No), - dll_tls_export: false, - is_like_windows: true, - is_like_msvc: true, - pre_link_args, - abi_return_struct_as_int: true, - emit_debug_gdb_scripts: false, - - // Currently this is the only supported method of debuginfo on MSVC - // where `*.pdb` files show up next to the final artifact. - split_debuginfo: SplitDebuginfo::Packed, - supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Packed]), - debuginfo_kind: DebuginfoKind::Pdb, - - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/netbsd_base.rs b/compiler/rustc_target/src/spec/netbsd_base.rs deleted file mode 100644 index be94ea234..000000000 --- a/compiler/rustc_target/src/spec/netbsd_base.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "netbsd".into(), - dynamic_linking: true, - families: cvs!["unix"], - no_default_libraries: false, - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - use_ctors_section: true, - default_dwarf_version: 2, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/nto_qnx_base.rs b/compiler/rustc_target/src/spec/nto_qnx_base.rs deleted file mode 100644 index f1405e9b4..000000000 --- a/compiler/rustc_target/src/spec/nto_qnx_base.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - crt_static_respected: true, - dynamic_linking: true, - executables: true, - families: cvs!["unix"], - has_rpath: true, - has_thread_local: false, - linker: Some("qcc".into()), - os: "nto".into(), - position_independent_executables: true, - static_position_independent_executables: true, - relro_level: RelroLevel::Full, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs deleted file mode 100644 index b0582b235..000000000 --- a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - arch: "nvptx64".into(), - data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(), - llvm_target: "nvptx64-nvidia-cuda".into(), - pointer_width: 64, - - options: TargetOptions { - os: "cuda".into(), - vendor: "nvidia".into(), - linker_flavor: LinkerFlavor::Ptx, - // The linker can be installed from `crates.io`. - linker: Some("rust-ptx-linker".into()), - - // With `ptx-linker` approach, it can be later overridden via link flags. - cpu: "sm_30".into(), - - // FIXME: create tests for the atomics. - max_atomic_width: Some(64), - - // Unwinding on CUDA is neither feasible nor useful. - panic_strategy: PanicStrategy::Abort, - - // Needed to use `dylib` and `bin` crate types and the linker. - dynamic_linking: true, - - // Avoid using dylib because it contain metadata not supported - // by LLVM NVPTX backend. - only_cdylib: true, - - // Let the `ptx-linker` to handle LLVM lowering into MC / assembly. - obj_is_bitcode: true, - - // Convenient and predicable naming scheme. - dll_prefix: "".into(), - dll_suffix: ".ptx".into(), - exe_suffix: ".ptx".into(), - - // Disable MergeFunctions LLVM optimisation pass because it can - // produce kernel functions that call other kernel functions. - // This behavior is not supported by PTX ISA. - merge_functions: MergeFunctions::Disabled, - - // The LLVM backend does not support stack canaries for this target - supports_stack_protector: false, - - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/openbsd_base.rs b/compiler/rustc_target/src/spec/openbsd_base.rs deleted file mode 100644 index e7db14e05..000000000 --- a/compiler/rustc_target/src/spec/openbsd_base.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "openbsd".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - abi_return_struct_as_int: true, - position_independent_executables: true, - frame_pointer: FramePointer::Always, // FIXME 43575: should be MayOmit... - relro_level: RelroLevel::Full, - default_dwarf_version: 2, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs b/compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs deleted file mode 100644 index 4e105a03e..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut base = super::aix_base::opts(); - base.max_atomic_width = Some(64); - base.add_pre_link_args( - LinkerFlavor::Unix(Cc::No), - &["-b64", "-bpT:0x100000000", "-bpD:0x110000000", "-bcdtors:all:0:s"], - ); - - Target { - llvm_target: "powerpc64-ibm-aix".into(), - pointer_width: 64, - data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs deleted file mode 100644 index e8fe55a00..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_freebsd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::freebsd_base::opts(); - base.cpu = "ppc64".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64-unknown-freebsd".into(), - pointer_width: 64, - data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), - arch: "powerpc64".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs deleted file mode 100644 index 7a0cc539f..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "ppc64".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs deleted file mode 100644 index f80b22828..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_musl.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "ppc64".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs deleted file mode 100644 index 3643f7b0c..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_unknown_openbsd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::openbsd_base::opts(); - base.cpu = "ppc64".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64-unknown-openbsd".into(), - pointer_width: 64, - data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), - arch: "powerpc64".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs deleted file mode 100644 index b0472e64e..000000000 --- a/compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::vxworks_base::opts(); - base.cpu = "ppc64".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: TargetOptions { endian: Endian::Big, ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs deleted file mode 100644 index 342b1cf4f..000000000 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_freebsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::freebsd_base::opts(); - base.cpu = "ppc64le".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64le-unknown-freebsd".into(), - pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64".into(), - arch: "powerpc64".into(), - options: TargetOptions { mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs deleted file mode 100644 index 815e3d278..000000000 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_gnu.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "ppc64le".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64le-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: TargetOptions { mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs deleted file mode 100644 index 0b9b78bce..000000000 --- a/compiler/rustc_target/src/spec/powerpc64le_unknown_linux_musl.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "ppc64le".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc64le-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), - options: TargetOptions { mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs deleted file mode 100644 index e036f5bdb..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::freebsd_base::opts(); - // Extra hint to linker that we are generating secure-PLT code. - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-m32", "--target=powerpc-unknown-freebsd13.0"], - ); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-freebsd13.0".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { - endian: Endian::Big, - features: "+secure-plt".into(), - mcount: "_mcount".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs deleted file mode 100644 index c8d6f8b9c..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnu.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs deleted file mode 100644 index fdaa9d366..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_gnuspe.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-linux-gnuspe".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { - abi: "spe".into(), - endian: Endian::Big, - mcount: "_mcount".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs deleted file mode 100644 index 7fe708cf5..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_linux_musl.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs deleted file mode 100644 index 6f8875ba7..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::netbsd_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-netbsd".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs deleted file mode 100644 index 280d36698..000000000 --- a/compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::openbsd_base::opts(); - base.endian = Endian::Big; - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-openbsd".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs deleted file mode 100644 index 6f245e6ab..000000000 --- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::vxworks_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "--secure-plt"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs b/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs deleted file mode 100644 index 1d5a5e5c6..000000000 --- a/compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::vxworks_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe", "--secure-plt"]); - base.max_atomic_width = Some(32); - base.stack_probes = StackProbeType::Inline; - - Target { - llvm_target: "powerpc-unknown-linux-gnuspe".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), - options: TargetOptions { - abi: "spe".into(), - endian: Endian::Big, - // feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2 - features: "+secure-plt,+msync".into(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/redox_base.rs b/compiler/rustc_target/src/spec/redox_base.rs deleted file mode 100644 index 468fe4785..000000000 --- a/compiler/rustc_target/src/spec/redox_base.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::{cvs, RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "redox".into(), - env: "relibc".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - position_independent_executables: true, - relro_level: RelroLevel::Full, - has_thread_local: true, - crt_static_default: true, - crt_static_respected: true, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs deleted file mode 100644 index bffd377bc..000000000 --- a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_gnu.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv32-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "riscv32".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv32".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "ilp32d".into(), - max_atomic_width: Some(32), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs deleted file mode 100644 index c9f3acffb..000000000 --- a/compiler/rustc_target/src/spec/riscv32gc_unknown_linux_musl.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv32-unknown-linux-musl".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "riscv32".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv32".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "ilp32d".into(), - max_atomic_width: Some(32), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs deleted file mode 100644 index 75a65a268..000000000 --- a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv32".into(), - max_atomic_width: Some(0), - atomic_cas: false, - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs deleted file mode 100644 index f2242bbe0..000000000 --- a/compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv32".into(), - max_atomic_width: Some(0), - atomic_cas: false, - features: "+m".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32imac_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imac_esp_espidf.rs deleted file mode 100644 index 079506540..000000000 --- a/compiler/rustc_target/src/spec/riscv32imac_esp_espidf.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - families: cvs!["unix"], - os: "espidf".into(), - env: "newlib".into(), - vendor: "espressif".into(), - linker: Some("riscv32-esp-elf-gcc".into()), - cpu: "generic-rv32".into(), - - // As RiscV32IMAC architecture does natively support atomics, - // automatically enable the support for the Rust STD library. - max_atomic_width: Some(64), - atomic_cas: true, - - features: "+m,+a,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs deleted file mode 100644 index 55c6e4d16..000000000 --- a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv32".into(), - max_atomic_width: Some(32), - features: "+m,+a,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs deleted file mode 100644 index a263e5d5c..000000000 --- a/compiler/rustc_target/src/spec/riscv32imac_unknown_xous_elf.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - os: "xous".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv32".into(), - max_atomic_width: Some(32), - features: "+m,+a,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs deleted file mode 100644 index 25638a092..000000000 --- a/compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - families: cvs!["unix"], - os: "espidf".into(), - env: "newlib".into(), - vendor: "espressif".into(), - linker: Some("riscv32-esp-elf-gcc".into()), - cpu: "generic-rv32".into(), - - // While the RiscV32IMC architecture does not natively support atomics, ESP-IDF does support - // the __atomic* and __sync* GCC builtins, so setting `max_atomic_width` to `Some(64)` - // and `atomic_cas` to `true` will cause the compiler to emit libcalls to these builtins. - // - // Support for atomics is necessary for the Rust STD library, which is supported by the ESP-IDF framework. - max_atomic_width: Some(64), - atomic_cas: true, - - features: "+m,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs deleted file mode 100644 index 01e773fae..000000000 --- a/compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - llvm_target: "riscv32".into(), - pointer_width: 32, - arch: "riscv32".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv32".into(), - max_atomic_width: Some(0), - atomic_cas: false, - features: "+m,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64_linux_android.rs b/compiler/rustc_target/src/spec/riscv64_linux_android.rs deleted file mode 100644 index 91f5e562d..000000000 --- a/compiler/rustc_target/src/spec/riscv64_linux_android.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-linux-android".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c,+Zba,+Zbb,+Zbs".into(), - llvm_abiname: "lp64d".into(), - supported_sanitizers: SanitizerSet::ADDRESS, - max_atomic_width: Some(64), - ..super::android_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs deleted file mode 100644 index 8281bac10..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-freebsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - ..super::freebsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs deleted file mode 100644 index 0585ed76f..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-fuchsia".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - supported_sanitizers: SanitizerSet::SHADOWCALLSTACK, - ..super::fuchsia_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_hermit.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_hermit.rs deleted file mode 100644 index 1f6a34c0c..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_hermit.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{CodeModel, RelocModel, Target, TargetOptions, TlsModel}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-hermit".into(), - pointer_width: 64, - arch: "riscv64".into(), - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - options: TargetOptions { - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - relocation_model: RelocModel::Pic, - code_model: Some(CodeModel::Medium), - tls_model: TlsModel::LocalExec, - max_atomic_width: Some(64), - llvm_abiname: "lp64d".into(), - ..super::hermit_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs deleted file mode 100644 index 90dccb280..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs deleted file mode 100644 index 1a56c78e6..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_netbsd.rs deleted file mode 100644 index a89bd363a..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_netbsd.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-netbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - mcount: "__mcount".into(), - ..super::netbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs deleted file mode 100644 index ab3c14e3f..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; -use crate::spec::{RelocModel, Target, TargetOptions}; - -use super::SanitizerSet; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - llvm_target: "riscv64".into(), - pointer_width: 64, - arch: "riscv64".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - llvm_abiname: "lp64d".into(), - cpu: "generic-rv64".into(), - max_atomic_width: Some(64), - features: "+m,+a,+f,+d,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - code_model: Some(CodeModel::Medium), - emit_debug_gdb_scripts: false, - eh_frame_header: false, - supported_sanitizers: SanitizerSet::KERNELADDRESS, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_openbsd.rs deleted file mode 100644 index ade9d7762..000000000 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_openbsd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{CodeModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "riscv64-unknown-openbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), - options: TargetOptions { - code_model: Some(CodeModel::Medium), - cpu: "generic-rv64".into(), - features: "+m,+a,+f,+d,+c".into(), - llvm_abiname: "lp64d".into(), - max_atomic_width: Some(64), - ..super::openbsd_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs deleted file mode 100644 index 0f1821c99..000000000 --- a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; -use crate::spec::{RelocModel, SanitizerSet, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - llvm_target: "riscv64".into(), - pointer_width: 64, - arch: "riscv64".into(), - - options: TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - cpu: "generic-rv64".into(), - max_atomic_width: Some(64), - features: "+m,+a,+c".into(), - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - code_model: Some(CodeModel::Medium), - emit_debug_gdb_scripts: false, - eh_frame_header: false, - supported_sanitizers: SanitizerSet::KERNELADDRESS, - ..Default::default() - }, - } -} diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs deleted file mode 100644 index f2c722b9a..000000000 --- a/compiler/rustc_target/src/spec/s390x_unknown_linux_gnu.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.endian = Endian::Big; - // z10 is the oldest CPU supported by LLVM - base.cpu = "z10".into(); - // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector - // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we - // also strip v128 from the data_layout below to match the older LLVM's expectation. - base.features = "-vector".into(); - base.max_atomic_width = Some(64); - base.min_global_align = Some(16); - base.stack_probes = StackProbeType::Inline; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; - - Target { - llvm_target: "s390x-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), - arch: "s390x".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs deleted file mode 100644 index 8fe9d023c..000000000 --- a/compiler/rustc_target/src/spec/s390x_unknown_linux_musl.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.endian = Endian::Big; - // z10 is the oldest CPU supported by LLVM - base.cpu = "z10".into(); - // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector - // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we - // also strip v128 from the data_layout below to match the older LLVM's expectation. - base.features = "-vector".into(); - base.max_atomic_width = Some(64); - base.min_global_align = Some(16); - base.static_position_independent_executables = true; - base.stack_probes = StackProbeType::Inline; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; - - Target { - llvm_target: "s390x-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), - arch: "s390x".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs deleted file mode 100644 index f97cdb4fb..000000000 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::{cvs, Cc, LinkerFlavor, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "solaris".into(), - dynamic_linking: true, - has_rpath: true, - families: cvs!["unix"], - is_like_solaris: true, - linker_flavor: LinkerFlavor::Unix(Cc::Yes), - limit_rdylib_exports: false, // Linker doesn't support this - eh_frame_header: false, - - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/solid_base.rs b/compiler/rustc_target/src/spec/solid_base.rs deleted file mode 100644 index eaf72b761..000000000 --- a/compiler/rustc_target/src/spec/solid_base.rs +++ /dev/null @@ -1,13 +0,0 @@ -use super::FramePointer; -use crate::spec::TargetOptions; - -pub fn opts(kernel: &str) -> TargetOptions { - TargetOptions { - os: format!("solid_{kernel}").into(), - vendor: "kmc".into(), - executables: false, - frame_pointer: FramePointer::NonLeaf, - has_thread_local: true, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs deleted file mode 100644 index 39efd8f30..000000000 --- a/compiler/rustc_target/src/spec/sparc64_unknown_linux_gnu.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.endian = Endian::Big; - base.cpu = "v9".into(); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "sparc64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".into(), - arch: "sparc64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs deleted file mode 100644 index 38ab066b0..000000000 --- a/compiler/rustc_target/src/spec/sparc64_unknown_netbsd.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::netbsd_base::opts(); - base.cpu = "v9".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "sparc64-unknown-netbsd".into(), - pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".into(), - arch: "sparc64".into(), - options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs deleted file mode 100644 index 06a5f782a..000000000 --- a/compiler/rustc_target/src/spec/sparc64_unknown_openbsd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::openbsd_base::opts(); - base.endian = Endian::Big; - base.cpu = "v9".into(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "sparc64-unknown-openbsd".into(), - pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".into(), - arch: "sparc64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs deleted file mode 100644 index b10e6264b..000000000 --- a/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.endian = Endian::Big; - base.cpu = "v9".into(); - base.max_atomic_width = Some(32); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mv8plus"]); - - Target { - llvm_target: "sparc-unknown-linux-gnu".into(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), - arch: "sparc".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/sparc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/sparc_unknown_none_elf.rs deleted file mode 100644 index 7e908a0f3..000000000 --- a/compiler/rustc_target/src/spec/sparc_unknown_none_elf.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - let options = TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), - linker: Some("sparc-elf-gcc".into()), - endian: Endian::Big, - cpu: "v7".into(), - abi: "elf".into(), - max_atomic_width: Some(32), - atomic_cas: true, - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - no_default_libraries: false, - emit_debug_gdb_scripts: false, - eh_frame_header: false, - ..Default::default() - }; - Target { - data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), - llvm_target: "sparc-unknown-none-elf".into(), - pointer_width: 32, - arch: "sparc".into(), - options, - } -} diff --git a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs deleted file mode 100644 index 4d2bc98ab..000000000 --- a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut base = super::solaris_base::opts(); - base.endian = Endian::Big; - base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); - // llvm calls this "v9" - base.cpu = "v9".into(); - base.vendor = "sun".into(); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "sparcv9-sun-solaris".into(), - pointer_width: 64, - data_layout: "E-m:e-i64:64-n32:64-S128".into(), - // Use "sparc64" instead of "sparcv9" here, since the former is already - // used widely in the source base. If we ever needed ABI - // differentiation from the sparc64, we could, but that would probably - // just be confusing. - arch: "sparc64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs new file mode 100644 index 000000000..8e6c00b12 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs @@ -0,0 +1,27 @@ +use crate::spec::base::apple::{macos_llvm_target, opts, Arch}; +use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64; + let mut base = opts("macos", arch); + base.cpu = "apple-m1".into(); + base.max_atomic_width = Some(128); + + // FIXME: The leak sanitizer currently fails the tests, see #88132. + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; + + Target { + // Clang automatically chooses a more specific target based on + // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work + // correctly, we do too. + llvm_target: macos_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + mcount: "\u{1}mcount".into(), + frame_pointer: FramePointer::NonLeaf, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs new file mode 100644 index 000000000..9fc5b5de4 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs @@ -0,0 +1,37 @@ +use crate::spec::base::apple::{ios_llvm_target, opts, Arch}; +use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64; + let mut base = opts("ios", arch); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; + + Target { + // Clang automatically chooses a more specific target based on + // IPHONEOS_DEPLOYMENT_TARGET. + // This is required for the target to pick the right + // MACH-O commands, so we do too. + llvm_target: ios_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64-apple-ios11.0.0\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs new file mode 100644 index 000000000..0172a3a9c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs @@ -0,0 +1,34 @@ +use crate::spec::base::apple::{opts, Arch}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let llvm_target = "arm64-apple-ios14.0-macabi"; + + let arch = Arch::Arm64_macabi; + let mut base = opts("ios", arch); + base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD; + + Target { + llvm_target: llvm_target.into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a12".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64-apple-ios-macabi\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -Os\0" + .into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs new file mode 100644 index 000000000..602a68777 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs @@ -0,0 +1,37 @@ +use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch}; +use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64_sim; + let mut base = opts("ios", arch); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; + + Target { + // Clang automatically chooses a more specific target based on + // IPHONEOS_DEPLOYMENT_TARGET. + // This is required for the simulator target to pick the right + // MACH-O commands, so we do too. + llvm_target: ios_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64-apple-ios14.0-simulator\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs new file mode 100644 index 000000000..a1a319355 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs @@ -0,0 +1,19 @@ +use crate::spec::base::apple::{opts, tvos_llvm_target, Arch}; +use crate::spec::{FramePointer, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64; + Target { + llvm_target: tvos_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + ..opts("tvos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs new file mode 100644 index 000000000..7b0bbb28e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs @@ -0,0 +1,31 @@ +use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch}; +use crate::spec::{FramePointer, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64_sim; + Target { + llvm_target: tvos_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + // Taken from (and slightly modified) the aarch64-apple-ios-sim spec which says: + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64-apple-tvos15.0-simulator\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..opts("tvos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs new file mode 100644 index 000000000..014560d22 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs @@ -0,0 +1,34 @@ +use crate::spec::base::apple::{opts, watchos_sim_llvm_target, Arch}; +use crate::spec::{FramePointer, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Arm64_sim; + Target { + // Clang automatically chooses a more specific target based on + // WATCHOS_DEPLOYMENT_TARGET. + // This is required for the simulator target to pick the right + // MACH-O commands, so we do too. + llvm_target: watchos_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + frame_pointer: FramePointer::NonLeaf, + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64-apple-watchos5.0-simulator\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..opts("watchos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs new file mode 100644 index 000000000..bbaa870ec --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64_be-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a,+outline-atomics".into(), + max_atomic_width: Some(128), + mcount: "\u{1}_mcount".into(), + endian: Endian::Big, + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs new file mode 100644 index 000000000..7536e507b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs @@ -0,0 +1,21 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.max_atomic_width = Some(128); + + Target { + llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + abi: "ilp32".into(), + features: "+v8a,+outline-atomics".into(), + mcount: "\u{1}_mcount".into(), + endian: Endian::Big, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs new file mode 100644 index 000000000..21de8a71a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64_be-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + mcount: "__mcount".into(), + max_atomic_width: Some(128), + endian: Endian::Big, + ..base::netbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_fuchsia.rs b/compiler/rustc_target/src/spec/targets/aarch64_fuchsia.rs new file mode 100644 index 000000000..3668db912 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_fuchsia.rs @@ -0,0 +1 @@ +pub use crate::spec::targets::aarch64_unknown_fuchsia::target; diff --git a/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs new file mode 100644 index 000000000..e5e22fd1e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let base = base::solid::opts("asp3"); + Target { + llvm_target: "aarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + linker: Some("aarch64-kmc-elf-gcc".into()), + features: "+v8a,+neon,+fp-armv8".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(128), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs new file mode 100644 index 000000000..7c6fed7ab --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a +// for target ABI requirements. + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-linux-android".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + max_atomic_width: Some(128), + // As documented in https://developer.android.com/ndk/guides/cpu-features.html + // the neon (ASIMD) and FP must exist on all android aarch64 targets. + features: "+v8a,+neon,+fp-armv8".into(), + supported_sanitizers: SanitizerSet::CFI + | SanitizerSet::HWADDRESS + | SanitizerSet::MEMTAG + | SanitizerSet::SHADOWCALLSTACK + | SanitizerSet::ADDRESS, + supports_xray: true, + ..base::android::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs new file mode 100644 index 000000000..02fcc2bb4 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs @@ -0,0 +1,26 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, Target, TargetOptions}; + +const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding_linker_script.ld"); + +/// A base target for Nintendo Switch devices using a pure LLVM toolchain. +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + link_script: Some(LINKER_SCRIPT.into()), + os: "horizon".into(), + max_atomic_width: Some(128), + panic_strategy: PanicStrategy::Abort, + position_independent_executables: true, + dynamic_linking: true, + relro_level: RelroLevel::Off, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding_linker_script.ld b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding_linker_script.ld new file mode 100644 index 000000000..f3441e659 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding_linker_script.ld @@ -0,0 +1,78 @@ +OUTPUT_FORMAT(elf64-littleaarch64) +OUTPUT_ARCH(aarch64) +ENTRY(_start) + +PHDRS +{ + text PT_LOAD FLAGS(5); + rodata PT_LOAD FLAGS(4); + data PT_LOAD FLAGS(6); + bss PT_LOAD FLAGS(6); + dynamic PT_DYNAMIC; +} + +SECTIONS +{ + . = 0; + + .text : ALIGN(0x1000) { + HIDDEN(__text_start = .); + KEEP(*(.text.jmp)) + + . = 0x80; + + *(.text .text.*) + *(.plt .plt.*) + } + + /* Read-only sections */ + + . = ALIGN(0x1000); + + .module_name : { *(.module_name) } :rodata + + .rodata : { *(.rodata .rodata.*) } :rodata + .hash : { *(.hash) } + .dynsym : { *(.dynsym .dynsym.*) } + .dynstr : { *(.dynstr .dynstr.*) } + .rela.dyn : { *(.rela.dyn) } + + .eh_frame : { + HIDDEN(__eh_frame_start = .); + *(.eh_frame .eh_frame.*) + HIDDEN(__eh_frame_end = .); + } + + .eh_frame_hdr : { + HIDDEN(__eh_frame_hdr_start = .); + *(.eh_frame_hdr .eh_frame_hdr.*) + HIDDEN(__eh_frame_hdr_end = .); + } + + /* Read-write sections */ + + . = ALIGN(0x1000); + + .data : { + *(.data .data.*) + *(.got .got.*) + *(.got.plt .got.plt.*) + } :data + + .dynamic : { + HIDDEN(__dynamic_start = .); + *(.dynamic) + } + + /* BSS section */ + + . = ALIGN(0x1000); + + .bss : { + HIDDEN(__bss_start = .); + *(.bss .bss.*) + *(COMMON) + . = ALIGN(8); + HIDDEN(__bss_end = .); + } :bss +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs new file mode 100644 index 000000000..1ea738142 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_gnullvm::opts(); + base.max_atomic_width = Some(128); + base.features = "+v8a,+neon,+fp-armv8".into(); + base.linker = Some("aarch64-w64-mingw32-clang".into()); + + Target { + llvm_target: "aarch64-pc-windows-gnu".into(), + pointer_width: 64, + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs new file mode 100644 index 000000000..cbd132972 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_msvc::opts(); + base.max_atomic_width = Some(128); + base.features = "+v8a,+neon,+fp-armv8".into(); + + Target { + llvm_target: "aarch64-pc-windows-msvc".into(), + pointer_width: 64, + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs new file mode 100644 index 000000000..0f95984a3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-freebsd".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + max_atomic_width: Some(128), + supported_sanitizers: SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::MEMORY + | SanitizerSet::THREAD, + ..base::freebsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs new file mode 100644 index 000000000..cacc6ea23 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-fuchsia".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + max_atomic_width: Some(128), + supported_sanitizers: SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::SHADOWCALLSTACK, + ..base::fuchsia::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs new file mode 100644 index 000000000..3839e0b9c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-hermit".into(), + pointer_width: 64, + arch: "aarch64".into(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + options: TargetOptions { + features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + max_atomic_width: Some(128), + ..base::hermit::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs new file mode 100644 index 000000000..c0b07db38 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a,+outline-atomics".into(), + mcount: "\u{1}_mcount".into(), + max_atomic_width: Some(128), + supported_sanitizers: SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::MEMTAG + | SanitizerSet::THREAD + | SanitizerSet::HWADDRESS, + supports_xray: true, + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs new file mode 100644 index 000000000..d4c6271b2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-linux-gnu_ilp32".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + abi: "ilp32".into(), + features: "+v8a,+outline-atomics".into(), + max_atomic_width: Some(128), + mcount: "\u{1}_mcount".into(), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs new file mode 100644 index 000000000..364df677e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.max_atomic_width = Some(128); + base.supports_xray = true; + base.features = "+v8a".into(); + base.supported_sanitizers = SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::THREAD; + + Target { + llvm_target: "aarch64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs new file mode 100644 index 000000000..5f3bef63a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs @@ -0,0 +1,27 @@ +use crate::spec::SanitizerSet; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_ohos::opts(); + base.max_atomic_width = Some(128); + + Target { + // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. + llvm_target: "aarch64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+reserve-x18".into(), + mcount: "\u{1}_mcount".into(), + supported_sanitizers: SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::MEMTAG + | SanitizerSet::THREAD + | SanitizerSet::HWADDRESS, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs new file mode 100644 index 000000000..3194d16ff --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + mcount: "__mcount".into(), + max_atomic_width: Some(128), + ..base::netbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs new file mode 100644 index 000000000..88fa6d5a7 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs @@ -0,0 +1,32 @@ +// Generic AArch64 target for bare-metal code - Floating point enabled +// +// Can be used in conjunction with the `target-feature` and +// `target-cpu` compiler flags to opt-in more hardware-specific +// features. +// +// For example, `-C target-cpu=cortex-a53`. + +use crate::spec::{ + Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetOptions, +}; + +pub fn target() -> Target { + let opts = TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(128), + panic_strategy: PanicStrategy::Abort, + ..Default::default() + }; + Target { + llvm_target: "aarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs new file mode 100644 index 000000000..48b79b0b9 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs @@ -0,0 +1,30 @@ +// Generic AArch64 target for bare-metal code - Floating point disabled +// +// Can be used in conjunction with the `target-feature` and +// `target-cpu` compiler flags to opt-in more hardware-specific +// features. +// +// For example, `-C target-cpu=cortex-a53`. + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let opts = TargetOptions { + abi: "softfloat".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + features: "+v8a,+strict-align,-neon,-fp-armv8".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(128), + panic_strategy: PanicStrategy::Abort, + ..Default::default() + }; + Target { + llvm_target: "aarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx_710.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx_710.rs new file mode 100644 index 000000000..aeeaab3af --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nto_qnx_710.rs @@ -0,0 +1,29 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-unknown".into(), + pointer_width: 64, + // from: https://llvm.org/docs/LangRef.html#data-layout + // e = little endian + // m:e = ELF mangling: Private symbols get a .L prefix + // i8:8:32 = 8-bit-integer, minimum_alignment=8, preferred_alignment=32 + // i16:16:32 = 16-bit-integer, minimum_alignment=16, preferred_alignment=32 + // i64:64 = 64-bit-integer, minimum_alignment=64, preferred_alignment=64 + // i128:128 = 128-bit-integer, minimum_alignment=128, preferred_alignment=128 + // n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently. + // S128 = 128 bits are the natural alignment of the stack in bits. + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + max_atomic_width: Some(128), + pre_link_args: TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-Vgcc_ntoaarch64le_cxx"], + ), + env: "nto71".into(), + ..base::nto_qnx::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs new file mode 100644 index 000000000..e3f5aafc7 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-openbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + max_atomic_width: Some(128), + ..base::openbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs new file mode 100644 index 000000000..de875e29f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::redox::opts(); + base.max_atomic_width = Some(128); + base.features = "+v8a".into(); + + Target { + llvm_target: "aarch64-unknown-redox".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs new file mode 100644 index 000000000..eec2668d4 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::teeos::opts(); + base.features = "+strict-align,+neon,+fp-armv8".into(); + base.max_atomic_width = Some(128); + base.linker = Some("aarch64-linux-gnu-ld".into()); + + Target { + llvm_target: "aarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs new file mode 100644 index 000000000..9ed6ed265 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs @@ -0,0 +1,20 @@ +// This defines the aarch64 target for UEFI systems as described in the UEFI specification. See the +// uefi-base module for generic UEFI options. + +use crate::spec::{base, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::uefi_msvc::opts(); + + base.max_atomic_width = Some(128); + base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/machine:arm64"]); + base.features = "+v8a".into(); + + Target { + llvm_target: "aarch64-unknown-windows".into(), + pointer_width: 64, + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs new file mode 100644 index 000000000..c64b2c7d1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_uwp_msvc::opts(); + base.max_atomic_width = Some(128); + base.features = "+v8a".into(); + + Target { + llvm_target: "aarch64-pc-windows-msvc".into(), + pointer_width: 64, + data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs new file mode 100644 index 000000000..29f61d857 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs @@ -0,0 +1,15 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a".into(), + max_atomic_width: Some(128), + ..base::vxworks::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs b/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs new file mode 100644 index 000000000..9931b7b86 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs @@ -0,0 +1,30 @@ +use crate::spec::base::apple::{opts, Arch}; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + let base = opts("watchos", Arch::Arm64_32); + Target { + llvm_target: "arm64_32-apple-watchos".into(), + pointer_width: 32, + data_layout: "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + features: "+v8a,+neon,+fp-armv8,+apple-a7".into(), + max_atomic_width: Some(128), + forces_embed_bitcode: true, + dynamic_linking: false, + position_independent_executables: true, + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + arm64_32-apple-watchos5.0.0\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs new file mode 100644 index 000000000..43b27b414 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "arm-linux-androideabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + // https://developer.android.com/ndk/guides/abis.html#armeabi + features: "+strict-align,+v5te".into(), + supported_sanitizers: SanitizerSet::ADDRESS, + max_atomic_width: Some(32), + ..base::android::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs new file mode 100644 index 000000000..e4fa54c4b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "arm-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+strict-align,+v6".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs new file mode 100644 index 000000000..f379ea35e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "arm-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + features: "+strict-align,+v6,+vfp2,-d32".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs new file mode 100644 index 000000000..f3d5ff892 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs @@ -0,0 +1,22 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it + // to determine the calling convention and float ABI, and it doesn't + // support the "musleabi" value. + llvm_target: "arm-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + // Most of these settings are copied from the arm_unknown_linux_gnueabi + // target. + features: "+strict-align,+v6".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs new file mode 100644 index 000000000..f3e366d59 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs @@ -0,0 +1,22 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and it + // doesn't support the "musleabihf" value. + llvm_target: "arm-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // Most of these settings are copied from the arm_unknown_linux_gnueabihf + // target. + features: "+strict-align,+v6,+vfp2,-d32".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs new file mode 100644 index 000000000..07c7e1c58 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs @@ -0,0 +1,20 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armeb-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+strict-align,+v8,+crc".into(), + endian: Endian::Big, + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs new file mode 100644 index 000000000..446efa90d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs @@ -0,0 +1,26 @@ +// Targets the Big endian Cortex-R4/R5 processor (ARMv7-R) + +use crate::abi::Endian; +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armebv7r-none-eabi".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + endian: Endian::Big, + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + max_atomic_width: Some(64), + emit_debug_gdb_scripts: false, + // GCC defaults to 8 for arm-none here. + c_enum_min_bits: Some(8), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs new file mode 100644 index 000000000..0c9e99ff8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs @@ -0,0 +1,27 @@ +// Targets the Cortex-R4F/R5F processor (ARMv7-R) + +use crate::abi::Endian; +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armebv7r-none-eabihf".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + endian: Endian::Big, + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + features: "+vfp3,-d32,-fp16".into(), + max_atomic_width: Some(64), + emit_debug_gdb_scripts: false, + // GCC defaults to 8 for arm-none here. + c_enum_min_bits: Some(8), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs new file mode 100644 index 000000000..44fdd3178 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs @@ -0,0 +1,49 @@ +//! Targets the ARMv4T, with code as `a32` code by default. +//! +//! Primarily of use for the GBA, but usable with other devices too. +//! +//! Please ping @Lokathor if changes are needed. +//! +//! **Important:** This target profile **does not** specify a linker script. You +//! just get the default link script when you build a binary for this target. +//! The default link script is very likely wrong, so you should use +//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. + +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv4t-none-eabi".into(), + pointer_width: 32, + arch: "arm".into(), + /* Data layout args are '-' separated: + * little endian + * stack is 64-bit aligned (EABI) + * pointers are 32-bit + * i64 must be 64-bit aligned (EABI) + * mangle names with ELF style + * native integers are 32-bit + * All other elements are default + */ + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + options: TargetOptions { + abi: "eabi".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], + // Force-enable 32-bit atomics, which allows the use of atomic load/store only. + // The resulting atomics are ABI incompatible with atomics backed by libatomic. + features: "+soft-float,+strict-align,+atomics-32".into(), + main_needs_argc_argv: false, + atomic_cas: false, + has_thumb_interworking: true, + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + // From thumb_base, rust-lang/rust#44993. + emit_debug_gdb_scripts: false, + // From thumb_base, GCC gives enums a minimum of 8 bits on no-os targets. + c_enum_min_bits: Some(8), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs new file mode 100644 index 000000000..5ab753c3d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv4t-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + has_thumb_interworking: true, + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs new file mode 100644 index 000000000..5e23efecd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs @@ -0,0 +1,41 @@ +//! Targets the ARMv5TE, with code as `a32` code by default. + +use crate::spec::{base, cvs, FramePointer, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv5te-none-eabi".into(), + pointer_width: 32, + arch: "arm".into(), + /* Data layout args are '-' separated: + * little endian + * stack is 64-bit aligned (EABI) + * pointers are 32-bit + * i64 must be 64-bit aligned (EABI) + * mangle names with ELF style + * native integers are 32-bit + * All other elements are default + */ + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + + options: TargetOptions { + abi: "eabi".into(), + // extra args passed to the external assembler (assuming `arm-none-eabi-as`): + // * activate t32/a32 interworking + // * use arch ARMv5TE + // * use little-endian + asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",], + // minimum extra features, these cannot be disabled via -C + // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. + // The resulting atomics are ABI incompatible with atomics backed by libatomic. + features: "+soft-float,+strict-align,+atomics-32".into(), + frame_pointer: FramePointer::MayOmit, + main_needs_argc_argv: false, + // don't have atomic compare-and-swap + atomic_cas: false, + has_thumb_interworking: true, + + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs new file mode 100644 index 000000000..7155ab289 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv5te-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + mcount: "\u{1}__gnu_mcount_nc".into(), + has_thumb_interworking: true, + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs new file mode 100644 index 000000000..3f25ab2bc --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs @@ -0,0 +1,23 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + // FIXME: this comment below does not seem applicable? + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and LLVM + // doesn't support the "musleabihf" value. + llvm_target: "armv5te-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + mcount: "\u{1}mcount".into(), + has_thumb_interworking: true, + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs new file mode 100644 index 000000000..af6e3baa2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv5te-unknown-linux-uclibcgnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+soft-float,+strict-align".into(), + // Atomic operations provided by compiler-builtins + max_atomic_width: Some(32), + mcount: "\u{1}__gnu_mcount_nc".into(), + has_thumb_interworking: true, + ..base::linux_uclibc::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs new file mode 100644 index 000000000..22f6ee810 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv6-unknown-freebsd-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // FIXME: change env to "gnu" when cfg_target_abi becomes stable + env: "gnueabihf".into(), + features: "+v6,+vfp2,-d32".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + ..base::freebsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs new file mode 100644 index 000000000..84d9ceac0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv6-unknown-netbsdelf-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // FIXME: remove env when cfg_target_abi becomes stable + env: "eabihf".into(), + features: "+v6,+vfp2,-d32".into(), + max_atomic_width: Some(64), + mcount: "__mcount".into(), + ..base::netbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs new file mode 100644 index 000000000..23f4a5abf --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs @@ -0,0 +1,36 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; + +/// A base target for Nintendo 3DS devices using the devkitARM toolchain. +/// +/// Requires the devkitARM toolchain for 3DS targets on the host system. + +pub fn target() -> Target { + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-specs=3dsx.specs", "-mtune=mpcore", "-mfloat-abi=hard", "-mtp=soft"], + ); + + Target { + llvm_target: "armv6k-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + os: "horizon".into(), + env: "newlib".into(), + vendor: "nintendo".into(), + abi: "eabihf".into(), + cpu: "mpcore".into(), + families: cvs!["unix"], + linker: Some("arm-none-eabi-gcc".into()), + relocation_model: RelocModel::Static, + features: "+vfp2".into(), + pre_link_args, + exe_suffix: ".elf".into(), + no_default_libraries: false, + has_thread_local: true, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs new file mode 100644 index 000000000..bb3e574e3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs @@ -0,0 +1,27 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; + +// This target if is for the baseline of the Android v7a ABI +// in thumb mode. It's named armv7-* instead of thumbv7-* +// for historical reasons. See the thumbv7neon variant for +// enabling NEON. + +// See https://developer.android.com/ndk/guides/abis.html#v7a +// for target ABI requirements. + +pub fn target() -> Target { + let mut base = base::android::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]); + Target { + llvm_target: "armv7-none-linux-android".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(), + supported_sanitizers: SanitizerSet::ADDRESS, + max_atomic_width: Some(64), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs new file mode 100644 index 000000000..62c936036 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs @@ -0,0 +1,41 @@ +use crate::abi::Endian; +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; + +/// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib). +/// +/// Requires the VITASDK toolchain on the host system. + +pub fn target() -> Target { + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-Wl,-q", "-Wl,--pic-veneer"], + ); + + Target { + llvm_target: "thumbv7a-vita-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + os: "vita".into(), + endian: Endian::Little, + c_int_width: "32".into(), + env: "newlib".into(), + vendor: "sony".into(), + abi: "eabihf".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), + no_default_libraries: false, + cpu: "cortex-a9".into(), + families: cvs!["unix"], + linker: Some("arm-vita-eabi-gcc".into()), + relocation_model: RelocModel::Static, + features: "+v7,+neon,+vfp3,+thumb2,+thumb-mode".into(), + pre_link_args, + exe_suffix: ".elf".into(), + has_thumb_interworking: true, + max_atomic_width: Some(64), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs new file mode 100644 index 000000000..9f4a432c6 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-freebsd-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // FIXME: change env to "gnu" when cfg_target_abi becomes stable + env: "gnueabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + ..base::freebsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs new file mode 100644 index 000000000..ad9fd773b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or +// hardfloat. + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+v7,+thumb2,+soft-float,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs new file mode 100644 index 000000000..aad7977d5 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for glibc Linux on ARMv7 without NEON or +// thumb-mode. See the thumbv7neon variant for enabling both. + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // Info about features at https://wiki.debian.org/ArmHardFloatPort + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}__gnu_mcount_nc".into(), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs new file mode 100644 index 000000000..7f30a5ad7 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for musl Linux on ARMv7 without thumb-mode, NEON or +// hardfloat. + +pub fn target() -> Target { + // Most of these settings are copied from the armv7_unknown_linux_gnueabi + // target. + Target { + // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it + // to determine the calling convention and float ABI, and it doesn't + // support the "musleabi" value. + llvm_target: "armv7-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + features: "+v7,+thumb2,+soft-float,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs new file mode 100644 index 000000000..ec5c6419f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs @@ -0,0 +1,25 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for musl Linux on ARMv7 without thumb-mode or NEON. + +pub fn target() -> Target { + Target { + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and LLVM + // doesn't support the "musleabihf" value. + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + // Most of these settings are copied from the armv7_unknown_linux_gnueabihf + // target. + options: TargetOptions { + abi: "eabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs new file mode 100644 index 000000000..9f2ac541d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for OpenHarmony on ARMv7 Linux with thumb-mode, but no NEON or +// hardfloat. + +pub fn target() -> Target { + // Most of these settings are copied from the armv7_unknown_linux_musleabi + // target. + Target { + // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. + llvm_target: "armv7-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + features: "+v7,+thumb2,+soft-float,-neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_ohos::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs new file mode 100644 index 000000000..212c80718 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs @@ -0,0 +1,23 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for uclibc Linux on ARMv7 without NEON, +// thumb-mode or hardfloat. + +pub fn target() -> Target { + let base = base::linux_uclibc::opts(); + Target { + llvm_target: "armv7-unknown-linux-gnueabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + features: "+v7,+thumb2,+soft-float,-neon".into(), + cpu: "generic".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + abi: "eabi".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs new file mode 100644 index 000000000..f760ad9e7 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for uclibc Linux on ARMv7 without NEON or +// thumb-mode. See the thumbv7neon variant for enabling both. + +pub fn target() -> Target { + let base = base::linux_uclibc::opts(); + Target { + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + // Info about features at https://wiki.debian.org/ArmHardFloatPort + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + cpu: "generic".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + abi: "eabihf".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs new file mode 100644 index 000000000..e5518c6da --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-netbsdelf-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // FIXME: remove env when cfg_target_abi becomes stable + env: "eabihf".into(), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + max_atomic_width: Some(64), + mcount: "__mcount".into(), + ..base::netbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs new file mode 100644 index 000000000..0b4e64307 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // Info about features at https://wiki.debian.org/ArmHardFloatPort + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + max_atomic_width: Some(64), + ..base::vxworks::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs new file mode 100644 index 000000000..57d40d54c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let base = base::solid::opts("asp3"); + Target { + llvm_target: "armv7a-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + linker: Some("arm-kmc-eabi-gcc".into()), + features: "+v7,+soft-float,+thumb2,-neon".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(64), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs new file mode 100644 index 000000000..3d21213c5 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let base = base::solid::opts("asp3"); + Target { + llvm_target: "armv7a-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + linker: Some("arm-kmc-eabi-gcc".into()), + features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(64), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs new file mode 100644 index 000000000..c5b61427e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs @@ -0,0 +1,40 @@ +// Generic ARMv7-A target for bare-metal code - floating point disabled +// +// This is basically the `armv7-unknown-linux-gnueabi` target with some changes +// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64` +// targets: +// +// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned +// memory access is disabled on boot on these cores +// - linker changed to LLD. rationale: C is not strictly needed to build +// bare-metal binaries (the `gcc` linker has the advantage that it knows where C +// libraries and crt*.o are but it's not much of an advantage here); LLD is also +// faster +// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets +// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic +// linking. rationale: matches `thumb` targets + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let opts = TargetOptions { + abi: "eabi".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(64), + panic_strategy: PanicStrategy::Abort, + emit_debug_gdb_scripts: false, + c_enum_min_bits: Some(8), + ..Default::default() + }; + Target { + llvm_target: "armv7a-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs new file mode 100644 index 000000000..ba3caad6a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs @@ -0,0 +1,32 @@ +// Generic ARMv7-A target for bare-metal code - floating point enabled (assumes +// FPU is present and emits FPU instructions) +// +// This is basically the `armv7-unknown-linux-gnueabihf` target with some +// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal +// `thumb` & `aarch64` targets. + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let opts = TargetOptions { + abi: "eabihf".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(), + relocation_model: RelocModel::Static, + disable_redzone: true, + max_atomic_width: Some(64), + panic_strategy: PanicStrategy::Abort, + emit_debug_gdb_scripts: false, + // GCC defaults to 8 for arm-none here. + c_enum_min_bits: Some(8), + ..Default::default() + }; + Target { + llvm_target: "armv7a-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7k_apple_watchos.rs b/compiler/rustc_target/src/spec/targets/armv7k_apple_watchos.rs new file mode 100644 index 000000000..751fdcb20 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7k_apple_watchos.rs @@ -0,0 +1,30 @@ +use crate::spec::base::apple::{opts, Arch}; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Armv7k; + Target { + llvm_target: "armv7k-apple-watchos".into(), + pointer_width: 32, + data_layout: "e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+v7,+vfp4,+neon".into(), + max_atomic_width: Some(64), + forces_embed_bitcode: true, + dynamic_linking: false, + position_independent_executables: true, + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + armv7k-apple-watchos3.0.0\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..opts("watchos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs new file mode 100644 index 000000000..68b252798 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs @@ -0,0 +1,25 @@ +// Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R) + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv7r-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + max_atomic_width: Some(64), + emit_debug_gdb_scripts: false, + // GCC defaults to 8 for arm-none here. + c_enum_min_bits: Some(8), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs new file mode 100644 index 000000000..909765a31 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs @@ -0,0 +1,26 @@ +// Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R) + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "armv7r-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabihf".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + features: "+vfp3,-d32,-fp16".into(), + max_atomic_width: Some(64), + emit_debug_gdb_scripts: false, + // GCC defaults to 8 for arm-none here. + c_enum_min_bits: Some(8), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs b/compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs new file mode 100644 index 000000000..44c624c4e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs @@ -0,0 +1,17 @@ +use crate::spec::base::apple::{ios_llvm_target, opts, Arch}; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::Armv7s; + Target { + llvm_target: ios_llvm_target(arch).into(), + pointer_width: 32, + data_layout: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".into(), + arch: arch.target_arch(), + options: TargetOptions { + features: "+v7,+vfp4,+neon".into(), + max_atomic_width: Some(64), + ..opts("ios", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/asmjs_unknown_emscripten.rs b/compiler/rustc_target/src/spec/targets/asmjs_unknown_emscripten.rs new file mode 100644 index 000000000..e4768c67a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/asmjs_unknown_emscripten.rs @@ -0,0 +1,7 @@ +use crate::spec::{targets::wasm32_unknown_emscripten, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut target = wasm32_unknown_emscripten::target(); + target.add_post_link_args(LinkerFlavor::EmCc, &["-sWASM=0", "--memory-init-file", "0"]); + target +} diff --git a/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs b/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs new file mode 100644 index 000000000..bf01413a8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs @@ -0,0 +1,5 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + base::avr_gnu::target("atmega328", "-mmcu=atmega328") +} diff --git a/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs b/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs new file mode 100644 index 000000000..91e091e23 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs @@ -0,0 +1,12 @@ +use crate::spec::Target; +use crate::{abi::Endian, spec::base}; + +pub fn target() -> Target { + Target { + llvm_target: "bpfeb".into(), + data_layout: "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + pointer_width: 64, + arch: "bpf".into(), + options: base::bpf::opts(Endian::Big), + } +} diff --git a/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs b/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs new file mode 100644 index 000000000..45ab750ea --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs @@ -0,0 +1,12 @@ +use crate::spec::Target; +use crate::{abi::Endian, spec::base}; + +pub fn target() -> Target { + Target { + llvm_target: "bpfel".into(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + pointer_width: 64, + arch: "bpf".into(), + options: base::bpf::opts(Endian::Little), + } +} diff --git a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs new file mode 100644 index 000000000..14cd33a26 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +// This target is for glibc Linux on Csky + +pub fn target() -> Target { + Target { + //https://github.com/llvm/llvm-project/blob/8b76aea8d8b1b71f6220bc2845abc749f18a19b7/clang/lib/Basic/Targets/CSKY.h + llvm_target: "csky-unknown-linux-gnuabiv2".into(), + pointer_width: 32, + data_layout: "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32-v128:32:32-a:0:32-Fi32-n32".into(), + arch: "csky".into(), + options: TargetOptions { + abi: "abiv2".into(), + features: "+2e3,+3e7,+7e10,+cache,+dsp1e2,+dspe60,+e1,+e2,+edsp,+elrw,+hard-tp,+high-registers,+hwdiv,+mp,+mp1e2,+nvic,+trust".into(), + late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-l:libatomic.a"]), + max_atomic_width: Some(32), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs new file mode 100644 index 000000000..0ce271c60 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +// This target is for glibc Linux on Csky + +pub fn target() -> Target { + Target { + //https://github.com/llvm/llvm-project/blob/8b76aea8d8b1b71f6220bc2845abc749f18a19b7/clang/lib/Basic/Targets/CSKY.h + llvm_target: "csky-unknown-linux-gnuabiv2".into(), + pointer_width: 32, + data_layout: "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32-v128:32:32-a:0:32-Fi32-n32".into(), + arch: "csky".into(), + options: TargetOptions { + abi: "abiv2hf".into(), + cpu: "ck860fv".into(), + features: "+hard-float,+hard-float-abi,+2e3,+3e7,+7e10,+cache,+dsp1e2,+dspe60,+e1,+e2,+edsp,+elrw,+hard-tp,+high-registers,+hwdiv,+mp,+mp1e2,+nvic,+trust".into(), + late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-l:libatomic.a", "-mhard-float"]), + max_atomic_width: Some(32), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs new file mode 100644 index 000000000..98a5e7abd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs @@ -0,0 +1,29 @@ +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "hexagonv60".into(); + base.max_atomic_width = Some(32); + // FIXME: HVX length defaults are per-CPU + base.features = "-small-data,+hvx-length128b".into(); + + base.crt_static_default = false; + base.has_rpath = true; + base.linker_flavor = LinkerFlavor::Unix(Cc::Yes); + + base.c_enum_min_bits = Some(8); + + Target { + llvm_target: "hexagon-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: concat!( + "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32", + ":32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32", + ":32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048", + ":2048:2048" + ) + .into(), + arch: "hexagon".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i386_apple_ios.rs b/compiler/rustc_target/src/spec/targets/i386_apple_ios.rs new file mode 100644 index 000000000..ed2c990ff --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i386_apple_ios.rs @@ -0,0 +1,23 @@ +use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch}; +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::I386; + Target { + // Clang automatically chooses a more specific target based on + // IPHONEOS_DEPLOYMENT_TARGET. + // This is required for the target to pick the right + // MACH-O commands, so we do too. + llvm_target: ios_sim_llvm_target(arch).into(), + pointer_width: 32, + data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:128-n8:16:32-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { + max_atomic_width: Some(64), + stack_probes: StackProbeType::X86, + ..opts("ios", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i386_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i386_unknown_linux_gnu.rs new file mode 100644 index 000000000..801a88933 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i386_unknown_linux_gnu.rs @@ -0,0 +1,8 @@ +use crate::spec::Target; + +pub fn target() -> Target { + let mut base = super::i686_unknown_linux_gnu::target(); + base.cpu = "i386".into(); + base.llvm_target = "i386-unknown-linux-gnu".into(); + base +} diff --git a/compiler/rustc_target/src/spec/targets/i486_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i486_unknown_linux_gnu.rs new file mode 100644 index 000000000..a11fbecc3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i486_unknown_linux_gnu.rs @@ -0,0 +1,8 @@ +use crate::spec::Target; + +pub fn target() -> Target { + let mut base = super::i686_unknown_linux_gnu::target(); + base.cpu = "i486".into(); + base.llvm_target = "i486-unknown-linux-gnu".into(); + base +} diff --git a/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs b/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs new file mode 100644 index 000000000..060893916 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs @@ -0,0 +1,23 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "i586-pc-unknown".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: TargetOptions { + cpu: "pentium4".into(), + max_atomic_width: Some(64), + pre_link_args: TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-Vgcc_ntox86_cxx"], + ), + env: "nto70".into(), + stack_probes: StackProbeType::X86, + ..base::nto_qnx::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i586_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i586_pc_windows_msvc.rs new file mode 100644 index 000000000..befb0f89f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i586_pc_windows_msvc.rs @@ -0,0 +1,8 @@ +use crate::spec::Target; + +pub fn target() -> Target { + let mut base = super::i686_pc_windows_msvc::target(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-pc-windows-msvc".into(); + base +} diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs new file mode 100644 index 000000000..b699a7af1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs @@ -0,0 +1,8 @@ +use crate::spec::Target; + +pub fn target() -> Target { + let mut base = super::i686_unknown_linux_gnu::target(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-unknown-linux-gnu".into(); + base +} diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs new file mode 100644 index 000000000..55a26eb00 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs @@ -0,0 +1,8 @@ +use crate::spec::Target; + +pub fn target() -> Target { + let mut base = super::i686_unknown_linux_musl::target(); + base.cpu = "pentium".into(); + base.llvm_target = "i586-unknown-linux-musl".into(); + base +} diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs new file mode 100644 index 000000000..8375fa4c0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.cpu = "pentium".into(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Call; + + Target { + llvm_target: "i586-unknown-netbsdelf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs new file mode 100644 index 000000000..242fe5ed9 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs @@ -0,0 +1,27 @@ +use crate::spec::base::apple::{macos_llvm_target, opts, Arch}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + // ld64 only understands i386 and not i686 + let arch = Arch::I386; + let mut base = opts("macos", arch); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::X86; + base.frame_pointer = FramePointer::Always; + + Target { + // Clang automatically chooses a more specific target based on + // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work + // correctly, we do too. + // + // While ld64 doesn't understand i686, LLVM does. + llvm_target: macos_llvm_target(Arch::I686).into(), + pointer_width: 32, + data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:128-n8:16:32-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_linux_android.rs b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs new file mode 100644 index 000000000..987265598 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs @@ -0,0 +1,25 @@ +use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions}; + +// See https://developer.android.com/ndk/guides/abis.html#x86 +// for target ABI requirements. + +pub fn target() -> Target { + let mut base = base::android::opts(); + + base.max_atomic_width = Some(64); + + // https://developer.android.com/ndk/guides/abis.html#x86 + base.cpu = "pentiumpro".into(); + base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into(); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-linux-android".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs new file mode 100644 index 000000000..8d4a39b58 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs @@ -0,0 +1,27 @@ +use crate::spec::{base, Cc, FramePointer, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_gnu::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.frame_pointer = FramePointer::Always; // Required for backtraces + base.linker = Some("i686-w64-mingw32-gcc".into()); + + // Mark all dynamic libraries and executables as compatible with the larger 4GiB address + // space available to x86 Windows binaries on x86_64. + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["-m", "i386pe", "--large-address-aware"], + ); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]); + + Target { + llvm_target: "i686-pc-windows-gnu".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:32-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs new file mode 100644 index 000000000..bb410cd8c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Cc, FramePointer, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_gnullvm::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.frame_pointer = FramePointer::Always; // Required for backtraces + base.linker = Some("i686-w64-mingw32-clang".into()); + + // Mark all dynamic libraries and executables as compatible with the larger 4GiB address + // space available to x86 Windows binaries on x86_64. + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["-m", "i386pe", "--large-address-aware"], + ); + + Target { + llvm_target: "i686-pc-windows-gnu".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:32-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs new file mode 100644 index 000000000..ba80c2319 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs @@ -0,0 +1,32 @@ +use crate::spec::{base, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_msvc::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + + base.add_pre_link_args( + LinkerFlavor::Msvc(Lld::No), + &[ + // Mark all dynamic libraries and executables as compatible with the larger 4GiB address + // space available to x86 Windows binaries on x86_64. + "/LARGEADDRESSAWARE", + // Ensure the linker will only produce an image if it can also produce a table of + // the image's safe exception handlers. + // https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers + "/SAFESEH", + ], + ); + // Workaround for #95429 + base.has_thread_local = false; + + Target { + llvm_target: "i686-pc-windows-msvc".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:128-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs new file mode 100644 index 000000000..70aa0b479 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::freebsd::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-freebsd".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs new file mode 100644 index 000000000..9715f6c21 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::haiku::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-haiku".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs new file mode 100644 index 000000000..9102673ef --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::hurd_gnu::opts(); + base.cpu = "pentiumpro".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) }; + + Target { + llvm_target: "i686-unknown-hurd-gnu".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs new file mode 100644 index 000000000..0ca058b2f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.supported_sanitizers = SanitizerSet::ADDRESS; + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs new file mode 100644 index 000000000..ce0df3a72 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs @@ -0,0 +1,33 @@ +use crate::spec::{base, Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]); + base.stack_probes = StackProbeType::X86; + + // The unwinder used by i686-unknown-linux-musl, the LLVM libunwind + // implementation, apparently relies on frame pointers existing... somehow. + // It's not clear to me why nor where this dependency is introduced, but the + // test suite does not pass with frame pointers eliminated and it passes + // with frame pointers present. + // + // If you think that this is no longer necessary, then please feel free to + // ignore! If it still passes the test suite and the bots then sounds good + // to me. + // + // This may or may not be related to this bug: + // https://llvm.org/bugs/show_bug.cgi?id=30879 + base.frame_pointer = FramePointer::Always; + + Target { + llvm_target: "i686-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs new file mode 100644 index 000000000..2a3ac5932 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-netbsdelf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs new file mode 100644 index 000000000..45883542b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::openbsd::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-openbsd".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs new file mode 100644 index 000000000..25315e19c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs @@ -0,0 +1,89 @@ +// This defines the ia32 target for UEFI systems as described in the UEFI specification. See the +// uefi-base module for generic UEFI options. On ia32 systems +// UEFI systems always run in protected-mode, have the interrupt-controller pre-configured and +// force a single-CPU execution. +// The cdecl ABI is used. It differs from the stdcall or fastcall ABI. +// "i686-unknown-windows" is used to get the minimal subset of windows-specific features. + +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::uefi_msvc::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + + // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to + // enable these CPU features explicitly before their first use, otherwise their instructions + // will trigger an exception. Rust does not inject any code that enables AVX/MMX/SSE + // instruction sets, so this must be done by the firmware. However, existing firmware is known + // to leave these uninitialized, thus triggering exceptions if we make use of them. Which is + // why we avoid them and instead use soft-floats. This is also what GRUB and friends did so + // far. + // If you initialize FP units yourself, you can override these flags with custom linker + // arguments, thus giving you access to full MMX/SSE acceleration. + base.features = "-mmx,-sse,+soft-float".into(); + + // Use -GNU here, because of the reason below: + // Background and Problem: + // If we use i686-unknown-windows, the LLVM IA32 MSVC generates compiler intrinsic + // _alldiv, _aulldiv, _allrem, _aullrem, _allmul, which will cause undefined symbol. + // A real issue is __aulldiv() is referred by __udivdi3() - udivmod_inner!(), from + // https://github.com/rust-lang-nursery/compiler-builtins. + // As result, rust-lld generates link error finally. + // Root-cause: + // In rust\src\llvm-project\llvm\lib\Target\X86\X86ISelLowering.cpp, + // we have below code to use MSVC intrinsics. It assumes MSVC target + // will link MSVC library. But that is NOT true in UEFI environment. + // UEFI does not link any MSVC or GCC standard library. + // if (Subtarget.isTargetKnownWindowsMSVC() || + // Subtarget.isTargetWindowsItanium()) { + // // Setup Windows compiler runtime calls. + // setLibcallName(RTLIB::SDIV_I64, "_alldiv"); + // setLibcallName(RTLIB::UDIV_I64, "_aulldiv"); + // setLibcallName(RTLIB::SREM_I64, "_allrem"); + // setLibcallName(RTLIB::UREM_I64, "_aullrem"); + // setLibcallName(RTLIB::MUL_I64, "_allmul"); + // setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::X86_StdCall); + // setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::X86_StdCall); + // setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::X86_StdCall); + // setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::X86_StdCall); + // setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::X86_StdCall); + // } + // The compiler intrinsics should be implemented by compiler-builtins. + // Unfortunately, compiler-builtins has not provided those intrinsics yet. Such as: + // i386/divdi3.S + // i386/lshrdi3.S + // i386/moddi3.S + // i386/muldi3.S + // i386/udivdi3.S + // i386/umoddi3.S + // Possible solution: + // 1. Eliminate Intrinsics generation. + // 1.1 Choose different target to bypass isTargetKnownWindowsMSVC(). + // 1.2 Remove the "Setup Windows compiler runtime calls" in LLVM + // 2. Implement Intrinsics. + // We evaluated all options. + // #2 is hard because we need implement the intrinsics (_aulldiv) generated + // from the other intrinsics (__udivdi3) implementation with the same + // functionality (udivmod_inner). If we let _aulldiv() call udivmod_inner!(), + // then we are in loop. We may have to find another way to implement udivmod_inner!(). + // #1.2 may break the existing usage. + // #1.1 seems the simplest solution today. + // The IA32 -gnu calling convention is same as the one defined in UEFI specification. + // It uses cdecl, EAX/ECX/EDX as volatile register, and EAX/EDX as return value. + // We also checked the LLVM X86TargetLowering, the differences between -gnu and -msvc + // is fmodf(f32), longjmp() and TLS. None of them impacts the UEFI code. + // As a result, we choose -gnu for i686 version before those intrinsics are implemented in + // compiler-builtins. After compiler-builtins implements all required intrinsics, we may + // remove -gnu and use the default one. + Target { + llvm_target: "i686-unknown-windows-gnu".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:32-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs new file mode 100644 index 000000000..ec211a710 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Cc, FramePointer, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_uwp_gnu::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.frame_pointer = FramePointer::Always; // Required for backtraces + + // Mark all dynamic libraries and executables as compatible with the larger 4GiB address + // space available to x86 Windows binaries on x86_64. + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["-m", "i386pe", "--large-address-aware"], + ); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]); + + Target { + llvm_target: "i686-pc-windows-gnu".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:32-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs new file mode 100644 index 000000000..7cca2fc6b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_uwp_msvc::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "i686-pc-windows-msvc".into(), + pointer_width: 32, + data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:128-n8:16:32-a:0:32-S32" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs new file mode 100644 index 000000000..965a89597 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::vxworks::opts(); + base.cpu = "pentium4".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "i686-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + f64:32:64-f80:32-n8:16:32-S128" + .into(), + arch: "x86".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs new file mode 100644 index 000000000..0f05e7c47 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "loongarch64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "loongarch64".into(), + options: TargetOptions { + cpu: "generic".into(), + features: "+f,+d".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs new file mode 100644 index 000000000..3b1ea8e20 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs @@ -0,0 +1,23 @@ +use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "loongarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "loongarch64".into(), + options: TargetOptions { + cpu: "generic".into(), + features: "+f,+d".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + code_model: Some(CodeModel::Small), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs new file mode 100644 index 000000000..ab9300ef9 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs @@ -0,0 +1,24 @@ +use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "loongarch64-unknown-none".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(), + arch: "loongarch64".into(), + options: TargetOptions { + cpu: "generic".into(), + features: "-f,-d".into(), + abi: "softfloat".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + llvm_abiname: "lp64s".into(), + max_atomic_width: Some(64), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, + code_model: Some(CodeModel::Small), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs new file mode 100644 index 000000000..b54f5d753 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs @@ -0,0 +1,16 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "M68020".into(); + base.max_atomic_width = Some(32); + + Target { + llvm_target: "m68k-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), + arch: "m68k".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs new file mode 100644 index 000000000..6191a6dfd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs @@ -0,0 +1,26 @@ +/// A target tuple for OpenWrt MIPS64 targets +/// +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2,+soft-float".into(); + base.max_atomic_width = Some(64); + base.crt_static_default = false; + + Target { + // LLVM doesn't recognize "muslabi64" yet. + llvm_target: "mips64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { + abi: "abi64".into(), + endian: Endian::Big, + mcount: "_mcount".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs new file mode 100644 index 000000000..e1131f07f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs @@ -0,0 +1,22 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mips64-unknown-linux-gnuabi64".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { + abi: "abi64".into(), + endian: Endian::Big, + // NOTE(mips64r2) matches C toolchain + cpu: "mips64r2".into(), + features: "+mips64r2,+xgot".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs new file mode 100644 index 000000000..147c1c224 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs @@ -0,0 +1,22 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2".into(); + base.max_atomic_width = Some(64); + Target { + // LLVM doesn't recognize "muslabi64" yet. + llvm_target: "mips64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { + abi: "abi64".into(), + endian: Endian::Big, + mcount: "_mcount".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs new file mode 100644 index 000000000..4c612554d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mips64el-unknown-linux-gnuabi64".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { + abi: "abi64".into(), + // NOTE(mips64r2) matches C toolchain + cpu: "mips64r2".into(), + features: "+mips64r2,+xgot".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs new file mode 100644 index 000000000..d60404f0c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "mips64r2".into(); + base.features = "+mips64r2".into(); + base.max_atomic_width = Some(64); + Target { + // LLVM doesn't recognize "muslabi64" yet. + llvm_target: "mips64el-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64".into(), + options: TargetOptions { abi: "abi64".into(), mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs new file mode 100644 index 000000000..c49b89bbd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs @@ -0,0 +1,20 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mips-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { + endian: Endian::Big, + cpu: "mips32r2".into(), + features: "+mips32r2,+fpxx,+nooddspreg".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs new file mode 100644 index 000000000..92d2d9d84 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "mips32r2".into(); + base.features = "+mips32r2,+soft-float".into(); + base.max_atomic_width = Some(32); + base.crt_static_default = false; + Target { + llvm_target: "mips-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs new file mode 100644 index 000000000..51df0a974 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs @@ -0,0 +1,20 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mips-unknown-linux-uclibc".into(), + pointer_width: 32, + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { + endian: Endian::Big, + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_uclibc::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs new file mode 100644 index 000000000..75beb91b1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs @@ -0,0 +1,36 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; + +// The PSP has custom linker requirements. +const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); + +pub fn target() -> Target { + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["--emit-relocs", "--nmagic"], + ); + + Target { + llvm_target: "mipsel-sony-psp".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + os: "psp".into(), + vendor: "sony".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + cpu: "mips2".into(), + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + + // PSP FPU only supports single precision floats. + features: "+single-float".into(), + + // PSP does not support trap-on-condition instructions. + llvm_args: cvs!["-mno-check-zero-division"], + pre_link_args, + link_script: Some(LINKER_SCRIPT.into()), + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_sony_psp_linker_script.ld b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp_linker_script.ld new file mode 100644 index 000000000..9eb35ad9f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp_linker_script.ld @@ -0,0 +1,45 @@ +ENTRY(module_start) +SECTIONS +{ + /* PRX format requires text to begin at 0 */ + .text 0 : { *(.text .text.*) } + + /* Sort stubs for convenient ordering */ + .sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) } + + /* PSP import library stub sections. Bundles together `.lib.stub.entry.*` + * sections for better `--gc-sections` support. */ + .lib.stub.top : { *(.lib.stub.top) } + .lib.stub : { *(.lib.stub) *(.lib.stub.entry.*) } + .lib.stub.btm : { *(.lib.stub.btm) } + + /* Keep these sections around, even though they may appear unused to the linker */ + .lib.ent.top : { KEEP(*(.lib.ent.top)) } + .lib.ent : { KEEP(*(.lib.ent)) } + .lib.ent.btm : { KEEP(*(.lib.ent.btm)) } + + .eh_frame_hdr : { *(.eh_frame_hdr) } + + /* Add symbols for LLVM's libunwind */ + __eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0; + __eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0; + .eh_frame : + { + __eh_frame_start = .; + KEEP(*(.eh_frame)) + __eh_frame_end = .; + } + + /* These are explicitly listed to avoid being merged into .rodata */ + .rodata.sceResident : { *(.rodata.sceResident) *(.rodata.sceResident.*) } + .rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) } + /* Sort NIDs for convenient ordering */ + .rodata.sceNid : { *(.rodata.sceNid) *(SORT(.rodata.sceNid.*)) } + + .rodata : { *(.rodata .rodata.*) } + .data : { *(.data .data.*) } + .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } + .bss : { *(.bss .bss.*) } + + /DISCARD/ : { *(.rel.sceStub.text .MIPS.abiflags .reginfo) } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs b/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs new file mode 100644 index 000000000..12a66efdd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs @@ -0,0 +1,37 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsel-sony-psx".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + os: "none".into(), + env: "psx".into(), + vendor: "sony".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + cpu: "mips1".into(), + executables: true, + linker: Some("rust-lld".into()), + relocation_model: RelocModel::Static, + exe_suffix: ".exe".into(), + + // PSX doesn't natively support floats. + features: "+soft-float".into(), + + // This should be 16 bits, but LLVM incorrectly tries emitting MIPS-II SYNC instructions + // for atomic loads and stores. This crashes rustc so we have to disable the Atomic* API + // until this is fixed upstream. See https://reviews.llvm.org/D122427#3420144 for more + // info. + max_atomic_width: Some(0), + + // PSX does not support trap-on-condition instructions. + llvm_args: cvs!["-mno-check-zero-division"], + llvm_abiname: "o32".into(), + panic_strategy: PanicStrategy::Abort, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs new file mode 100644 index 000000000..c2e482148 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsel-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + cpu: "mips32r2".into(), + features: "+mips32r2,+fpxx,+nooddspreg".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs new file mode 100644 index 000000000..5eed05045 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs @@ -0,0 +1,16 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "mips32r2".into(); + base.features = "+mips32r2,+soft-float".into(); + base.max_atomic_width = Some(32); + base.crt_static_default = false; + Target { + llvm_target: "mipsel-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs new file mode 100644 index 000000000..77e69119d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsel-unknown-linux-uclibc".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_uclibc::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs new file mode 100644 index 000000000..706a1af3e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs @@ -0,0 +1,21 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.max_atomic_width = Some(32); + base.cpu = "mips32".into(); + + Target { + llvm_target: "mipsel-unknown-netbsd".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + options: TargetOptions { + features: "+soft-float".into(), + mcount: "__mcount".into(), + endian: Endian::Little, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs new file mode 100644 index 000000000..43b01e7a0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs @@ -0,0 +1,26 @@ +//! Bare MIPS32r2, little endian, softfloat, O32 calling convention +//! +//! Can be used for MIPS M4K core (e.g. on PIC32MX devices) + +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsel-unknown-none".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + cpu: "mips32r2".into(), + features: "+mips32r2,+soft-float,+noabicalls".into(), + max_atomic_width: Some(32), + linker: Some("rust-lld".into()), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs new file mode 100644 index 000000000..59783882e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs @@ -0,0 +1,20 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsisa32r6-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips32r6".into(), + options: TargetOptions { + endian: Endian::Big, + cpu: "mips32r6".into(), + features: "+mips32r6".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs new file mode 100644 index 000000000..c3d79412e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsisa32r6el-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), + arch: "mips32r6".into(), + + options: TargetOptions { + cpu: "mips32r6".into(), + features: "+mips32r6".into(), + max_atomic_width: Some(32), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs new file mode 100644 index 000000000..2ae6e7521 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs @@ -0,0 +1,22 @@ +use crate::abi::Endian; +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsisa64r6-unknown-linux-gnuabi64".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64r6".into(), + options: TargetOptions { + abi: "abi64".into(), + endian: Endian::Big, + // NOTE(mips64r6) matches C toolchain + cpu: "mips64r6".into(), + features: "+mips64r6".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs new file mode 100644 index 000000000..31637e9f6 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "mipsisa64r6el-unknown-linux-gnuabi64".into(), + pointer_width: 64, + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "mips64r6".into(), + options: TargetOptions { + abi: "abi64".into(), + // NOTE(mips64r6) matches C toolchain + cpu: "mips64r6".into(), + features: "+mips64r6".into(), + max_atomic_width: Some(64), + mcount: "_mcount".into(), + + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs b/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs new file mode 100644 index 000000000..251fd2a0a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs @@ -0,0 +1,59 @@ +use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "msp430-none-elf".into(), + pointer_width: 16, + data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".into(), + arch: "msp430".into(), + + options: TargetOptions { + c_int_width: "16".into(), + + // The LLVM backend currently can't generate object files. To + // workaround this LLVM generates assembly files which then we feed + // to gcc to get object files. For this reason we have a hard + // dependency on this specific gcc. + asm_args: cvs!["-mcpu=msp430"], + linker: Some("msp430-elf-gcc".into()), + linker_flavor: LinkerFlavor::Unix(Cc::Yes), + + // There are no atomic CAS instructions available in the MSP430 + // instruction set, and the LLVM backend doesn't currently support + // compiler fences so the Atomic* API is missing on this target. + // When the LLVM backend gains support for compile fences uncomment + // the `singlethread: true` line and set `max_atomic_width` to + // `Some(16)`. + max_atomic_width: Some(0), + atomic_cas: false, + // singlethread: true, + + // Because these devices have very little resources having an + // unwinder is too onerous so we default to "abort" because the + // "unwind" strategy is very rare. + panic_strategy: PanicStrategy::Abort, + + // Similarly, one almost always never wants to use relocatable + // code because of the extra costs it involves. + relocation_model: RelocModel::Static, + + // Right now we invoke an external assembler and this isn't + // compatible with multiple codegen units, and plus we probably + // don't want to invoke that many gcc instances. + default_codegen_units: Some(1), + + // Since MSP430 doesn't meaningfully support faulting on illegal + // instructions, LLVM generates a call to abort() function instead + // of a trap instruction. Such calls are 4 bytes long, and that is + // too much overhead for such small target. + trap_unreachable: false, + + // See the thumb_base.rs file for an explanation of this value + emit_debug_gdb_scripts: false, + + eh_frame_header: false, + + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs new file mode 100644 index 000000000..b0582b235 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -0,0 +1,52 @@ +use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + arch: "nvptx64".into(), + data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(), + llvm_target: "nvptx64-nvidia-cuda".into(), + pointer_width: 64, + + options: TargetOptions { + os: "cuda".into(), + vendor: "nvidia".into(), + linker_flavor: LinkerFlavor::Ptx, + // The linker can be installed from `crates.io`. + linker: Some("rust-ptx-linker".into()), + + // With `ptx-linker` approach, it can be later overridden via link flags. + cpu: "sm_30".into(), + + // FIXME: create tests for the atomics. + max_atomic_width: Some(64), + + // Unwinding on CUDA is neither feasible nor useful. + panic_strategy: PanicStrategy::Abort, + + // Needed to use `dylib` and `bin` crate types and the linker. + dynamic_linking: true, + + // Avoid using dylib because it contain metadata not supported + // by LLVM NVPTX backend. + only_cdylib: true, + + // Let the `ptx-linker` to handle LLVM lowering into MC / assembly. + obj_is_bitcode: true, + + // Convenient and predicable naming scheme. + dll_prefix: "".into(), + dll_suffix: ".ptx".into(), + exe_suffix: ".ptx".into(), + + // Disable MergeFunctions LLVM optimisation pass because it can + // produce kernel functions that call other kernel functions. + // This behavior is not supported by PTX ISA. + merge_functions: MergeFunctions::Disabled, + + // The LLVM backend does not support stack canaries for this target + supports_stack_protector: false, + + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs new file mode 100644 index 000000000..c512e4c7c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut base = base::aix::opts(); + base.max_atomic_width = Some(64); + base.add_pre_link_args( + LinkerFlavor::Unix(Cc::No), + &["-b64", "-bpT:0x100000000", "-bpD:0x110000000", "-bcdtors:all:0:s"], + ); + + Target { + llvm_target: "powerpc64-ibm-aix".into(), + pointer_width: 64, + data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs new file mode 100644 index 000000000..e470ec05e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::freebsd::opts(); + base.cpu = "ppc64".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64-unknown-freebsd".into(), + pointer_width: 64, + data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs new file mode 100644 index 000000000..34e3184d3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "ppc64".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs new file mode 100644 index 000000000..e2e707f4a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "ppc64".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs new file mode 100644 index 000000000..ebaeb04be --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::openbsd::opts(); + base.cpu = "ppc64".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64-unknown-openbsd".into(), + pointer_width: 64, + data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs new file mode 100644 index 000000000..e2085ba7c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::vxworks::opts(); + base.cpu = "ppc64".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { endian: Endian::Big, ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs new file mode 100644 index 000000000..b399d36d8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::freebsd::opts(); + base.cpu = "ppc64le".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64le-unknown-freebsd".into(), + pointer_width: 64, + data_layout: "e-m:e-Fn32-i64:64-n32:64".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs new file mode 100644 index 000000000..194c3170e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "ppc64le".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64le-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs new file mode 100644 index 000000000..1f53e6895 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "ppc64le".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc64le-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + arch: "powerpc64".into(), + options: TargetOptions { mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs new file mode 100644 index 000000000..6d094f9a3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs @@ -0,0 +1,26 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::freebsd::opts(); + // Extra hint to linker that we are generating secure-PLT code. + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-m32", "--target=powerpc-unknown-freebsd13.0"], + ); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-freebsd13.0".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { + endian: Endian::Big, + features: "+secure-plt".into(), + mcount: "_mcount".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs new file mode 100644 index 000000000..1600698da --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs new file mode 100644 index 000000000..af0fbfebe --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs @@ -0,0 +1,22 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-linux-gnuspe".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { + abi: "spe".into(), + endian: Endian::Big, + mcount: "_mcount".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs new file mode 100644 index 000000000..9b0ac4a0f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs new file mode 100644 index 000000000..bc2e239d9 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-netbsd".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs new file mode 100644 index 000000000..081aaaea2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::openbsd::opts(); + base.endian = Endian::Big; + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-openbsd".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs new file mode 100644 index 000000000..e8bccc153 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::vxworks::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "--secure-plt"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs new file mode 100644 index 000000000..fa4ef098e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs @@ -0,0 +1,23 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::vxworks::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe", "--secure-plt"]); + base.max_atomic_width = Some(32); + base.stack_probes = StackProbeType::Inline; + + Target { + llvm_target: "powerpc-unknown-linux-gnuspe".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), + arch: "powerpc".into(), + options: TargetOptions { + abi: "spe".into(), + endian: Endian::Big, + // feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2 + features: "+secure-plt,+msync".into(), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs new file mode 100644 index 000000000..06e8f1837 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv32-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + arch: "riscv32".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv32".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "ilp32d".into(), + max_atomic_width: Some(32), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs new file mode 100644 index 000000000..722703d23 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv32-unknown-linux-musl".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + arch: "riscv32".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv32".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "ilp32d".into(), + max_atomic_width: Some(32), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs new file mode 100644 index 000000000..75a65a268 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs @@ -0,0 +1,23 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), + max_atomic_width: Some(0), + atomic_cas: false, + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs new file mode 100644 index 000000000..f2242bbe0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs @@ -0,0 +1,24 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), + max_atomic_width: Some(0), + atomic_cas: false, + features: "+m".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs new file mode 100644 index 000000000..25f5c3bc2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs @@ -0,0 +1,31 @@ +use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + families: cvs!["unix"], + os: "espidf".into(), + env: "newlib".into(), + vendor: "espressif".into(), + linker: Some("riscv32-esp-elf-gcc".into()), + cpu: "generic-rv32".into(), + + // As RiscV32IMAC architecture does natively support atomics, + // automatically enable the support for the Rust STD library. + max_atomic_width: Some(32), + atomic_cas: true, + + features: "+m,+a,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs new file mode 100644 index 000000000..55c6e4d16 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs @@ -0,0 +1,23 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), + max_atomic_width: Some(32), + features: "+m,+a,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs new file mode 100644 index 000000000..a263e5d5c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs @@ -0,0 +1,22 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + os: "xous".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), + max_atomic_width: Some(32), + features: "+m,+a,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs new file mode 100644 index 000000000..3aa9923ee --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs @@ -0,0 +1,34 @@ +use crate::spec::{cvs, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + families: cvs!["unix"], + os: "espidf".into(), + env: "newlib".into(), + vendor: "espressif".into(), + linker: Some("riscv32-esp-elf-gcc".into()), + cpu: "generic-rv32".into(), + + // While the RiscV32IMC architecture does not natively support atomics, ESP-IDF does support + // the __atomic* and __sync* GCC builtins, so setting `max_atomic_width` to `Some(32)` + // and `atomic_cas` to `true` will cause the compiler to emit libcalls to these builtins. + // + // Support for atomics is necessary for the Rust STD library, which is supported by the ESP-IDF framework. + max_atomic_width: Some(32), + atomic_cas: true, + + features: "+m,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs new file mode 100644 index 000000000..01e773fae --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs @@ -0,0 +1,24 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), + llvm_target: "riscv32".into(), + pointer_width: 32, + arch: "riscv32".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv32".into(), + max_atomic_width: Some(0), + atomic_cas: false, + features: "+m,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs b/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs new file mode 100644 index 000000000..40e447dbb --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, CodeModel, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-linux-android".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c,+zba,+zbb,+zbs,+v".into(), + llvm_abiname: "lp64d".into(), + supported_sanitizers: SanitizerSet::ADDRESS, + max_atomic_width: Some(64), + ..base::android::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs new file mode 100644 index 000000000..2c7878de8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-freebsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + ..base::freebsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs new file mode 100644 index 000000000..a29470c24 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, CodeModel, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-fuchsia".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + supported_sanitizers: SanitizerSet::SHADOWCALLSTACK, + ..base::fuchsia::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs new file mode 100644 index 000000000..b7e29d2da --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, CodeModel, RelocModel, Target, TargetOptions, TlsModel}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-hermit".into(), + pointer_width: 64, + arch: "riscv64".into(), + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + options: TargetOptions { + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + relocation_model: RelocModel::Pic, + code_model: Some(CodeModel::Medium), + tls_model: TlsModel::LocalExec, + max_atomic_width: Some(64), + llvm_abiname: "lp64d".into(), + ..base::hermit::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs new file mode 100644 index 000000000..c0969d4e1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs new file mode 100644 index 000000000..656e260d0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs new file mode 100644 index 000000000..43a313a94 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + mcount: "__mcount".into(), + ..base::netbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs new file mode 100644 index 000000000..f29e22424 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs @@ -0,0 +1,28 @@ +use crate::spec::SanitizerSet; +use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; +use crate::spec::{RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + llvm_target: "riscv64".into(), + pointer_width: 64, + arch: "riscv64".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + llvm_abiname: "lp64d".into(), + cpu: "generic-rv64".into(), + max_atomic_width: Some(64), + features: "+m,+a,+f,+d,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + code_model: Some(CodeModel::Medium), + emit_debug_gdb_scripts: false, + eh_frame_header: false, + supported_sanitizers: SanitizerSet::KERNELADDRESS, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs new file mode 100644 index 000000000..1f1da7d5a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, CodeModel, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "riscv64-unknown-openbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + arch: "riscv64".into(), + options: TargetOptions { + code_model: Some(CodeModel::Medium), + cpu: "generic-rv64".into(), + features: "+m,+a,+f,+d,+c".into(), + llvm_abiname: "lp64d".into(), + max_atomic_width: Some(64), + ..base::openbsd::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs new file mode 100644 index 000000000..0f1821c99 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs @@ -0,0 +1,26 @@ +use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; +use crate::spec::{RelocModel, SanitizerSet, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), + llvm_target: "riscv64".into(), + pointer_width: 64, + arch: "riscv64".into(), + + options: TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + cpu: "generic-rv64".into(), + max_atomic_width: Some(64), + features: "+m,+a,+c".into(), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + code_model: Some(CodeModel::Medium), + emit_debug_gdb_scripts: false, + eh_frame_header: false, + supported_sanitizers: SanitizerSet::KERNELADDRESS, + ..Default::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs new file mode 100644 index 000000000..6fc410eb2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs @@ -0,0 +1,26 @@ +use crate::abi::Endian; +use crate::spec::{base, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.endian = Endian::Big; + // z10 is the oldest CPU supported by LLVM + base.cpu = "z10".into(); + // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector + // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we + // also strip v128 from the data_layout below to match the older LLVM's expectation. + base.features = "-vector".into(); + base.max_atomic_width = Some(64); + base.min_global_align = Some(16); + base.stack_probes = StackProbeType::Inline; + base.supported_sanitizers = + SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; + + Target { + llvm_target: "s390x-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), + arch: "s390x".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs new file mode 100644 index 000000000..03772aab3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs @@ -0,0 +1,27 @@ +use crate::abi::Endian; +use crate::spec::{base, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.endian = Endian::Big; + // z10 is the oldest CPU supported by LLVM + base.cpu = "z10".into(); + // FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector + // ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we + // also strip v128 from the data_layout below to match the older LLVM's expectation. + base.features = "-vector".into(); + base.max_atomic_width = Some(64); + base.min_global_align = Some(16); + base.static_position_independent_executables = true; + base.stack_probes = StackProbeType::Inline; + base.supported_sanitizers = + SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; + + Target { + llvm_target: "s390x-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), + arch: "s390x".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs new file mode 100644 index 000000000..20ec9a84e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.endian = Endian::Big; + base.cpu = "v9".into(); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "sparc64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs new file mode 100644 index 000000000..c8c0fd2e1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.cpu = "v9".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "sparc64-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), + options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs new file mode 100644 index 000000000..82ce61006 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::openbsd::opts(); + base.endian = Endian::Big; + base.cpu = "v9".into(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "sparc64-unknown-openbsd".into(), + pointer_width: 64, + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + arch: "sparc64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs new file mode 100644 index 000000000..548fbb9ed --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs @@ -0,0 +1,18 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.endian = Endian::Big; + base.cpu = "v9".into(); + base.max_atomic_width = Some(32); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mv8plus"]); + + Target { + llvm_target: "sparc-unknown-linux-gnu".into(), + pointer_width: 32, + data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), + arch: "sparc".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs new file mode 100644 index 000000000..7e908a0f3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs @@ -0,0 +1,27 @@ +use crate::abi::Endian; +use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; + +pub fn target() -> Target { + let options = TargetOptions { + linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), + linker: Some("sparc-elf-gcc".into()), + endian: Endian::Big, + cpu: "v7".into(), + abi: "elf".into(), + max_atomic_width: Some(32), + atomic_cas: true, + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + no_default_libraries: false, + emit_debug_gdb_scripts: false, + eh_frame_header: false, + ..Default::default() + }; + Target { + data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), + llvm_target: "sparc-unknown-none-elf".into(), + pointer_width: 32, + arch: "sparc".into(), + options, + } +} diff --git a/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs new file mode 100644 index 000000000..16cd991dd --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs @@ -0,0 +1,24 @@ +use crate::abi::Endian; +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut base = base::solaris::opts(); + base.endian = Endian::Big; + base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); + // llvm calls this "v9" + base.cpu = "v9".into(); + base.vendor = "sun".into(); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "sparcv9-sun-solaris".into(), + pointer_width: 64, + data_layout: "E-m:e-i64:64-n32:64-S128".into(), + // Use "sparc64" instead of "sparcv9" here, since the former is already + // used widely in the source base. If we ever needed ABI + // differentiation from the sparc64, we could, but that would probably + // just be confusing. + arch: "sparc64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs new file mode 100644 index 000000000..7b5c019b1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs @@ -0,0 +1,59 @@ +//! Targets the ARMv4T, with code as `t32` code by default. +//! +//! Primarily of use for the GBA, but usable with other devices too. +//! +//! Please ping @Lokathor if changes are needed. +//! +//! **Important:** This target profile **does not** specify a linker script. You +//! just get the default link script when you build a binary for this target. +//! The default link script is very likely wrong, so you should use +//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. + +use crate::spec::{base, PanicStrategy, RelocModel, Target, TargetOptions}; +use crate::spec::{cvs, FramePointer}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv4t-none-eabi".into(), + pointer_width: 32, + arch: "arm".into(), + /* Data layout args are '-' separated: + * little endian + * stack is 64-bit aligned (EABI) + * pointers are 32-bit + * i64 must be 64-bit aligned (EABI) + * mangle names with ELF style + * native integers are 32-bit + * All other elements are default + */ + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + options: TargetOptions { + abi: "eabi".into(), + + // extra args passed to the external assembler (assuming `arm-none-eabi-as`): + // * activate t32/a32 interworking + // * use arch ARMv4T + // * use little-endian + asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], + + // minimum extra features, these cannot be disabled via -C + // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. + // The resulting atomics are ABI incompatible with atomics backed by libatomic. + features: "+soft-float,+strict-align,+atomics-32".into(), + + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + // suggested from thumb_base, rust-lang/rust#44993. + emit_debug_gdb_scripts: false, + frame_pointer: FramePointer::MayOmit, + + main_needs_argc_argv: false, + + // don't have atomic compare-and-swap + atomic_cas: false, + has_thumb_interworking: true, + + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs new file mode 100644 index 000000000..d9212afb0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs @@ -0,0 +1,41 @@ +//! Targets the ARMv5TE, with code as `t32` code by default. + +use crate::spec::{base, cvs, FramePointer, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv5te-none-eabi".into(), + pointer_width: 32, + arch: "arm".into(), + /* Data layout args are '-' separated: + * little endian + * stack is 64-bit aligned (EABI) + * pointers are 32-bit + * i64 must be 64-bit aligned (EABI) + * mangle names with ELF style + * native integers are 32-bit + * All other elements are default + */ + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + + options: TargetOptions { + abi: "eabi".into(), + // extra args passed to the external assembler (assuming `arm-none-eabi-as`): + // * activate t32/a32 interworking + // * use arch ARMv5TE + // * use little-endian + asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",], + // minimum extra features, these cannot be disabled via -C + // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. + // The resulting atomics are ABI incompatible with atomics backed by libatomic. + features: "+soft-float,+strict-align,+atomics-32".into(), + frame_pointer: FramePointer::MayOmit, + main_needs_argc_argv: false, + // don't have atomic compare-and-swap + atomic_cas: false, + has_thumb_interworking: true, + + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs new file mode 100644 index 000000000..ac076fb88 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs @@ -0,0 +1,25 @@ +// Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv6m-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + // The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them + // with +strict-align. + // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. + // The resulting atomics are ABI incompatible with atomics backed by libatomic. + features: "+strict-align,+atomics-32".into(), + // There are no atomic CAS instructions available in the instruction set of the ARMv6-M + // architecture + atomic_cas: false, + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs new file mode 100644 index 000000000..128ac1dd1 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs @@ -0,0 +1,28 @@ +use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Target { + let mut base = base::windows_msvc::opts(); + // Prevent error LNK2013: BRANCH24(T) fixup overflow + // The LBR optimization tries to eliminate branch islands, + // but if the displacement is larger than can fit + // in the instruction, this error will occur. The linker + // should be smart enough to insert branch islands only + // where necessary, but this is not the observed behavior. + // Disabling the LBR optimization works around the issue. + base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/OPT:NOLBR"]); + + Target { + llvm_target: "thumbv7a-pc-windows-msvc".into(), + pointer_width: 32, + data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + features: "+vfp3,+neon".into(), + max_atomic_width: Some(64), + // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is + // implemented for windows/arm in LLVM + panic_strategy: PanicStrategy::Abort, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs new file mode 100644 index 000000000..810ed6a24 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, PanicStrategy, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv7a-pc-windows-msvc".into(), + pointer_width: 32, + data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + features: "+vfp3,+neon".into(), + max_atomic_width: Some(64), + // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is + // implemented for windows/arm in LLVM + panic_strategy: PanicStrategy::Abort, + ..base::windows_uwp_msvc::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs new file mode 100644 index 000000000..1752f1d9a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs @@ -0,0 +1,27 @@ +// Targets the Cortex-M4 and Cortex-M7 processors (ARMv7E-M) +// +// This target assumes that the device doesn't have a FPU (Floating Point Unit) and lowers all the +// floating point operations to software routines (intrinsics). +// +// As such, this target uses the "soft" calling convention (ABI) where floating point values are +// passed to/from subroutines via general purpose registers (R0, R1, etc.). +// +// To opt-in to hardware accelerated floating point operations, you can use, for example, +// `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv7em-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs new file mode 100644 index 000000000..c113c62fc --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs @@ -0,0 +1,36 @@ +// Targets the Cortex-M4F and Cortex-M7F processors (ARMv7E-M) +// +// This target assumes that the device does have a FPU (Floating Point Unit) and lowers all (single +// precision) floating point operations to hardware instructions. +// +// Additionally, this target uses the "hard" floating convention (ABI) where floating point values +// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.). +// +// To opt into double precision hardware support, use the `-C target-feature=+fp64` flag. + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv7em-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabihf".into(), + // `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the + // Cortex-M7 (vfp5) + // `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers + // available + // `-fp64` The Cortex-M4 only supports single precision floating point operations + // whereas in the Cortex-M7 double precision is optional + // + // Reference: + // ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension + features: "+vfp4,-d32,-fp64".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs new file mode 100644 index 000000000..f9ab3ce1a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs @@ -0,0 +1,18 @@ +// Targets the Cortex-M3 processor (ARMv7-M) + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv7m-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs new file mode 100644 index 000000000..c07aa944d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +// This target if is for the Android v7a ABI in thumb mode with +// NEON unconditionally enabled and, therefore, with 32 FPU registers +// enabled as well. See section A2.6.2 on page A2-56 in +// https://web.archive.org/web/20210307234416/https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf + +// See https://developer.android.com/ndk/guides/abis.html#v7a +// for target ABI requirements. + +pub fn target() -> Target { + let mut base = base::android::opts(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]); + Target { + llvm_target: "armv7-none-linux-android".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabi".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), + max_atomic_width: Some(64), + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs new file mode 100644 index 000000000..b4045037c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs @@ -0,0 +1,23 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for glibc Linux on ARMv7 with thumb mode enabled +// (for consistency with Android and Debian-based distributions) +// and with NEON unconditionally enabled and, therefore, with 32 FPU +// registers enabled as well. See section A2.6.2 on page A2-56 in +// https://web.archive.org/web/20210307234416/https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf + +pub fn target() -> Target { + Target { + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + options: TargetOptions { + abi: "eabihf".into(), + // Info about features at https://wiki.debian.org/ArmHardFloatPort + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), + max_atomic_width: Some(64), + ..base::linux_gnu::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs new file mode 100644 index 000000000..6ef30f10f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs @@ -0,0 +1,29 @@ +use crate::spec::{base, Target, TargetOptions}; + +// This target is for musl Linux on ARMv7 with thumb mode enabled +// (for consistency with Android and Debian-based distributions) +// and with NEON unconditionally enabled and, therefore, with 32 FPU +// registers enabled as well. See section A2.6.2 on page A2-56 in +// https://web.archive.org/web/20210307234416/https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf + +pub fn target() -> Target { + Target { + // It's important we use "gnueabihf" and not "musleabihf" here. LLVM + // uses it to determine the calling convention and float ABI, and LLVM + // doesn't support the "musleabihf" value. + llvm_target: "armv7-unknown-linux-gnueabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + // Most of these settings are copied from the thumbv7neon_unknown_linux_gnueabihf + // target. + options: TargetOptions { + abi: "eabihf".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), + max_atomic_width: Some(64), + mcount: "\u{1}mcount".into(), + ..base::linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs new file mode 100644 index 000000000..bf6257486 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs @@ -0,0 +1,21 @@ +// Targets the Cortex-M23 processor (Baseline ARMv8-M) + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv8m.base-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + // ARMv8-M baseline doesn't support unaligned loads/stores so we disable them + // with +strict-align. + features: "+strict-align".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs new file mode 100644 index 000000000..07fc7fead --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs @@ -0,0 +1,19 @@ +// Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), +// without the Floating Point extension. + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv8m.main-none-eabi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabi".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs new file mode 100644 index 000000000..61d4e8fc8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs @@ -0,0 +1,25 @@ +// Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), +// with the Floating Point extension. + +use crate::spec::{base, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "thumbv8m.main-none-eabihf".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), + arch: "arm".into(), + + options: TargetOptions { + abi: "eabihf".into(), + // If the Floating Point extension is implemented in the Cortex-M33 + // processor, the Cortex-M33 Technical Reference Manual states that + // the FPU uses the FPv5 architecture, single-precision instructions + // and 16 D registers. + // These parameters map to the following LLVM features. + features: "+fp-armv8,-fp64,-d32".into(), + max_atomic_width: Some(32), + ..base::thumb::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs new file mode 100644 index 000000000..394f02eca --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs @@ -0,0 +1,35 @@ +use crate::spec::{ + base, cvs, LinkArgs, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions, +}; + +pub fn target() -> Target { + // Reset flags for non-Em flavors back to empty to satisfy sanity checking tests. + let pre_link_args = LinkArgs::new(); + let post_link_args = TargetOptions::link_args( + LinkerFlavor::EmCc, + &["-sABORTING_MALLOC=0", "-Wl,--fatal-warnings"], + ); + + let opts = TargetOptions { + os: "emscripten".into(), + linker_flavor: LinkerFlavor::EmCc, + // emcc emits two files - a .js file to instantiate the wasm and supply platform + // functionality, and a .wasm file. + exe_suffix: ".js".into(), + linker: None, + pre_link_args, + post_link_args, + relocation_model: RelocModel::Pic, + panic_strategy: PanicStrategy::Unwind, + no_default_libraries: false, + families: cvs!["unix", "wasm"], + ..base::wasm::options() + }; + Target { + llvm_target: "wasm32-unknown-emscripten".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs new file mode 100644 index 000000000..2a40d9c66 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs @@ -0,0 +1,55 @@ +//! A "bare wasm" target representing a WebAssembly output that makes zero +//! assumptions about its environment. +//! +//! The `wasm32-unknown-unknown` target is intended to encapsulate use cases +//! that do not rely on any imported functionality. The binaries generated are +//! entirely self-contained by default when using the standard library. Although +//! the standard library is available, most of it returns an error immediately +//! (e.g. trying to create a TCP stream or something like that). +//! +//! This target is more or less managed by the Rust and WebAssembly Working +//! Group nowadays at . + +use crate::spec::abi::Abi; +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut options = base::wasm::options(); + options.os = "unknown".into(); + + // This is a default for backwards-compatibility with the original + // definition of this target oh-so-long-ago. Once the "wasm" ABI is + // stable and the wasm-bindgen project has switched to using it then there's + // no need for this and it can be removed. + // + // Currently this is the reason that this target's ABI is mismatched with + // clang's ABI. This means that, in the limit, you can't merge C and Rust + // code on this target due to this ABI mismatch. + options.default_adjusted_cabi = Some(Abi::Wasm); + + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::No), + &[ + // For now this target just never has an entry symbol no matter the output + // type, so unconditionally pass this. + "--no-entry", + ], + ); + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::Yes), + &[ + // Make sure clang uses LLD as its linker and is configured appropriately + // otherwise + "--target=wasm32-unknown-unknown", + "-Wl,--no-entry", + ], + ); + + Target { + llvm_target: "wasm32-unknown-unknown".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), + options, + } +} diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs new file mode 100644 index 000000000..6dbcb01ea --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasi.rs @@ -0,0 +1,119 @@ +//! The `wasm32-wasi` target is a new and still (as of April 2019) an +//! experimental target. The definition in this file is likely to be tweaked +//! over time and shouldn't be relied on too much. +//! +//! The `wasi` target is a proposal to define a standardized set of syscalls +//! that WebAssembly files can interoperate with. This set of syscalls is +//! intended to empower WebAssembly binaries with native capabilities such as +//! filesystem access, network access, etc. +//! +//! You can see more about the proposal at . +//! +//! The Rust target definition here is interesting in a few ways. We want to +//! serve two use cases here with this target: +//! +//! * First, we want Rust usage of the target to be as hassle-free as possible, +//! ideally avoiding the need to configure and install a local wasm32-wasi +//! toolchain. +//! +//! * Second, one of the primary use cases of LLVM's new wasm backend and the +//! wasm support in LLD is that any compiled language can interoperate with +//! any other. To that the `wasm32-wasi` target is the first with a viable C +//! standard library and sysroot common definition, so we want Rust and C/C++ +//! code to interoperate when compiled to `wasm32-unknown-unknown`. +//! +//! You'll note, however, that the two goals above are somewhat at odds with one +//! another. To attempt to solve both use cases in one go we define a target +//! that (ab)uses the `crt-static` target feature to indicate which one you're +//! in. +//! +//! ## No interop with C required +//! +//! By default the `crt-static` target feature is enabled, and when enabled +//! this means that the bundled version of `libc.a` found in `liblibc.rlib` +//! is used. This isn't intended really for interoperation with a C because it +//! may be the case that Rust's bundled C library is incompatible with a +//! foreign-compiled C library. In this use case, though, we use `rust-lld` and +//! some copied crt startup object files to ensure that you can download the +//! wasi target for Rust and you're off to the races, no further configuration +//! necessary. +//! +//! All in all, by default, no external dependencies are required. You can +//! compile `wasm32-wasi` binaries straight out of the box. You can't, however, +//! reliably interoperate with C code in this mode (yet). +//! +//! ## Interop with C required +//! +//! For the second goal we repurpose the `target-feature` flag, meaning that +//! you'll need to do a few things to have C/Rust code interoperate. +//! +//! 1. All Rust code needs to be compiled with `-C target-feature=-crt-static`, +//! indicating that the bundled C standard library in the Rust sysroot will +//! not be used. +//! +//! 2. If you're using rustc to build a linked artifact then you'll need to +//! specify `-C linker` to a `clang` binary that supports +//! `wasm32-wasi` and is configured with the `wasm32-wasi` sysroot. This +//! will cause Rust code to be linked against the libc.a that the specified +//! `clang` provides. +//! +//! 3. If you're building a staticlib and integrating Rust code elsewhere, then +//! compiling with `-C target-feature=-crt-static` is all you need to do. +//! +//! You can configure the linker via Cargo using the +//! `CARGO_TARGET_WASM32_WASI_LINKER` env var. Be sure to also set +//! `CC_wasm32-wasi` if any crates in the dependency graph are using the `cc` +//! crate. +//! +//! ## Remember, this is all in flux +//! +//! The wasi target is **very** new in its specification. It's likely going to +//! be a long effort to get it standardized and stable. We'll be following it as +//! best we can with this target. Don't start relying on too much here unless +//! you know what you're getting in to! + +use crate::spec::crt_objects; +use crate::spec::LinkSelfContainedDefault; +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut options = base::wasm::options(); + + options.os = "wasi".into(); + options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]); + + options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); + options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); + + // FIXME: Figure out cases in which WASM needs to link with a native toolchain. + options.link_self_contained = LinkSelfContainedDefault::True; + + // Right now this is a bit of a workaround but we're currently saying that + // the target by default has a static crt which we're taking as a signal + // for "use the bundled crt". If that's turned off then the system's crt + // will be used, but this means that default usage of this target doesn't + // need an external compiler but it's still interoperable with an external + // compiler if configured correctly. + options.crt_static_default = true; + options.crt_static_respected = true; + + // Allow `+crt-static` to create a "cdylib" output which is just a wasm file + // without a main function. + options.crt_static_allows_dylibs = true; + + // WASI's `sys::args::init` function ignores its arguments; instead, + // `args::args()` makes the WASI API calls itself. + options.main_needs_argc_argv = false; + + // And, WASI mangles the name of "main" to distinguish between different + // signatures. + options.entry_name = "__main_void".into(); + + Target { + llvm_target: "wasm32-wasi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), + options, + } +} diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs new file mode 100644 index 000000000..28ea4cc9e --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs @@ -0,0 +1,133 @@ +//! The `wasm32-wasi-preview1-threads` target is a new and still (as of July 2023) an +//! experimental target. The definition in this file is likely to be tweaked +//! over time and shouldn't be relied on too much. +//! +//! The `wasi-threads` target is a proposal to define a standardized set of syscalls +//! that WebAssembly files can interoperate with. This set of syscalls is +//! intended to empower WebAssembly binaries with native capabilities such as +//! threads, filesystem access, network access, etc. +//! +//! You can see more about the proposal at . +//! +//! The Rust target definition here is interesting in a few ways. We want to +//! serve two use cases here with this target: +//! +//! * First, we want Rust usage of the target to be as hassle-free as possible, +//! ideally avoiding the need to configure and install a local wasm32-wasi-preview1-threads +//! toolchain. +//! +//! * Second, one of the primary use cases of LLVM's new wasm backend and the +//! wasm support in LLD is that any compiled language can interoperate with +//! any other. To that the `wasm32-wasi-preview1-threads` target is the first with a viable C +//! standard library and sysroot common definition, so we want Rust and C/C++ +//! code to interoperate when compiled to `wasm32-unknown-unknown`. +//! +//! You'll note, however, that the two goals above are somewhat at odds with one +//! another. To attempt to solve both use cases in one go we define a target +//! that (ab)uses the `crt-static` target feature to indicate which one you're +//! in. +//! +//! ## No interop with C required +//! +//! By default the `crt-static` target feature is enabled, and when enabled +//! this means that the bundled version of `libc.a` found in `liblibc.rlib` +//! is used. This isn't intended really for interoperation with a C because it +//! may be the case that Rust's bundled C library is incompatible with a +//! foreign-compiled C library. In this use case, though, we use `rust-lld` and +//! some copied crt startup object files to ensure that you can download the +//! wasi target for Rust and you're off to the races, no further configuration +//! necessary. +//! +//! All in all, by default, no external dependencies are required. You can +//! compile `wasm32-wasi-preview1-threads` binaries straight out of the box. You can't, however, +//! reliably interoperate with C code in this mode (yet). +//! +//! ## Interop with C required +//! +//! For the second goal we repurpose the `target-feature` flag, meaning that +//! you'll need to do a few things to have C/Rust code interoperate. +//! +//! 1. All Rust code needs to be compiled with `-C target-feature=-crt-static`, +//! indicating that the bundled C standard library in the Rust sysroot will +//! not be used. +//! +//! 2. If you're using rustc to build a linked artifact then you'll need to +//! specify `-C linker` to a `clang` binary that supports +//! `wasm32-wasi-preview1-threads` and is configured with the `wasm32-wasi-preview1-threads` sysroot. This +//! will cause Rust code to be linked against the libc.a that the specified +//! `clang` provides. +//! +//! 3. If you're building a staticlib and integrating Rust code elsewhere, then +//! compiling with `-C target-feature=-crt-static` is all you need to do. +//! +//! You can configure the linker via Cargo using the +//! `CARGO_TARGET_WASM32_WASI_LINKER` env var. Be sure to also set +//! `CC_wasm32-wasi-preview1-threads` if any crates in the dependency graph are using the `cc` +//! crate. +//! +//! ## Remember, this is all in flux +//! +//! The wasi target is **very** new in its specification. It's likely going to +//! be a long effort to get it standardized and stable. We'll be following it as +//! best we can with this target. Don't start relying on too much here unless +//! you know what you're getting in to! + +use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut options = base::wasm::options(); + + options.os = "wasi".into(); + + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::No), + &["--import-memory", "--export-memory", "--shared-memory"], + ); + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::Yes), + &[ + "--target=wasm32-wasi-threads", + "-Wl,--import-memory", + "-Wl,--export-memory,", + "-Wl,--shared-memory", + ], + ); + + options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); + options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); + + // FIXME: Figure out cases in which WASM needs to link with a native toolchain. + options.link_self_contained = LinkSelfContainedDefault::True; + + // Right now this is a bit of a workaround but we're currently saying that + // the target by default has a static crt which we're taking as a signal + // for "use the bundled crt". If that's turned off then the system's crt + // will be used, but this means that default usage of this target doesn't + // need an external compiler but it's still interoperable with an external + // compiler if configured correctly. + options.crt_static_default = true; + options.crt_static_respected = true; + + // Allow `+crt-static` to create a "cdylib" output which is just a wasm file + // without a main function. + options.crt_static_allows_dylibs = true; + + // WASI's `sys::args::init` function ignores its arguments; instead, + // `args::args()` makes the WASI API calls itself. + options.main_needs_argc_argv = false; + + // And, WASI mangles the name of "main" to distinguish between different + // signatures. + options.entry_name = "__main_void".into(); + + options.singlethread = false; + options.features = "+atomics,+bulk-memory,+mutable-globals".into(); + + Target { + llvm_target: "wasm32-wasi".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), + options, + } +} diff --git a/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs new file mode 100644 index 000000000..54c5ae8e2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs @@ -0,0 +1,47 @@ +//! A "bare wasm" target representing a WebAssembly output that makes zero +//! assumptions about its environment. +//! +//! The `wasm64-unknown-unknown` target is intended to encapsulate use cases +//! that do not rely on any imported functionality. The binaries generated are +//! entirely self-contained by default when using the standard library. Although +//! the standard library is available, most of it returns an error immediately +//! (e.g. trying to create a TCP stream or something like that). + +use crate::spec::{base, Cc, LinkerFlavor, Target}; + +pub fn target() -> Target { + let mut options = base::wasm::options(); + options.os = "unknown".into(); + + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::No), + &[ + // For now this target just never has an entry symbol no matter the output + // type, so unconditionally pass this. + "--no-entry", + "-mwasm64", + ], + ); + options.add_pre_link_args( + LinkerFlavor::WasmLld(Cc::Yes), + &[ + // Make sure clang uses LLD as its linker and is configured appropriately + // otherwise + "--target=wasm64-unknown-unknown", + "-Wl,--no-entry", + ], + ); + + // Any engine that implements wasm64 will surely implement the rest of these + // features since they were all merged into the official spec by the time + // wasm64 was designed. + options.features = "+bulk-memory,+mutable-globals,+sign-ext,+nontrapping-fptoint".into(); + + Target { + llvm_target: "wasm64-unknown-unknown".into(), + pointer_width: 64, + data_layout: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm64".into(), + options, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs new file mode 100644 index 000000000..9170a10d2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs @@ -0,0 +1,26 @@ +use crate::spec::base::apple::{macos_llvm_target, opts, Arch}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::X86_64; + let mut base = opts("macos", arch); + base.max_atomic_width = Some(128); // penryn+ supports cmpxchg16b + base.frame_pointer = FramePointer::Always; + base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = + SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD; + + Target { + // Clang automatically chooses a more specific target based on + // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work + // correctly, we do too. + llvm_target: macos_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs new file mode 100644 index 000000000..d9f3f7de6 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs @@ -0,0 +1,21 @@ +use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch}; +use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::X86_64_sim; + let mut base = opts("ios", arch); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; + + Target { + llvm_target: ios_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { + max_atomic_width: Some(128), + stack_probes: StackProbeType::X86, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs new file mode 100644 index 000000000..5e6fbac34 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs @@ -0,0 +1,24 @@ +use crate::spec::base::apple::{opts, Arch}; +use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let llvm_target = "x86_64-apple-ios14.0-macabi"; + + let arch = Arch::X86_64_macabi; + let mut base = opts("ios", arch); + base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD; + + Target { + llvm_target: llvm_target.into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { + max_atomic_width: Some(128), + stack_probes: StackProbeType::X86, + ..base + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs new file mode 100644 index 000000000..1c4d9196c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs @@ -0,0 +1,18 @@ +use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch}; +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::X86_64_sim; + Target { + llvm_target: tvos_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { + max_atomic_width: Some(128), + stack_probes: StackProbeType::X86, + ..opts("tvos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs new file mode 100644 index 000000000..258148677 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs @@ -0,0 +1,30 @@ +use crate::spec::base::apple::{opts, watchos_sim_llvm_target, Arch}; +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::X86_64_sim; + Target { + llvm_target: watchos_sim_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { + max_atomic_width: Some(128), + stack_probes: StackProbeType::X86, + forces_embed_bitcode: true, + // Taken from a clang build on Xcode 11.4.1. + // These arguments are not actually invoked - they just have + // to look right to pass App Store validation. + bitcode_llvm_cmdline: "-triple\0\ + x86_64-apple-watchos5.0-simulator\0\ + -emit-obj\0\ + -disable-llvm-passes\0\ + -target-abi\0\ + darwinpcs\0\ + -Os\0" + .into(), + ..opts("watchos", arch) + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs new file mode 100644 index 000000000..f4117edc3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs @@ -0,0 +1,83 @@ +use std::borrow::Cow; + +use crate::spec::{cvs, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +pub fn target() -> Target { + let pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &[ + "-e", + "elf_entry", + "-Bstatic", + "--gc-sections", + "-z", + "text", + "-z", + "norelro", + "--no-undefined", + "--error-unresolved-symbols", + "--no-undefined-version", + "-Bsymbolic", + "--export-dynamic", + // The following symbols are needed by libunwind, which is linked after + // libstd. Make sure they're included in the link. + "-u", + "__rust_abort", + "-u", + "__rust_c_alloc", + "-u", + "__rust_c_dealloc", + "-u", + "__rust_print_err", + "-u", + "__rust_rwlock_rdlock", + "-u", + "__rust_rwlock_unlock", + "-u", + "__rust_rwlock_wrlock", + ], + ); + + const EXPORT_SYMBOLS: &[&str] = &[ + "sgx_entry", + "HEAP_BASE", + "HEAP_SIZE", + "RELA", + "RELACOUNT", + "ENCLAVE_SIZE", + "CFGDATA_BASE", + "DEBUG", + "EH_FRM_HDR_OFFSET", + "EH_FRM_HDR_LEN", + "EH_FRM_OFFSET", + "EH_FRM_LEN", + "TEXT_BASE", + "TEXT_SIZE", + ]; + let opts = TargetOptions { + os: "unknown".into(), + env: "sgx".into(), + vendor: "fortanix".into(), + abi: "fortanix".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + max_atomic_width: Some(64), + cpu: "x86-64".into(), + plt_by_default: false, + features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), + llvm_args: cvs!["--x86-experimental-lvi-inline-asm-hardening"], + position_independent_executables: true, + pre_link_args, + override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), + relax_elf_relocations: true, + ..Default::default() + }; + Target { + llvm_target: "x86_64-elf".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_fuchsia.rs b/compiler/rustc_target/src/spec/targets/x86_64_fuchsia.rs new file mode 100644 index 000000000..46df00e9c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_fuchsia.rs @@ -0,0 +1 @@ +pub use crate::spec::targets::x86_64_unknown_fuchsia::target; diff --git a/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs new file mode 100644 index 000000000..6cffda44f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs @@ -0,0 +1,24 @@ +use crate::spec::{ + base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions, +}; + +pub fn target() -> Target { + let mut base = base::android::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + // https://developer.android.com/ndk/guides/abis.html#86-64 + base.features = "+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-linux-android".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx710.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx710.rs new file mode 100644 index 000000000..93aec4c42 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_nto_qnx710.rs @@ -0,0 +1,22 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "x86_64-pc-unknown".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: TargetOptions { + cpu: "x86-64".into(), + plt_by_default: false, + max_atomic_width: Some(64), + pre_link_args: TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-Vgcc_ntox86_64_cxx"], + ), + env: "nto71".into(), + ..base::nto_qnx::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs new file mode 100644 index 000000000..ca6a6dc50 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::solaris::opts(); + base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.vendor = "pc".into(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; + + Target { + llvm_target: "x86_64-pc-solaris".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs new file mode 100644 index 000000000..6d3e07270 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_gnu::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + // Use high-entropy 64 bit address space for ASLR + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["-m", "i386pep", "--high-entropy-va"], + ); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]); + base.max_atomic_width = Some(64); + base.linker = Some("x86_64-w64-mingw32-gcc".into()); + + Target { + llvm_target: "x86_64-pc-windows-gnu".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs new file mode 100644 index 000000000..a56ebfa58 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_gnullvm::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.max_atomic_width = Some(64); + base.linker = Some("x86_64-w64-mingw32-clang".into()); + + Target { + llvm_target: "x86_64-pc-windows-gnu".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs new file mode 100644 index 000000000..7d6276a0c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_msvc::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + + Target { + llvm_target: "x86_64-pc-windows-msvc".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_sun_solaris.rs b/compiler/rustc_target/src/spec/targets/x86_64_sun_solaris.rs new file mode 100644 index 000000000..cca099d3b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_sun_solaris.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Cc, LinkerFlavor, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::solaris::opts(); + base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.vendor = "sun".into(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "x86_64-pc-solaris".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs b/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs new file mode 100644 index 000000000..c12cb1ab0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "x86_64-unknown-linux-musl".into(), + pointer_width: 64, + arch: "x86_64".into(), + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + options: TargetOptions { + cpu: "x86-64".into(), + plt_by_default: false, + pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]), + max_atomic_width: Some(64), + stack_probes: StackProbeType::X86, + ..base::unikraft_linux_musl::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs new file mode 100644 index 000000000..68d1a755b --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::dragonfly::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "x86_64-unknown-dragonfly".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs new file mode 100644 index 000000000..e3f29fa5a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs @@ -0,0 +1,22 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::freebsd::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = + SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::MEMORY | SanitizerSet::THREAD; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-unknown-freebsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs new file mode 100644 index 000000000..c8850d703 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::fuchsia::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI; + + Target { + llvm_target: "x86_64-unknown-fuchsia".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs new file mode 100644 index 000000000..ca55e6514 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::haiku::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + // This option is required to build executables on Haiku x86_64 + base.position_independent_executables = true; + + Target { + llvm_target: "x86_64-unknown-haiku".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs new file mode 100644 index 000000000..3cc50d40d --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "x86_64-unknown-hermit".into(), + pointer_width: 64, + arch: "x86_64".into(), + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + options: TargetOptions { + cpu: "x86-64".into(), + features: "+rdrnd,+rdseed".into(), + plt_by_default: false, + max_atomic_width: Some(64), + stack_probes: StackProbeType::X86, + ..base::hermit::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs new file mode 100644 index 000000000..eb2b13cb5 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs @@ -0,0 +1,21 @@ +use crate::spec::{base, Cc, LinkerFlavor, SanitizerSet, Target}; + +pub fn target() -> Target { + let mut base = base::illumos::opts(); + base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64", "-std=c99"]); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; + + Target { + // LLVM does not currently have a separate illumos target, + // so we still pass Solaris to it + llvm_target: "x86_64-pc-solaris".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs new file mode 100644 index 000000000..7b86fe738 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs @@ -0,0 +1,18 @@ +use crate::spec::{base, PanicStrategy, Target}; + +pub fn target() -> Target { + let mut base = base::l4re::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.panic_strategy = PanicStrategy::Abort; + + Target { + llvm_target: "x86_64-unknown-l4re-uclibc".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs new file mode 100644 index 000000000..80e267c16 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -0,0 +1,27 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.static_position_independent_executables = true; + base.supported_sanitizers = SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::SAFESTACK + | SanitizerSet::THREAD; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs new file mode 100644 index 000000000..622bfe8bb --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs @@ -0,0 +1,24 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_gnu::opts(); + base.cpu = "x86-64".into(); + base.abi = "x32".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mx32"]); + base.stack_probes = StackProbeType::X86; + base.has_thread_local = false; + // BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI + // breaks code gen. See LLVM bug 36743 + base.plt_by_default = true; + + Target { + llvm_target: "x86_64-unknown-linux-gnux32".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ + i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs new file mode 100644 index 000000000..d74ff466a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_musl::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.static_position_independent_executables = true; + base.supported_sanitizers = SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::THREAD; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs new file mode 100644 index 000000000..87b004df0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs @@ -0,0 +1,26 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::linux_ohos::opts(); + base.cpu = "x86-64".into(); + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.static_position_independent_executables = true; + base.supported_sanitizers = SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::THREAD; + base.supports_xray = true; + + Target { + // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. + llvm_target: "x86_64-unknown-linux-musl".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs new file mode 100644 index 000000000..04060513a --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs @@ -0,0 +1,27 @@ +use crate::spec::{ + base, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions, +}; + +pub fn target() -> Target { + let mut base = base::netbsd::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = SanitizerSet::ADDRESS + | SanitizerSet::CFI + | SanitizerSet::LEAK + | SanitizerSet::MEMORY + | SanitizerSet::THREAD; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: TargetOptions { mcount: "__mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs new file mode 100644 index 000000000..9aa95a35f --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs @@ -0,0 +1,38 @@ +// Generic x86-64 target for bare-metal code - Floating point disabled +// +// Can be used in conjunction with the `target-feature` and +// `target-cpu` compiler flags to opt-in more hardware-specific +// features. + +use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; +use crate::spec::{RelroLevel, SanitizerSet, StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let opts = TargetOptions { + cpu: "x86-64".into(), + plt_by_default: false, + max_atomic_width: Some(64), + stack_probes: StackProbeType::X86, + position_independent_executables: true, + static_position_independent_executables: true, + relro_level: RelroLevel::Full, + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + features: + "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float" + .into(), + supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, + disable_redzone: true, + panic_strategy: PanicStrategy::Abort, + code_model: Some(CodeModel::Kernel), + ..Default::default() + }; + Target { + llvm_target: "x86_64-unknown-none-elf".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: opts, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs new file mode 100644 index 000000000..5e6e7efb2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::openbsd::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supports_xray = true; + + Target { + llvm_target: "x86_64-unknown-openbsd".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs new file mode 100644 index 000000000..382ff71f0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs @@ -0,0 +1,19 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::redox::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + + Target { + llvm_target: "x86_64-unknown-redox".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs new file mode 100644 index 000000000..5abfb8162 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs @@ -0,0 +1,41 @@ +// This defines the amd64 target for UEFI systems as described in the UEFI specification. See the +// uefi-base module for generic UEFI options. On x86_64 systems (mostly called "x64" in the spec) +// UEFI systems always run in long-mode, have the interrupt-controller pre-configured and force a +// single-CPU execution. +// The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with +// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features. + +use crate::{ + abi::call::Conv, + spec::{base, Target}, +}; + +pub fn target() -> Target { + let mut base = base::uefi_msvc::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.entry_abi = Conv::X86_64Win64; + + // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to + // enable these CPU features explicitly before their first use, otherwise their instructions + // will trigger an exception. Rust does not inject any code that enables AVX/MMX/SSE + // instruction sets, so this must be done by the firmware. However, existing firmware is known + // to leave these uninitialized, thus triggering exceptions if we make use of them. Which is + // why we avoid them and instead use soft-floats. This is also what GRUB and friends did so + // far. + // + // If you initialize FP units yourself, you can override these flags with custom linker + // arguments, thus giving you access to full MMX/SSE acceleration. + base.features = "-mmx,-sse,+soft-float".into(); + + Target { + llvm_target: "x86_64-unknown-windows".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs new file mode 100644 index 000000000..a46d3a0e2 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs @@ -0,0 +1,23 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, Target}; + +pub fn target() -> Target { + let mut base = base::windows_uwp_gnu::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + // Use high-entropy 64 bit address space for ASLR + base.add_pre_link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["-m", "i386pep", "--high-entropy-va"], + ); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]); + base.max_atomic_width = Some(64); + + Target { + llvm_target: "x86_64-pc-windows-gnu".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs new file mode 100644 index 000000000..a3bc27aa0 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs @@ -0,0 +1,17 @@ +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut base = base::windows_uwp_msvc::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + + Target { + llvm_target: "x86_64-pc-windows-msvc".into(), + pointer_width: 64, + data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs new file mode 100644 index 000000000..4b221fe69 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs @@ -0,0 +1,20 @@ +use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = base::vxworks::opts(); + base.cpu = "x86-64".into(); + base.plt_by_default = false; + base.max_atomic_width = Some(64); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.disable_redzone = true; + + Target { + llvm_target: "x86_64-unknown-linux-gnu".into(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: "x86_64".into(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs new file mode 100644 index 000000000..a30e9d17c --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs @@ -0,0 +1,44 @@ +use crate::spec::base::apple::{macos_llvm_target, opts, Arch}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; +use crate::spec::{StackProbeType, Target, TargetOptions}; + +pub fn target() -> Target { + let arch = Arch::X86_64h; + let mut base = opts("macos", arch); + base.max_atomic_width = Some(128); + base.frame_pointer = FramePointer::Always; + base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); + base.stack_probes = StackProbeType::X86; + base.supported_sanitizers = + SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD; + + // x86_64h is core2-avx without a few of the features which would otherwise + // be guaranteed, so we need to disable those. This imitates clang's logic: + // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L77-L78 + // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L133-L141 + // + // FIXME: Sadly, turning these off here disables them in such a way that they + // aren't re-enabled by `-Ctarget-cpu=native` (on a machine that has them). + // It would be nice if this were not the case, but fixing it seems tricky + // (and given that the main use-case for this target is for use in universal + // binaries, probably not that important). + base.features = "-rdrnd,-aes,-pclmul,-rtm,-fsgsbase".into(); + // Double-check that the `cpu` is what we expect (if it's not the list above + // may need updating). + assert_eq!( + base.cpu, "core-avx2", + "you need to adjust the feature list in x86_64h-apple-darwin if you change this", + ); + + Target { + // Clang automatically chooses a more specific target based on + // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work + // correctly, we do too. + llvm_target: macos_llvm_target(arch).into(), + pointer_width: 64, + data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .into(), + arch: arch.target_arch(), + options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, + } +} diff --git a/compiler/rustc_target/src/spec/teeos_base.rs b/compiler/rustc_target/src/spec/teeos_base.rs deleted file mode 100644 index 1bc71bab0..000000000 --- a/compiler/rustc_target/src/spec/teeos_base.rs +++ /dev/null @@ -1,29 +0,0 @@ -use super::{Cc, LinkerFlavor, Lld, PanicStrategy}; -use crate::spec::{RelroLevel, TargetOptions}; - -pub fn opts() -> TargetOptions { - let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"]; - let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"]; - - let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args); - super::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args); - - TargetOptions { - os: "teeos".into(), - vendor: "unknown".into(), - dynamic_linking: true, - linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), - // rpath hardcodes -Wl, so it can't be used together with ld.lld. - // C TAs also don't support rpath, so this is fine. - has_rpath: false, - // Note: Setting has_thread_local to true causes an error when - // loading / dyn-linking the TA - has_thread_local: false, - position_independent_executables: true, - relro_level: RelroLevel::Full, - crt_static_respected: true, - pre_link_args, - panic_strategy: PanicStrategy::Abort, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/tests/tests_impl.rs b/compiler/rustc_target/src/spec/tests/tests_impl.rs index e0ecf8037..257867b1b 100644 --- a/compiler/rustc_target/src/spec/tests/tests_impl.rs +++ b/compiler/rustc_target/src/spec/tests/tests_impl.rs @@ -97,7 +97,7 @@ impl Target { ); } - if self.link_self_contained == LinkSelfContainedDefault::False { + if self.link_self_contained.is_disabled() { assert!( self.pre_link_objects_self_contained.is_empty() && self.post_link_objects_self_contained.is_empty() diff --git a/compiler/rustc_target/src/spec/thumb_base.rs b/compiler/rustc_target/src/spec/thumb_base.rs deleted file mode 100644 index 0decfecb4..000000000 --- a/compiler/rustc_target/src/spec/thumb_base.rs +++ /dev/null @@ -1,59 +0,0 @@ -// These `thumbv*` targets cover the ARM Cortex-M family of processors which are widely used in -// microcontrollers. Namely, all these processors: -// -// - Cortex-M0 -// - Cortex-M0+ -// - Cortex-M1 -// - Cortex-M3 -// - Cortex-M4(F) -// - Cortex-M7(F) -// - Cortex-M23 -// - Cortex-M33 -// -// We have opted for these instead of one target per processor (e.g., `cortex-m0`, `cortex-m3`, -// etc) because the differences between some processors like the cortex-m0 and cortex-m1 are almost -// nonexistent from the POV of codegen so it doesn't make sense to have separate targets for them. -// And if differences exist between two processors under the same target, rustc flags can be used to -// optimize for one processor or the other. -// -// Also, we have not chosen a single target (`arm-none-eabi`) like GCC does because this makes -// difficult to integrate Rust code and C code. Targeting the Cortex-M4 requires different gcc flags -// than the ones you would use for the Cortex-M0 and with a single target it'd be impossible to -// differentiate one processor from the other. -// -// About arm vs thumb in the name. The Cortex-M devices only support the Thumb instruction set, -// which is more compact (higher code density), and not the ARM instruction set. That's why LLVM -// triples use thumb instead of arm. We follow suit because having thumb in the name let us -// differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of -// build scripts / gcc flags. - -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions}; - -pub fn opts() -> TargetOptions { - // See rust-lang/rfcs#1645 for a discussion about these defaults - TargetOptions { - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - // In most cases, LLD is good enough - linker: Some("rust-lld".into()), - // Because these devices have very little resources having an unwinder is too onerous so we - // default to "abort" because the "unwind" strategy is very rare. - panic_strategy: PanicStrategy::Abort, - // Similarly, one almost always never wants to use relocatable code because of the extra - // costs it involves. - relocation_model: RelocModel::Static, - // When this section is added a volatile load to its start address is also generated. This - // volatile load is a footgun as it can end up loading an invalid memory address, depending - // on how the user set up their linker scripts. This section adds pretty printer for stuff - // like std::Vec, which is not that used in no-std context, so it's best to left it out - // until we figure a way to add the pretty printers without requiring a volatile load cf. - // rust-lang/rust#44993. - emit_debug_gdb_scripts: false, - // LLVM is eager to trash the link register when calling `noreturn` functions, which - // breaks debugging. Preserve LR by default to prevent that from happening. - frame_pointer: FramePointer::Always, - // ARM supports multiple ABIs for enums, the linux one matches the default of 32 here - // but any arm-none or thumb-none target will be defaulted to 8 on GCC. - c_enum_min_bits: Some(8), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs deleted file mode 100644 index 88a76f49a..000000000 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! Targets the ARMv4T, with code as `t32` code by default. -//! -//! Primarily of use for the GBA, but usable with other devices too. -//! -//! Please ping @Lokathor if changes are needed. -//! -//! **Important:** This target profile **does not** specify a linker script. You -//! just get the default link script when you build a binary for this target. -//! The default link script is very likely wrong, so you should use -//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. - -use crate::spec::{cvs, FramePointer}; -use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv4t-none-eabi".into(), - pointer_width: 32, - arch: "arm".into(), - /* Data layout args are '-' separated: - * little endian - * stack is 64-bit aligned (EABI) - * pointers are 32-bit - * i64 must be 64-bit aligned (EABI) - * mangle names with ELF style - * native integers are 32-bit - * All other elements are default - */ - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - options: TargetOptions { - abi: "eabi".into(), - - // extra args passed to the external assembler (assuming `arm-none-eabi-as`): - // * activate t32/a32 interworking - // * use arch ARMv4T - // * use little-endian - asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",], - - // minimum extra features, these cannot be disabled via -C - // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. - // The resulting atomics are ABI incompatible with atomics backed by libatomic. - features: "+soft-float,+strict-align,+atomics-32".into(), - - panic_strategy: PanicStrategy::Abort, - relocation_model: RelocModel::Static, - // suggested from thumb_base, rust-lang/rust#44993. - emit_debug_gdb_scripts: false, - frame_pointer: FramePointer::MayOmit, - - main_needs_argc_argv: false, - - // don't have atomic compare-and-swap - atomic_cas: false, - has_thumb_interworking: true, - - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs deleted file mode 100644 index 021b0e0eb..000000000 --- a/compiler/rustc_target/src/spec/thumbv5te_none_eabi.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Targets the ARMv5TE, with code as `t32` code by default. - -use crate::spec::{cvs, FramePointer, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv5te-none-eabi".into(), - pointer_width: 32, - arch: "arm".into(), - /* Data layout args are '-' separated: - * little endian - * stack is 64-bit aligned (EABI) - * pointers are 32-bit - * i64 must be 64-bit aligned (EABI) - * mangle names with ELF style - * native integers are 32-bit - * All other elements are default - */ - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - - options: TargetOptions { - abi: "eabi".into(), - // extra args passed to the external assembler (assuming `arm-none-eabi-as`): - // * activate t32/a32 interworking - // * use arch ARMv5TE - // * use little-endian - asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",], - // minimum extra features, these cannot be disabled via -C - // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. - // The resulting atomics are ABI incompatible with atomics backed by libatomic. - features: "+soft-float,+strict-align,+atomics-32".into(), - frame_pointer: FramePointer::MayOmit, - main_needs_argc_argv: false, - // don't have atomic compare-and-swap - atomic_cas: false, - has_thumb_interworking: true, - - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs deleted file mode 100644 index c9bb0112f..000000000 --- a/compiler/rustc_target/src/spec/thumbv6m_none_eabi.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv6m-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - // The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them - // with +strict-align. - // Also force-enable 32-bit atomics, which allows the use of atomic load/store only. - // The resulting atomics are ABI incompatible with atomics backed by libatomic. - features: "+strict-align,+atomics-32".into(), - // There are no atomic CAS instructions available in the instruction set of the ARMv6-M - // architecture - atomic_cas: false, - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs deleted file mode 100644 index f1be274f0..000000000 --- a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::spec::{LinkerFlavor, Lld, PanicStrategy, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::windows_msvc_base::opts(); - // Prevent error LNK2013: BRANCH24(T) fixup overflow - // The LBR optimization tries to eliminate branch islands, - // but if the displacement is larger than can fit - // in the instruction, this error will occur. The linker - // should be smart enough to insert branch islands only - // where necessary, but this is not the observed behavior. - // Disabling the LBR optimization works around the issue. - base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/OPT:NOLBR"]); - - Target { - llvm_target: "thumbv7a-pc-windows-msvc".into(), - pointer_width: 32, - data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - features: "+vfp3,+neon".into(), - max_atomic_width: Some(64), - // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is - // implemented for windows/arm in LLVM - panic_strategy: PanicStrategy::Abort, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs deleted file mode 100644 index 65c2f5a70..000000000 --- a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{PanicStrategy, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv7a-pc-windows-msvc".into(), - pointer_width: 32, - data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - features: "+vfp3,+neon".into(), - max_atomic_width: Some(64), - // FIXME(jordanrh): use PanicStrategy::Unwind when SEH is - // implemented for windows/arm in LLVM - panic_strategy: PanicStrategy::Abort, - ..super::windows_uwp_msvc_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs deleted file mode 100644 index 000e5f2d3..000000000 --- a/compiler/rustc_target/src/spec/thumbv7em_none_eabi.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Targets the Cortex-M4 and Cortex-M7 processors (ARMv7E-M) -// -// This target assumes that the device doesn't have a FPU (Floating Point Unit) and lowers all the -// floating point operations to software routines (intrinsics). -// -// As such, this target uses the "soft" calling convention (ABI) where floating point values are -// passed to/from subroutines via general purpose registers (R0, R1, etc.). -// -// To opt-in to hardware accelerated floating point operations, you can use, for example, -// `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv7em-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs b/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs deleted file mode 100644 index 39a72564e..000000000 --- a/compiler/rustc_target/src/spec/thumbv7em_none_eabihf.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Targets the Cortex-M4F and Cortex-M7F processors (ARMv7E-M) -// -// This target assumes that the device does have a FPU (Floating Point Unit) and lowers all (single -// precision) floating point operations to hardware instructions. -// -// Additionally, this target uses the "hard" floating convention (ABI) where floating point values -// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.). -// -// To opt into double precision hardware support, use the `-C target-feature=+fp64` flag. - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv7em-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabihf".into(), - // `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the - // Cortex-M7 (vfp5) - // `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers - // available - // `-fp64` The Cortex-M4 only supports single precision floating point operations - // whereas in the Cortex-M7 double precision is optional - // - // Reference: - // ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension - features: "+vfp4,-d32,-fp64".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs deleted file mode 100644 index ab25cde66..000000000 --- a/compiler/rustc_target/src/spec/thumbv7m_none_eabi.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Targets the Cortex-M3 processor (ARMv7-M) - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv7m-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs b/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs deleted file mode 100644 index 8d80fcd5f..000000000 --- a/compiler/rustc_target/src/spec/thumbv7neon_linux_androideabi.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -// This target if is for the Android v7a ABI in thumb mode with -// NEON unconditionally enabled and, therefore, with 32 FPU registers -// enabled as well. See section A2.6.2 on page A2-56 in -// https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf - -// See https://developer.android.com/ndk/guides/abis.html#v7a -// for target ABI requirements. - -pub fn target() -> Target { - let mut base = super::android_base::opts(); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-march=armv7-a"]); - Target { - llvm_target: "armv7-none-linux-android".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabi".into(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), - max_atomic_width: Some(64), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs deleted file mode 100644 index 28c81340a..000000000 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for glibc Linux on ARMv7 with thumb mode enabled -// (for consistency with Android and Debian-based distributions) -// and with NEON unconditionally enabled and, therefore, with 32 FPU -// registers enabled as well. See section A2.6.2 on page A2-56 in -// https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf - -pub fn target() -> Target { - Target { - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - options: TargetOptions { - abi: "eabihf".into(), - // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), - max_atomic_width: Some(64), - ..super::linux_gnu_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs deleted file mode 100644 index 2c375ab22..000000000 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -// This target is for musl Linux on ARMv7 with thumb mode enabled -// (for consistency with Android and Debian-based distributions) -// and with NEON unconditionally enabled and, therefore, with 32 FPU -// registers enabled as well. See section A2.6.2 on page A2-56 in -// https://static.docs.arm.com/ddi0406/cd/DDI0406C_d_armv7ar_arm.pdf - -pub fn target() -> Target { - Target { - // It's important we use "gnueabihf" and not "musleabihf" here. LLVM - // uses it to determine the calling convention and float ABI, and LLVM - // doesn't support the "musleabihf" value. - llvm_target: "armv7-unknown-linux-gnueabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - // Most of these settings are copied from the thumbv7neon_unknown_linux_gnueabihf - // target. - options: TargetOptions { - abi: "eabihf".into(), - features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), - max_atomic_width: Some(64), - mcount: "\u{1}mcount".into(), - ..super::linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs deleted file mode 100644 index 756b1834c..000000000 --- a/compiler/rustc_target/src/spec/thumbv8m_base_none_eabi.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Targets the Cortex-M23 processor (Baseline ARMv8-M) - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv8m.base-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - // ARMv8-M baseline doesn't support unaligned loads/stores so we disable them - // with +strict-align. - features: "+strict-align".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs deleted file mode 100644 index 4b6268546..000000000 --- a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabi.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), -// without the Floating Point extension. - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv8m.main-none-eabi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabi".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs b/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs deleted file mode 100644 index 86c25f9e4..000000000 --- a/compiler/rustc_target/src/spec/thumbv8m_main_none_eabihf.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), -// with the Floating Point extension. - -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "thumbv8m.main-none-eabihf".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), - - options: TargetOptions { - abi: "eabihf".into(), - // If the Floating Point extension is implemented in the Cortex-M33 - // processor, the Cortex-M33 Technical Reference Manual states that - // the FPU uses the FPv5 architecture, single-precision instructions - // and 16 D registers. - // These parameters map to the following LLVM features. - features: "+fp-armv8,-fp64,-d32".into(), - max_atomic_width: Some(32), - ..super::thumb_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/uefi_msvc_base.rs b/compiler/rustc_target/src/spec/uefi_msvc_base.rs deleted file mode 100644 index a50a55ad7..000000000 --- a/compiler/rustc_target/src/spec/uefi_msvc_base.rs +++ /dev/null @@ -1,52 +0,0 @@ -// This defines a base target-configuration for native UEFI systems. The UEFI specification has -// quite detailed sections on the ABI of all the supported target architectures. In almost all -// cases it simply follows what Microsoft Windows does. Hence, whenever in doubt, see the MSDN -// documentation. -// UEFI uses COFF/PE32+ format for binaries. All binaries must be statically linked. No dynamic -// linker is supported. As native to COFF, binaries are position-dependent, but will be relocated -// by the loader if the pre-chosen memory location is already in use. -// UEFI forbids running code on anything but the boot-CPU. No interrupts are allowed other than -// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all -// code runs in the same environment, no process separation is supported. - -use crate::spec::{LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions}; - -pub fn opts() -> TargetOptions { - let mut base = super::msvc_base::opts(); - - base.add_pre_link_args( - LinkerFlavor::Msvc(Lld::No), - &[ - // Non-standard subsystems have no default entry-point in PE+ files. We have to define - // one. "efi_main" seems to be a common choice amongst other implementations and the - // spec. - "/entry:efi_main", - // COFF images have a "Subsystem" field in their header, which defines what kind of - // program it is. UEFI has 3 fields reserved, which are EFI_APPLICATION, - // EFI_BOOT_SERVICE_DRIVER, and EFI_RUNTIME_DRIVER. We default to EFI_APPLICATION, - // which is very likely the most common option. Individual projects can override this - // with custom linker flags. - // The subsystem-type only has minor effects on the application. It defines the memory - // regions the application is loaded into (runtime-drivers need to be put into - // reserved areas), as well as whether a return from the entry-point is treated as - // exit (default for applications). - "/subsystem:efi_application", - ], - ); - - TargetOptions { - os: "uefi".into(), - linker_flavor: LinkerFlavor::Msvc(Lld::Yes), - disable_redzone: true, - exe_suffix: ".efi".into(), - allows_weak_linkage: false, - panic_strategy: PanicStrategy::Abort, - // LLVM does not emit inline assembly because the LLVM target does not get considered as… - // "Windows". - stack_probes: StackProbeType::Call, - singlethread: true, - linker: Some("rust-lld".into()), - entry_name: "efi_main".into(), - ..base - } -} diff --git a/compiler/rustc_target/src/spec/unikraft_linux_musl_base.rs b/compiler/rustc_target/src/spec/unikraft_linux_musl_base.rs deleted file mode 100644 index 9ccd0a1e7..000000000 --- a/compiler/rustc_target/src/spec/unikraft_linux_musl_base.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::spec::{cvs, PanicStrategy, RelocModel, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "linux".into(), - env: "musl".into(), - vendor: "unikraft".into(), - linker: Some("kraftld".into()), - relocation_model: RelocModel::Static, - families: cvs!["unix"], - has_thread_local: true, - panic_strategy: PanicStrategy::Abort, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs deleted file mode 100644 index aa4784b63..000000000 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{cvs, TargetOptions}; - -pub fn opts() -> TargetOptions { - TargetOptions { - os: "vxworks".into(), - env: "gnu".into(), - vendor: "wrs".into(), - linker: Some("wr-c++".into()), - exe_suffix: ".vxe".into(), - dynamic_linking: true, - families: cvs!["unix"], - has_rpath: true, - has_thread_local: true, - crt_static_default: true, - crt_static_respected: true, - crt_static_allows_dylibs: true, - // VxWorks needs to implement this to support profiling - mcount: "_mcount".into(), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs deleted file mode 100644 index 6f77ef98c..000000000 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ /dev/null @@ -1,34 +0,0 @@ -use super::{cvs, wasm_base}; -use super::{LinkArgs, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions}; - -pub fn target() -> Target { - // Reset flags for non-Em flavors back to empty to satisfy sanity checking tests. - let pre_link_args = LinkArgs::new(); - let post_link_args = TargetOptions::link_args( - LinkerFlavor::EmCc, - &["-sABORTING_MALLOC=0", "-Wl,--fatal-warnings"], - ); - - let opts = TargetOptions { - os: "emscripten".into(), - linker_flavor: LinkerFlavor::EmCc, - // emcc emits two files - a .js file to instantiate the wasm and supply platform - // functionality, and a .wasm file. - exe_suffix: ".js".into(), - linker: None, - pre_link_args, - post_link_args, - relocation_model: RelocModel::Pic, - panic_strategy: PanicStrategy::Unwind, - no_default_libraries: false, - families: cvs!["unix", "wasm"], - ..wasm_base::options() - }; - Target { - llvm_target: "wasm32-unknown-emscripten".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs deleted file mode 100644 index 06529c2e4..000000000 --- a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs +++ /dev/null @@ -1,55 +0,0 @@ -//! A "bare wasm" target representing a WebAssembly output that makes zero -//! assumptions about its environment. -//! -//! The `wasm32-unknown-unknown` target is intended to encapsulate use cases -//! that do not rely on any imported functionality. The binaries generated are -//! entirely self-contained by default when using the standard library. Although -//! the standard library is available, most of it returns an error immediately -//! (e.g. trying to create a TCP stream or something like that). -//! -//! This target is more or less managed by the Rust and WebAssembly Working -//! Group nowadays at . - -use super::{wasm_base, Cc, LinkerFlavor, Target}; -use crate::spec::abi::Abi; - -pub fn target() -> Target { - let mut options = wasm_base::options(); - options.os = "unknown".into(); - - // This is a default for backwards-compatibility with the original - // definition of this target oh-so-long-ago. Once the "wasm" ABI is - // stable and the wasm-bindgen project has switched to using it then there's - // no need for this and it can be removed. - // - // Currently this is the reason that this target's ABI is mismatched with - // clang's ABI. This means that, in the limit, you can't merge C and Rust - // code on this target due to this ABI mismatch. - options.default_adjusted_cabi = Some(Abi::Wasm); - - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::No), - &[ - // For now this target just never has an entry symbol no matter the output - // type, so unconditionally pass this. - "--no-entry", - ], - ); - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::Yes), - &[ - // Make sure clang uses LLD as its linker and is configured appropriately - // otherwise - "--target=wasm32-unknown-unknown", - "-Wl,--no-entry", - ], - ); - - Target { - llvm_target: "wasm32-unknown-unknown".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), - options, - } -} diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi.rs deleted file mode 100644 index a0476d542..000000000 --- a/compiler/rustc_target/src/spec/wasm32_wasi.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! The `wasm32-wasi` target is a new and still (as of April 2019) an -//! experimental target. The definition in this file is likely to be tweaked -//! over time and shouldn't be relied on too much. -//! -//! The `wasi` target is a proposal to define a standardized set of syscalls -//! that WebAssembly files can interoperate with. This set of syscalls is -//! intended to empower WebAssembly binaries with native capabilities such as -//! filesystem access, network access, etc. -//! -//! You can see more about the proposal at . -//! -//! The Rust target definition here is interesting in a few ways. We want to -//! serve two use cases here with this target: -//! -//! * First, we want Rust usage of the target to be as hassle-free as possible, -//! ideally avoiding the need to configure and install a local wasm32-wasi -//! toolchain. -//! -//! * Second, one of the primary use cases of LLVM's new wasm backend and the -//! wasm support in LLD is that any compiled language can interoperate with -//! any other. To that the `wasm32-wasi` target is the first with a viable C -//! standard library and sysroot common definition, so we want Rust and C/C++ -//! code to interoperate when compiled to `wasm32-unknown-unknown`. -//! -//! You'll note, however, that the two goals above are somewhat at odds with one -//! another. To attempt to solve both use cases in one go we define a target -//! that (ab)uses the `crt-static` target feature to indicate which one you're -//! in. -//! -//! ## No interop with C required -//! -//! By default the `crt-static` target feature is enabled, and when enabled -//! this means that the bundled version of `libc.a` found in `liblibc.rlib` -//! is used. This isn't intended really for interoperation with a C because it -//! may be the case that Rust's bundled C library is incompatible with a -//! foreign-compiled C library. In this use case, though, we use `rust-lld` and -//! some copied crt startup object files to ensure that you can download the -//! wasi target for Rust and you're off to the races, no further configuration -//! necessary. -//! -//! All in all, by default, no external dependencies are required. You can -//! compile `wasm32-wasi` binaries straight out of the box. You can't, however, -//! reliably interoperate with C code in this mode (yet). -//! -//! ## Interop with C required -//! -//! For the second goal we repurpose the `target-feature` flag, meaning that -//! you'll need to do a few things to have C/Rust code interoperate. -//! -//! 1. All Rust code needs to be compiled with `-C target-feature=-crt-static`, -//! indicating that the bundled C standard library in the Rust sysroot will -//! not be used. -//! -//! 2. If you're using rustc to build a linked artifact then you'll need to -//! specify `-C linker` to a `clang` binary that supports -//! `wasm32-wasi` and is configured with the `wasm32-wasi` sysroot. This -//! will cause Rust code to be linked against the libc.a that the specified -//! `clang` provides. -//! -//! 3. If you're building a staticlib and integrating Rust code elsewhere, then -//! compiling with `-C target-feature=-crt-static` is all you need to do. -//! -//! You can configure the linker via Cargo using the -//! `CARGO_TARGET_WASM32_WASI_LINKER` env var. Be sure to also set -//! `CC_wasm32-wasi` if any crates in the dependency graph are using the `cc` -//! crate. -//! -//! ## Remember, this is all in flux -//! -//! The wasi target is **very** new in its specification. It's likely going to -//! be a long effort to get it standardized and stable. We'll be following it as -//! best we can with this target. Don't start relying on too much here unless -//! you know what you're getting in to! - -use super::crt_objects::{self, LinkSelfContainedDefault}; -use super::{wasm_base, Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut options = wasm_base::options(); - - options.os = "wasi".into(); - options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]); - - options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); - options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); - - // FIXME: Figure out cases in which WASM needs to link with a native toolchain. - options.link_self_contained = LinkSelfContainedDefault::True; - - // Right now this is a bit of a workaround but we're currently saying that - // the target by default has a static crt which we're taking as a signal - // for "use the bundled crt". If that's turned off then the system's crt - // will be used, but this means that default usage of this target doesn't - // need an external compiler but it's still interoperable with an external - // compiler if configured correctly. - options.crt_static_default = true; - options.crt_static_respected = true; - - // Allow `+crt-static` to create a "cdylib" output which is just a wasm file - // without a main function. - options.crt_static_allows_dylibs = true; - - // WASI's `sys::args::init` function ignores its arguments; instead, - // `args::args()` makes the WASI API calls itself. - options.main_needs_argc_argv = false; - - // And, WASI mangles the name of "main" to distinguish between different - // signatures. - options.entry_name = "__main_void".into(); - - Target { - llvm_target: "wasm32-wasi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), - options, - } -} diff --git a/compiler/rustc_target/src/spec/wasm32_wasi_preview1_threads.rs b/compiler/rustc_target/src/spec/wasm32_wasi_preview1_threads.rs deleted file mode 100644 index c567155fe..000000000 --- a/compiler/rustc_target/src/spec/wasm32_wasi_preview1_threads.rs +++ /dev/null @@ -1,134 +0,0 @@ -//! The `wasm32-wasi-preview1-threads` target is a new and still (as of July 2023) an -//! experimental target. The definition in this file is likely to be tweaked -//! over time and shouldn't be relied on too much. -//! -//! The `wasi-threads` target is a proposal to define a standardized set of syscalls -//! that WebAssembly files can interoperate with. This set of syscalls is -//! intended to empower WebAssembly binaries with native capabilities such as -//! threads, filesystem access, network access, etc. -//! -//! You can see more about the proposal at . -//! -//! The Rust target definition here is interesting in a few ways. We want to -//! serve two use cases here with this target: -//! -//! * First, we want Rust usage of the target to be as hassle-free as possible, -//! ideally avoiding the need to configure and install a local wasm32-wasi-preview1-threads -//! toolchain. -//! -//! * Second, one of the primary use cases of LLVM's new wasm backend and the -//! wasm support in LLD is that any compiled language can interoperate with -//! any other. To that the `wasm32-wasi-preview1-threads` target is the first with a viable C -//! standard library and sysroot common definition, so we want Rust and C/C++ -//! code to interoperate when compiled to `wasm32-unknown-unknown`. -//! -//! You'll note, however, that the two goals above are somewhat at odds with one -//! another. To attempt to solve both use cases in one go we define a target -//! that (ab)uses the `crt-static` target feature to indicate which one you're -//! in. -//! -//! ## No interop with C required -//! -//! By default the `crt-static` target feature is enabled, and when enabled -//! this means that the bundled version of `libc.a` found in `liblibc.rlib` -//! is used. This isn't intended really for interoperation with a C because it -//! may be the case that Rust's bundled C library is incompatible with a -//! foreign-compiled C library. In this use case, though, we use `rust-lld` and -//! some copied crt startup object files to ensure that you can download the -//! wasi target for Rust and you're off to the races, no further configuration -//! necessary. -//! -//! All in all, by default, no external dependencies are required. You can -//! compile `wasm32-wasi-preview1-threads` binaries straight out of the box. You can't, however, -//! reliably interoperate with C code in this mode (yet). -//! -//! ## Interop with C required -//! -//! For the second goal we repurpose the `target-feature` flag, meaning that -//! you'll need to do a few things to have C/Rust code interoperate. -//! -//! 1. All Rust code needs to be compiled with `-C target-feature=-crt-static`, -//! indicating that the bundled C standard library in the Rust sysroot will -//! not be used. -//! -//! 2. If you're using rustc to build a linked artifact then you'll need to -//! specify `-C linker` to a `clang` binary that supports -//! `wasm32-wasi-preview1-threads` and is configured with the `wasm32-wasi-preview1-threads` sysroot. This -//! will cause Rust code to be linked against the libc.a that the specified -//! `clang` provides. -//! -//! 3. If you're building a staticlib and integrating Rust code elsewhere, then -//! compiling with `-C target-feature=-crt-static` is all you need to do. -//! -//! You can configure the linker via Cargo using the -//! `CARGO_TARGET_WASM32_WASI_LINKER` env var. Be sure to also set -//! `CC_wasm32-wasi-preview1-threads` if any crates in the dependency graph are using the `cc` -//! crate. -//! -//! ## Remember, this is all in flux -//! -//! The wasi target is **very** new in its specification. It's likely going to -//! be a long effort to get it standardized and stable. We'll be following it as -//! best we can with this target. Don't start relying on too much here unless -//! you know what you're getting in to! - -use super::crt_objects::{self, LinkSelfContainedDefault}; -use super::{wasm_base, Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut options = wasm_base::options(); - - options.os = "wasi".into(); - - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::No), - &["--import-memory", "--export-memory", "--shared-memory"], - ); - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::Yes), - &[ - "--target=wasm32-wasi-threads", - "-Wl,--import-memory", - "-Wl,--export-memory,", - "-Wl,--shared-memory", - ], - ); - - options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); - options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); - - // FIXME: Figure out cases in which WASM needs to link with a native toolchain. - options.link_self_contained = LinkSelfContainedDefault::True; - - // Right now this is a bit of a workaround but we're currently saying that - // the target by default has a static crt which we're taking as a signal - // for "use the bundled crt". If that's turned off then the system's crt - // will be used, but this means that default usage of this target doesn't - // need an external compiler but it's still interoperable with an external - // compiler if configured correctly. - options.crt_static_default = true; - options.crt_static_respected = true; - - // Allow `+crt-static` to create a "cdylib" output which is just a wasm file - // without a main function. - options.crt_static_allows_dylibs = true; - - // WASI's `sys::args::init` function ignores its arguments; instead, - // `args::args()` makes the WASI API calls itself. - options.main_needs_argc_argv = false; - - // And, WASI mangles the name of "main" to distinguish between different - // signatures. - options.entry_name = "__main_void".into(); - - options.singlethread = false; - options.features = "+atomics,+bulk-memory,+mutable-globals".into(); - - Target { - llvm_target: "wasm32-wasi".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), - options, - } -} diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs deleted file mode 100644 index 3fda398d2..000000000 --- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! A "bare wasm" target representing a WebAssembly output that makes zero -//! assumptions about its environment. -//! -//! The `wasm64-unknown-unknown` target is intended to encapsulate use cases -//! that do not rely on any imported functionality. The binaries generated are -//! entirely self-contained by default when using the standard library. Although -//! the standard library is available, most of it returns an error immediately -//! (e.g. trying to create a TCP stream or something like that). - -use super::{wasm_base, Cc, LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut options = wasm_base::options(); - options.os = "unknown".into(); - - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::No), - &[ - // For now this target just never has an entry symbol no matter the output - // type, so unconditionally pass this. - "--no-entry", - "-mwasm64", - ], - ); - options.add_pre_link_args( - LinkerFlavor::WasmLld(Cc::Yes), - &[ - // Make sure clang uses LLD as its linker and is configured appropriately - // otherwise - "--target=wasm64-unknown-unknown", - "-Wl,--no-entry", - ], - ); - - // Any engine that implements wasm64 will surely implement the rest of these - // features since they were all merged into the official spec by the time - // wasm64 was designed. - options.features = "+bulk-memory,+mutable-globals,+sign-ext,+nontrapping-fptoint".into(); - - Target { - llvm_target: "wasm64-unknown-unknown".into(), - pointer_width: 64, - data_layout: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), - arch: "wasm64".into(), - options, - } -} diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs deleted file mode 100644 index 341763aad..000000000 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ /dev/null @@ -1,133 +0,0 @@ -use super::crt_objects::LinkSelfContainedDefault; -use super::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel}; - -pub fn options() -> TargetOptions { - macro_rules! args { - ($prefix:literal) => { - &[ - // By default LLD only gives us one page of stack (64k) which is a - // little small. Default to a larger stack closer to other PC platforms - // (1MB) and users can always inject their own link-args to override this. - concat!($prefix, "-z"), - concat!($prefix, "stack-size=1048576"), - // By default LLD's memory layout is: - // - // 1. First, a blank page - // 2. Next, all static data - // 3. Finally, the main stack (which grows down) - // - // This has the unfortunate consequence that on stack overflows you - // corrupt static data and can cause some exceedingly weird bugs. To - // help detect this a little sooner we instead request that the stack is - // placed before static data. - // - // This means that we'll generate slightly larger binaries as references - // to static data will take more bytes in the ULEB128 encoding, but - // stack overflow will be guaranteed to trap as it underflows instead of - // corrupting static data. - concat!($prefix, "--stack-first"), - // FIXME we probably shouldn't pass this but instead pass an explicit list - // of symbols we'll allow to be undefined. We don't currently have a - // mechanism of knowing, however, which symbols are intended to be imported - // from the environment and which are intended to be imported from other - // objects linked elsewhere. This is a coarse approximation but is sure to - // hide some bugs and frustrate someone at some point, so we should ideally - // work towards a world where we can explicitly list symbols that are - // supposed to be imported and have all other symbols generate errors if - // they remain undefined. - concat!($prefix, "--allow-undefined"), - // Rust code should never have warnings, and warnings are often - // indicative of bugs, let's prevent them. - concat!($prefix, "--fatal-warnings"), - // LLD only implements C++-like demangling, which doesn't match our own - // mangling scheme. Tell LLD to not demangle anything and leave it up to - // us to demangle these symbols later. Currently rustc does not perform - // further demangling, but tools like twiggy and wasm-bindgen are intended - // to do so. - concat!($prefix, "--no-demangle"), - ] - }; - } - - let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::WasmLld(Cc::No), args!("")); - super::add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,")); - - TargetOptions { - is_like_wasm: true, - families: cvs!["wasm"], - - // we allow dynamic linking, but only cdylibs. Basically we allow a - // final library artifact that exports some symbols (a wasm module) but - // we don't allow intermediate `dylib` crate types - dynamic_linking: true, - only_cdylib: true, - - // relatively self-explanatory! - exe_suffix: ".wasm".into(), - dll_prefix: "".into(), - dll_suffix: ".wasm".into(), - eh_frame_header: false, - - max_atomic_width: Some(64), - - // Unwinding doesn't work right now, so the whole target unconditionally - // defaults to panic=abort. Note that this is guaranteed to change in - // the future once unwinding is implemented. Don't rely on this as we're - // basically guaranteed to change it once WebAssembly supports - // exceptions. - panic_strategy: PanicStrategy::Abort, - - // Wasm doesn't have atomics yet, so tell LLVM that we're in a single - // threaded model which will legalize atomics to normal operations. - singlethread: true, - - // no dynamic linking, no need for default visibility! - default_hidden_visibility: true, - - // Symbol visibility takes care of this for the WebAssembly. - // Additionally the only known linker, LLD, doesn't support the script - // arguments just yet - limit_rdylib_exports: false, - - // we use the LLD shipped with the Rust toolchain by default - linker: Some("rust-lld".into()), - linker_flavor: LinkerFlavor::WasmLld(Cc::No), - - pre_link_args, - - // FIXME: Figure out cases in which WASM needs to link with a native toolchain. - // - // rust-lang/rust#104137: cannot blindly remove this without putting in - // some other way to compensate for lack of `-nostartfiles` in linker - // invocation. - link_self_contained: LinkSelfContainedDefault::True, - - // This has no effect in LLVM 8 or prior, but in LLVM 9 and later when - // PIC code is implemented this has quite a drastic effect if it stays - // at the default, `pic`. In an effort to keep wasm binaries as minimal - // as possible we're defaulting to `static` for now, but the hope is - // that eventually we can ship a `pic`-compatible standard library which - // works with `static` as well (or works with some method of generating - // non-relative calls and such later on). - relocation_model: RelocModel::Static, - - // When the atomics feature is activated then these two keys matter, - // otherwise they're basically ignored by the standard library. In this - // mode, however, the `#[thread_local]` attribute works (i.e. - // `has_thread_local`) and we need to get it to work by specifying - // `local-exec` as that's all that's implemented in LLVM today for wasm. - has_thread_local: true, - tls_model: TlsModel::LocalExec, - - // gdb scripts don't work on wasm blobs - emit_debug_gdb_scripts: false, - - // There's more discussion of this at - // https://bugs.llvm.org/show_bug.cgi?id=52442 but the general result is - // that this isn't useful for wasm and has tricky issues with - // representation, so this is disabled. - generate_arange_section: false, - - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs deleted file mode 100644 index 2231983f0..000000000 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ /dev/null @@ -1,107 +0,0 @@ -use crate::spec::crt_objects::{self, LinkSelfContainedDefault}; -use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; -use std::borrow::Cow; - -pub fn opts() -> TargetOptions { - let mut pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &[ - // Enable ASLR - "--dynamicbase", - // ASLR will rebase it anyway so leaving that option enabled only leads to confusion - "--disable-auto-image-base", - ], - ); - super::add_link_args( - &mut pre_link_args, - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &[ - // Tell GCC to avoid linker plugins, because we are not bundling - // them with Windows installer, and Rust does its own LTO anyways. - "-fno-use-linker-plugin", - "-Wl,--dynamicbase", - "-Wl,--disable-auto-image-base", - ], - ); - - // Order of `late_link_args*` was found through trial and error to work with various - // mingw-w64 versions (not tested on the CI). It's expected to change from time to time. - let mingw_libs = &[ - "-lmsvcrt", - "-lmingwex", - "-lmingw32", - "-lgcc", // alas, mingw* libraries above depend on libgcc - // mingw's msvcrt is a weird hybrid import library and static library. - // And it seems that the linker fails to use import symbols from msvcrt - // that are required from functions in msvcrt in certain cases. For example - // `_fmode` that is used by an implementation of `__p__fmode` in x86_64. - // The library is purposely listed twice to fix that. - // - // See https://github.com/rust-lang/rust/pull/47483 for some more details. - "-lmsvcrt", - "-luser32", - "-lkernel32", - ]; - let mut late_link_args = - TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs); - super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs); - // If any of our crates are dynamically linked then we need to use - // the shared libgcc_s-dw2-1.dll. This is required to support - // unwinding across DLL boundaries. - let dynamic_unwind_libs = &["-lgcc_s"]; - let mut late_link_args_dynamic = - TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs); - super::add_link_args( - &mut late_link_args_dynamic, - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - dynamic_unwind_libs, - ); - // If all of our crates are statically linked then we can get away - // with statically linking the libgcc unwinding code. This allows - // binaries to be redistributed without the libgcc_s-dw2-1.dll - // dependency, but unfortunately break unwinding across DLL - // boundaries when unwinding across FFI boundaries. - let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"]; - let mut late_link_args_static = - TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs); - super::add_link_args( - &mut late_link_args_static, - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - static_unwind_libs, - ); - - TargetOptions { - os: "windows".into(), - env: "gnu".into(), - vendor: "pc".into(), - // FIXME(#13846) this should be enabled for windows - function_sections: false, - linker: Some("gcc".into()), - dynamic_linking: true, - dll_tls_export: false, - dll_prefix: "".into(), - dll_suffix: ".dll".into(), - exe_suffix: ".exe".into(), - families: cvs!["windows"], - is_like_windows: true, - allows_weak_linkage: false, - pre_link_args, - pre_link_objects: crt_objects::pre_mingw(), - post_link_objects: crt_objects::post_mingw(), - pre_link_objects_self_contained: crt_objects::pre_mingw_self_contained(), - post_link_objects_self_contained: crt_objects::post_mingw_self_contained(), - link_self_contained: LinkSelfContainedDefault::Mingw, - late_link_args, - late_link_args_dynamic, - late_link_args_static, - abi_return_struct_as_int: true, - emit_debug_gdb_scripts: false, - requires_uwtable: true, - eh_frame_header: false, - // FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to - // output DWO, despite using DWARF, doesn't use ELF.. - debuginfo_kind: DebuginfoKind::Pdb, - supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs b/compiler/rustc_target/src/spec/windows_gnullvm_base.rs deleted file mode 100644 index b1d8e2be5..000000000 --- a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; -use std::borrow::Cow; - -pub fn opts() -> TargetOptions { - // We cannot use `-nodefaultlibs` because compiler-rt has to be passed - // as a path since it's not added to linker search path by the default. - // There were attempts to make it behave like libgcc (so one can just use -l) - // but LLVM maintainers rejected it: https://reviews.llvm.org/D51440 - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-nolibc", "--unwindlib=none"], - ); - // Order of `late_link_args*` does not matter with LLD. - let late_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"], - ); - - TargetOptions { - os: "windows".into(), - env: "gnu".into(), - vendor: "pc".into(), - abi: "llvm".into(), - linker: Some("clang".into()), - dynamic_linking: true, - dll_tls_export: false, - dll_prefix: "".into(), - dll_suffix: ".dll".into(), - exe_suffix: ".exe".into(), - families: cvs!["windows"], - is_like_windows: true, - allows_weak_linkage: false, - pre_link_args, - late_link_args, - abi_return_struct_as_int: true, - emit_debug_gdb_scripts: false, - requires_uwtable: true, - eh_frame_header: false, - no_default_libraries: false, - has_thread_local: true, - // FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to - // output DWO, despite using DWARF, doesn't use ELF.. - debuginfo_kind: DebuginfoKind::Pdb, - supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/windows_msvc_base.rs b/compiler/rustc_target/src/spec/windows_msvc_base.rs deleted file mode 100644 index 21062c337..000000000 --- a/compiler/rustc_target/src/spec/windows_msvc_base.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::spec::{cvs, TargetOptions}; - -pub fn opts() -> TargetOptions { - let base = super::msvc_base::opts(); - - TargetOptions { - os: "windows".into(), - env: "msvc".into(), - vendor: "pc".into(), - dynamic_linking: true, - dll_prefix: "".into(), - dll_suffix: ".dll".into(), - exe_suffix: ".exe".into(), - staticlib_prefix: "".into(), - staticlib_suffix: ".lib".into(), - families: cvs!["windows"], - crt_static_allows_dylibs: true, - crt_static_respected: true, - requires_uwtable: true, - // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC - // as there's been trouble in the past of linking the C++ standard - // library required by LLVM. This likely needs to happen one day, but - // in general Windows is also a more controlled environment than - // Unix, so it's not necessarily as critical that this be implemented. - // - // Note that there are also some licensing worries about statically - // linking some libraries which require a specific agreement, so it may - // not ever be possible for us to pass this flag. - no_default_libraries: false, - has_thread_local: true, - - ..base - } -} diff --git a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs b/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs deleted file mode 100644 index f30c33d99..000000000 --- a/compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::spec::{Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions}; - -pub fn opts() -> TargetOptions { - let base = super::windows_gnu_base::opts(); - - // FIXME: This should be updated for the exception machinery changes from #67502 - // and inherit from `windows_gnu_base`, at least partially. - let mingw_libs = &[ - "-lwinstorecompat", - "-lruntimeobject", - "-lsynchronization", - "-lvcruntime140_app", - "-lucrt", - "-lwindowsapp", - "-lmingwex", - "-lmingw32", - ]; - let mut late_link_args = - TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs); - super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs); - // Reset the flags back to empty until the FIXME above is addressed. - let late_link_args_dynamic = LinkArgs::new(); - let late_link_args_static = LinkArgs::new(); - - TargetOptions { - abi: "uwp".into(), - vendor: "uwp".into(), - limit_rdylib_exports: false, - late_link_args, - late_link_args_dynamic, - late_link_args_static, - - ..base - } -} diff --git a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs b/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs deleted file mode 100644 index 8c942c59d..000000000 --- a/compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::spec::{LinkerFlavor, Lld, TargetOptions}; - -pub fn opts() -> TargetOptions { - let mut opts = super::windows_msvc_base::opts(); - - opts.abi = "uwp".into(); - opts.vendor = "uwp".into(); - opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]); - - opts -} diff --git a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs deleted file mode 100644 index e3f5d7321..000000000 --- a/compiler/rustc_target/src/spec/x86_64_apple_darwin.rs +++ /dev/null @@ -1,26 +0,0 @@ -use super::apple_base::{macos_llvm_target, opts, Arch}; -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::X86_64; - let mut base = opts("macos", arch); - base.max_atomic_width = Some(128); // penryn+ supports cmpxchg16b - base.frame_pointer = FramePointer::Always; - base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD; - - Target { - // Clang automatically chooses a more specific target based on - // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work - // correctly, we do too. - llvm_target: macos_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios.rs deleted file mode 100644 index 061b6a96f..000000000 --- a/compiler/rustc_target/src/spec/x86_64_apple_ios.rs +++ /dev/null @@ -1,21 +0,0 @@ -use super::apple_base::{ios_sim_llvm_target, opts, Arch}; -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::X86_64_sim; - let mut base = opts("ios", arch); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; - - Target { - llvm_target: ios_sim_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { - max_atomic_width: Some(128), - stack_probes: StackProbeType::X86, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs deleted file mode 100644 index fd1926f29..000000000 --- a/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs +++ /dev/null @@ -1,24 +0,0 @@ -use super::apple_base::{opts, Arch}; -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let llvm_target = "x86_64-apple-ios14.0-macabi"; - - let arch = Arch::X86_64_macabi; - let mut base = opts("ios", arch); - base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD; - - Target { - llvm_target: llvm_target.into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { - max_atomic_width: Some(128), - stack_probes: StackProbeType::X86, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs b/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs deleted file mode 100644 index 2ec4d9569..000000000 --- a/compiler/rustc_target/src/spec/x86_64_apple_tvos.rs +++ /dev/null @@ -1,18 +0,0 @@ -use super::apple_base::{opts, tvos_sim_llvm_target, Arch}; -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::X86_64_sim; - Target { - llvm_target: tvos_sim_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { - max_atomic_width: Some(128), - stack_probes: StackProbeType::X86, - ..opts("tvos", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs deleted file mode 100644 index 5fcc00a86..000000000 --- a/compiler/rustc_target/src/spec/x86_64_apple_watchos_sim.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::apple_base::{opts, watchos_sim_llvm_target, Arch}; -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::X86_64_sim; - Target { - llvm_target: watchos_sim_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { - max_atomic_width: Some(128), - stack_probes: StackProbeType::X86, - forces_embed_bitcode: true, - // Taken from a clang build on Xcode 11.4.1. - // These arguments are not actually invoked - they just have - // to look right to pass App Store validation. - bitcode_llvm_cmdline: "-triple\0\ - x86_64-apple-watchos5.0-simulator\0\ - -emit-obj\0\ - -disable-llvm-passes\0\ - -target-abi\0\ - darwinpcs\0\ - -Os\0" - .into(), - ..opts("watchos", arch) - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs deleted file mode 100644 index a7ed74f47..000000000 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ /dev/null @@ -1,83 +0,0 @@ -use std::borrow::Cow; - -use super::{cvs, Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -pub fn target() -> Target { - let pre_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &[ - "-e", - "elf_entry", - "-Bstatic", - "--gc-sections", - "-z", - "text", - "-z", - "norelro", - "--no-undefined", - "--error-unresolved-symbols", - "--no-undefined-version", - "-Bsymbolic", - "--export-dynamic", - // The following symbols are needed by libunwind, which is linked after - // libstd. Make sure they're included in the link. - "-u", - "__rust_abort", - "-u", - "__rust_c_alloc", - "-u", - "__rust_c_dealloc", - "-u", - "__rust_print_err", - "-u", - "__rust_rwlock_rdlock", - "-u", - "__rust_rwlock_unlock", - "-u", - "__rust_rwlock_wrlock", - ], - ); - - const EXPORT_SYMBOLS: &[&str] = &[ - "sgx_entry", - "HEAP_BASE", - "HEAP_SIZE", - "RELA", - "RELACOUNT", - "ENCLAVE_SIZE", - "CFGDATA_BASE", - "DEBUG", - "EH_FRM_HDR_OFFSET", - "EH_FRM_HDR_LEN", - "EH_FRM_OFFSET", - "EH_FRM_LEN", - "TEXT_BASE", - "TEXT_SIZE", - ]; - let opts = TargetOptions { - os: "unknown".into(), - env: "sgx".into(), - vendor: "fortanix".into(), - abi: "fortanix".into(), - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - max_atomic_width: Some(64), - cpu: "x86-64".into(), - plt_by_default: false, - features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), - llvm_args: cvs!["--x86-experimental-lvi-inline-asm-hardening"], - position_independent_executables: true, - pre_link_args, - override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), - relax_elf_relocations: true, - ..Default::default() - }; - Target { - llvm_target: "x86_64-elf".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs b/compiler/rustc_target/src/spec/x86_64_fuchsia.rs deleted file mode 100644 index 96fed0975..000000000 --- a/compiler/rustc_target/src/spec/x86_64_fuchsia.rs +++ /dev/null @@ -1 +0,0 @@ -pub use crate::spec::x86_64_unknown_fuchsia::target; diff --git a/compiler/rustc_target/src/spec/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/x86_64_linux_android.rs deleted file mode 100644 index c110674fd..000000000 --- a/compiler/rustc_target/src/spec/x86_64_linux_android.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::android_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - // https://developer.android.com/ndk/guides/abis.html#86-64 - base.features = "+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-linux-android".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_pc_nto_qnx710.rs b/compiler/rustc_target/src/spec/x86_64_pc_nto_qnx710.rs deleted file mode 100644 index 8424757df..000000000 --- a/compiler/rustc_target/src/spec/x86_64_pc_nto_qnx710.rs +++ /dev/null @@ -1,23 +0,0 @@ -use super::nto_qnx_base; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "x86_64-pc-unknown".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: TargetOptions { - cpu: "x86-64".into(), - plt_by_default: false, - max_atomic_width: Some(64), - pre_link_args: TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-Vgcc_ntox86_64_cxx"], - ), - env: "nto71".into(), - ..nto_qnx_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs deleted file mode 100644 index e2c59d293..000000000 --- a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::solaris_base::opts(); - base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.vendor = "pc".into(); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; - - Target { - llvm_target: "x86_64-pc-solaris".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs deleted file mode 100644 index 1b8885c34..000000000 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_gnu_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - // Use high-entropy 64 bit address space for ASLR - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["-m", "i386pep", "--high-entropy-va"], - ); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]); - base.max_atomic_width = Some(64); - base.linker = Some("x86_64-w64-mingw32-gcc".into()); - - Target { - llvm_target: "x86_64-pc-windows-gnu".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs deleted file mode 100644 index 8f5e398a0..000000000 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_gnullvm.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_gnullvm_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.max_atomic_width = Some(64); - base.linker = Some("x86_64-w64-mingw32-clang".into()); - - Target { - llvm_target: "x86_64-pc-windows-gnu".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs deleted file mode 100644 index 6b897ca70..000000000 --- a/compiler/rustc_target/src/spec/x86_64_pc_windows_msvc.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_msvc_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - - Target { - llvm_target: "x86_64-pc-windows-msvc".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs deleted file mode 100644 index 650065f63..000000000 --- a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::solaris_base::opts(); - base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64"]); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.vendor = "sun".into(); - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "x86_64-pc-solaris".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unikraft_linux_musl.rs b/compiler/rustc_target/src/spec/x86_64_unikraft_linux_musl.rs deleted file mode 100644 index 2aa093b13..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unikraft_linux_musl.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "x86_64-unknown-linux-musl".into(), - pointer_width: 64, - arch: "x86_64".into(), - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - options: TargetOptions { - cpu: "x86-64".into(), - plt_by_default: false, - pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]), - max_atomic_width: Some(64), - stack_probes: StackProbeType::X86, - ..super::unikraft_linux_musl_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs b/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs deleted file mode 100644 index 3b8e75977..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_dragonfly.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::dragonfly_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "x86_64-unknown-dragonfly".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs deleted file mode 100644 index b2d91d099..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::freebsd_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::MEMORY | SanitizerSet::THREAD; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-unknown-freebsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/x86_64_unknown_fuchsia.rs deleted file mode 100644 index bee935419..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_fuchsia.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::fuchsia_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI; - - Target { - llvm_target: "x86_64-unknown-fuchsia".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs b/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs deleted file mode 100644 index 16ed3150e..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_haiku.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::haiku_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - // This option is required to build executables on Haiku x86_64 - base.position_independent_executables = true; - - Target { - llvm_target: "x86_64-unknown-haiku".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs deleted file mode 100644 index 1eb069301..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_hermit.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - Target { - llvm_target: "x86_64-unknown-hermit".into(), - pointer_width: 64, - arch: "x86_64".into(), - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - options: TargetOptions { - cpu: "x86-64".into(), - features: "+rdrnd,+rdseed".into(), - plt_by_default: false, - max_atomic_width: Some(64), - stack_probes: StackProbeType::X86, - ..super::hermit_base::opts() - }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs b/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs deleted file mode 100644 index 9259cfe5f..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_illumos.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, SanitizerSet, Target}; - -pub fn target() -> Target { - let mut base = super::illumos_base::opts(); - base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), &["-m64", "-std=c99"]); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD; - - Target { - // LLVM does not currently have a separate illumos target, - // so we still pass Solaris to it - llvm_target: "x86_64-pc-solaris".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs b/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs deleted file mode 100644 index 912d289c4..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_l4re_uclibc.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{PanicStrategy, Target}; - -pub fn target() -> Target { - let mut base = super::l4re_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.panic_strategy = PanicStrategy::Abort; - - Target { - llvm_target: "x86_64-unknown-l4re-uclibc".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs deleted file mode 100644 index 2f970f87c..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.static_position_independent_executables = true; - base.supported_sanitizers = SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::SAFESTACK - | SanitizerSet::THREAD; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs deleted file mode 100644 index 5469d02c5..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_gnux32.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.cpu = "x86-64".into(); - base.abi = "x32".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mx32"]); - base.stack_probes = StackProbeType::X86; - base.has_thread_local = false; - // BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI - // breaks code gen. See LLVM bug 36743 - base.plt_by_default = true; - - Target { - llvm_target: "x86_64-unknown-linux-gnux32".into(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs deleted file mode 100644 index 7154f5fa3..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_musl_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.static_position_independent_executables = true; - base.supported_sanitizers = SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs deleted file mode 100644 index a96be8cd5..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_linux_ohos.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::linux_ohos_base::opts(); - base.cpu = "x86-64".into(); - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.static_position_independent_executables = true; - base.supported_sanitizers = SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - base.supports_xray = true; - - Target { - // LLVM 15 doesn't support OpenHarmony yet, use a linux target instead. - llvm_target: "x86_64-unknown-linux-musl".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs deleted file mode 100644 index 2e7bf34f7..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::netbsd_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = SanitizerSet::ADDRESS - | SanitizerSet::CFI - | SanitizerSet::LEAK - | SanitizerSet::MEMORY - | SanitizerSet::THREAD; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-unknown-netbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: TargetOptions { mcount: "__mcount".into(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/x86_64_unknown_none.rs deleted file mode 100644 index fe3b24f2d..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_none.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Generic x86-64 target for bare-metal code - Floating point disabled -// -// Can be used in conjunction with the `target-feature` and -// `target-cpu` compiler flags to opt-in more hardware-specific -// features. - -use super::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; -use super::{RelroLevel, SanitizerSet, StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let opts = TargetOptions { - cpu: "x86-64".into(), - plt_by_default: false, - max_atomic_width: Some(64), - stack_probes: StackProbeType::X86, - position_independent_executables: true, - static_position_independent_executables: true, - relro_level: RelroLevel::Full, - linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), - linker: Some("rust-lld".into()), - features: - "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float" - .into(), - supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, - disable_redzone: true, - panic_strategy: PanicStrategy::Abort, - code_model: Some(CodeModel::Kernel), - ..Default::default() - }; - Target { - llvm_target: "x86_64-unknown-none-elf".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: opts, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs deleted file mode 100644 index 86fa9bf7e..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::openbsd_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supports_xray = true; - - Target { - llvm_target: "x86_64-unknown-openbsd".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs b/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs deleted file mode 100644 index decc97367..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_redox.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::redox_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - - Target { - llvm_target: "x86_64-unknown-redox".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs deleted file mode 100644 index 41ba76806..000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs +++ /dev/null @@ -1,38 +0,0 @@ -// This defines the amd64 target for UEFI systems as described in the UEFI specification. See the -// uefi-base module for generic UEFI options. On x86_64 systems (mostly called "x64" in the spec) -// UEFI systems always run in long-mode, have the interrupt-controller pre-configured and force a -// single-CPU execution. -// The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with -// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features. - -use crate::{abi::call::Conv, spec::Target}; - -pub fn target() -> Target { - let mut base = super::uefi_msvc_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.entry_abi = Conv::X86_64Win64; - - // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to - // enable these CPU features explicitly before their first use, otherwise their instructions - // will trigger an exception. Rust does not inject any code that enables AVX/MMX/SSE - // instruction sets, so this must be done by the firmware. However, existing firmware is known - // to leave these uninitialized, thus triggering exceptions if we make use of them. Which is - // why we avoid them and instead use soft-floats. This is also what GRUB and friends did so - // far. - // - // If you initialize FP units yourself, you can override these flags with custom linker - // arguments, thus giving you access to full MMX/SSE acceleration. - base.features = "-mmx,-sse,+soft-float".into(); - - Target { - llvm_target: "x86_64-unknown-windows".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs deleted file mode 100644 index 1a9d2a571..000000000 --- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_gnu.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target}; - -pub fn target() -> Target { - let mut base = super::windows_uwp_gnu_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - // Use high-entropy 64 bit address space for ASLR - base.add_pre_link_args( - LinkerFlavor::Gnu(Cc::No, Lld::No), - &["-m", "i386pep", "--high-entropy-va"], - ); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]); - base.max_atomic_width = Some(64); - - Target { - llvm_target: "x86_64-pc-windows-gnu".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs deleted file mode 100644 index 1ae403fa8..000000000 --- a/compiler/rustc_target/src/spec/x86_64_uwp_windows_msvc.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::windows_uwp_msvc_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - - Target { - llvm_target: "x86_64-pc-windows-msvc".into(), - pointer_width: 64, - data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs deleted file mode 100644 index a7c4aaecf..000000000 --- a/compiler/rustc_target/src/spec/x86_64_wrs_vxworks.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target}; - -pub fn target() -> Target { - let mut base = super::vxworks_base::opts(); - base.cpu = "x86-64".into(); - base.plt_by_default = false; - base.max_atomic_width = Some(64); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.disable_redzone = true; - - Target { - llvm_target: "x86_64-unknown-linux-gnu".into(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: "x86_64".into(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/x86_64h_apple_darwin.rs b/compiler/rustc_target/src/spec/x86_64h_apple_darwin.rs deleted file mode 100644 index 54f7490b2..000000000 --- a/compiler/rustc_target/src/spec/x86_64h_apple_darwin.rs +++ /dev/null @@ -1,44 +0,0 @@ -use super::apple_base::{macos_llvm_target, opts, Arch}; -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; -use crate::spec::{StackProbeType, Target, TargetOptions}; - -pub fn target() -> Target { - let arch = Arch::X86_64h; - let mut base = opts("macos", arch); - base.max_atomic_width = Some(128); - base.frame_pointer = FramePointer::Always; - base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); - base.stack_probes = StackProbeType::X86; - base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD; - - // x86_64h is core2-avx without a few of the features which would otherwise - // be guaranteed, so we need to disable those. This imitates clang's logic: - // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L77-L78 - // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L133-L141 - // - // FIXME: Sadly, turning these off here disables them in such a way that they - // aren't re-enabled by `-Ctarget-cpu=native` (on a machine that has them). - // It would be nice if this were not the case, but fixing it seems tricky - // (and given that the main use-case for this target is for use in universal - // binaries, probably not that important). - base.features = "-rdrnd,-aes,-pclmul,-rtm,-fsgsbase".into(); - // Double-check that the `cpu` is what we expect (if it's not the list above - // may need updating). - assert_eq!( - base.cpu, "core-avx2", - "you need to adjust the feature list in x86_64h-apple-darwin if you change this", - ); - - Target { - // Clang automatically chooses a more specific target based on - // MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work - // correctly, we do too. - llvm_target: macos_llvm_target(arch).into(), - pointer_width: 64, - data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .into(), - arch: arch.target_arch(), - options: TargetOptions { mcount: "\u{1}mcount".into(), ..base }, - } -} -- cgit v1.2.3