From ad26dab27cd314d13e64fe5b49cfa5260a57ab53 Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Thu, 12 May 2022 21:17:31 +0800 Subject: [PATCH 01/11] Initial support for loongarch64-unknown-linux-gnu --- .../src/spec/loongarch64_unknown_linux_gnu.rs | 17 ++++ compiler/rustc_target/src/spec/mod.rs | 1 + src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../src/platform-support/loongarch-linux.md | 92 +++++++++++++++++++ tests/ui/check-cfg/compact-values.stderr | 2 +- 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs create mode 100644 src/doc/rustc/src/platform-support/loongarch-linux.md diff --git a/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs new file mode 100644 index 0000000000000..db8b9c70e6702 --- /dev/null +++ b/compiler/rustc_target/src/spec/loongarch64_unknown_linux_gnu.rs @@ -0,0 +1,17 @@ +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/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 2553b11d8789b..c92a796c70e0d 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1021,6 +1021,7 @@ supported_targets! { ("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32), ("i686-unknown-linux-gnu", i686_unknown_linux_gnu), ("i586-unknown-linux-gnu", i586_unknown_linux_gnu), + ("loongarch64-unknown-linux-gnu", loongarch64_unknown_linux_gnu), ("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu), ("mips-unknown-linux-gnu", mips_unknown_linux_gnu), ("mips64-unknown-linux-gnuabi64", mips64_unknown_linux_gnuabi64), diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 752f1cc4aba03..bbf53a09ce897 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -28,6 +28,7 @@ - [\*-android and \*-androideabi](platform-support/android.md) - [\*-unknown-fuchsia](platform-support/fuchsia.md) - [\*-kmc-solid_\*](platform-support/kmc-solid.md) + - [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md) - [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md) - [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md) - [mipsel-sony-psx](platform-support/mipsel-sony-psx.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 2d74a2240969c..f9de456d17e5b 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -263,6 +263,7 @@ target | std | host | notes `i686-uwp-windows-gnu` | ? | | `i686-uwp-windows-msvc` | ? | | `i686-wrs-vxworks` | ? | | +[`loongarch64-unknown-linux-gnu`](platform-support/loongarch-linux.md) | ? | | LoongArch64 Linux (LP64D ABI) [`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux `mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc [`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux MUSL diff --git a/src/doc/rustc/src/platform-support/loongarch-linux.md b/src/doc/rustc/src/platform-support/loongarch-linux.md new file mode 100644 index 0000000000000..e046ec244ece9 --- /dev/null +++ b/src/doc/rustc/src/platform-support/loongarch-linux.md @@ -0,0 +1,92 @@ +# loongarch\*-unknown-linux-\* + +**Tier: 3** + +[LoongArch] is a new RISC ISA developed by Loongson Technology Corporation Limited. + +[LoongArch]: https://loongson.github.io/LoongArch-Documentation/README-EN.html + +The target name follow this format: `--, where `` specifies the CPU family/model, `` specifies the vendor and `` the operating system name. +While the integer base ABI is implied by the machine field, the floating point base ABI type is encoded into the os field of the specifier using the string suffix ``. + +| `` | `Description` | +|------------------------|--------------------------------------------------------------------| +| f64 | The base ABI use 64-bits FPRs for parameter passing.(lp64d)| +| f32 | The base ABI uses 32-bit FPRs for parameter passing. (lp64f)| +| sf | The base ABI uses no FPR for parameter passing. (lp64s) | + +|`ABI type(Base ABI/ABI extension)`| `C library` | `kernel` | `target tuple` | +|----------------------------------|-------------|----------|----------------------------------| +| lp64d/base | glibc | linux | loongarch64-unknown-linux-gnu | +| lp64f/base | glibc | linux | loongarch64-unknown-linux-gnuf32 | +| lp64s/base | glibc | linux | loongarch64-unknown-linux-gnusf | +| lp64d/base | musl libc | linux | loongarch64-unknown-linux-musl| +| lp64f/base | musl libc | linux | loongarch64-unknown-linux-muslf32| +| lp64s/base | musl libc | linux | loongarch64-unknown-linux-muslsf | + +## Target maintainers + +- [ZHAI xiaojuan](https://github.com/zhaixiaojuan) `zhaixiaojuan@loongson.cn` +- [WANG rui](https://github.com/heiher) `wangrui@loongson.cn` +- [ZHAI xiang](https://github.com/xiangzhai) `zhaixiang@loongson.cn` +- [WANG Xuerui](https://github.com/xen0n) `git@xen0n.name` + +## Requirements + +This target is cross-compiled. +A GNU toolchain for LoongArch target is required. It can be downloaded from https://github.com/loongson/build-tools/releases, or built from the source code of GCC (12.1.0 or later) and Binutils (2.40 or later). + +## Building the target + +The target can be built by enabling it for a `rustc` build. + +```toml +[build] +target = ["loongarch64-unknown-linux-gnu"] +``` + +Make sure `loongarch64-unknown-linux-gnu-gcc` can be searched from the directories specified in`$PATH`. Alternatively, you can use GNU LoongArch Toolchain by adding the following to `config.toml`: + +```toml +[target.loongarch64-unknown-linux-gnu] +# ADJUST THIS PATH TO POINT AT YOUR TOOLCHAIN +cc = "/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc" +cxx = "/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-g++" +ar = "/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-ar" +ranlib = "/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-ranlib" +linker = "/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc" +``` + +## Cross-compilation + +This target can be cross-compiled on a `x86_64-unknown-linux-gnu` host. Cross-compilation on other hosts may work but is not tested. + +## Testing +To test a cross-compiled binary on your build system, install the qemu binary that supports the LoongArch architecture and execute the following commands. +```text +CC_loongarch64_unknown_linux_gnu=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc \ +CXX_loongarch64_unknown_linux_gnu=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-g++ \ +AR_loongarch64_unknown_linux_gnu=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc-ar \ +CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNUN_LINKER=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc \ +# SET TARGET SYSTEM LIBRARY PATH +CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNUN_RUNNER="qemu-loongarch64 -L /TOOLCHAIN_PATH/TARGET_LIBRAY_PATH" \ +cargo run --target loongarch64-unknown-linux-gnu --release +``` +Tested on x86 architecture, other architectures not tested. + +## Building Rust programs + +Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you will either need to build Rust with the target enabled (see "Building the target" above), or build your own copy of `std` by using `build-std` or similar. + +If `rustc` has support for that target and the library artifacts are available, then Rust static libraries can be built for that target: + +```shell +$ rustc --target loongarch64-unknown-linux-gnu your-code.rs --crate-type staticlib +$ ls libyour_code.a +``` + +On Rust Nightly it's possible to build without the target artifacts available: + +```text +cargo build -Z build-std --target loongarch64-unknown-linux-gnu +``` diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 9864aa385f99e..5ca4d3b3de741 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition value LL | #[cfg(target(os = "linux", arch = "X"))] | ^^^^^^^^^^ | - = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 + = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, loongarch64, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted From a5e23115bdd3b4655d2bad6076c69c90eec6f12d Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Wed, 6 Jul 2022 18:29:04 +0800 Subject: [PATCH 02/11] library/std: Add support for loongarch64 --- library/std/src/env.rs | 1 + library/std/src/os/linux/raw.rs | 1 + library/std/src/sys/common/alloc.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 183f9ab3b08f6..3014fe6e2fc2b 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -895,6 +895,7 @@ pub mod consts { /// - x86_64 /// - arm /// - aarch64 + /// - loongarch64 /// - m68k /// - mips /// - mips64 diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs index f46028c3a96c9..c55ca8ba26e2f 100644 --- a/library/std/src/os/linux/raw.rs +++ b/library/std/src/os/linux/raw.rs @@ -231,6 +231,7 @@ mod arch { } #[cfg(any( + target_arch = "loongarch64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", diff --git a/library/std/src/sys/common/alloc.rs b/library/std/src/sys/common/alloc.rs index 403a5e627f1e7..a5fcbdf39c6c6 100644 --- a/library/std/src/sys/common/alloc.rs +++ b/library/std/src/sys/common/alloc.rs @@ -22,6 +22,7 @@ pub const MIN_ALIGN: usize = 8; #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", + target_arch = "loongarch64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", From 50be2a30cb8d5141e45c1528b7f538094174941f Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Wed, 6 Jul 2022 18:41:14 +0800 Subject: [PATCH 03/11] library/unwind: Add definitions for loongarch64 --- library/unwind/src/libunwind.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index eeeed3afcd30c..f6a68073b2f7e 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -75,6 +75,9 @@ pub const unwinder_private_data_size: usize = 20; #[cfg(all(target_arch = "hexagon", target_os = "linux"))] pub const unwinder_private_data_size: usize = 35; +#[cfg(target_arch = "loongarch64")] +pub const unwinder_private_data_size: usize = 2; + #[repr(C)] pub struct _Unwind_Exception { pub exception_class: _Unwind_Exception_Class, From f465bc7874012fdd019d8025861e6dae1e996d5e Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Thu, 7 Jul 2022 10:38:18 +0800 Subject: [PATCH 04/11] rustdoc: Add human-readable cfg string for loongarch64 --- src/librustdoc/clean/cfg.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index dd58a5b51fc1a..5177cffe6bae4 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -517,6 +517,7 @@ impl<'a> fmt::Display for Display<'a> { "aarch64" => "AArch64", "arm" => "ARM", "asmjs" => "JavaScript", + "loongarch64" => "LoongArch LA64", "m68k" => "M68k", "mips" => "MIPS", "mips64" => "MIPS-64", From 10f7ba562a2f84ff2cfc6d5beec795c24c7e15cd Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Thu, 7 Jul 2022 11:35:08 +0800 Subject: [PATCH 05/11] Add LLVM target and cputype matching for loongarch64 --- src/bootstrap/bootstrap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 013d1ab525b0c..cd59484398c3c 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -304,6 +304,7 @@ def default_build_triple(verbose): 'i486': 'i686', 'i686': 'i686', 'i786': 'i686', + 'loongarch64': 'loongarch64', 'm68k': 'm68k', 'powerpc': 'powerpc', 'powerpc64': 'powerpc64', From ccf54177990bd569ec1903735e2c55b6b68471a8 Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Thu, 7 Jul 2022 15:46:10 +0800 Subject: [PATCH 06/11] Enable loongarch64 LLVM target --- compiler/rustc_llvm/build.rs | 1 + compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 7 +++++++ compiler/rustc_llvm/src/lib.rs | 8 ++++++++ config.example.toml | 2 +- src/bootstrap/llvm.rs | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index f8e9ec535e456..b0783d75d4756 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -10,6 +10,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[ "aarch64", "amdgpu", "avr", + "loongarch", "m68k", "mips", "powerpc", diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index e604e44a7157b..d48b3a30fc167 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -146,6 +146,12 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) { #define SUBTARGET_HEXAGON #endif +#ifdef LLVM_COMPONENT_LOONGARCH +#define SUBTARGET_LOONGARCH SUBTARGET(LoongArch) +#else +#define SUBTARGET_LOONGARCH +#endif + #define GEN_SUBTARGETS \ SUBTARGET_X86 \ SUBTARGET_ARM \ @@ -159,6 +165,7 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) { SUBTARGET_SPARC \ SUBTARGET_HEXAGON \ SUBTARGET_RISCV \ + SUBTARGET_LOONGARCH \ #define SUBTARGET(x) \ namespace llvm { \ diff --git a/compiler/rustc_llvm/src/lib.rs b/compiler/rustc_llvm/src/lib.rs index 8542dcf5bf0fe..06351731bdecd 100644 --- a/compiler/rustc_llvm/src/lib.rs +++ b/compiler/rustc_llvm/src/lib.rs @@ -102,6 +102,14 @@ pub fn initialize_available_targets() { LLVMInitializeM68kAsmPrinter, LLVMInitializeM68kAsmParser ); + init_target!( + llvm_component = "loongarch", + LLVMInitializeLoongArchTargetInfo, + LLVMInitializeLoongArchTarget, + LLVMInitializeLoongArchTargetMC, + LLVMInitializeLoongArchAsmPrinter, + LLVMInitializeLoongArchAsmParser + ); init_target!( llvm_component = "mips", LLVMInitializeMipsTargetInfo, diff --git a/config.example.toml b/config.example.toml index 5ef83760aed2d..27b6781ca3550 100644 --- a/config.example.toml +++ b/config.example.toml @@ -88,7 +88,7 @@ changelog-seen = 2 # the resulting rustc being unable to compile for the disabled architectures. # # To add support for new targets, see https://rustc-dev-guide.rust-lang.org/building/new-target.html. -#targets = "AArch64;ARM;BPF;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86" +#targets = "AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86" # LLVM experimental targets to build support for. These targets are specified in # the same format as above, but since these targets are experimental, they are diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs index de06f8ca8c0bb..55b2da7872d2a 100644 --- a/src/bootstrap/llvm.rs +++ b/src/bootstrap/llvm.rs @@ -291,7 +291,7 @@ impl Step for Llvm { let llvm_targets = match &builder.config.llvm_targets { Some(s) => s, None => { - "AArch64;ARM;BPF;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\ + "AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;\ Sparc;SystemZ;WebAssembly;X86" } }; From ca8cad789675b8d8350090c4b8c3a3365d6bcd5b Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Wed, 10 Aug 2022 17:32:53 +0800 Subject: [PATCH 07/11] Add loongarch64 to exception list --- src/bootstrap/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 20b92b294fec5..61d764c05c7ec 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -129,7 +129,8 @@ const EXTRA_CHECK_CFGS: &[(Option, &'static str, Option<&[&'static str]>)] /* Extra values not defined in the built-in targets yet, but used in std */ (Some(Mode::Std), "target_env", Some(&["libnx"])), // (Some(Mode::Std), "target_os", Some(&[])), - (Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa"])), + // #[cfg(bootstrap)] loongarch64 + (Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa", "loongarch64"])), /* Extra names used by dependencies */ // FIXME: Used by serde_json, but we should not be triggering on external dependencies. (Some(Mode::Rustc), "no_btreemap_remove_entry", None), From b7c5323d42a661665c97e2e14223ac57068775db Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Fri, 3 Feb 2023 11:37:31 +0800 Subject: [PATCH 08/11] Add loongarch64 to fn create_object_file --- compiler/rustc_codegen_ssa/src/back/metadata.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 4ab56699922f5..19485175fd1c1 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -128,6 +128,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option Architecture::Msp430, "hexagon" => Architecture::Hexagon, "bpf" => Architecture::Bpf, + "loongarch64" => Architecture::LoongArch64, // Unsupported architecture. _ => return None, }; From 737e1d25692ff57699fddb379d62dd6ec1cb2006 Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Fri, 3 Feb 2023 11:47:27 +0800 Subject: [PATCH 09/11] loongarch64: calculate the ELF header flags --- compiler/rustc_codegen_ssa/src/back/metadata.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 19485175fd1c1..8ee7d8cf6d027 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -192,6 +192,10 @@ pub(crate) fn create_object_file(sess: &Session) -> Option { + // Source: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version + elf::EF_LARCH_OBJABI_V1 | elf::EF_LARCH_ABI_DOUBLE_FLOAT + } _ => 0, }; // adapted from LLVM's `MCELFObjectTargetWriter::getOSABI` From bf1758d229d08a1a40fb78c0031bba26060a8fe6 Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Fri, 3 Feb 2023 16:24:11 +0800 Subject: [PATCH 10/11] Define UNWIND_DATA_REG for loongarch64 --- library/std/src/personality/gcc.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/personality/gcc.rs b/library/std/src/personality/gcc.rs index 41c0fe725a540..0421b47be024e 100644 --- a/library/std/src/personality/gcc.rs +++ b/library/std/src/personality/gcc.rs @@ -77,6 +77,9 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 #[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 +#[cfg(target_arch = "loongarch64")] +const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1 + // The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c From a3f0046142aec8e00d3e8192f83a8cc0bacef9e8 Mon Sep 17 00:00:00 2001 From: zhaixiaojuan Date: Tue, 28 Mar 2023 16:18:12 +0800 Subject: [PATCH 11/11] Define MIN_ALIGN for loongarch64 --- compiler/rustc_codegen_gcc/example/alloc_system.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_codegen_gcc/example/alloc_system.rs b/compiler/rustc_codegen_gcc/example/alloc_system.rs index 9ec18da90d819..046903fe5aca4 100644 --- a/compiler/rustc_codegen_gcc/example/alloc_system.rs +++ b/compiler/rustc_codegen_gcc/example/alloc_system.rs @@ -15,6 +15,7 @@ const MIN_ALIGN: usize = 8; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64", + target_arch = "loongarch64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))]