gnu: gcc: Allow cross-compilation of GCC itself.
* gnu/packages/gcc.scm (gcc-4.7): Define `CC_FOR_TARGET', `AR_FOR_TARGET', etc. when cross-compiling.
This commit is contained in:
parent
e7133c7680
commit
de1d41f980
|
@ -32,129 +32,150 @@
|
||||||
"ftp://gcc.gnu.org/pub/gcc/infrastructure/")
|
"ftp://gcc.gnu.org/pub/gcc/infrastructure/")
|
||||||
|
|
||||||
(define-public gcc-4.7
|
(define-public gcc-4.7
|
||||||
(let ((stripped? #t)) ; TODO: make this a parameter
|
(let* ((stripped? #t) ; TODO: make this a parameter
|
||||||
|
(maybe-target-tools
|
||||||
|
(lambda ()
|
||||||
|
;; Return the `_FOR_TARGET' variables that are needed when
|
||||||
|
;; cross-compiling GCC.
|
||||||
|
(let ((target (%current-target-system)))
|
||||||
|
(if target
|
||||||
|
(map (lambda (var tool)
|
||||||
|
(string-append (string-append var "_FOR_TARGET")
|
||||||
|
"=" target "-" tool))
|
||||||
|
'("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
|
||||||
|
'("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
|
||||||
|
'()))))
|
||||||
|
(configure-flags
|
||||||
|
(lambda ()
|
||||||
|
;; This is terrible. Since we have two levels of quasiquotation,
|
||||||
|
;; we have to do this convoluted thing just so we can insert the
|
||||||
|
;; contents of (maybe-target-tools).
|
||||||
|
(list 'quasiquote
|
||||||
|
(append
|
||||||
|
'("--enable-plugin"
|
||||||
|
"--enable-languages=c,c++"
|
||||||
|
"--disable-multilib"
|
||||||
|
|
||||||
|
"--with-local-prefix=/no-gcc-local-prefix"
|
||||||
|
|
||||||
|
,(let ((libc (assoc-ref %build-inputs "libc")))
|
||||||
|
(if libc
|
||||||
|
(string-append "--with-native-system-header-dir=" libc
|
||||||
|
"/include")
|
||||||
|
"--without-headers")))
|
||||||
|
|
||||||
|
(maybe-target-tools))))))
|
||||||
(package
|
(package
|
||||||
(name "gcc")
|
(name "gcc")
|
||||||
(version "4.7.3")
|
(version "4.7.3")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method url-fetch)
|
(method url-fetch)
|
||||||
(uri (string-append "mirror://gnu/gcc/gcc-"
|
(uri (string-append "mirror://gnu/gcc/gcc-"
|
||||||
version "/gcc-" version ".tar.bz2"))
|
version "/gcc-" version ".tar.bz2"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
|
"1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
|
||||||
(build-system gnu-build-system)
|
(build-system gnu-build-system)
|
||||||
(inputs `(("gmp" ,gmp)
|
(inputs `(("gmp" ,gmp)
|
||||||
("mpfr" ,mpfr)
|
("mpfr" ,mpfr)
|
||||||
("mpc" ,mpc)
|
("mpc" ,mpc)
|
||||||
("isl" ,isl)
|
("isl" ,isl)
|
||||||
("cloog" ,cloog)
|
("cloog" ,cloog)
|
||||||
("libelf" ,libelf)
|
("libelf" ,libelf)
|
||||||
("zlib" ,zlib)))
|
("zlib" ,zlib)))
|
||||||
(arguments
|
(arguments
|
||||||
`(#:out-of-source? #t
|
`(#:out-of-source? #t
|
||||||
#:strip-binaries? ,stripped?
|
#:strip-binaries? ,stripped?
|
||||||
#:configure-flags
|
#:configure-flags ,(configure-flags)
|
||||||
`("--enable-plugin"
|
#:make-flags
|
||||||
"--enable-languages=c,c++"
|
(let ((libc (assoc-ref %build-inputs "libc")))
|
||||||
"--disable-multilib"
|
`(,@(if libc
|
||||||
|
(list (string-append "LDFLAGS_FOR_TARGET="
|
||||||
|
"-B" libc "/lib "
|
||||||
|
"-Wl,-dynamic-linker "
|
||||||
|
"-Wl," libc
|
||||||
|
,(glibc-dynamic-linker)))
|
||||||
|
'())
|
||||||
|
,(string-append "BOOT_CFLAGS=-O2 "
|
||||||
|
,(if stripped? "-g0" "-g"))))
|
||||||
|
|
||||||
"--with-local-prefix=/no-gcc-local-prefix"
|
#:tests? #f
|
||||||
|
#:phases
|
||||||
|
(alist-cons-before
|
||||||
|
'configure 'pre-configure
|
||||||
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
|
(let ((out (assoc-ref outputs "out"))
|
||||||
|
(libc (assoc-ref inputs "libc")))
|
||||||
|
(when libc
|
||||||
|
;; The following is not performed for `--without-headers'
|
||||||
|
;; cross-compiler builds.
|
||||||
|
|
||||||
,(let ((libc (assoc-ref %build-inputs "libc")))
|
;; Fix the dynamic linker's file name.
|
||||||
(if libc
|
(substitute* (find-files "gcc/config"
|
||||||
(string-append "--with-native-system-header-dir=" libc
|
"^linux(64|-elf)?\\.h$")
|
||||||
"/include")
|
(("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
|
||||||
"--without-headers")))
|
(format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
|
||||||
#:make-flags
|
suffix
|
||||||
(let ((libc (assoc-ref %build-inputs "libc")))
|
(string-append libc ,(glibc-dynamic-linker)))))
|
||||||
`(,@(if libc
|
|
||||||
(list (string-append "LDFLAGS_FOR_TARGET="
|
|
||||||
"-B" libc "/lib "
|
|
||||||
"-Wl,-dynamic-linker "
|
|
||||||
"-Wl," libc
|
|
||||||
,(glibc-dynamic-linker)))
|
|
||||||
'())
|
|
||||||
,(string-append "BOOT_CFLAGS=-O2 "
|
|
||||||
,(if stripped? "-g0" "-g"))))
|
|
||||||
|
|
||||||
#:tests? #f
|
;; Tell where to find libstdc++, libc, and `?crt*.o', except
|
||||||
#:phases
|
;; `crt{begin,end}.o', which come with GCC.
|
||||||
(alist-cons-before
|
(substitute* (find-files "gcc/config"
|
||||||
'configure 'pre-configure
|
"^(gnu-user(64)?|linux-elf)\\.h$")
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(("#define LIB_SPEC (.*)$" _ suffix)
|
||||||
(let ((out (assoc-ref outputs "out"))
|
;; Note that with this "lib" spec, we may still add a
|
||||||
(libc (assoc-ref inputs "libc")))
|
;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
|
||||||
(when libc
|
;; There's not much that can be done to avoid it, though.
|
||||||
;; The following is not performed for `--without-headers'
|
(format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
|
||||||
;; cross-compiler builds.
|
|
||||||
|
|
||||||
;; Fix the dynamic linker's file name.
|
|
||||||
(substitute* (find-files "gcc/config"
|
|
||||||
"^linux(64|-elf)?\\.h$")
|
|
||||||
(("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
|
|
||||||
(format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
|
|
||||||
suffix
|
|
||||||
(string-append libc ,(glibc-dynamic-linker)))))
|
|
||||||
|
|
||||||
;; Tell where to find libstdc++, libc, and `?crt*.o', except
|
|
||||||
;; `crt{begin,end}.o', which come with GCC.
|
|
||||||
(substitute* (find-files "gcc/config"
|
|
||||||
"^(gnu-user(64)?|linux-elf)\\.h$")
|
|
||||||
(("#define LIB_SPEC (.*)$" _ suffix)
|
|
||||||
;; Note that with this "lib" spec, we may still add a
|
|
||||||
;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
|
|
||||||
;; There's not much that can be done to avoid it, though.
|
|
||||||
(format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
|
|
||||||
%{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
|
%{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
|
||||||
libc libc out out suffix))
|
libc libc out out suffix))
|
||||||
(("#define STARTFILE_SPEC.*$" line)
|
(("#define STARTFILE_SPEC.*$" line)
|
||||||
(format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
|
(format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
|
||||||
#define STANDARD_STARTFILE_PREFIX_2 \"\"
|
#define STANDARD_STARTFILE_PREFIX_2 \"\"
|
||||||
~a~%"
|
~a~%"
|
||||||
libc line))))
|
libc line))))
|
||||||
|
|
||||||
;; Don't retain a dependency on the build-time sed.
|
;; Don't retain a dependency on the build-time sed.
|
||||||
(substitute* "fixincludes/fixincl.x"
|
(substitute* "fixincludes/fixincl.x"
|
||||||
(("static char const sed_cmd_z\\[\\] =.*;")
|
(("static char const sed_cmd_z\\[\\] =.*;")
|
||||||
"static char const sed_cmd_z[] = \"sed\";"))))
|
"static char const sed_cmd_z[] = \"sed\";"))))
|
||||||
|
|
||||||
(alist-cons-after
|
(alist-cons-after
|
||||||
'configure 'post-configure
|
'configure 'post-configure
|
||||||
(lambda _
|
(lambda _
|
||||||
;; Don't store configure flags, to avoid retaining references to
|
;; Don't store configure flags, to avoid retaining references to
|
||||||
;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
|
;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
|
||||||
(substitute* "Makefile"
|
(substitute* "Makefile"
|
||||||
(("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
|
(("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
|
||||||
"TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
|
"TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
|
||||||
(alist-replace 'install
|
(alist-replace 'install
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(lambda* (#:key outputs #:allow-other-keys)
|
||||||
(zero?
|
(zero?
|
||||||
(system* "make"
|
(system* "make"
|
||||||
,(if stripped?
|
,(if stripped?
|
||||||
"install-strip"
|
"install-strip"
|
||||||
"install"))))
|
"install"))))
|
||||||
%standard-phases)))))
|
%standard-phases)))))
|
||||||
|
|
||||||
(native-search-paths
|
(native-search-paths
|
||||||
(list (search-path-specification
|
(list (search-path-specification
|
||||||
(variable "CPATH")
|
(variable "CPATH")
|
||||||
(directories '("include")))
|
(directories '("include")))
|
||||||
(search-path-specification
|
(search-path-specification
|
||||||
(variable "LIBRARY_PATH")
|
(variable "LIBRARY_PATH")
|
||||||
(directories '("lib" "lib64")))))
|
(directories '("lib" "lib64")))))
|
||||||
|
|
||||||
(properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
|
(properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
|
||||||
(synopsis "GNU Compiler Collection")
|
(synopsis "GNU Compiler Collection")
|
||||||
(description
|
(description
|
||||||
"The GNU Compiler Collection includes compiler front ends for C, C++,
|
"The GNU Compiler Collection includes compiler front ends for C, C++,
|
||||||
Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
|
Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
|
||||||
libraries for these languages (libstdc++, libgcj, libgomp,...).
|
libraries for these languages (libstdc++, libgcj, libgomp,...).
|
||||||
|
|
||||||
GCC development is a part of the GNU Project, aiming to improve the compiler
|
GCC development is a part of the GNU Project, aiming to improve the compiler
|
||||||
used in the GNU system including the GNU/Linux variant.")
|
used in the GNU system including the GNU/Linux variant.")
|
||||||
(license gpl3+)
|
(license gpl3+)
|
||||||
(home-page "http://gcc.gnu.org/"))))
|
(home-page "http://gcc.gnu.org/"))))
|
||||||
|
|
||||||
(define-public gcc-4.8
|
(define-public gcc-4.8
|
||||||
;; FIXME: Move to gcc.scm when Binutils is updated.
|
;; FIXME: Move to gcc.scm when Binutils is updated.
|
||||||
|
|
Loading…
Reference in New Issue