index
:
guix
koszko
koszko-scripts
Wojtek's customized Guix
about
summary
refs
log
tree
commit
diff
log msg
author
committer
range
;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012-2021, 2023-2024 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017, 2021 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018, 2019 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2018, 2019, 2021, 2022, 2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2019, 2020, 2022 Marius Bakke <marius@gnu.org> ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu packages make-bootstrap) #:use-module (guix gexp) #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix memoization) #:use-module ((guix licenses) #:select (gpl3+)) #:use-module (guix build-system trivial) #:use-module (guix build-system gnu) #:use-module ((gnu packages) #:select (search-patch search-patches)) #:use-module (gnu packages base) #:use-module (gnu packages cross-base) #:use-module (gnu packages bash) #:use-module (gnu packages compression) #:use-module (gnu packages gawk) #:use-module (gnu packages gcc) #:use-module (gnu packages guile) #:use-module (gnu packages bdw-gc) #:use-module (gnu packages libunistring) #:use-module (gnu packages linux) #:use-module (gnu packages hurd) #:use-module (gnu packages mes) #:use-module (gnu packages multiprecision) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:export (%bootstrap-binaries-tarball %linux-libre-headers-bootstrap-tarball %binutils-bootstrap-tarball %glibc-bootstrap-tarball %gcc-bootstrap-tarball %guile-bootstrap-tarball %bootstrap-tarballs %guile-static-stripped %guile-static-initrd)) ;;; Commentary: ;;; ;;; This module provides tools to build tarballs of the "bootstrap binaries" ;;; used in (gnu packages bootstrap). These statically-linked binaries are ;;; taken for granted and used as the root of the whole bootstrap procedure. ;;; ;;; Code: (define glibc-for-bootstrap (mlambdaq (base) "Return a libc deriving from BASE whose `system' and `popen' functions looks for `sh' in $PATH, and without nscd, and with static NSS modules." (package (inherit base) (source (origin (inherit (package-source base)) (patches (append (search-patches (match (package-version base) ("2.39" "glibc-2.39-bootstrap-system.patch") (_ "glibc-bootstrap-system.patch"))) (origin-patches (package-source base)))))) (arguments (substitute-keyword-arguments (package-arguments base) ((#:configure-flags flags) ;; Arrange so that getaddrinfo & co. do not contact the nscd, ;; and can use statically-linked NSS modules. `(cons* "--disable-nscd" "--disable-build-nscd" "--enable-static-nss" ,flags)) ((#:phases phases #~%standard-phases) ;; Apply i686-linux-specific patch. (if (target-x86-32?) #~(modify-phases #$phases (add-after 'unpack 'apply-libm-patch (lambda _ (define patch #$(local-file (search-patch "glibc-2.39-fmod-libm-a.patch"))) (invoke "patch" "--force" "-p1" "-i" patch)))) phases)))) ;; Remove the 'debug' output to allow bit-reproducible builds (when the ;; 'debug' output is used, ELF files end up with a .gnu_debuglink, which ;; includes a CRC of the corresponding debugging symbols; those symbols ;; contain store file names, so the CRC changes at every rebuild.) (outputs (delete "debug" (package-outputs base)))))) (define gcc-for-bootstrap (mlambdaq (glibc) "Return a variant of GCC that uses the bootstrap variant of GLIBC." (package (inherit gcc) (outputs '("out")) ;all in one so libgcc_s is easily found (inputs `( ;; Distinguish the name so we can refer to it below. ("bootstrap-libc" ,(glibc-for-bootstrap glibc)) ("libc:static" ,(glibc-for-bootstrap glibc) "static") ,@(package-inputs gcc)))))) (define (package-with-relocatable-glibc p) "Return a variant of P that uses the libc as defined by `glibc-for-bootstrap'." (define (cross-bootstrap-libc target) (glibc-for-bootstrap ;; `cross-libc' already returns a cross libc, so clear ;; %CURRENT-TARGET-SYSTEM. (parameterize ((%current-target-system #f)) (cross-libc target)))) ;; Standard inputs with the above libc and corresponding GCC. (define (inputs) (if (%current-target-system) ; is this package cross built? `(("cross-libc" ,(cross-bootstrap-libc (%current-target-system))) ("cross-libc:static" ,(cross-bootstrap-libc (%current-target-system)) "static")) '())) (define (native-inputs) (if (%current-target-system) (let* ((target (%current-target-system)) (xgcc (cross-gcc target #:xbinutils (cross-binutils target) #:libc (cross-bootstrap-libc target)))) `(("cross-gcc" ,(package (inherit xgcc) (search-paths ;; Ensure the cross libc headers appears on the ;; C++ system header search path. (cons (search-path-specification (variable "CROSS_CPLUS_INCLUDE_PATH") (files '("include"))) (package-search-paths gcc))))) ("cross-binutils" ,(cross-binutils target)) ,@(%final-inputs))) `(("libc" ,(glibc-for-bootstrap glibc)) ("libc:static" ,(glibc-for-bootstrap glibc) "static") ("gcc" ,(gcc-for-bootstrap glibc)) ,@(fold alist-delete (%final-inputs) '("libc" "gcc"))))) (package-with-explicit-inputs p inputs (current-source-location) #:native-inputs native-inputs)) (define %static-inputs ;; Packages that are to be used as %BOOTSTRAP-INPUTS. (let ((coreutils (package (inherit coreutils) (arguments (substitute-keyword-arguments (package-arguments coreutils) ((#:configure-flags _ #~'()) #~'("--disable-nls" "--disable-silent-rules" "--enable-no-install-program=stdbuf,libstdbuf.so" "CFLAGS=-Os -g0" ; smaller, please "LDFLAGS=-static -pthread" ;; Work around a cross-compilation bug whereby libcoreutils.a ;; would provide '__mktime_internal', which conflicts with the ;; one in libc.a. #$@(if (%current-target-system) #~("gl_cv_func_working_mktime=yes") #~()))) ((#:tests? _ #t) #f))) ;signal-related Gnulib tests fail ;; Remove optional dependencies such as GMP. (inputs '()) ;; Remove the 'debug' output (see above for the reason.) (outputs '("out")))) (bzip2 (package (inherit bzip2) (arguments (substitute-keyword-arguments (package-arguments bzip2) ((#:phases phases) #~(modify-phases #$phases (add-before 'build 'dash-static (lambda _ (substitute* "Makefile" (("^LDFLAGS[[:blank:]]*=.*$") "LDFLAGS = -static")))))))))) (xz (package (inherit xz) (outputs '("out")) (arguments (list #:strip-flags #~'("--strip-all") #:phases #~(modify-phases %standard-phases (add-before 'configure 'static-executable (lambda _ ;; Ask Libtool for a static executable. (substitute* "src/xz/Makefile.in" (("^xz_LDADD =") "xz_LDADD = -all-static"))))))))) (gawk (package (inherit gawk) (source (origin (inherit (package-source gawk)) (modules '((guix build utils))) (snippet ;; Do not build 'getopt.c' since that leads to a ;; link failure due to duplicate symbols with ;; 'libc.a'. '(substitute* "support/Makefile.in" (("getopt\\.\\$\\(OBJEXT\\)") ""))) (patches (cons (search-patch "gawk-shell.patch") (origin-patches (package-source gawk)))))) (arguments (substitute-keyword-arguments (package-arguments gawk) ((#:configure-flags _ #~'()) ;; Starting from gawk 4.1.0, some of the tests for the ;; plug-in mechanism just fail on static builds: ;; ;; ./fts.awk:1: error: can't open shared library `filefuncs' for reading (No such file or directory) ;; ;; Therefore disable extensions support. #~(list "--disable-extensions")) ((#:phases phases) #~(modify-phases #$phases (add-before 'configure 'no-export-dynamic (lambda _ ;; Since we use `-static', remove ;; `-export-dynamic'. (substitute* "configure" (("-Wl,-export-dynamic") "")))))))) (inputs (if (%current-target-system) (list static-bash) '())))) (tar (package (inherit tar) (arguments (substitute-keyword-arguments (package-arguments tar) ((#:configure-flags flags #~'()) ;; Work around a cross-compilation bug whereby libgnu.a ;; would provide '__mktime_internal', which conflicts ;; with the one in libc.a. #~'("gl_cv_func_working_mktime=yes")) ((#:phases phases) #~(modify-phases #$phases (replace 'set-shell-file-name (lambda _ ;; Do not use "/bin/sh" to run programs; see ;; <http://lists.gnu.org/archive/html/guix-devel/2016-09/msg02272.html>. (substitute* "src/system.c" (("/bin/sh") "sh") (("execv ") "execvp ")))))))))) ;; We don't want to retain a reference to /gnu/store in the bootstrap ;; versions of egrep/fgrep, so we remove the custom phase added since ;; grep@2.25. The effect is 'egrep' and 'fgrep' look for 'grep' in ;; $PATH. (grep (package (inherit grep) (inputs '()) ;remove PCRE, which is optional (arguments (substitute-keyword-arguments (package-arguments grep) ((#:configure-flags flags #~'()) #~(cons "--disable-perl-regexp" (delete "--enable-perl-regexp" #$flags))) ((#:phases phases) #~(modify-phases #$phases (delete 'fix-egrep-and-fgrep)))))))