File 0003-drop-latomic-for-riscv-targets.patch of Package rust
From 20693010f6fb4a18e5117a28099dd7e034d64448 Mon Sep 17 00:00:00 2001
From: Yao Zi <[email protected]>
Date: Sun, 13 Oct 2024 20:14:47 +0000
Subject: [PATCH] drop -latomic for riscv targets
Rustc doesn't recognize compiler-rt based Linux distro correctly and
tries to link libatomic on these targets. Let's drop the linkflag
manually.
Signed-off-by: Yao Zi <[email protected]>
---
compiler/rustc_llvm/build.rs | 18 +-----------------
src/bootstrap/src/core/build_steps/llvm.rs | 19 -------------------
2 files changed, 1 insertion(+), 36 deletions(-)
diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 4c1f78e..9da5723 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -230,15 +230,7 @@ fn main() {
println!("cargo:rustc-link-lib=kstat");
}
- if (target.starts_with("arm") && !target.contains("freebsd"))
- || target.starts_with("mips-")
- || target.starts_with("mipsel-")
- || target.starts_with("powerpc-")
- || target.starts_with("sparc-")
- {
- // 32-bit targets need to link libatomic.
- println!("cargo:rustc-link-lib=atomic");
- } else if target.contains("windows-gnu") {
+ if target.contains("windows-gnu") {
println!("cargo:rustc-link-lib=shell32");
println!("cargo:rustc-link-lib=uuid");
} else if target.contains("haiku")
@@ -348,14 +340,6 @@ fn main() {
"stdc++"
};
- // RISC-V GCC erroneously requires libatomic for sub-word
- // atomic operations. Some BSD uses Clang as its system
- // compiler and provides no libatomic in its base system so
- // does not want this.
- if target.starts_with("riscv") && !target.contains("freebsd") && !target.contains("openbsd") {
- println!("cargo:rustc-link-lib=atomic");
- }
-
// C++ runtime library
if !target.contains("msvc") {
if let Some(s) = llvm_static_stdcpp {
diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
index f234b08..1d07b98 100644
--- a/src/bootstrap/src/core/build_steps/llvm.rs
+++ b/src/bootstrap/src/core/build_steps/llvm.rs
@@ -400,25 +400,6 @@ impl Step for Llvm {
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
}
- if (target.starts_with("csky")
- || target.starts_with("riscv")
- || target.starts_with("sparc-"))
- && !target.contains("freebsd")
- && !target.contains("openbsd")
- && !target.contains("netbsd")
- {
- // CSKY and RISC-V GCC erroneously requires linking against
- // `libatomic` when using 1-byte and 2-byte C++
- // atomics but the LLVM build system check cannot
- // detect this. Therefore it is set manually here.
- // Some BSD uses Clang as its system compiler and
- // provides no libatomic in its base system so does
- // not want this. 32-bit SPARC requires linking against
- // libatomic as well.
- ldflags.exe.push(" -latomic");
- ldflags.shared.push(" -latomic");
- }
-
if target.starts_with("mips") && target.contains("netbsd") {
// LLVM wants 64-bit atomics, while mipsel is 32-bit only, so needs -latomic
ldflags.exe.push(" -latomic");
--
2.47.0