(begin (use-modules (srfi srfi-1) (srfi srfi-26) (guix build gnu-build-system) (guix build utils)) (begin (define %build-inputs (quote (("source" . "/gnu/store/f0bnpwfmnip7nxamgbma26qwszv3bcji-gcc-14.3.0.tar.xz") ("texinfo" . "/gnu/store/jkm969l65w38160zjyibj65wq7p3n5ja-texinfo-6.8") ("perl" . "/gnu/store/n7pgwxvqs1a1hx6sp23f7g2rk651lbln-perl-boot0-5.36.0") ("static-bash" . "/gnu/store/z1w145shnlr9nfqyfc7gym4fw4kpwj9y-bash-static-5.2.37") ("gmp-source" . "/gnu/store/3a20wsq8h1qj980cpc8qni6rj6q468sh-gmp-6.0.0a.tar.xz") ("mpfr-source" . "/gnu/store/r9p3xn779270x72p7fawzhbplcw0h8ma-mpfr-4.2.2.tar.xz") ("mpc-source" . "/gnu/store/5kilzai1n79bknkfccraqrh273gd3b5x-mpc-1.3.1.tar.gz") ("ld-wrapper" . "/gnu/store/k8p9xxh4l77slhjylib18fah9b3rzikz-ld-wrapper-boot3-0") ("binutils" . "/gnu/store/ma70w69hn7s43y5giwfgy41snk9jvbv8-binutils-2.44") ("libstdc++" . "/gnu/store/if65lpxny2h73ab84f7yqqwisbvv82c9-libstdc++-14.3.0") ("zlib" . "/gnu/store/bi1h06hpk0ck8gq9ny1gyxvwm15lxrnj-zlib-1.3.1") ("libc" . "/gnu/store/sm52smrxi5bi3vx2x3p782sylrh2jkk3-glibc-2.41") ("libc:static" . "/gnu/store/li9f2i9ak215y861z0hm3rs6f235ykyw-glibc-2.41-static") ("gcc" . "/gnu/store/n6l3ac5m6da98x4fvmxg0dp52cykfb3b-gcc-cross-boot0-wrapped-14.3.0") ("ld-wrapper-cross" . "/gnu/store/ay6q6m0bjfdx5jrp8nw5si3ydyl0yqad-ld-wrapper-boot0-0") ("binutils-cross" . "/gnu/store/hh4dbnxr2bczpkhjpb6wvhpj1dzqv6zs-binutils-cross-boot0-2.44") ("bzip2" . "/gnu/store/bwhk7mi9i4ys5w2wsbnfyigwwp8pqfkq-bzip2-boot0-1.0.8") ("coreutils" . "/gnu/store/gn9ngz6psd2frzslwifsvli61dmijgbq-coreutils-boot0-9.1") ("gawk" . "/gnu/store/way59xg0d2n2kgpb9yidbz7973fjjp0i-gawk-boot0-5.3.0") ("patch" . "/gnu/store/141gc4fwp7rbvmq6ynbwqibm9c4dv3f6-patch-boot0-2.7.6") ("sed" . "/gnu/store/div48p18zfc15mnj9xfd6nc0d126ckji-sed-boot0-4.9") ("tar" . "/gnu/store/3miwwqidab1k6dynbhvx9smw8r35xc2m-tar-boot0-1.35") ("make" . "/gnu/store/amvqxzwkwdy7qx2b6g4pdv9723w8wyb4-make-boot0-4.4.1") ("diffutils" . "/gnu/store/dvqkmj2ix0sfgfcijvx03wxay7b50y2k-diffutils-boot0-3.12") ("findutils" . "/gnu/store/bgzkm5jsik7zl1mnlgcmdjs3r7wky3g1-findutils-boot0-4.10.0") ("file" . "/gnu/store/a3j8vzdjnhmyp6g4h168ffgddib6zmk6-file-boot0-5.46") ("bash" . "/gnu/store/ac973jmmvv70y6xjn2d5rnih6gd19s2f-bash-mesboot-5.2.37") ("coreutils" . "/gnu/store/48zzvabsg1rsrq99wd2i92d60lzmd71k-coreutils-mesboot-9.1") ("grep" . "/gnu/store/igkvc8k782fi29yanvp04hv3s2ymsg1s-grep-mesboot-3.11") ("sed" . "/gnu/store/600v63djvfg1c30cplszglb2729qxvk0-sed-mesboot-4.8") ("tar" . "/gnu/store/wq0kn0nvnx3zk424mq3q62hhydxscwhq-tar-mesboot-1.35") ("xz" . "/gnu/store/1n6fngk89jk1y0grxxi3q0k8l4bnmf9p-xz-mesboot-5.4.5") ("gcc-wrapper" . "/gnu/store/hws34smywkwzb6dhq4dm7dwc5n3asdfx-gcc-mesboot-wrapper-4.9.4") ("gawk" . "/gnu/store/zfkrb361iy4l1avx02qz39pl5czxyacv-gawk-mesboot-3.1.8") ("make" . "/gnu/store/b0pb60c7r0b3xgpp2bvlflah3gv00w2q-make-mesboot-3.82") ("gzip" . "/gnu/store/fgx3c56cfylbfjdi731s3zggp03js9d3-gzip-mesboot-1.2.4") ("patch" . "/gnu/store/i29sqgr7lhaq1crnqwa5rxi43d8skfw1-patch-mesboot-2.5.9") ("guile" . "/gnu/store/lgi9x15a0w35mcpd7g1kb9274r6wy4pv-guile-bootstrap-2.0") ("kernel-headers" . "/gnu/store/d41d6s3pmn5ys0ihi82056qq7z9fjsyk-linux-libre-headers-6.12.17")))) (define %outputs (list (cons "out" ((@ (guile) getenv) "out")) (cons "lib" ((@ (guile) getenv) "lib")))) (define %output (assoc-ref %outputs "out")) (gnu-build #:source "/gnu/store/f0bnpwfmnip7nxamgbma26qwszv3bcji-gcc-14.3.0.tar.xz" #:system "x86_64-linux" #:build "x86_64-unknown-linux-gnu" #:outputs %outputs #:inputs %build-inputs #:search-paths (quote (("INFOPATH" ("share/info") ":" directory #f) ("PERL5LIB" ("lib/perl5/site_perl") ":" directory #f) ("BASH_LOADABLES_PATH" ("lib/bash") ":" directory #f) ("C_INCLUDE_PATH" ("include") ":" directory #f) ("CPLUS_INCLUDE_PATH" ("include/c++" "include") ":" directory #f) ("OBJC_INCLUDE_PATH" ("include") ":" directory #f) ("OBJCPLUS_INCLUDE_PATH" ("include/c++" "include") ":" directory #f) ("LIBRARY_PATH" ("lib" "lib64") ":" directory #f) ("GUIX_LOCPATH" ("lib/locale") ":" directory #f) ("TZDIR" ("share/zoneinfo") #f directory #f) ("C_INCLUDE_PATH" ("include" "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include") ":" directory #f) ("LIBRARY_PATH" ("lib") ":" directory #f))) #:phases (modify-phases (modify-phases (modify-phases %standard-phases (add-before (quote configure) (quote relax-gcc-14s-strictness) (lambda* (#:key inputs #:allow-other-keys) (let ((bash (assoc-ref inputs "bash")) (wrapper (string-append (getcwd) "/gcc.sh")) (stage-wrapper (string-append (getcwd) "/stage-gcc.sh"))) (with-output-to-file wrapper (lambda _ (format #t "#! ~a/bin/bash\nexec gcc \"$@\"     -Wno-error=implicit-function-declaration" bash))) (chmod wrapper 365) (with-output-to-file stage-wrapper (lambda _ (format #t "#! ~a/bin/bash\nexec \"$@\"     -Wno-error=implicit-function-declaration" bash))) (chmod stage-wrapper 365) (cond (#f (setenv "CC_FOR_BUILD" wrapper)) (else (setenv "CC" wrapper) (setenv "STAGE_CC_WRAPPER" stage-wrapper)))))) (add-before (quote configure) (quote pre-configure) (lambda* (#:key inputs outputs #:allow-other-keys) (let ((libdir (or (assoc-ref outputs "lib") (assoc-ref outputs "out"))) (libc (assoc-ref inputs "libc"))) (when libc (for-each (lambda (x) (substitute* (find-files "gcc/config" "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$") (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line) line))) (quote (1 2 3))) (substitute* (find-files "gcc/config" "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$") (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$" _ gnu-user suffix) (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%" gnu-user suffix (string-append libc "/lib/ld-linux-x86-64.so.2")))) (substitute* (find-files "gcc/config" "^gnu-user.*\\.h$") (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix) (format #f "#define GNU_USER_TARGET_LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a" libc libc libdir suffix)) (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line) (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib/\"\n#define STANDARD_STARTFILE_PREFIX_2 \"\"\n~a" libc line))) (substitute* "gcc/config/rs6000/sysv4.h" (("#define LIB_LINUX_SPEC (.*)$" _ suffix) (format #f "#define LIB_LINUX_SPEC \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a" libc libc libdir suffix)) (("#define\tSTARTFILE_LINUX_SPEC.*$" line) (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib/\"\n#define STANDARD_STARTFILE_PREFIX_2 \"\"\n~a" libc line)))) (when (file-exists? "gcc/config/rs6000") (substitute* (find-files "gcc/config/rs6000") (("/lib64") "/lib"))) (substitute* "fixincludes/fixincl.x" (("static char const sed_cmd_z\\[\\] =.*;") "static char const sed_cmd_z[] = \"sed\";")) (when (file-exists? "gcc/config/aarch64") (substitute* "gcc/config/aarch64/t-aarch64-linux" (("lib64") "lib"))) (when (file-exists? "gcc/config/riscv") (substitute* (quote ("gcc/config/riscv/linux.h" "gcc/config/riscv/riscv.h")) (("define STARTFILE_PREFIX_SPEC") "define __STARTFILE_PREFIX_SPEC"))) (when (file-exists? "libbacktrace") (substitute* "libbacktrace/configure" (("WARN_FLAGS=(.*)-Werror" _ flags) (string-append "WARN_FLAGS=" flags))) (when (file-exists? "libsanitizer/libbacktrace") (substitute* "libsanitizer/libbacktrace/Makefile.in" (("-Werror") "")))) (substitute* "libstdc++-v3/src/Makefile.in" (("^OPT_LDFLAGS = ") "OPT_LDFLAGS = -Wl,-rpath=$(libdir) ")) (substitute* "libstdc++-v3/python/Makefile.in" (("pythondir = .*$") (string-append "pythondir = " libdir "/share" "/gcc-$(gcc_version)/python\n"))) (substitute* "gcc/config.in" (("PREFIX_INCLUDE_DIR") "PREFIX_INCLUDE_DIR_isnt_necessary_here"))))) (add-after (quote configure) (quote post-configure) (lambda _ (substitute* "Makefile" (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest) "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))))) (add-before (quote configure) (quote pre-x86-configure) (lambda _ (substitute* (quote ("gcc/config/i386/t-linux64" "gcc/config/i386/t-gnu64")) (("\\.\\./lib64") "../lib"))))) (add-after (quote unpack) (quote unpack-gmp&co) (lambda* (#:key inputs #:allow-other-keys) (let ((gmp (assoc-ref %build-inputs "gmp-source")) (mpfr (assoc-ref %build-inputs "mpfr-source")) (mpc (assoc-ref %build-inputs "mpc-source"))) (for-each (lambda (source) (invoke "tar" "xvf" source)) (list gmp mpfr mpc)) (symlink "gmp-6.0.0" "gmp") (symlink "mpfr-4.2.2" "mpfr") (symlink "mpc-1.3.1" "mpc")))) (add-after (quote unpack) (quote fix-build-with-external-libstdc++) (lambda* (#:key inputs #:allow-other-keys) (let ((libstdc++ (assoc-ref inputs "libstdc++"))) (substitute* "libstdc++-v3/src/c++17/Makefile.in" (("AM_CXXFLAGS = ") (string-append "CPLUS_INCLUDE_PATH = " (string-join (remove (cut string-prefix? libstdc++ <>) (string-split (getenv "CPLUS_INCLUDE_PATH") #\:)) ":") "\nAM_CXXFLAGS = "))))))) #:locale "C.UTF-8" #:separate-from-pid1? #t #:bootstrap-scripts %bootstrap-scripts #:configure-flags (append (quasiquote ("--enable-plugin" "--enable-languages=c,c++,objc,obj-c++" "--disable-multilib" "--with-system-zlib" "--disable-libstdcxx-pch" "--with-local-prefix=/no-gcc-local-prefix" (unquote (string-append "--with-gxx-include-dir=" (assoc-ref %outputs "out") "/include/c++")) (unquote (let ((libc (assoc-ref %build-inputs "libc"))) (if libc (string-append "--with-native-system-header-dir=" libc "/include") "--without-headers"))))) (list "--disable-plugin")) #:make-flags (let ((zlib (assoc-ref %build-inputs "zlib"))) (map (lambda (flag) (if (string-prefix? "LDFLAGS=" flag) (string-append flag " -L" (assoc-ref %build-inputs "libstdc++") "/lib -L" zlib "/lib -Wl,-rpath=" zlib "/lib") flag)) (let* ((libc (assoc-ref %build-inputs "libc")) (libc-native (or (assoc-ref %build-inputs "libc-native") libc))) (quasiquote ((unquote-splicing (if libc (list (string-append "LDFLAGS_FOR_TARGET=" "-B" libc "/lib " "-Wl,-dynamic-linker " "-Wl," libc "/lib/ld-linux-x86-64.so.2")) (quote ()))) (unquote (string-append "LDFLAGS=" "-Wl,-rpath=" libc-native "/lib " "-Wl,-dynamic-linker " "-Wl," libc-native "/lib/ld-linux-x86-64.so.2")) (unquote (string-append "BOOT_CFLAGS=-O2 " "-g0"))))))) #:out-of-source? #t #:tests? #f #:test-target "check" #:parallel-build? #t #:parallel-tests? #t #:patch-shebangs? #t #:license-file-regexp "^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\.(txt|md))?)$" #:strip-binaries? #t #:validate-runpath? #f #:make-dynamic-linker-cache? #t #:license-file-regexp "^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\.(txt|md))?)$" #:strip-flags (quote ("--strip-unneeded" "--enable-deterministic-archives")) #:strip-directories (quote ("lib" "lib64" "libexec" "bin" "sbin")))))