git.iko.soy/typeable/nixpkgs
on master help sign in
Add gcc-5.1.0
commit90ebf5b952d4cb7042eb827fb554d379b6427402 authorShea Levy <shea@shealevy.com> dateThu 30 Apr 2015, 10:48 (12 years ago) parent0f3586e
8 files changed+930
pkgs/development/compilers/gcc/5.1/builder.sh+255 pkgs/development/compilers/gcc/5.1/default.nix+526 pkgs/development/compilers/gcc/5.1/gfortran-driving.patch+20 pkgs/development/compilers/gcc/5.1/gnat-cflags.patch+33 pkgs/development/compilers/gcc/5.1/java-jvgenmain-link.patch+17 pkgs/development/compilers/gcc/5.1/libstdc++-target.patch+32 pkgs/development/compilers/gcc/5.1/no-sys-dirs.patch+28 pkgs/top-level/all-packages.nix+19
pkgs/development/compilers/gcc/5.1/builder.shnew file+255
@@ -0,0 +1,255 @@
1+source $stdenv/setup
2+
3+
4+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
5+mkdir $NIX_FIXINC_DUMMY
6+
7+
8+if test "$staticCompiler" = "1"; then
9+ EXTRA_LDFLAGS="-static"
10+else
11+ EXTRA_LDFLAGS=""
12+fi
13+
14+# GCC interprets empty paths as ".", which we don't want.
15+if test -z "$CPATH"; then unset CPATH; fi
16+if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
17+echo "\$CPATH is \`$CPATH'"
18+echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'"
19+
20+if test "$noSysDirs" = "1"; then
21+
22+ if test -e $NIX_CC/nix-support/orig-libc; then
23+
24+ # Figure out what extra flags to pass to the gcc compilers
25+ # being generated to make sure that they use our glibc.
26+ extraFlags="$(cat $NIX_CC/nix-support/libc-cflags)"
27+ extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before)"
28+
29+ # Use *real* header files, otherwise a limits.h is generated
30+ # that does not include Glibc's limits.h (notably missing
31+ # SSIZE_MAX, which breaks the build).
32+ export NIX_FIXINC_DUMMY=$(cat $NIX_CC/nix-support/orig-libc)/include
33+
34+ # The path to the Glibc binaries such as `crti.o'.
35+ glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
36+
37+ else
38+ # Hack: support impure environments.
39+ extraFlags="-isystem /usr/include"
40+ extraLDFlags="-L/usr/lib64 -L/usr/lib"
41+ glibc_libdir="/usr/lib"
42+ export NIX_FIXINC_DUMMY=/usr/include
43+ fi
44+
45+ extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
46+ extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
47+
48+ # BOOT_CFLAGS defaults to `-g -O2'; since we override it below,
49+ # make sure to explictly add them so that files compiled with the
50+ # bootstrap compiler are optimized and (optionally) contain
51+ # debugging information (info "(gccinstall) Building").
52+ if test -n "$dontStrip"; then
53+ extraFlags="-O2 -g $extraFlags"
54+ else
55+ # Don't pass `-g' at all; this saves space while building.
56+ extraFlags="-O2 $extraFlags"
57+ fi
58+
59+ EXTRA_FLAGS="$extraFlags"
60+ for i in $extraLDFlags; do
61+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
62+ done
63+
64+ if test -n "$targetConfig"; then
65+ # Cross-compiling, we need gcc not to read ./specs in order to build
66+ # the g++ compiler (after the specs for the cross-gcc are created).
67+ # Having LIBRARY_PATH= makes gcc read the specs from ., and the build
68+ # breaks. Having this variable comes from the default.nix code to bring
69+ # gcj in.
70+ unset LIBRARY_PATH
71+ unset CPATH
72+ if test -z "$crossStageStatic"; then
73+ EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include"
74+ EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib -Wl,-rpath,${libcCross}/lib -Wl,-rpath-link,${libcCross}/lib"
75+ fi
76+ else
77+ if test -z "$NIX_CC_CROSS"; then
78+ EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
79+ EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS"
80+ EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
81+ else
82+ # This the case of cross-building the gcc.
83+ # We need special flags for the target, different than those of the build
84+ # Assertion:
85+ test -e $NIX_CC_CROSS/nix-support/orig-libc
86+
87+ # Figure out what extra flags to pass to the gcc compilers
88+ # being generated to make sure that they use our glibc.
89+ extraFlags="$(cat $NIX_CC_CROSS/nix-support/libc-cflags)"
90+ extraLDFlags="$(cat $NIX_CC_CROSS/nix-support/libc-ldflags) $(cat $NIX_CC_CROSS/nix-support/libc-ldflags-before)"
91+
92+ # Use *real* header files, otherwise a limits.h is generated
93+ # that does not include Glibc's limits.h (notably missing
94+ # SSIZE_MAX, which breaks the build).
95+ NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_CC_CROSS/nix-support/orig-libc)/include
96+
97+ # The path to the Glibc binaries such as `crti.o'.
98+ glibc_dir="$(cat $NIX_CC_CROSS/nix-support/orig-libc)"
99+ glibc_libdir="$glibc_dir/lib"
100+ configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include"
101+
102+ extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
103+ extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
104+
105+ EXTRA_TARGET_CFLAGS="$extraFlags"
106+ for i in $extraLDFlags; do
107+ EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i"
108+ done
109+ fi
110+ fi
111+
112+ # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
113+ # the startfiles.
114+ # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
115+ # for the startfiles.
116+ makeFlagsArray+=( \
117+ NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
118+ SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
119+ CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
120+ CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
121+ CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
122+ CXXFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
123+ FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
124+ LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
125+ LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \
126+ )
127+
128+ if test -z "$targetConfig"; then
129+ makeFlagsArray+=( \
130+ BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
131+ BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
132+ )
133+ fi
134+
135+ if test -n "$targetConfig" -a "$crossStageStatic" == 1; then
136+ # We don't want the gcc build to assume there will be a libc providing
137+ # limits.h in this stagae
138+ makeFlagsArray+=( \
139+ LIMITS_H_TEST=false \
140+ )
141+ else
142+ makeFlagsArray+=( \
143+ LIMITS_H_TEST=true \
144+ )
145+ fi
146+fi
147+
148+if test -n "$targetConfig"; then
149+ # The host strip will destroy some important details of the objects
150+ dontStrip=1
151+fi
152+
153+providedPreConfigure="$preConfigure";
154+preConfigure() {
155+ if test -n "$newlibSrc"; then
156+ tar xvf "$newlibSrc" -C ..
157+ ln -s ../newlib-*/newlib newlib
158+ # Patch to get armvt5el working:
159+ sed -i -e 's/ arm)/ arm*)/' newlib/configure.host
160+ fi
161+
162+ # Bug - they packaged zlib
163+ if test -d "zlib"; then
164+ # This breaks the build without-headers, which should build only
165+ # the target libgcc as target libraries.
166+ # See 'configure:5370'
167+ rm -Rf zlib
168+ fi
169+
170+ if test -f "$NIX_CC/nix-support/orig-libc"; then
171+ # Patch the configure script so it finds glibc headers. It's
172+ # important for example in order not to get libssp built,
173+ # because its functionality is in glibc already.
174+ glibc_headers="$(cat $NIX_CC/nix-support/orig-libc)/include"
175+ sed -i \
176+ -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
177+ gcc/configure
178+ fi
179+
180+ if test -n "$crossMingw" -a -n "$crossStageStatic"; then
181+ mkdir -p ../mingw
182+ # --with-build-sysroot expects that:
183+ cp -R $libcCross/include ../mingw
184+ configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
185+ fi
186+
187+ # Eval the preConfigure script from nix expression.
188+ eval "$providedPreConfigure"
189+
190+ # Perform the build in a different directory.
191+ mkdir ../build
192+ cd ../build
193+ configureScript=../$sourceRoot/configure
194+}
195+
196+
197+postConfigure() {
198+ # Don't store the configure flags in the resulting executables.
199+ sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
200+}
201+
202+
203+preInstall() {
204+ # Make ‘lib64’ a symlink to ‘lib’.
205+ if [ -n "$is64bit" -a -z "$enableMultilib" ]; then
206+ mkdir -p $out/lib
207+ ln -s lib $out/lib64
208+ fi
209+}
210+
211+
212+postInstall() {
213+ # Remove precompiled headers for now. They are very big and
214+ # probably not very useful yet.
215+ find $out/include -name "*.gch" -exec rm -rf {} \; -prune
216+
217+ # Remove `fixincl' to prevent a retained dependency on the
218+ # previous gcc.
219+ rm -rf $out/libexec/gcc/*/*/install-tools
220+ rm -rf $out/lib/gcc/*/*/install-tools
221+
222+ # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
223+ rm -rf $out/bin/gccbug
224+ # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
225+ for i in $out/libexec/gcc/*/*/*; do
226+ if PREV_RPATH=`patchelf --print-rpath $i`; then
227+ patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
228+ fi
229+ done
230+
231+ # Get rid of some "fixed" header files
232+ rm -rf $out/lib/gcc/*/*/include/root
233+
234+ # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
235+ for i in $out/bin/*-gcc*; do
236+ if cmp -s $out/bin/gcc $i; then
237+ ln -sfn gcc $i
238+ fi
239+ done
240+
241+ for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
242+ if cmp -s $out/bin/g++ $i; then
243+ ln -sfn g++ $i
244+ fi
245+ done
246+
247+ # Disable RANDMMAP on grsec, which causes segfaults when using
248+ # precompiled headers.
249+ # See https://bugs.gentoo.org/show_bug.cgi?id=301299#c31
250+ paxmark r $out/libexec/gcc/*/*/{cc1,cc1plus}
251+
252+ eval "$postInstallGhdl"
253+}
254+
255+genericBuild
pkgs/development/compilers/gcc/5.1/default.nixnew file+526
@@ -0,0 +1,526 @@
1+{ stdenv, fetchurl, noSysDirs
2+, langC ? true, langCC ? true, langFortran ? false
3+, langObjC ? stdenv.isDarwin
4+, langObjCpp ? stdenv.isDarwin
5+, langJava ? false
6+, langAda ? false
7+, langVhdl ? false
8+, langGo ? false
9+, profiledCompiler ? false
10+, staticCompiler ? false
11+, enableShared ? true
12+, texinfo ? null
13+, perl ? null # optional, for texi2pod (then pod2man); required for Java
14+, gmp, mpfr, libmpc, gettext, which
15+, libelf # optional, for link-time optimizations (LTO)
16+, isl ? null # optional, for the Graphite optimization framework.
17+, zlib ? null, boehmgc ? null
18+, zip ? null, unzip ? null, pkgconfig ? null
19+, gtk ? null, libart_lgpl ? null
20+, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
21+, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
22+, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
23+, x11Support ? langJava
24+, gnatboot ? null
25+, enableMultilib ? false
26+, enablePlugin ? true # whether to support user-supplied plug-ins
27+, name ? "gcc"
28+, cross ? null
29+, binutilsCross ? null
30+, libcCross ? null
31+, crossStageStatic ? true
32+, gnat ? null
33+, libpthread ? null, libpthreadCross ? null # required for GNU/Hurd
34+, stripped ? true
35+, gnused ? null
36+}:
37+
38+assert langJava -> zip != null && unzip != null
39+ && zlib != null && boehmgc != null
40+ && perl != null; # for `--enable-java-home'
41+assert langAda -> gnatboot != null;
42+assert langVhdl -> gnat != null;
43+
44+# LTO needs libelf and zlib.
45+assert libelf != null -> zlib != null;
46+
47+# Make sure we get GNU sed.
48+assert stdenv.isDarwin -> gnused != null;
49+
50+# The go frontend is written in c++
51+assert langGo -> langCC;
52+
53+with stdenv.lib;
54+with builtins;
55+
56+let version = "5.1.0";
57+
58+ # Whether building a cross-compiler for GNU/Hurd.
59+ crossGNU = cross != null && cross.config == "i586-pc-gnu";
60+
61+ enableParallelBuilding = true;
62+
63+ patches = [ ]
64+ ++ optional (cross != null) ./libstdc++-target.patch
65+ ++ optional noSysDirs ./no-sys-dirs.patch
66+ # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
67+ # target libraries and tools.
68+ ++ optional langAda ./gnat-cflags.patch
69+ ++ optional langFortran ./gfortran-driving.patch;
70+
71+ javaEcj = fetchurl {
72+ # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
73+ # `configure' time.
74+
75+ # XXX: Eventually we might want to take it from upstream.
76+ url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
77+ sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
78+ };
79+
80+ # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a
81+ # binary distribution here to allow the whole chain to be bootstrapped.
82+ javaAntlr = fetchurl {
83+ url = http://www.antlr.org/download/antlr-4.4-complete.jar;
84+ sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz";
85+ };
86+
87+ xlibs = [
88+ libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
89+ xproto renderproto xextproto inputproto randrproto
90+ ];
91+
92+ javaAwtGtk = langJava && x11Support;
93+
94+ /* Platform flags */
95+ platformFlags = let
96+ gccArch = stdenv.platform.gcc.arch or null;
97+ gccCpu = stdenv.platform.gcc.cpu or null;
98+ gccAbi = stdenv.platform.gcc.abi or null;
99+ gccFpu = stdenv.platform.gcc.fpu or null;
100+ gccFloat = stdenv.platform.gcc.float or null;
101+ gccMode = stdenv.platform.gcc.mode or null;
102+ withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
103+ withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
104+ withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
105+ withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
106+ withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
107+ withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
108+ in
109+ withArch +
110+ withCpu +
111+ withAbi +
112+ withFpu +
113+ withFloat +
114+ withMode;
115+
116+ /* Cross-gcc settings */
117+ crossMingw = cross != null && cross.libc == "msvcrt";
118+ crossDarwin = cross != null && cross.libc == "libSystem";
119+ crossConfigureFlags = let
120+ gccArch = stdenv.cross.gcc.arch or null;
121+ gccCpu = stdenv.cross.gcc.cpu or null;
122+ gccAbi = stdenv.cross.gcc.abi or null;
123+ gccFpu = stdenv.cross.gcc.fpu or null;
124+ gccFloat = stdenv.cross.gcc.float or null;
125+ gccMode = stdenv.cross.gcc.mode or null;
126+ withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
127+ withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
128+ withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
129+ withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
130+ withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
131+ withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
132+ in
133+ "--target=${cross.config}" +
134+ withArch +
135+ withCpu +
136+ withAbi +
137+ withFpu +
138+ withFloat +
139+ withMode +
140+ (if crossMingw && crossStageStatic then
141+ " --with-headers=${libcCross}/include" +
142+ " --with-gcc" +
143+ " --with-gnu-as" +
144+ " --with-gnu-ld" +
145+ " --with-gnu-ld" +
146+ " --disable-shared" +
147+ " --disable-nls" +
148+ " --disable-debug" +
149+ " --enable-sjlj-exceptions" +
150+ " --enable-threads=win32" +
151+ " --disable-win32-registry"
152+ else if crossStageStatic then
153+ " --disable-libssp --disable-nls" +
154+ " --without-headers" +
155+ " --disable-threads " +
156+ " --disable-libmudflap " +
157+ " --disable-libgomp " +
158+ " --disable-libquadmath" +
159+ " --disable-shared" +
160+ " --disable-libatomic " + # libatomic requires libc
161+ " --disable-decimal-float" # libdecnumber requires libc
162+ else
163+ (if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
164+ else " --with-headers=${libcCross}/include") +
165+ # Ensure that -print-prog-name is able to find the correct programs.
166+ (stdenv.lib.optionalString (crossMingw || crossDarwin) (
167+ " --with-as=${binutilsCross}/bin/${cross.config}-as" +
168+ " --with-ld=${binutilsCross}/bin/${cross.config}-ld"
169+ )) +
170+ " --enable-__cxa_atexit" +
171+ " --enable-long-long" +
172+ (if crossMingw then
173+ " --enable-threads=win32" +
174+ " --enable-sjlj-exceptions" +
175+ " --enable-hash-synchronization" +
176+ " --disable-libssp" +
177+ " --disable-nls" +
178+ " --with-dwarf2" +
179+ # I think noone uses shared gcc libs in mingw, so we better do the same.
180+ # In any case, mingw32 g++ linking is broken by default with shared libs,
181+ # unless adding "-lsupc++" to any linking command. I don't know why.
182+ " --disable-shared" +
183+ # To keep ABI compatibility with upstream mingw-w64
184+ " --enable-fully-dynamic-string"
185+ else (if cross.libc == "uclibc" then
186+ # In uclibc cases, libgomp needs an additional '-ldl'
187+ # and as I don't know how to pass it, I disable libgomp.
188+ " --disable-libgomp" else "") +
189+ " --enable-threads=posix" +
190+ " --enable-nls" +
191+ " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
192+ );
193+ stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
194+ crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
195+
196+ bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
197+
198+in
199+
200+# We need all these X libraries when building AWT with GTK+.
201+assert x11Support -> (filter (x: x == null) ([ gtk libart_lgpl ] ++ xlibs)) == [];
202+
203+stdenv.mkDerivation ({
204+ name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
205+
206+ builder = ./builder.sh;
207+
208+ src = fetchurl {
209+ url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
210+ sha256 = "1bd5vj4px3s8nlakbgrh38ynxq4s654m6nxz7lrj03mvkkwgvnmp";
211+ };
212+
213+ inherit patches;
214+
215+ postPatch =
216+ if (stdenv.isGNU
217+ || (libcCross != null # e.g., building `gcc.crossDrv'
218+ && libcCross ? crossConfig
219+ && libcCross.crossConfig == "i586-pc-gnu")
220+ || (crossGNU && libcCross != null))
221+ then
222+ # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
223+ # in glibc, so add the right `-I' flags to the default spec string.
224+ assert libcCross != null -> libpthreadCross != null;
225+ let
226+ libc = if libcCross != null then libcCross else stdenv.glibc;
227+ gnu_h = "gcc/config/gnu.h";
228+ extraCPPDeps =
229+ libc.propagatedBuildInputs
230+ ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
231+ ++ stdenv.lib.optional (libpthread != null) libpthread;
232+ extraCPPSpec =
233+ concatStrings (intersperse " "
234+ (map (x: "-I${x}/include") extraCPPDeps));
235+ extraLibSpec =
236+ if libpthreadCross != null
237+ then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
238+ else "-L${libpthread}/lib";
239+ in
240+ '' echo "augmenting \`CPP_SPEC' in \`${gnu_h}' with \`${extraCPPSpec}'..."
241+ sed -i "${gnu_h}" \
242+ -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
243+
244+ echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
245+ sed -i "${gnu_h}" \
246+ -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
247+
248+ echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
249+ sed -i "${gnu_h}" \
250+ -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
251+ ''
252+ else if cross != null || stdenv.cc.libc != null then
253+ # On NixOS, use the right path to the dynamic linker instead of
254+ # `/lib/ld*.so'.
255+ let
256+ libc = if libcCross != null then libcCross else stdenv.cc.libc;
257+ in
258+ '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
259+ for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
260+ do
261+ grep -q LIBC_DYNAMIC_LINKER "$header" || continue
262+ echo " fixing \`$header'..."
263+ sed -i "$header" \
264+ -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
265+ done
266+ ''
267+ else null;
268+
269+ inherit noSysDirs staticCompiler langJava crossStageStatic
270+ libcCross crossMingw;
271+
272+ nativeBuildInputs = [ texinfo which gettext ]
273+ ++ (optional (perl != null) perl)
274+ ++ (optional javaAwtGtk pkgconfig);
275+
276+ buildInputs = [ gmp mpfr libmpc libelf ]
277+ ++ (optional (isl != null) isl)
278+ ++ (optional (zlib != null) zlib)
279+ ++ (optionals langJava [ boehmgc zip unzip ])
280+ ++ (optionals javaAwtGtk ([ gtk libart_lgpl ] ++ xlibs))
281+ ++ (optionals (cross != null) [binutilsCross])
282+ ++ (optionals langAda [gnatboot])
283+ ++ (optionals langVhdl [gnat])
284+
285+ # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
286+ # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
287+ ++ (optional stdenv.isDarwin gnused)
288+ ;
289+
290+ NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-lm -ldl";
291+
292+ preConfigure = stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) ''
293+ export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
294+ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
295+ export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
296+ export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
297+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
298+ if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then
299+ configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include)
300+ makeFlagsArray+=( \
301+ CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \
302+ CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
303+ FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \
304+ )
305+ fi
306+ '';
307+
308+ dontDisableStatic = true;
309+
310+ configureFlags = "
311+ ${if stdenv.isSunOS then
312+ " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
313+ # On Illumos/Solaris GNU as is preferred
314+ " --with-gnu-as --without-gnu-ld "
315+ else ""}
316+ --enable-lto
317+ ${if enableMultilib then "--disable-libquadmath" else "--disable-multilib"}
318+ ${if enableShared then "" else "--disable-shared"}
319+ ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
320+ ${optionalString (isl != null) "--with-isl=${isl}"}
321+ ${if langJava then
322+ "--with-ecj-jar=${javaEcj} " +
323+
324+ # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
325+ # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
326+ "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
327+ else ""}
328+ ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
329+ ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""}
330+ --with-gmp=${gmp}
331+ --with-mpfr=${mpfr}
332+ --with-mpc=${libmpc}
333+ ${if libelf != null then "--with-libelf=${libelf}" else ""}
334+ --disable-libstdcxx-pch
335+ --without-included-gettext
336+ --with-system-zlib
337+ --enable-static
338+ --enable-languages=${
339+ concatStrings (intersperse ","
340+ ( optional langC "c"
341+ ++ optional langCC "c++"
342+ ++ optional langFortran "fortran"
343+ ++ optional langJava "java"
344+ ++ optional langAda "ada"
345+ ++ optional langVhdl "vhdl"
346+ ++ optional langGo "go"
347+ ++ optional langObjC "objc"
348+ ++ optional langObjCpp "obj-c++"
349+ ++ optionals crossDarwin [ "objc" "obj-c++" ]
350+ )
351+ )
352+ }
353+ ${if (stdenv ? glibc && cross == null)
354+ then " --with-native-system-header-dir=${stdenv.glibc}/include"
355+ else ""}
356+ ${if langAda then " --enable-libada" else ""}
357+ ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
358+ ${if cross != null then crossConfigureFlags else ""}
359+ ${if !bootstrap then "--disable-bootstrap" else ""}
360+ ${if cross == null then platformFlags else ""}
361+ ";
362+
363+ targetConfig = if cross != null then cross.config else null;
364+
365+ buildFlags = if bootstrap then
366+ (if profiledCompiler then "profiledbootstrap" else "bootstrap")
367+ else "";
368+
369+ installTargets =
370+ if stripped
371+ then "install-strip"
372+ else "install";
373+
374+ crossAttrs = let
375+ xgccArch = stdenv.cross.gcc.arch or null;
376+ xgccCpu = stdenv.cross.gcc.cpu or null;
377+ xgccAbi = stdenv.cross.gcc.abi or null;
378+ xgccFpu = stdenv.cross.gcc.fpu or null;
379+ xgccFloat = stdenv.cross.gcc.float or null;
380+ xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
381+ xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
382+ xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
383+ xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
384+ xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
385+ in {
386+ AR = "${stdenv.cross.config}-ar";
387+ LD = "${stdenv.cross.config}-ld";
388+ CC = "${stdenv.cross.config}-gcc";
389+ CXX = "${stdenv.cross.config}-gcc";
390+ AR_FOR_TARGET = "${stdenv.cross.config}-ar";
391+ LD_FOR_TARGET = "${stdenv.cross.config}-ld";
392+ CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
393+ NM_FOR_TARGET = "${stdenv.cross.config}-nm";
394+ CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
395+ # If we are making a cross compiler, cross != null
396+ NIX_CC_CROSS = if cross == null then "${stdenv.ccCross}" else "";
397+ dontStrip = true;
398+ configureFlags = ''
399+ ${if enableMultilib then "" else "--disable-multilib"}
400+ ${if enableShared then "" else "--disable-shared"}
401+ ${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""}
402+ ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
403+ ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""}
404+ --with-gmp=${gmp.crossDrv}
405+ --with-mpfr=${mpfr.crossDrv}
406+ --disable-libstdcxx-pch
407+ --without-included-gettext
408+ --with-system-zlib
409+ --enable-languages=${
410+ concatStrings (intersperse ","
411+ ( optional langC "c"
412+ ++ optional langCC "c++"
413+ ++ optional langFortran "fortran"
414+ ++ optional langJava "java"
415+ ++ optional langAda "ada"
416+ ++ optional langVhdl "vhdl"
417+ ++ optional langGo "go"
418+ )
419+ )
420+ }
421+ ${if langAda then " --enable-libada" else ""}
422+ --target=${stdenv.cross.config}
423+ ${xwithArch}
424+ ${xwithCpu}
425+ ${xwithAbi}
426+ ${xwithFpu}
427+ ${xwithFloat}
428+ '';
429+ buildFlags = "";
430+ };
431+
432+
433+ # Needed for the cross compilation to work
434+ AR = "ar";
435+ LD = "ld";
436+ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
437+ CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
438+
439+ # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
440+ # the library headers and binaries, regarless of the language being
441+ # compiled.
442+
443+ # Note: When building the Java AWT GTK+ peer, the build system doesn't
444+ # honor `--with-gmp' et al., e.g., when building
445+ # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
446+ # add them to $CPATH and $LIBRARY_PATH in this case.
447+ #
448+ # Likewise, the LTO code doesn't find zlib.
449+
450+ CPATH = concatStrings
451+ (intersperse ":" (map (x: x + "/include")
452+ (optionals (zlib != null) [ zlib ]
453+ ++ optionals langJava [ boehmgc ]
454+ ++ optionals javaAwtGtk xlibs
455+ ++ optionals javaAwtGtk [ gmp mpfr ]
456+ ++ optional (libpthread != null) libpthread
457+ ++ optional (libpthreadCross != null) libpthreadCross
458+
459+ # On GNU/Hurd glibc refers to Mach & Hurd
460+ # headers.
461+ ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" )
462+ libcCross.propagatedBuildInputs)));
463+
464+ LIBRARY_PATH = concatStrings
465+ (intersperse ":" (map (x: x + "/lib")
466+ (optionals (zlib != null) [ zlib ]
467+ ++ optionals langJava [ boehmgc ]
468+ ++ optionals javaAwtGtk xlibs
469+ ++ optionals javaAwtGtk [ gmp mpfr ]
470+ ++ optional (libpthread != null) libpthread)));
471+
472+ EXTRA_TARGET_CFLAGS =
473+ if cross != null && libcCross != null
474+ then "-idirafter ${libcCross}/include"
475+ else null;
476+
477+ EXTRA_TARGET_LDFLAGS =
478+ if cross != null && libcCross != null
479+ then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
480+ (optionalString (libpthreadCross != null)
481+ " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
482+ else null;
483+
484+ passthru =
485+ { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
486+
487+ inherit enableParallelBuilding enableMultilib;
488+
489+ inherit (stdenv) is64bit;
490+
491+ meta = {
492+ homepage = http://gcc.gnu.org/;
493+ license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+
494+ description = "GNU Compiler Collection, version ${version}"
495+ + (if stripped then "" else " (with debugging info)");
496+
497+ longDescription = ''
498+ The GNU Compiler Collection includes compiler front ends for C, C++,
499+ Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
500+ as libraries for these languages (libstdc++, libgcj, libgomp,...).
501+
502+ GCC development is a part of the GNU Project, aiming to improve the
503+ compiler used in the GNU system including the GNU/Linux variant.
504+ '';
505+
506+ maintainers = with stdenv.lib.maintainers; [ viric shlevy simons ];
507+
508+ # gnatboot is not available out of linux platforms, so we disable the darwin build
509+ # for the gnat (ada compiler).
510+ platforms =
511+ stdenv.lib.platforms.linux ++
512+ stdenv.lib.platforms.freebsd ++
513+ optionals (langAda == false) stdenv.lib.platforms.darwin;
514+ };
515+}
516+
517+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
518+ makeFlags = [ "all-gcc" "all-target-libgcc" ];
519+ installTargets = "install-gcc install-target-libgcc";
520+}
521+
522+# Strip kills static libs of other archs (hence cross != null)
523+// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
524+
525+// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
526+)
pkgs/development/compilers/gcc/5.1/gfortran-driving.patchnew file+20
@@ -0,0 +1,20 @@
1+This patch fixes interaction with Libtool.
2+See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details.
3+
4+--- a/gcc/fortran/gfortranspec.c
5++++ b/gcc/fortran/gfortranspec.c
6+@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n"));
7+ {
8+ fprintf (stderr, _("Driving:"));
9+ for (i = 0; i < g77_newargc; i++)
10++ {
11++ if (g77_new_decoded_options[i].opt_index == OPT_l)
12++ /* Make sure no white space is inserted after `-l'. */
13++ fprintf (stderr, " -l%s",
14++ g77_new_decoded_options[i].canonical_option[1]);
15++ else
16+ fprintf (stderr, " %s",
17+ g77_new_decoded_options[i].orig_option_with_args_text);
18++ }
19+ fprintf (stderr, "\n");
20+ }
pkgs/development/compilers/gcc/5.1/gnat-cflags.patchnew file+33
@@ -0,0 +1,33 @@
1+diff --git a/libada/Makefile.in b/libada/Makefile.in
2+index f5057a0..337e0c6 100644
3+--- a/libada/Makefile.in
4++++ b/libada/Makefile.in
5+@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
6+ WARN_CFLAGS = @warn_cflags@
7+
8+ TARGET_LIBGCC2_CFLAGS=
9+-GNATLIBCFLAGS= -g -O2
10++GNATLIBCFLAGS= -g -O2 $(CFLAGS)
11+ GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
12+ -DIN_RTS @have_getipinfo@
13+
14+--- a/gcc/ada/gcc-interface/Makefile.in
15++++ b/gcc/ada/gcc-interface/Makefile.in
16+@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
17+ SOME_ADAFLAGS =-gnata
18+ FORCE_DEBUG_ADAFLAGS = -g
19+ GNATLIBFLAGS = -gnatpg -nostdinc
20+-GNATLIBCFLAGS = -g -O2
21++GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
22+ # Pretend that _Unwind_GetIPInfo is available for the target by default. This
23+ # should be autodetected during the configuration of libada and passed down to
24+ # here, but we need something for --disable-libada and hope for the best.
25+@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
26+ # Link flags used to build gnat tools. By default we prefer to statically
27+ # link with libgcc to avoid a dependency on shared libgcc (which is tricky
28+ # to deal with as it may conflict with the libgcc provided by the system).
29+-GCC_LINK_FLAGS=-static-libgcc
30++GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
31+
32+ # End of variables for you to override.
33+
pkgs/development/compilers/gcc/5.1/java-jvgenmain-link.patchnew file+17
@@ -0,0 +1,17 @@
1+The `jvgenmain' executable must be linked against `vec.o', among others,
2+since it uses its vector API.
3+
4+--- gcc-4.3.3/gcc/java/Make-lang.in 2008-12-05 00:00:19.000000000 +0100
5++++ gcc-4.3.3/gcc/java/Make-lang.in 2009-07-03 16:11:41.000000000 +0200
6+@@ -109,9 +109,9 @@ jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIB
7+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
8+ $(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS)
9+
10+-jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS)
11++jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) $(BUILD_RTL)
12+ rm -f $@
13+- $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(LIBS)
14++ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(BUILD_RTL) $(LIBS)
15+
16+ #
17+ # Build hooks:
pkgs/development/compilers/gcc/5.1/libstdc++-target.patchnew file+32
@@ -0,0 +1,32 @@
1+Patch to make the target libraries 'configure' scripts find the proper CPP.
2+I noticed that building the mingw32 cross compiler.
3+Looking at the build script for mingw in archlinux, I think that only nixos
4+needs this patch. I don't know why.
5+diff --git a/Makefile.in b/Makefile.in
6+index 93f66b6..d691917 100644
7+--- a/Makefile.in
8++++ b/Makefile.in
9+@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
10+ AR="$(AR_FOR_TARGET)"; export AR; \
11+ AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
12+ CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
13++ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
14+ CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
15+ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
16+ CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
17+@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
18+ RAW_CXX_TARGET_EXPORTS = \
19+ $(BASE_TARGET_EXPORTS) \
20+ CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
21+- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
22++ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
23++ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
24+
25+ NORMAL_TARGET_EXPORTS = \
26+ $(BASE_TARGET_EXPORTS) \
27+- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
28++ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
29++ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
30+
31+ # Where to find GMP
32+ HOST_GMPLIBS = @gmplibs@
pkgs/development/compilers/gcc/5.1/no-sys-dirs.patchnew file+28
@@ -0,0 +1,28 @@
1+diff -ru -x '*~' gcc-4.8.3-orig/gcc/cppdefault.c gcc-4.8.3/gcc/cppdefault.c
2+--- gcc-4.8.3-orig/gcc/cppdefault.c 2013-01-10 21:38:27.000000000 +0100
3++++ gcc-4.8.3/gcc/cppdefault.c 2014-08-18 16:20:32.893944536 +0200
4+@@ -35,6 +35,8 @@
5+ # undef CROSS_INCLUDE_DIR
6+ #endif
7+
8++#undef LOCAL_INCLUDE_DIR
9++
10+ const struct default_include cpp_include_defaults[]
11+ #ifdef INCLUDE_DEFAULTS
12+ = INCLUDE_DEFAULTS;
13+diff -ru -x '*~' gcc-4.8.3-orig/gcc/gcc.c gcc-4.8.3/gcc/gcc.c
14+--- gcc-4.8.3-orig/gcc/gcc.c 2014-03-23 12:30:57.000000000 +0100
15++++ gcc-4.8.3/gcc/gcc.c 2014-08-18 13:19:32.689201690 +0200
16+@@ -1162,10 +1162,10 @@
17+ /* Default prefixes to attach to command names. */
18+
19+ #ifndef STANDARD_STARTFILE_PREFIX_1
20+-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
21++#define STANDARD_STARTFILE_PREFIX_1 ""
22+ #endif
23+ #ifndef STANDARD_STARTFILE_PREFIX_2
24+-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
25++#define STANDARD_STARTFILE_PREFIX_2 ""
26+ #endif
27+
28+ #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */
pkgs/top-level/all-packages.nix+19
@@ -3618,6 +3618,25 @@ let
36183618 else null;
36193619 }));
36203620
3621+ gcc51 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/5.1 {
3622+ inherit noSysDirs;
3623+
3624+ # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
3625+ profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
3626+
3627+ # When building `gcc.crossDrv' (a "Canadian cross", with host == target
3628+ # and host != build), `cross' must be null but the cross-libc must still
3629+ # be passed.
3630+ cross = null;
3631+ libcCross = if crossSystem != null then libcCross else null;
3632+ libpthreadCross =
3633+ if crossSystem != null && crossSystem.config == "i586-pc-gnu"
3634+ then gnu.libpthreadCross
3635+ else null;
3636+
3637+ isl = isl_0_14;
3638+ }));
3639+
36213640 gfortran = gfortran48;
36223641
36233642 gfortran48 = wrapCC (gcc48.cc.override {