Skip to content

Commit 806b75b

Browse files
committed
guix: consolidate Linux GCC package
Refactor our Linux GCC to be a single 'package', and avoid the use of `package-with-extra-configure-variable`.
1 parent 4415275 commit 806b75b

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

contrib/guix/manifest.scm

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,8 @@ FILE-NAME found in ./patches relative to the current file."
4040
((%patch-path (list (string-append (dirname (current-filename)) "/patches"))))
4141
(list (search-patch file-name) ...)))
4242

43-
(define (make-gcc-rpath-link xgcc)
44-
"Given a XGCC package, return a modified package that replace each instance of
45-
-rpath in the default system spec that's inserted by Guix with -rpath-link"
46-
(package
47-
(inherit xgcc)
48-
(arguments
49-
(substitute-keyword-arguments (package-arguments xgcc)
50-
((#:phases phases)
51-
`(modify-phases ,phases
52-
(add-after 'pre-configure 'replace-rpath-with-rpath-link
53-
(lambda _
54-
(substitute* (cons "gcc/config/rs6000/sysv4.h"
55-
(find-files "gcc/config"
56-
"^gnu-user.*\\.h$"))
57-
(("-rpath=") "-rpath-link="))
58-
#t))))))))
59-
6043
(define building-on (string-append "--build=" (list-ref (string-split (%current-system) #\-) 0) "-guix-linux-gnu"))
6144

62-
(define (explicit-cross-configure package)
63-
(define building-on (string-append (list-ref (string-split (%current-system) #\-) 0) "-guix-linux-gnu"))
64-
(package-with-extra-configure-variable package "--build" building-on))
65-
6645
(define (make-cross-toolchain target
6746
base-gcc-for-libc
6847
base-kernel-headers
@@ -72,9 +51,9 @@ FILE-NAME found in ./patches relative to the current file."
7251
(let* ((xbinutils (cross-binutils target))
7352
;; 1. Build a cross-compiling gcc without targeting any libc, derived
7453
;; from BASE-GCC-FOR-LIBC
75-
(xgcc-sans-libc (explicit-cross-configure (cross-gcc target
76-
#:xgcc base-gcc-for-libc
77-
#:xbinutils xbinutils)))
54+
(xgcc-sans-libc (cross-gcc target
55+
#:xgcc base-gcc-for-libc
56+
#:xbinutils xbinutils))
7857
;; 2. Build cross-compiled kernel headers with XGCC-SANS-LIBC, derived
7958
;; from BASE-KERNEL-HEADERS
8059
(xkernel (cross-kernel-headers target
@@ -90,10 +69,10 @@ FILE-NAME found in ./patches relative to the current file."
9069
xkernel))
9170
;; 4. Build a cross-compiling gcc targeting XLIBC, derived from
9271
;; BASE-GCC
93-
(xgcc (explicit-cross-configure (cross-gcc target
94-
#:xgcc base-gcc
95-
#:xbinutils xbinutils
96-
#:libc xlibc))))
72+
(xgcc (cross-gcc target
73+
#:xgcc base-gcc
74+
#:xbinutils xbinutils
75+
#:libc xlibc)))
9776
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
9877
;; XGCC
9978
(package
@@ -117,21 +96,12 @@ chain for " target " development."))
11796
(define base-gcc gcc-10)
11897
(define base-linux-kernel-headers linux-libre-headers-5.15)
11998

120-
;; https://gcc.gnu.org/install/configure.html
121-
(define (hardened-gcc gcc)
122-
(package-with-extra-configure-variable (
123-
package-with-extra-configure-variable (
124-
package-with-extra-configure-variable gcc
125-
"--enable-initfini-array" "yes")
126-
"--enable-default-ssp" "yes")
127-
"--enable-default-pie" "yes"))
128-
12999
(define* (make-bitcoin-cross-toolchain target
130100
#:key
131-
(base-gcc-for-libc base-gcc)
101+
(base-gcc-for-libc linux-base-gcc)
132102
(base-kernel-headers base-linux-kernel-headers)
133103
(base-libc glibc-2.27)
134-
(base-gcc (make-gcc-rpath-link (hardened-gcc base-gcc))))
104+
(base-gcc linux-base-gcc))
135105
"Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values
136106
desirable for building Bitcoin Core release binaries."
137107
(make-cross-toolchain target
@@ -529,6 +499,30 @@ inspecting signatures in Mach-O binaries.")
529499
;; and thus will ensure that this works properly.
530500
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))
531501

502+
(define-public linux-base-gcc
503+
(package
504+
(inherit base-gcc)
505+
(arguments
506+
(substitute-keyword-arguments (package-arguments base-gcc)
507+
((#:configure-flags flags)
508+
`(append ,flags
509+
;; https://gcc.gnu.org/install/configure.html
510+
(list "--enable-initfini-array=yes",
511+
"--enable-default-ssp=yes",
512+
"--enable-default-pie=yes",
513+
building-on)))
514+
((#:phases phases)
515+
`(modify-phases ,phases
516+
;; Given a XGCC package, return a modified package that replace each instance of
517+
;; -rpath in the default system spec that's inserted by Guix with -rpath-link
518+
(add-after 'pre-configure 'replace-rpath-with-rpath-link
519+
(lambda _
520+
(substitute* (cons "gcc/config/rs6000/sysv4.h"
521+
(find-files "gcc/config"
522+
"^gnu-user.*\\.h$"))
523+
(("-rpath=") "-rpath-link="))
524+
#t))))))))
525+
532526
(define-public glibc-2.27
533527
(package
534528
(inherit glibc-2.31)

0 commit comments

Comments
 (0)