Skip to content

Commit

Permalink
guix: pre time-machine bump changes (Windows)
Browse files Browse the repository at this point in the history
Summary:
Split out of #27897. This is some refactoring to the Windows Guix build
that facilitates bumping our Guix time-machine. Namely, avoiding
`package-with-extra-configure-variable`, which is non-functional in the
newer time-machine, see https://issues.guix.gnu.org/64436.

At the same time, consolidate our Windows GCC build into mingw-w64-base-gcc.
Rename `gcc-10-remap-guix-store.patch` to avoid changing it whenever GCC changes.

We move the old `building-on` inside `explicit-cross-configure`, so that
non-windows builds continue to work. Note that `explicit-cross-configure`
will be going away entirely (see #27897).

This is a backport of [[bitcoin/bitcoin#28294 | core#28294]]

Test Plan: `HOSTS="x86_64-w64-mingw32" contrib/guix/guix-build`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D15485
  • Loading branch information
fanquake authored and PiRK committed Feb 19, 2024
1 parent ddfdd6f commit d53bb4b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,6 @@ FILE-NAME found in ./patches relative to the current file."
((%patch-path (list (string-append (dirname (current-filename)) "/patches"))))
(list (search-patch file-name) ...)))

(define (make-ssp-fixed-gcc xgcc)
"Given a XGCC package, return a modified package that uses the SSP function
from glibc instead of from libssp.so. Our `symbol-check' script will complain if
we link against libssp.so, and thus will ensure that this works properly.

Taken from:
http://www.linuxfromscratch.org/hlfs/view/development/chapter05/gcc-pass1.html"
(package
(inherit xgcc)
(arguments
(substitute-keyword-arguments (package-arguments xgcc)
((#:make-flags flags)
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))

(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"
Expand All @@ -74,9 +60,10 @@ http://www.linuxfromscratch.org/hlfs/view/development/chapter05/gcc-pass1.html"
(("-rpath=") "-rpath-link="))
#t))))))))

(define building-on (string-append (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
Expand Down Expand Up @@ -156,26 +143,20 @@ desirable for building Bitcoin ABC release binaries."
base-libc
base-gcc))

(define (make-gcc-with-pthreads gcc)
(package-with-extra-configure-variable
(package-with-extra-patches gcc
(search-our-patches "gcc-10-remap-guix-store.patch"))
"--enable-threads" "posix"))

(define (make-mingw-w64-cross-gcc cross-gcc)
(package-with-extra-patches cross-gcc
(search-our-patches "vmov-alignment.patch"
(define (gcc-mingw-patches gcc)
(package-with-extra-patches gcc
(search-our-patches "gcc-remap-guix-store.patch"
"vmov-alignment.patch"
"gcc-broken-longjmp.patch")))

(define (make-mingw-pthreads-cross-toolchain target)
"Create a cross-compilation toolchain package for TARGET"
(let* ((xbinutils (cross-binutils target))
(pthreads-xlibc mingw-w64-x86_64-winpthreads)
(pthreads-xgcc (make-gcc-with-pthreads
(cross-gcc target
#:xgcc (make-ssp-fixed-gcc (make-mingw-w64-cross-gcc base-gcc))
(pthreads-xgcc (cross-gcc target
#:xgcc (gcc-mingw-patches mingw-w64-base-gcc)
#:xbinutils xbinutils
#:libc pthreads-xlibc))))
#:libc pthreads-xlibc)))
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
;; XGCC
(package
Expand Down Expand Up @@ -546,6 +527,22 @@ inspecting signatures in Mach-O binaries.")
"--enable-stack-protector" "all")
"--enable-bind-now" "yes"))

(define-public mingw-w64-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-threads=posix",
building-on)))
((#:make-flags flags)
;; Uses the SSP functions from glibc instead of from libssp.so.
;; Our 'symbol-check' script will complain if we link against libssp.so,
;; and thus will ensure that this works properly.
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))

(define-public glibc-2.28
(package
(inherit glibc-2.31)
Expand Down

0 comments on commit d53bb4b

Please sign in to comment.