From 6c033b18ee78be22bd236496bf987625e24058d1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 31 Mar 2011 21:44:55 +0000 Subject: [PATCH] Initial copy of gcc-4.5 to gcc-4.6 svn path=/nixpkgs/trunk/; revision=26637 --- pkgs/development/compilers/gcc-4.6/builder.sh | 236 ++++++++++ .../development/compilers/gcc-4.6/default.nix | 428 ++++++++++++++++++ .../compilers/gcc-4.6/ghdl-ortho-cflags.patch | 111 +++++ .../compilers/gcc-4.6/gnat-cflags.patch | 33 ++ .../gcc-4.6/java-jvgenmain-link.patch | 17 + .../compilers/gcc-4.6/libstdc++-target.patch | 32 ++ .../compilers/gcc-4.6/no-sys-dirs.patch | 54 +++ .../development/compilers/gcc-4.6/sources.nix | 26 ++ .../compilers/gcc-4.6/update-gcc.sh | 1 + 9 files changed, 938 insertions(+) create mode 100644 pkgs/development/compilers/gcc-4.6/builder.sh create mode 100644 pkgs/development/compilers/gcc-4.6/default.nix create mode 100644 pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch create mode 100644 pkgs/development/compilers/gcc-4.6/gnat-cflags.patch create mode 100644 pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch create mode 100644 pkgs/development/compilers/gcc-4.6/libstdc++-target.patch create mode 100644 pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch create mode 100644 pkgs/development/compilers/gcc-4.6/sources.nix create mode 120000 pkgs/development/compilers/gcc-4.6/update-gcc.sh diff --git a/pkgs/development/compilers/gcc-4.6/builder.sh b/pkgs/development/compilers/gcc-4.6/builder.sh new file mode 100644 index 00000000000..aedd5b46b12 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/builder.sh @@ -0,0 +1,236 @@ +source $stdenv/setup + + +export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy +mkdir $NIX_FIXINC_DUMMY + + +# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad +# Thing. +export CPP="gcc -E" + +if test "$staticCompiler" = "1"; then + EXTRA_LDFLAGS="-static" +else + EXTRA_LDFLAGS="" +fi + +# GCC interprets empty paths as ".", which we don't want. +if test -z "$CPATH"; then unset CPATH; fi +if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi +echo "\$CPATH is \`$CPATH'" +echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'" + +if test "$noSysDirs" = "1"; then + + if test -e $NIX_GCC/nix-support/orig-libc; then + + # Figure out what extra flags to pass to the gcc compilers + # being generated to make sure that they use our glibc. + extraFlags="$(cat $NIX_GCC/nix-support/libc-cflags)" + extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)" + + # Use *real* header files, otherwise a limits.h is generated + # that does not include Glibc's limits.h (notably missing + # SSIZE_MAX, which breaks the build). + export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include + + # The path to the Glibc binaries such as `crti.o'. + glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib" + + else + # Hack: support impure environments. + extraFlags="-isystem /usr/include" + extraLDFlags="-L/usr/lib64 -L/usr/lib" + glibc_libdir="/usr/lib" + export NIX_FIXINC_DUMMY=/usr/include + fi + + extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY $extraFlags" + extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" + + EXTRA_FLAGS="$extraFlags" + for i in $extraLDFlags; do + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i" + done + + if test -n "$targetConfig"; then + # Cross-compiling, we need gcc not to read ./specs in order to build + # the g++ compiler (after the specs for the cross-gcc are created). + # Having LIBRARY_PATH= makes gcc read the specs from ., and the build + # breaks. Having this variable comes from the default.nix code to bring + # gcj in. + unset LIBRARY_PATH + unset CPATH + if test -z "$crossStageStatic"; then + EXTRA_TARGET_CFLAGS="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include" + EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib" + fi + else + if test -z "$NIX_GCC_CROSS"; then + EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" + EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" + else + # This the case of cross-building the gcc. + # We need special flags for the target, different than those of the build + # Assertion: + test -e $NIX_GCC_CROSS/nix-support/orig-libc + + # Figure out what extra flags to pass to the gcc compilers + # being generated to make sure that they use our glibc. + extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)" + extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)" + + # Use *real* header files, otherwise a limits.h is generated + # that does not include Glibc's limits.h (notably missing + # SSIZE_MAX, which breaks the build). + NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include + + # The path to the Glibc binaries such as `crti.o'. + glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib" + + extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY_CROSS $extraFlags" + extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" + + EXTRA_TARGET_CFLAGS="$extraFlags" + for i in $extraLDFlags; do + EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i" + done + fi + fi + + + # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find + # the startfiles. + # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx + # for the startfiles. + makeFlagsArray=( \ + "${makeFlagsArray[@]}" \ + NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ + CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ + FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ + LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ + LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \ + ) + + if test -z "$targetConfig"; then + makeFlagsArray=( \ + "${makeFlagsArray[@]}" \ + BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ + BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ + ) + fi + + if test -n "$targetConfig" -a "$crossStageStatic" == 1; then + # We don't want the gcc build to assume there will be a libc providing + # limits.h in this stagae + makeFlagsArray=( \ + "${makeFlagsArray[@]}" \ + LIMITS_H_TEST=false \ + ) + else + makeFlagsArray=( \ + "${makeFlagsArray[@]}" \ + LIMITS_H_TEST=true \ + ) + fi +fi + +if test -n "$targetConfig"; then + # The host strip will destroy some important details of the objects + dontStrip=1 +fi + + +preConfigure() { + if test -n "$newlibSrc"; then + tar xvf "$newlibSrc" -C .. + ln -s ../newlib-*/newlib newlib + # Patch to get armvt5el working: + sed -i -e 's/ arm)/ arm*)/' newlib/configure.host + fi + # Bug - they packaged zlib + if test -d "zlib"; then + # This breaks the build without-headers, which should build only + # the target libgcc as target libraries. + # See 'configure:5370' + rm -Rf zlib + fi + + # Patch the configure script so it finds glibc headers + # It's important for example in order not to get libssp built, because it's + # functionality is in glibc already. + glibc_headers="$(cat $NIX_GCC/nix-support/orig-libc)/include" + sed -i \ + -e s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers, \ + gcc/configure + + if test -n "$crossMingw" -a -n "$crossStageStatic"; then + mkdir -p ../mingw + # --with-build-sysroot expects that: + cp -R $libcCross/include ../mingw + configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." + fi + + # Perform the build in a different directory. + mkdir ../build + cd ../build + configureScript=../$sourceRoot/configure +} + + +postConfigure() { + # Don't store the configure flags in the resulting executables. + sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile +} + + +postInstall() { + # Remove precompiled headers for now. They are very big and + # probably not very useful yet. + find $out/include -name "*.gch" -exec rm -rf {} \; -prune + + # Remove `fixincl' to prevent a retained dependency on the + # previous gcc. + rm -rf $out/libexec/gcc/*/*/install-tools + rm -rf $out/lib/gcc/*/*/install-tools + + # More dependencies with the previous gcc or some libs (gccbug stores the build command line) + rm -rf $out/bin/gccbug + # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out + for i in $out/libexec/gcc/*/*/*; do + PREV_RPATH=`patchelf --print-rpath $i` + patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i + done + + # Get rid of some "fixed" header files + rm -rf $out/lib/gcc/*/*/include/root + + # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks. + for i in $out/bin/*-gcc*; do + if cmp -s $out/bin/gcc $i; then + ln -sfn gcc $i + fi + done + + for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do + if cmp -s $out/bin/g++ $i; then + ln -sfn g++ $i + fi + done + + eval "$postInstallGhdl" +} + + +if test -z "$targetConfig" && test -z "$crossConfig"; then + if test -z "$profiledCompiler"; then + buildFlags="bootstrap $buildFlags" + else + buildFlags="profiledbootstrap $buildFlags" + fi +fi + +genericBuild diff --git a/pkgs/development/compilers/gcc-4.6/default.nix b/pkgs/development/compilers/gcc-4.6/default.nix new file mode 100644 index 00000000000..19efa57af8e --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/default.nix @@ -0,0 +1,428 @@ +{ stdenv, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false +, langJava ? false +, langAda ? false +, langVhdl ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, mpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, ppl ? null, cloogppl ? null # optional, for the Graphite optimization framework +, bison ? null, flex ? null +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null +, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null +, gnatboot ? null +, enableMultilib ? false +, name ? "gcc" +, cross ? null +, binutilsCross ? null +, libcCross ? null +, crossStageStatic ? true +, gnat ? null +, libpthread ? null, libpthreadCross ? null # required for GNU/Hurd +}: + +assert langTreelang -> bison != null && flex != null; +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' +assert langAda -> gnatboot != null; +assert langVhdl -> gnat != null; + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +with stdenv.lib; +with builtins; + +let version = "4.5.1"; + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = http://www.antlr.org/download/antlr-3.1.3.jar; + sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xproto renderproto xextproto inputproto randrproto + ]; + + javaAwtGtk = langJava && gtk != null; + + /* Cross-gcc settings */ + gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; + gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; + gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; + withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; + withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; + withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + crossMingw = (cross != null && cross.libc == "msvcrt"); + + crossConfigureFlags = + "--target=${cross.config}" + + withArch + + withCpu + + withAbi + + (if (crossMingw && crossStageStatic) then + " --with-headers=${libcCross}/include" + + " --with-gcc" + + " --with-gnu-as" + + " --with-gnu-ld" + + " --with-gnu-ld" + + " --disable-shared" + + " --disable-nls" + + " --disable-debug" + + " --enable-sjlj-exceptions" + + " --enable-threads=win32" + + " --disable-win32-registry" + else if crossStageStatic then + " --disable-libssp --disable-nls" + + " --without-headers" + + " --disable-threads " + + " --disable-libmudflap " + + " --disable-libgomp " + + " --disable-shared" + + " --disable-decimal-float" # libdecnumber requires libc + else + " --with-headers=${libcCross}/include" + + " --enable-__cxa_atexit" + + " --enable-long-long" + + (if crossMingw then + " --enable-threads=win32" + + " --enable-sjlj-exceptions" + + " --enable-hash-synchronization" + + " --enable-version-specific-runtime-libs" + + " --disable-libssp" + + " --disable-nls" + + " --with-dwarf2" + else + " --enable-threads=posix" + + " --enable-nls" + + " --disable-decimal-float") # No final libdecnumber (it may work only in 386) + ); + stageNameAddon = if (crossStageStatic) then "-stage-static" else + "-stage-final"; + crossNameAddon = if (cross != null) then "-${cross.config}" + stageNameAddon else ""; + +in + +# We need all these X libraries when building AWT with GTK+. +assert gtk != null -> (filter (x: x == null) xlibs) == []; + +stdenv.mkDerivation ({ + name = "${name}-${version}" + crossNameAddon; + + builder = ./builder.sh; + + src = (import ./sources.nix) { + inherit fetchurl optional version; + inherit langC langCC langFortran langJava langAda; + }; + + patches = + [ ] + ++ optional (cross != null) ./libstdc++-target.patch + ++ optional noSysDirs ./no-sys-dirs.patch + # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its + # target libraries and tools. + ++ optional langAda ./gnat-cflags.patch + ++ optional langVhdl ./ghdl-ortho-cflags.patch + ; + + postPatch = + if (stdenv.system == "i586-pc-gnu" + || (cross != null && cross.config == "i586-pc-gnu" + && libcCross != null)) + then + # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not + # in glibc, so add the right `-I' flags to the default spec string. + let + libc = if cross != null then libcCross else stdenv.glibc; + gnu_h = "gcc/config/gnu.h"; + i386_gnu_h = "gcc/config/i386/gnu.h"; + extraCPPDeps = + libc.propagatedBuildInputs + ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross + ++ stdenv.lib.optional (libpthread != null) libpthread; + extraCPPSpec = + concatStrings (intersperse " " + (map (x: "-I${x}/include") extraCPPDeps)); + extraLibSpec = + if libpthreadCross != null + then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}" + else "-L${libpthread}/lib"; + in + '' echo "augmenting \`CPP_SPEC' in \`${i386_gnu_h}' with \`${extraCPPSpec}'..." + sed -i "${i386_gnu_h}" \ + -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g' + + echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..." + sed -i "${gnu_h}" \ + -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g' + '' + else if cross != null || stdenv.gcc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if (cross != null && libcCross != null) then libcCross else stdenv.gcc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g' + done + '' + else null; + + inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic + libcCross crossMingw; + + buildNativeInputs = [ texinfo which ] + ++ optional (perl != null) perl; + + buildInputs = [ gmp mpfr mpc libelf gettext ] + ++ (optional (ppl != null) ppl) + ++ (optional (cloogppl != null) cloogppl) + ++ (optionals langTreelang [bison flex]) + ++ (optional (zlib != null) zlib) + ++ (optional (boehmgc != null) boehmgc) + ++ (optionals langJava [zip unzip]) + ++ (optionals javaAwtGtk [gtk pkgconfig libart_lgpl] ++ xlibs) + ++ (optionals (cross != null) [binutilsCross]) + ++ (optionals langAda [gnatboot]) + ++ (optionals langVhdl [gnat]) + ; + + configureFlagsArray = stdenv.lib.optionals + (ppl != null && ppl.dontDisableStatic == true) + [ "--with-host-libstdcxx=-lstdc++ -lgcc_s" + "--with-stage1-libs=-lstdc++ -lgcc_s" ]; + + configureFlags = " + ${if enableMultilib then "" else "--disable-multilib"} + ${if enableShared then "" else "--disable-shared"} + ${if ppl != null then "--with-ppl=${ppl}" else ""} + ${if cloogppl != null then "--with-cloog=${cloogppl}" else ""} + ${if langJava then + "--with-ecj-jar=${javaEcj} " + + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # . + "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " + else ""} + ${if javaAwtGtk then "--enable-java-awt=gtk" else ""} + ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} + --with-gmp=${gmp} + --with-mpfr=${mpfr} + --with-mpc=${mpc} + ${if (libelf != null) then "--with-libelf=${libelf}" else ""} + --disable-libstdcxx-pch + --without-included-gettext + --with-system-zlib + --enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langTreelang "treelang" + ++ optional langAda "ada" + ++ optional langVhdl "vhdl" + ) + ) + } + ${ # Trick that should be taken out once we have a mips64-linux not loongson2f + if cross == null && stdenv.system == "mips64-linux" then "--with-arch=loongson2f" else ""} + ${if langAda then " --enable-libada" else ""} + ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} + ${if cross != null then crossConfigureFlags else ""} + "; + + targetConfig = if (cross != null) then cross.config else null; + + crossAttrs = { + AR = "${stdenv.cross.config}-ar"; + LD = "${stdenv.cross.config}-ld"; + CC = "${stdenv.cross.config}-gcc"; + CXX = "${stdenv.cross.config}-gcc"; + AR_FOR_TARGET = "${stdenv.cross.config}-ar"; + LD_FOR_TARGET = "${stdenv.cross.config}-ld"; + CC_FOR_TARGET = "${stdenv.cross.config}-gcc"; + NM_FOR_TARGET = "${stdenv.cross.config}-nm"; + CXX_FOR_TARGET = "${stdenv.cross.config}-g++"; + # If we are making a cross compiler, cross != null + NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else ""; + dontStrip = true; + configureFlags = '' + ${if enableMultilib then "" else "--disable-multilib"} + ${if enableShared then "" else "--disable-shared"} + ${if ppl != null then "--with-ppl=${ppl.hostDrv}" else ""} + ${if cloogppl != null then "--with-cloog=${cloogppl.hostDrv}" else ""} + ${if langJava then "--with-ecj-jar=${javaEcj.hostDrv}" else ""} + ${if javaAwtGtk then "--enable-java-awt=gtk" else ""} + ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.hostDrv}" else ""} + --with-gmp=${gmp.hostDrv} + --with-mpfr=${mpfr.hostDrv} + --disable-libstdcxx-pch + --without-included-gettext + --with-system-zlib + --enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langTreelang "treelang" + ++ optional langAda "ada" + ++ optional langVhdl "vhdl" + ) + ) + } + ${if langAda then " --enable-libada" else ""} + ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} + ${if cross != null then crossConfigureFlags else ""} + --target=${stdenv.cross.config} + ''; + }; + + + # Needed for the cross compilation to work + AR = "ar"; + LD = "ld"; + CC = "gcc"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find + # the library headers and binaries, regarless of the language being + # compiled. + + # Note: When building the Java AWT GTK+ peer, the build system doesn't + # honor `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just + # add them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + + CPATH = concatStrings + (intersperse ":" (map (x: x + "/include") + (optionals (zlib != null) [ zlib ] + ++ optionals langJava [ boehmgc ] + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + ++ optional (libpthread != null) libpthread + ++ optional (libpthreadCross != null) libpthreadCross + + # On GNU/Hurd glibc refers to Mach & Hurd + # headers. + ++ optionals (libcCross != null && + hasAttr "propagatedBuildInputs" libcCross) + libcCross.propagatedBuildInputs))); + + LIBRARY_PATH = concatStrings + (intersperse ":" (map (x: x + "/lib") + (optionals (zlib != null) [ zlib ] + ++ optionals langJava [ boehmgc ] + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + ++ optional (libpthread != null) libpthread))); + + EXTRA_TARGET_CFLAGS = + if cross != null && libcCross != null + then "-g0 -O2 -idirafter ${libcCross}/include" + else null; + + EXTRA_TARGET_LDFLAGS = + if cross != null && libcCross != null + then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" + + (optionalString (libpthreadCross != null) + " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}") + else null; + + passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl + enableMultilib version; }; + + enableParallelBuilding = true; + + meta = { + homepage = http://gcc.gnu.org/; + license = "GPLv3+"; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}"; + + longDescription = '' + 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 libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = [ + stdenv.lib.maintainers.ludo + stdenv.lib.maintainers.viric + ]; + + # Volunteers needed for the {Cyg,Dar}win ports of *PPL. + # gnatboot is not available out of linux platforms, so we disable the darwin build + # for the gnat (ada compiler). + platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ]; + }; +} + +// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs langVhdl rec { + name = "ghdl-0.29"; + + ghdlSrc = fetchurl { + url = "http://ghdl.free.fr/ghdl-0.29.tar.bz2"; + sha256 = "15mlinr1lwljwll9ampzcfcrk9bk0qpdks1kxlvb70xf9zhh2jva"; + }; + + # Ghdl has some timestamps checks, storing file timestamps in '.cf' files. + # As we will change the timestamps to 1970-01-01 00:00:01, we also set the + # content of that .cf to that value. This way ghdl does not complain on + # the installed object files from the basic libraries (ieee, ...) + postInstallGhdl = '' + pushd $out + find . -name "*.cf" -exec \ + sed 's/[0-9]*\.000" /19700101000001.000" /g' -i {} \; + popd + ''; + + postUnpack = '' + tar xvf ${ghdlSrc} + mv ghdl-*/vhdl gcc*/gcc + rm -Rf ghdl-* + ''; + + meta = { + homepage = "http://ghdl.free.fr/"; + license = "GPLv2+"; + description = "Complete VHDL simulator, using the GCC technology (gcc ${version})"; + maintainers = with stdenv.lib.maintainers; [viric]; + platforms = with stdenv.lib.platforms; linux; + }; + +}) diff --git a/pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch b/pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch new file mode 100644 index 00000000000..901534591c8 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/ghdl-ortho-cflags.patch @@ -0,0 +1,111 @@ +diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in +index 8f481df..681ac59 100644 +--- a/gcc/vhdl/Make-lang.in ++++ b/gcc/vhdl/Make-lang.in +@@ -96,7 +96,7 @@ AGCC_GCCOBJ_DIR=../ + AGCC_INC_FLAGS=-I$(AGCC_GCCOBJ_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/include \ + -I$(AGCC_GCCSRC_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/gcc/config \ + -I$(AGCC_GCCSRC_DIR)/libcpp/include +-AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS) ++AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS) $(CFLAGS) $(INCLUDES) + + AGCC_LOCAL_OBJS=ortho-lang.o + +@@ -140,7 +140,7 @@ ghdl$(exeext): force + + # Ghdl libraries. + ghdllib: ghdl$(exeext) $(GCC_PASSES) force +- $(MAKE_IN_VHDL) GRT_FLAGS="-O -g" ghdllib ++ $(MAKE_IN_VHDL) GRT_FLAGS="-O -g $(CFLAGS)" ghdllib + + # Build hooks: + +diff --git a/gcc/vhdl/Makefile.in b/gcc/vhdl/Makefile.in +index d754c6c..07abc4a 100644 +--- a/gcc/vhdl/Makefile.in ++++ b/gcc/vhdl/Makefile.in +@@ -80,7 +80,8 @@ T_CPPFLAGS = + X_ADAFLAGS = + T_ADAFLAGS = + +-ADAC = $(CC) ++# Never use the bootstrapped compiler, as it may not be built for ada ++ADAC = gcc + + ECHO = echo + CHMOD = chmod +diff --git a/gcc/vhdl/ortho-lang.c b/gcc/vhdl/ortho-lang.c +index 84aeb92..8eddd42 100644 +--- a/gcc/vhdl/ortho-lang.c ++++ b/gcc/vhdl/ortho-lang.c +@@ -16,6 +16,7 @@ + #include "options.h" + #include "real.h" +-#include "tree-gimple.h" ++#include "gimple.h" ++#include "tree.h" + #include "function.h" + #include "cgraph.h" + #include "target.h" +@@ -680,38 +681,10 @@ type_for_mode (enum machine_mode mode, int unsignedp) + + const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; + +-/* Tree code classes. */ +- +-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, +- +-const enum tree_code_class tree_code_type[] = { +-#include "tree.def" +- 'x' +-}; +-#undef DEFTREECODE +- +-/* Table indexed by tree code giving number of expression +- operands beyond the fixed part of the node structure. +- Not used for types or decls. */ +- +-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, +- +-const unsigned char tree_code_length[] = { +-#include "tree.def" +- 0 +-}; +-#undef DEFTREECODE +- +-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) NAME, +-const char * const tree_code_name[] = { +-#include "tree.def" +- "@@dummy" +-}; +-#undef DEFTREECODE + + union lang_tree_node + GTY((desc ("0"), +- chain_next ("(union lang_tree_node *) GENERIC_NEXT (&%h.generic)"))) ++ chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)"))) + { + union tree_node GTY ((tag ("0"))) generic; + }; +@@ -1162,7 +1135,7 @@ new_access_type (tree dtype) + res = make_node (POINTER_TYPE); + TREE_TYPE (res) = NULL_TREE; + /* Seems necessary. */ +- TYPE_MODE (res) = Pmode; ++ SET_TYPE_MODE (res, Pmode); + layout_type (res); + return res; + } +diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in +index e201f64..f36fb97 100644 +--- a/gcc/vhdl/Make-lang.in ++++ b/gcc/vhdl/Make-lang.in +@@ -132,7 +132,7 @@ ghdl1$(exeext): $(AGCC_OBJS) $(AGCC_DEPS) force + -cargs $(CFLAGS) $(GHDL_ADAFLAGS) + $(GNATMAKE) -o $@ -aI$(srcdir)/vhdl -aOvhdl ortho_gcc-main \ + -bargs -E -cargs $(CFLAGS) $(GHDL_ADAFLAGS) \ +- -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS) ++ -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS) $(CLOOGLIBS) $(PPLLIBS) + + # The driver for ghdl. + ghdl$(exeext): force diff --git a/pkgs/development/compilers/gcc-4.6/gnat-cflags.patch b/pkgs/development/compilers/gcc-4.6/gnat-cflags.patch new file mode 100644 index 00000000000..bf2acf065e9 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/gnat-cflags.patch @@ -0,0 +1,33 @@ +diff --git a/libada/Makefile.in b/libada/Makefile.in +index f5057a0..337e0c6 100644 +--- a/libada/Makefile.in ++++ b/libada/Makefile.in +@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN) + WARN_CFLAGS = @warn_cflags@ + + TARGET_LIBGCC2_CFLAGS= +-GNATLIBCFLAGS= -g -O2 ++GNATLIBCFLAGS= -g -O2 $(CFLAGS) + GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \ + -DIN_RTS @have_getipinfo@ + +--- a/gcc/ada/gcc-interface/Makefile.in ++++ b/gcc/ada/gcc-interface/Makefile.in +@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata + SOME_ADAFLAGS =-gnata + FORCE_DEBUG_ADAFLAGS = -g + GNATLIBFLAGS = -gnatpg -nostdinc +-GNATLIBCFLAGS = -g -O2 ++GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET) + # Pretend that _Unwind_GetIPInfo is available for the target by default. This + # should be autodetected during the configuration of libada and passed down to + # here, but we need something for --disable-libada and hope for the best. +@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR)) + # Link flags used to build gnat tools. By default we prefer to statically + # link with libgcc to avoid a dependency on shared libgcc (which is tricky + # to deal with as it may conflict with the libgcc provided by the system). +-GCC_LINK_FLAGS=-static-libgcc ++GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET) + + # End of variables for you to override. + diff --git a/pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch new file mode 100644 index 00000000000..2612e8bfbbb --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/java-jvgenmain-link.patch @@ -0,0 +1,17 @@ +The `jvgenmain' executable must be linked against `vec.o', among others, +since it uses its vector API. + +--- gcc-4.3.3/gcc/java/Make-lang.in 2008-12-05 00:00:19.000000000 +0100 ++++ gcc-4.3.3/gcc/java/Make-lang.in 2009-07-03 16:11:41.000000000 +0200 +@@ -109,9 +109,9 @@ jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIB + $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \ + $(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS) + +-jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) ++jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) $(BUILD_RTL) + rm -f $@ +- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(LIBS) ++ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(BUILD_RTL) $(LIBS) + + # + # Build hooks: diff --git a/pkgs/development/compilers/gcc-4.6/libstdc++-target.patch b/pkgs/development/compilers/gcc-4.6/libstdc++-target.patch new file mode 100644 index 00000000000..fb622b39580 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/libstdc++-target.patch @@ -0,0 +1,32 @@ +Patch to make the target libraries 'configure' scripts find the proper CPP. +I noticed that building the mingw32 cross compiler. +Looking at the build script for mingw in archlinux, I think that only nixos +needs this patch. I don't know why. +diff --git a/Makefile.in b/Makefile.in +index 93f66b6..d691917 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ + AR="$(AR_FOR_TARGET)"; export AR; \ + AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ + CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ ++ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ + CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ + CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ +@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ + RAW_CXX_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ + CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ +- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + NORMAL_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ +- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + # Where to find GMP + HOST_GMPLIBS = @gmplibs@ diff --git a/pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch b/pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch new file mode 100644 index 00000000000..8128fa87da5 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/no-sys-dirs.patch @@ -0,0 +1,54 @@ +diff -ru gcc-4.3.1-orig/gcc/cppdefault.c gcc-4.3.1/gcc/cppdefault.c +--- gcc-4.3.1-orig/gcc/cppdefault.c 2007-07-26 10:37:01.000000000 +0200 ++++ gcc-4.3.1/gcc/cppdefault.c 2008-06-25 17:48:23.000000000 +0200 +@@ -41,6 +41,10 @@ + # undef CROSS_INCLUDE_DIR + #endif + ++#undef LOCAL_INCLUDE_DIR ++#undef SYSTEM_INCLUDE_DIR ++#undef STANDARD_INCLUDE_DIR ++ + const struct default_include cpp_include_defaults[] + #ifdef INCLUDE_DEFAULTS + = INCLUDE_DEFAULTS; +diff -ru gcc-4.3.1-orig/gcc/gcc.c gcc-4.3.1/gcc/gcc.c +--- gcc-4.3.1-orig/gcc/gcc.c 2008-03-02 23:55:19.000000000 +0100 ++++ gcc-4.3.1/gcc/gcc.c 2008-06-25 17:52:53.000000000 +0200 +@@ -1478,10 +1478,10 @@ + /* Default prefixes to attach to command names. */ + + #ifndef STANDARD_STARTFILE_PREFIX_1 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_1 "" + #endif + #ifndef STANDARD_STARTFILE_PREFIX_2 +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "" + #endif + + #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ +--- gcc-4.3.1-orig/gcc/Makefile.in 2008-05-11 20:54:15.000000000 +0200 ++++ gcc-4.3.1/gcc/Makefile.in 2008-06-25 17:48:23.000000000 +0200 +@@ -378,7 +378,11 @@ + MD5_H = $(srcdir)/../include/md5.h + + # Default native SYSTEM_HEADER_DIR, to be overridden by targets. +-NATIVE_SYSTEM_HEADER_DIR = /usr/include ++# Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent ++# `fixinc' from fixing header files in /usr/include. However, ++# NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set ++# it to some dummy directory. ++NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY) + # Default cross SYSTEM_HEADER_DIR, to be overridden by targets. + CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@ + +@@ -3277,7 +3281,7 @@ + -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ + -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \ + -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \ +- -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \ ++ -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \ + -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \ + -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \ + -DPREFIX=\"$(prefix)/\" \ diff --git a/pkgs/development/compilers/gcc-4.6/sources.nix b/pkgs/development/compilers/gcc-4.6/sources.nix new file mode 100644 index 00000000000..6059e03880b --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/sources.nix @@ -0,0 +1,26 @@ +/* Automatically generated by `update-gcc.sh', do not edit. + For GCC 4.5.1. */ +{ fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }: + +assert version == "4.5.1"; +optional /* langC */ true (fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2"; + sha256 = "0sjjw3qfcpdk0fs5d2rhl0xqcaclg86ifbq45dbk9ca072l3fyxm"; +}) ++ +optional langCC (fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2"; + sha256 = "0j6ffb96b3r75hrjshg52llv21ax7r8jdx44hhj0maiisnl9wd55"; +}) ++ +optional langFortran (fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2"; + sha256 = "0xgwjc3h5fc5c100bnw24c35255il33lj5qbgpxf0zl8di2q13aw"; +}) ++ +optional langJava (fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2"; + sha256 = "0mh37q4ibg05h1hdh39pkj1hycvdg6i79m4698knw7pppm14ax8q"; +}) ++ +optional langAda (fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2"; + sha256 = "11chdbl7h046lnl83k79vj7dvgxz6kq7cnmwx94z644vaiflg153"; +}) ++ +[] diff --git a/pkgs/development/compilers/gcc-4.6/update-gcc.sh b/pkgs/development/compilers/gcc-4.6/update-gcc.sh new file mode 120000 index 00000000000..dd7bcd60c1b --- /dev/null +++ b/pkgs/development/compilers/gcc-4.6/update-gcc.sh @@ -0,0 +1 @@ +../gcc-4.4/update-gcc.sh \ No newline at end of file