From 2d55b2dc2de900d9f8200305d65e7b6649c32469 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Tue, 26 Dec 2023 22:23:54 +0800 Subject: [PATCH] Update loongarch64 --- 0001-rustc-Convert-to-ABI-v0.patch | 129 +++++++++++++++++++++++++++++ rust.spec | 12 ++- 2 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 0001-rustc-Convert-to-ABI-v0.patch diff --git a/0001-rustc-Convert-to-ABI-v0.patch b/0001-rustc-Convert-to-ABI-v0.patch new file mode 100644 index 0000000..c697114 --- /dev/null +++ b/0001-rustc-Convert-to-ABI-v0.patch @@ -0,0 +1,129 @@ +From e970f0538843026f7d804e29b435b4d27be5be53 Mon Sep 17 00:00:00 2001 +From: WANG Rui +Date: Thu, 19 Sep 2024 16:03:01 +0800 +Subject: [PATCH] rustc: Convert to ABI v0 + +--- + compiler/rustc_codegen_ssa/src/back/metadata.rs | 13 +------------ + 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 +++---- + compiler/rustc_target/src/target_features.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 b683e1b45..a1bed40d4 100644 +--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs ++++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs +@@ -326,18 +326,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_llvm/build.rs b/compiler/rustc_llvm/build.rs +index 4b0c1229d..106b6b6b0 100644 +--- a/compiler/rustc_llvm/build.rs ++++ b/compiler/rustc_llvm/build.rs +@@ -261,6 +261,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 647b6500c..b9e748352 100644 +--- a/compiler/rustc_target/src/abi/call/loongarch.rs ++++ b/compiler/rustc_target/src/abi/call/loongarch.rs +@@ -332,8 +332,8 @@ where + { + 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 0f05e7c47..00dbbed6e 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 3b1ea8e20..c56035b0b 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, +diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs +index 5f5de57dd..23f07a33b 100644 +--- a/compiler/rustc_target/src/target_features.rs ++++ b/compiler/rustc_target/src/target_features.rs +@@ -372,13 +372,6 @@ const CSKY_ALLOWED_FEATURES: &[(&str, Stability)] = &[ + + const LOONGARCH_ALLOWED_FEATURES: &[(&str, Stability)] = &[ + // tidy-alphabetical-start +- ("d", Unstable(sym::loongarch_target_feature)), +- ("f", Unstable(sym::loongarch_target_feature)), +- ("lasx", Unstable(sym::loongarch_target_feature)), +- ("lbt", Unstable(sym::loongarch_target_feature)), +- ("lsx", Unstable(sym::loongarch_target_feature)), +- ("lvz", Unstable(sym::loongarch_target_feature)), +- ("ual", Unstable(sym::loongarch_target_feature)), + // tidy-alphabetical-end + ]; + +-- +2.46.1 + + diff --git a/rust.spec b/rust.spec index 3e45f1c..6661cbf 100644 --- a/rust.spec +++ b/rust.spec @@ -1,6 +1,7 @@ +%define anolis_release .0.1 Name: rust Version: 1.76.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 @@ -140,6 +141,8 @@ Source102: cargo_vendor.prov # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) Patch100: rustc-1.76.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" @@ -581,6 +584,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 @@ -1045,6 +1050,9 @@ timeout -v 30m %{__xk} test --no-fail-fast rustfmt || : %changelog +* Wed Sep 18 2024 WANG Rui - 1.76.0-1.0.1 +- Add support for loongarch64. + * Wed Apr 17 2024 Josh Stone - 1.76.0-1 - Update to 1.76.0. - Sync rust-toolset macros to rust-packaging v25.2 -- Gitee