mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
guix: consolidate Linux GCC package
Refactor our Linux GCC to be a single 'package', and avoid the use of `package-with-extra-configure-variable`.
This commit is contained in:
parent
4415275f96
commit
806b75b213
1 changed files with 33 additions and 39 deletions
|
@ -40,29 +40,8 @@ FILE-NAME found in ./patches relative to the current file."
|
||||||
((%patch-path (list (string-append (dirname (current-filename)) "/patches"))))
|
((%patch-path (list (string-append (dirname (current-filename)) "/patches"))))
|
||||||
(list (search-patch file-name) ...)))
|
(list (search-patch file-name) ...)))
|
||||||
|
|
||||||
(define (make-gcc-rpath-link xgcc)
|
|
||||||
"Given a XGCC package, return a modified package that replace each instance of
|
|
||||||
-rpath in the default system spec that's inserted by Guix with -rpath-link"
|
|
||||||
(package
|
|
||||||
(inherit xgcc)
|
|
||||||
(arguments
|
|
||||||
(substitute-keyword-arguments (package-arguments xgcc)
|
|
||||||
((#:phases phases)
|
|
||||||
`(modify-phases ,phases
|
|
||||||
(add-after 'pre-configure 'replace-rpath-with-rpath-link
|
|
||||||
(lambda _
|
|
||||||
(substitute* (cons "gcc/config/rs6000/sysv4.h"
|
|
||||||
(find-files "gcc/config"
|
|
||||||
"^gnu-user.*\\.h$"))
|
|
||||||
(("-rpath=") "-rpath-link="))
|
|
||||||
#t))))))))
|
|
||||||
|
|
||||||
(define building-on (string-append "--build=" (list-ref (string-split (%current-system) #\-) 0) "-guix-linux-gnu"))
|
(define building-on (string-append "--build=" (list-ref (string-split (%current-system) #\-) 0) "-guix-linux-gnu"))
|
||||||
|
|
||||||
(define (explicit-cross-configure package)
|
|
||||||
(define building-on (string-append (list-ref (string-split (%current-system) #\-) 0) "-guix-linux-gnu"))
|
|
||||||
(package-with-extra-configure-variable package "--build" building-on))
|
|
||||||
|
|
||||||
(define (make-cross-toolchain target
|
(define (make-cross-toolchain target
|
||||||
base-gcc-for-libc
|
base-gcc-for-libc
|
||||||
base-kernel-headers
|
base-kernel-headers
|
||||||
|
@ -72,9 +51,9 @@ FILE-NAME found in ./patches relative to the current file."
|
||||||
(let* ((xbinutils (cross-binutils target))
|
(let* ((xbinutils (cross-binutils target))
|
||||||
;; 1. Build a cross-compiling gcc without targeting any libc, derived
|
;; 1. Build a cross-compiling gcc without targeting any libc, derived
|
||||||
;; from BASE-GCC-FOR-LIBC
|
;; from BASE-GCC-FOR-LIBC
|
||||||
(xgcc-sans-libc (explicit-cross-configure (cross-gcc target
|
(xgcc-sans-libc (cross-gcc target
|
||||||
#:xgcc base-gcc-for-libc
|
#:xgcc base-gcc-for-libc
|
||||||
#:xbinutils xbinutils)))
|
#:xbinutils xbinutils))
|
||||||
;; 2. Build cross-compiled kernel headers with XGCC-SANS-LIBC, derived
|
;; 2. Build cross-compiled kernel headers with XGCC-SANS-LIBC, derived
|
||||||
;; from BASE-KERNEL-HEADERS
|
;; from BASE-KERNEL-HEADERS
|
||||||
(xkernel (cross-kernel-headers target
|
(xkernel (cross-kernel-headers target
|
||||||
|
@ -90,10 +69,10 @@ FILE-NAME found in ./patches relative to the current file."
|
||||||
xkernel))
|
xkernel))
|
||||||
;; 4. Build a cross-compiling gcc targeting XLIBC, derived from
|
;; 4. Build a cross-compiling gcc targeting XLIBC, derived from
|
||||||
;; BASE-GCC
|
;; BASE-GCC
|
||||||
(xgcc (explicit-cross-configure (cross-gcc target
|
(xgcc (cross-gcc target
|
||||||
#:xgcc base-gcc
|
#:xgcc base-gcc
|
||||||
#:xbinutils xbinutils
|
#:xbinutils xbinutils
|
||||||
#:libc xlibc))))
|
#:libc xlibc)))
|
||||||
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
|
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
|
||||||
;; XGCC
|
;; XGCC
|
||||||
(package
|
(package
|
||||||
|
@ -117,21 +96,12 @@ chain for " target " development."))
|
||||||
(define base-gcc gcc-10)
|
(define base-gcc gcc-10)
|
||||||
(define base-linux-kernel-headers linux-libre-headers-5.15)
|
(define base-linux-kernel-headers linux-libre-headers-5.15)
|
||||||
|
|
||||||
;; https://gcc.gnu.org/install/configure.html
|
|
||||||
(define (hardened-gcc gcc)
|
|
||||||
(package-with-extra-configure-variable (
|
|
||||||
package-with-extra-configure-variable (
|
|
||||||
package-with-extra-configure-variable gcc
|
|
||||||
"--enable-initfini-array" "yes")
|
|
||||||
"--enable-default-ssp" "yes")
|
|
||||||
"--enable-default-pie" "yes"))
|
|
||||||
|
|
||||||
(define* (make-bitcoin-cross-toolchain target
|
(define* (make-bitcoin-cross-toolchain target
|
||||||
#:key
|
#:key
|
||||||
(base-gcc-for-libc base-gcc)
|
(base-gcc-for-libc linux-base-gcc)
|
||||||
(base-kernel-headers base-linux-kernel-headers)
|
(base-kernel-headers base-linux-kernel-headers)
|
||||||
(base-libc glibc-2.27)
|
(base-libc glibc-2.27)
|
||||||
(base-gcc (make-gcc-rpath-link (hardened-gcc base-gcc))))
|
(base-gcc linux-base-gcc))
|
||||||
"Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values
|
"Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values
|
||||||
desirable for building Bitcoin Core release binaries."
|
desirable for building Bitcoin Core release binaries."
|
||||||
(make-cross-toolchain target
|
(make-cross-toolchain target
|
||||||
|
@ -529,6 +499,30 @@ inspecting signatures in Mach-O binaries.")
|
||||||
;; and thus will ensure that this works properly.
|
;; and thus will ensure that this works properly.
|
||||||
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))
|
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))
|
||||||
|
|
||||||
|
(define-public linux-base-gcc
|
||||||
|
(package
|
||||||
|
(inherit base-gcc)
|
||||||
|
(arguments
|
||||||
|
(substitute-keyword-arguments (package-arguments base-gcc)
|
||||||
|
((#:configure-flags flags)
|
||||||
|
`(append ,flags
|
||||||
|
;; https://gcc.gnu.org/install/configure.html
|
||||||
|
(list "--enable-initfini-array=yes",
|
||||||
|
"--enable-default-ssp=yes",
|
||||||
|
"--enable-default-pie=yes",
|
||||||
|
building-on)))
|
||||||
|
((#:phases phases)
|
||||||
|
`(modify-phases ,phases
|
||||||
|
;; Given a XGCC package, return a modified package that replace each instance of
|
||||||
|
;; -rpath in the default system spec that's inserted by Guix with -rpath-link
|
||||||
|
(add-after 'pre-configure 'replace-rpath-with-rpath-link
|
||||||
|
(lambda _
|
||||||
|
(substitute* (cons "gcc/config/rs6000/sysv4.h"
|
||||||
|
(find-files "gcc/config"
|
||||||
|
"^gnu-user.*\\.h$"))
|
||||||
|
(("-rpath=") "-rpath-link="))
|
||||||
|
#t))))))))
|
||||||
|
|
||||||
(define-public glibc-2.27
|
(define-public glibc-2.27
|
||||||
(package
|
(package
|
||||||
(inherit glibc-2.31)
|
(inherit glibc-2.31)
|
||||||
|
|
Loading…
Add table
Reference in a new issue