about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Kortkamp <t@tobik.me>2021-12-03 18:48:53 +0100
committerTobias Kortkamp <t@tobik.me>2021-12-03 18:49:42 +0100
commite24045e5873a19690bda6a07a63912adfc375b13 (patch)
treec028b0bebec814f894799a0ecd7b39a094e9dc34
parent47474f10558a473258510b0e5dea13d607a5d34c (diff)
downloadrust-e24045e5873a19690bda6a07a63912adfc375b13.tar.gz
rust-e24045e5873a19690bda6a07a63912adfc375b13.zip
Explain why libatomic is not needed on FreeBSD riscv64
From Jessica Clarke (jrtc27@)
-rw-r--r--compiler/rustc_llvm/build.rs5
-rw-r--r--src/bootstrap/native.rs9
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 7f3345d2a70..3b6808d693f 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -276,7 +276,10 @@ fn main() {
         "stdc++"
     };
 
-    // RISC-V requires libatomic for sub-word atomic operations
+    // RISC-V GCC erroneously requires libatomic for sub-word
+    // atomic operations. FreeBSD uses Clang as its system
+    // compiler and provides no libatomic in its base system so
+    // does not want this.
     if !target.contains("freebsd") && target.starts_with("riscv") {
         println!("cargo:rustc-link-lib=atomic");
     }
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index f50797285d2..4a754e6da12 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -250,8 +250,13 @@ impl Step for Llvm {
         }
 
         if !target.contains("freebsd") && target.starts_with("riscv") {
-            // In RISC-V, using C++ atomics require linking to `libatomic` but the LLVM build
-            // system check cannot detect this. Therefore it is set manually here.
+            // 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.
+            // FreeBSD uses Clang as its system compiler and
+            // provides no libatomic in its base system so does
+            // not want this.
             if !builder.config.llvm_tools_enabled {
                 cfg.define("CMAKE_EXE_LINKER_FLAGS", "-latomic");
             } else {