- (package (inherit base)
- (source (origin (inherit (package-source base))
- (patches (cons (search-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))))
-
- ;; 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)))))
+ (package
+ (inherit base)
+ (source (origin (inherit (package-source base))
+ (patches (cons (search-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))))
+
+ ;; 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
+ (native-search-paths
+ ;; Set CPLUS_INCLUDE_PATH so GCC is able to find the libc
+ ;; C++ headers.
+ (cons (search-path-specification
+ (variable "CPLUS_INCLUDE_PATH")
+ (files '("include")))
+ (package-native-search-paths gcc)))
+ (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)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments gcc)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-before 'configure 'treat-glibc-as-system-header
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((libc (assoc-ref inputs "bootstrap-libc")))
+ ;; GCCs build processes requires that the libc
+ ;; we're building against is on the system header
+ ;; search path.
+ (for-each (lambda (var)
+ (setenv var (string-append libc "/include")))
+ '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
+ #t))))))))))