gnu: make-rust-sysroot: Accept other mingw targets.

* gnu/packages/rust.scm (make-rust-sysroot/implementation)[arguments]:
Adjust the custom 'patch-for-mingw phase to generate the name of the
mingw input package based on the target architecture.
[inputs, native-inputs]: Use make-mingw-w64 to choose the mingw package
for the target.

Change-Id: I48638095a504675753e65fdb6f0286c31cebde66
This commit is contained in:
Efraim Flashner 2024-12-05 13:20:18 +02:00
parent 76bc375080
commit be53521d4c
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -1487,24 +1487,23 @@ exec -a \"$0\" \"~a\" \"$@\""
#$@(if (target-mingw? target) #$@(if (target-mingw? target)
`((add-after 'set-env 'patch-for-mingw `((add-after 'set-env 'patch-for-mingw
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(setenv "LIBRARY_PATH" (let* ((arch ,(string-take target
(string-join (string-index target #\-)))
(delete (mingw (assoc-ref inputs
(string-append (string-append "mingw-w64-" arch
(or (assoc-ref inputs "mingw-w64-i686-winpthreads") "-winpthreads"))))
(assoc-ref inputs "mingw-w64-x86_64-winpthreads")) (setenv "LIBRARY_PATH"
"/lib") (string-join
(string-split (getenv "LIBRARY_PATH") #\:)) (delete
":")) (string-append mingw "/lib")
(setenv "CPLUS_INCLUDE_PATH" (string-split (getenv "LIBRARY_PATH") #\:))
(string-join ":"))
(delete (setenv "CPLUS_INCLUDE_PATH"
(string-append (string-join
(or (assoc-ref inputs "mingw-w64-i686-winpthreads") (delete
(assoc-ref inputs "mingw-w64-x86_64-winpthreads")) (string-append mingw "/include")
"/include") (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))
(string-split (getenv "CPLUS_INCLUDE_PATH") #\:)) ":")))
":"))
;; When building a rust-sysroot this crate is only used for ;; When building a rust-sysroot this crate is only used for
;; the rust-installer. ;; the rust-installer.
(substitute* '("vendor/num_cpus-1.13.0/src/linux.rs" (substitute* '("vendor/num_cpus-1.13.0/src/linux.rs"
@ -1610,9 +1609,9 @@ ar = \"" (search-input-file inputs (string-append "/bin/" #$(ar-for-target targe
(if (target-mingw? target) (if (target-mingw? target)
(modify-inputs (package-propagated-inputs base-rust) (modify-inputs (package-propagated-inputs base-rust)
(prepend (prepend
(if (string=? "i686-w64-mingw32" target) (make-mingw-w64
mingw-w64-i686-winpthreads (string-take target (string-index target #\-))
mingw-w64-x86_64-winpthreads))) #:with-winpthreads? #t)))
(package-propagated-inputs base-rust))) (package-propagated-inputs base-rust)))
(native-inputs (native-inputs
(if (target-mingw? target) (if (target-mingw? target)
@ -1620,9 +1619,9 @@ ar = \"" (search-input-file inputs (string-append "/bin/" #$(ar-for-target targe
(prepend (cross-gcc target (prepend (cross-gcc target
#:libc (cross-libc target)) #:libc (cross-libc target))
(cross-binutils target) (cross-binutils target)
(if (string=? "i686-w64-mingw32" target) (make-mingw-w64
mingw-w64-i686-winpthreads (string-take target (string-index target #\-))
mingw-w64-x86_64-winpthreads))) #:with-winpthreads? #t)))
(modify-inputs (package-native-inputs base-rust) (modify-inputs (package-native-inputs base-rust)
(prepend (cross-gcc target (prepend (cross-gcc target
#:libc (cross-libc target)) #:libc (cross-libc target))