summaryrefslogtreecommitdiff
path: root/gnu/packages/rust.scm
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2024-01-15 17:39:39 +0200
committerEfraim Flashner <efraim@flashner.co.il>2024-02-20 13:57:42 +0200
commit930bba14588898bd3c0035ec37a9004ca2028a37 (patch)
treed36156f8fbfd7468488a415f80fa0b2633774b2b /gnu/packages/rust.scm
parentd3f4df4be93ce5c28f7b40a3a91aeb6a86284e80 (diff)
gnu: rust-bootstrap: Add support for powerpc64le-linux.
* gnu/packages/rust.scm (rust-bootstrap)[inputs]: When building for powerpc64le-linux add clang-13. [arguments]: When building for powerpc64le-linux add a phase adjusting the llvm output. Adjust the 'configure phase to start the build with clang as the C/C++ compiler and switch to GCC after building rustc. Change-Id: Iad5c8b5bba03289595f18e242392aa7feb249888
Diffstat (limited to 'gnu/packages/rust.scm')
-rw-r--r--gnu/packages/rust.scm31
1 files changed, 28 insertions, 3 deletions
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 25e843dba64..432f5cf9568 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -182,7 +182,10 @@
182 (max-silent-time . 18000))) ;5 hours (for armel) 182 (max-silent-time . 18000))) ;5 hours (for armel)
183 (build-system gnu-build-system) 183 (build-system gnu-build-system)
184 (inputs 184 (inputs
185 `(("llvm" ,llvm-13) 185 `(,@(if (target-ppc64le?)
186 `(("clang" ,clang-13))
187 `())
188 ("llvm" ,llvm-13)
186 ("openssl" ,openssl-1.1) 189 ("openssl" ,openssl-1.1)
187 ("zlib" ,zlib))) 190 ("zlib" ,zlib)))
188 (native-inputs 191 (native-inputs
@@ -200,6 +203,7 @@
200 #:validate-runpath? #f 203 #:validate-runpath? #f
201 ;; Most of the build is single-threaded. This also improves the 204 ;; Most of the build is single-threaded. This also improves the
202 ;; build time on machines with "only" 8GB of RAM. 205 ;; build time on machines with "only" 8GB of RAM.
206 ;; ppc64le regularly sees race conditions between various dependant crates.
203 #:parallel-build? ,(target-x86-64?) 207 #:parallel-build? ,(target-x86-64?)
204 #:make-flags 208 #:make-flags
205 (list ,(string-append "RUSTC_TARGET=" 209 (list ,(string-append "RUSTC_TARGET="
@@ -217,6 +221,15 @@
217 "OUTDIR_SUF=") ;do not add version suffix to output dir 221 "OUTDIR_SUF=") ;do not add version suffix to output dir
218 #:phases 222 #:phases
219 (modify-phases %standard-phases 223 (modify-phases %standard-phases
224 ,@(if (target-ppc64le?)
225 `((add-after 'unpack 'patch-sources-for-newer-llvm
226 (lambda _
227 ;; Adjust some sources for llvm-13, see llvm commit
228 ;; acce401068e78a8c5dc9e06802111ffad3da763f
229 (substitute* (find-files "." "powerpc64le_unknown_linux_gnu.rs")
230 (("e-m:e-i64:64-n32:64-v256:256:256-v512:512:512")
231 "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512")))))
232 '())
220 (add-after 'unpack 'setup-mrustc-sources 233 (add-after 'unpack 'setup-mrustc-sources
221 (lambda* (#:key inputs #:allow-other-keys) 234 (lambda* (#:key inputs #:allow-other-keys)
222 (copy-recursively (assoc-ref inputs "mrustc-source") "../mrustc") 235 (copy-recursively (assoc-ref inputs "mrustc-source") "../mrustc")
@@ -275,8 +288,11 @@
275 (setenv "CARGO_HOME" cargo-home)))) 288 (setenv "CARGO_HOME" cargo-home))))
276 (replace 'configure 289 (replace 'configure
277 (lambda _ 290 (lambda _
278 (setenv "CC" "gcc") 291 ,@(if (target-ppc64le?)
279 (setenv "CXX" "g++") 292 `((setenv "CC" "clang")
293 (setenv "CXX" "clang++"))
294 `((setenv "CC" "gcc")
295 (setenv "CXX" "g++")))
280 ;; The Guix LLVM package installs only shared libraries. 296 ;; The Guix LLVM package installs only shared libraries.
281 (setenv "LLVM_LINK_SHARED" "1") 297 (setenv "LLVM_LINK_SHARED" "1")
282 ;; rustc still insists on having 'cc' on PATH in some places 298 ;; rustc still insists on having 'cc' on PATH in some places
@@ -308,10 +324,19 @@
308 (display "Building LIBS...\n") 324 (display "Building LIBS...\n")
309 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags) 325 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
310 326
327 ;; The psm crate FTBFS on ppc64le with gcc.
311 (display "Building rustc...\n") 328 (display "Building rustc...\n")
312 (apply invoke "make" "-f" "minicargo.mk" "output/rustc" 329 (apply invoke "make" "-f" "minicargo.mk" "output/rustc"
313 make-flags) 330 make-flags)
314 331
332 ;; We can to continue the build with gcc after building rustc.
333 ;; librustc_driver.so undefined reference to
334 ;; `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
335 ,@(if (target-ppc64le?)
336 `((setenv "CC" "gcc")
337 (setenv "CXX" "g++"))
338 `())
339
315 (display "Building cargo...\n") 340 (display "Building cargo...\n")
316 (apply invoke "make" "-f" "minicargo.mk" "output/cargo" 341 (apply invoke "make" "-f" "minicargo.mk" "output/cargo"
317 make-flags) 342 make-flags)