diff --git a/0001-rustc-Convert-to-ABI-v0.patch b/0001-rustc-Convert-to-ABI-v0.patch new file mode 100644 index 0000000000000000000000000000000000000000..279a2e0919c2689ecaff3a23d46aab7fd35da2d2 --- /dev/null +++ b/0001-rustc-Convert-to-ABI-v0.patch @@ -0,0 +1,128 @@ +From 22ed00acf647ef81cb02515619b2520287a9cb7d Mon Sep 17 00:00:00 2001 +From: WANG Rui +Date: Fri, 28 Jul 2023 17:19:20 +0800 +Subject: [PATCH] rustc: Convert to ABI v0 + +--- + compiler/rustc_codegen_ssa/src/back/metadata.rs | 13 +------------ + compiler/rustc_codegen_ssa/src/target_features.rs | 7 ------- + compiler/rustc_llvm/build.rs | 1 + + compiler/rustc_target/src/abi/call/loongarch.rs | 4 ++-- + .../spec/targets/loongarch64_unknown_linux_gnu.rs | 7 +++---- + .../src/spec/targets/loongarch64_unknown_none.rs | 7 +++---- + 6 files changed, 10 insertions(+), 29 deletions(-) + +diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs +index cb60ed729c1..840cb2970af 100644 +--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs ++++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs +@@ -321,18 +321,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option { + // Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version +- let mut e_flags: u32 = elf::EF_LARCH_OBJABI_V1; +- +- // Set the appropriate flag based on ABI +- // This needs to match LLVM `LoongArchELFStreamer.cpp` +- match &*sess.target.llvm_abiname { +- "ilp32s" | "lp64s" => e_flags |= elf::EF_LARCH_ABI_SOFT_FLOAT, +- "ilp32f" | "lp64f" => e_flags |= elf::EF_LARCH_ABI_SINGLE_FLOAT, +- "ilp32d" | "lp64d" => e_flags |= elf::EF_LARCH_ABI_DOUBLE_FLOAT, +- _ => bug!("unknown RISC-V ABI name"), +- } +- +- e_flags ++ elf::EF_LARCH_ABI_DOUBLE_FLOAT + } + Architecture::Avr => { + // Resolve the ISA revision and set +diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs +index 2936f1de3cb..956e42f14a7 100644 +--- a/compiler/rustc_codegen_ssa/src/target_features.rs ++++ b/compiler/rustc_codegen_ssa/src/target_features.rs +@@ -354,13 +354,6 @@ + + const LOONGARCH_ALLOWED_FEATURES: &[(&str, Option)] = &[ + // tidy-alphabetical-start +- ("d", Some(sym::loongarch_target_feature)), +- ("f", Some(sym::loongarch_target_feature)), +- ("lasx", Some(sym::loongarch_target_feature)), +- ("lbt", Some(sym::loongarch_target_feature)), +- ("lsx", Some(sym::loongarch_target_feature)), +- ("lvz", Some(sym::loongarch_target_feature)), +- ("ual", Some(sym::loongarch_target_feature)), + // tidy-alphabetical-end + ]; + +diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs +index fe13162cd4a..19439d4c6de 100644 +--- a/compiler/rustc_llvm/build.rs ++++ b/compiler/rustc_llvm/build.rs +@@ -255,6 +255,7 @@ fn main() { + } else if target.contains("haiku") + || target.contains("darwin") + || (is_crossed && (target.contains("dragonfly") || target.contains("solaris"))) ++ || target.contains("loongarch") + { + println!("cargo:rustc-link-lib=z"); + } else if target.contains("netbsd") { +diff --git a/compiler/rustc_target/src/abi/call/loongarch.rs b/compiler/rustc_target/src/abi/call/loongarch.rs +index e649d58bbca..2c24156aa54 100644 +--- a/compiler/rustc_target/src/abi/call/loongarch.rs ++++ b/compiler/rustc_target/src/abi/call/loongarch.rs +@@ -324,8 +324,8 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) + { + let xlen = cx.data_layout().pointer_size.bits(); + let flen = match &cx.target_spec().llvm_abiname[..] { +- "ilp32f" | "lp64f" => 32, +- "ilp32d" | "lp64d" => 64, ++ "lp64" => 64, ++ "lp32" | "lpx32" => 32, + _ => 0, + }; + +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 +index 0f05e7c475a..00dbbed6ebd 100644 +--- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs ++++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs +@@ -4,12 +4,11 @@ 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(), ++ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "loongarch64".into(), + options: TargetOptions { +- cpu: "generic".into(), +- features: "+f,+d".into(), +- llvm_abiname: "lp64d".into(), ++ cpu: "la464".into(), ++ llvm_abiname: "lp64".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 +index 3b1ea8e206f..c56035b0b90 100644 +--- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs ++++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs +@@ -5,14 +5,13 @@ 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(), ++ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(), + arch: "loongarch64".into(), + options: TargetOptions { +- cpu: "generic".into(), +- features: "+f,+d".into(), ++ cpu: "la464".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), +- llvm_abiname: "lp64d".into(), ++ llvm_abiname: "lp64".into(), + max_atomic_width: Some(64), + relocation_model: RelocModel::Static, + panic_strategy: PanicStrategy::Abort, +-- +2.46.0 + diff --git a/rust.spec b/rust.spec index af52df5db8d4e9bd36b8fd95f0f58a065576c52f..c6e9401ce1c89fe24fb973f9f7c9ad85899d5c6d 100644 --- a/rust.spec +++ b/rust.spec @@ -1,6 +1,7 @@ +%define anolis_release .0.1 Name: rust Version: 1.75.0 -Release: 1%{?dist} +Release: 1%{anolis_release}%{?dist} Summary: The Rust Programming Language License: (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-DFS-2016) # ^ written as: (rust itself) and (bundled libraries) @@ -8,7 +9,7 @@ URL: https://www.rust-lang.org # Only x86_64, i686, and aarch64 are Tier 1 platforms at this time. # https://doc.rust-lang.org/nightly/rustc/platform-support.html -%global rust_arches x86_64 i686 aarch64 ppc64le s390x +%global rust_arches x86_64 i686 aarch64 ppc64le s390x loongarch64 ExclusiveArch: %{rust_arches} # To bootstrap from scratch, set the channel and date from src/stage0.json @@ -133,6 +134,8 @@ Source100: macros.rust-toolset # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) Patch100: rustc-1.75.0-disable-libssh2.patch +Patch102: 0001-rustc-Convert-to-ABI-v0.patch + # Get the Rust triple for any arch. %{lua: function rust_triple(arch) local abi = "gnu" @@ -573,6 +576,8 @@ rm -rf %{wasi_libc_dir}/dlmalloc/ %patch -P100 -p1 %endif +%patch -P102 -p1 + # Use our explicit python3 first sed -i.try-python -e '/^try python3 /i try "%{__python3}" "$@"' ./configure @@ -655,7 +660,7 @@ end} %build %{export_rust_env} -%ifarch %{arm} %{ix86} +%ifarch %{arm} %{ix86} loongarch64 # full debuginfo and compiler opts are exhausting memory; just do libstd for now # https://github.com/rust-lang/rust/issues/45854 %define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2 @@ -1040,6 +1045,9 @@ timeout -v 30m %{__xk} test --no-fail-fast rustfmt || : %changelog +* Mon Jun 17 2024 WANG Rui - 1.75.0-1.0.1 +- Add support for loongarch64. + * Fri Jan 05 2024 Josh Stone - 1.75.0-1 - Update to 1.75.0.