@@ -0,0 +1,551 @@
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+, gtk2 ? 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+, libcCross ? null
30+, crossStageStatic ? true
31+, gnat ? null
32+, libpthread ? null, libpthreadCross ? null # required for GNU/Hurd
33+, stripped ? true
34+, gnused ? null
35+, binutils ? null
36+, cloog # unused; just for compat with gcc4, as we override the parameter on some places
37+, darwin ? null
38+, flex ? null
39+, buildPlatform, hostPlatform, targetPlatform
40+}:
41+
42+assert langJava -> zip != null && unzip != null
43+ && zlib != null && boehmgc != null
44+ && perl != null; # for `--enable-java-home'
45+assert langAda -> gnatboot != null;
46+assert langVhdl -> gnat != null;
47+
48+# LTO needs libelf and zlib.
49+assert libelf != null -> zlib != null;
50+
51+# Make sure we get GNU sed.
52+assert stdenv.isDarwin -> gnused != null;
53+
54+# Need c++filt on darwin
55+assert stdenv.isDarwin -> binutils != null;
56+
57+# The go frontend is written in c++
58+assert langGo -> langCC;
59+
60+with stdenv.lib;
61+with builtins;
62+
63+let version = "7.1.0";
64+
65+ # Whether building a cross-compiler for GNU/Hurd.
66+ crossGNU = cross != null && cross.config == "i586-pc-gnu";
67+
68+ enableParallelBuilding = true;
69+
70+ patches =
71+ [ ]
72+ ++ optional (cross != null) ../libstdc++-target.patch
73+ ++ optional noSysDirs ../no-sys-dirs.patch
74+ # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
75+ # target libraries and tools.
76+ ++ optional langAda ../gnat-cflags.patch
77+ ++ optional langFortran ../gfortran-driving.patch;
78+
79+ javaEcj = fetchurl {
80+ # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
81+ # `configure' time.
82+
83+ # XXX: Eventually we might want to take it from upstream.
84+ url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
85+ sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
86+ };
87+
88+ # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a
89+ # binary distribution here to allow the whole chain to be bootstrapped.
90+ javaAntlr = fetchurl {
91+ url = http://www.antlr.org/download/antlr-4.4-complete.jar;
92+ sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz";
93+ };
94+
95+ xlibs = [
96+ libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
97+ xproto renderproto xextproto inputproto randrproto
98+ ];
99+
100+ javaAwtGtk = langJava && x11Support;
101+
102+ /* Platform flags */
103+ platformFlags = let
104+ gccArch = stdenv.platform.gcc.arch or null;
105+ gccCpu = stdenv.platform.gcc.cpu or null;
106+ gccAbi = stdenv.platform.gcc.abi or null;
107+ gccFpu = stdenv.platform.gcc.fpu or null;
108+ gccFloat = stdenv.platform.gcc.float or null;
109+ gccMode = stdenv.platform.gcc.mode or null;
110+ withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
111+ withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
112+ withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
113+ withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
114+ withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
115+ withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
116+ in
117+ withArch +
118+ withCpu +
119+ withAbi +
120+ withFpu +
121+ withFloat +
122+ withMode;
123+
124+ /* Cross-gcc settings */
125+ crossMingw = cross != null && cross.libc == "msvcrt";
126+ crossDarwin = cross != null && cross.libc == "libSystem";
127+ crossConfigureFlags = let
128+ gccArch = targetPlatform.gcc.arch or null;
129+ gccCpu = targetPlatform.gcc.cpu or null;
130+ gccAbi = targetPlatform.gcc.abi or null;
131+ gccFpu = targetPlatform.gcc.fpu or null;
132+ gccFloat = targetPlatform.gcc.float or null;
133+ gccMode = targetPlatform.gcc.mode or null;
134+ withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
135+ withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
136+ withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
137+ withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
138+ withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
139+ withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
140+ in
141+ "--target=${cross.config}" +
142+ withArch +
143+ withCpu +
144+ withAbi +
145+ withFpu +
146+ withFloat +
147+ withMode +
148+ # Ensure that -print-prog-name is able to find the correct programs.
149+ " --with-as=${binutils}/bin/${cross.config}-as" +
150+ " --with-ld=${binutils}/bin/${cross.config}-ld" +
151+ (if crossMingw && crossStageStatic then
152+ " --with-headers=${libcCross}/include" +
153+ " --with-gcc" +
154+ " --with-gnu-as" +
155+ " --with-gnu-ld" +
156+ " --with-gnu-ld" +
157+ " --disable-shared" +
158+ " --disable-nls" +
159+ " --disable-debug" +
160+ " --enable-sjlj-exceptions" +
161+ " --enable-threads=win32" +
162+ " --disable-win32-registry"
163+ else if crossStageStatic then
164+ " --disable-libssp --disable-nls" +
165+ " --without-headers" +
166+ " --disable-threads " +
167+ " --disable-libgomp " +
168+ " --disable-libquadmath" +
169+ " --disable-shared" +
170+ " --disable-libatomic " + # libatomic requires libc
171+ " --disable-decimal-float" # libdecnumber requires libc
172+ else
173+ (if crossDarwin then " --with-sysroot=${getLib libcCross}/share/sysroot"
174+ else " --with-headers=${getDev libcCross}/include") +
175+ # Ensure that -print-prog-name is able to find the correct programs.
176+ " --enable-__cxa_atexit" +
177+ " --enable-long-long" +
178+ (if crossMingw then
179+ " --enable-threads=win32" +
180+ " --enable-sjlj-exceptions" +
181+ " --enable-hash-synchronization" +
182+ " --disable-libssp" +
183+ " --disable-nls" +
184+ " --with-dwarf2" +
185+ # I think noone uses shared gcc libs in mingw, so we better do the same.
186+ # In any case, mingw32 g++ linking is broken by default with shared libs,
187+ # unless adding "-lsupc++" to any linking command. I don't know why.
188+ " --disable-shared" +
189+ # To keep ABI compatibility with upstream mingw-w64
190+ " --enable-fully-dynamic-string"
191+ else (if cross.libc == "uclibc" then
192+ # libsanitizer requires netrom/netrom.h which is not
193+ # available in uclibc.
194+ " --disable-libsanitizer" +
195+ # In uclibc cases, libgomp needs an additional '-ldl'
196+ # and as I don't know how to pass it, I disable libgomp.
197+ " --disable-libgomp" else "") +
198+ " --enable-threads=posix" +
199+ " --enable-nls" +
200+ " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
201+ );
202+ stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
203+ crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
204+
205+ bootstrap = cross == null;
206+
207+in
208+
209+# We need all these X libraries when building AWT with GTK+.
210+assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == [];
211+
212+stdenv.mkDerivation ({
213+ name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
214+
215+ builder = ../builder.sh;
216+
217+ src = fetchurl {
218+ url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.bz2";
219+ sha256 = "05xwps0ci7wgxh50askpa2r9p8518qxdgh6ad7pnyk7n6p13d0ca";
220+ };
221+
222+ inherit patches;
223+
224+ outputs = [ "out" "lib" "man" "info" ];
225+ setOutputFlags = false;
226+ NIX_NO_SELF_RPATH = true;
227+
228+ libc_dev = stdenv.cc.libc_dev;
229+
230+ hardeningDisable = [ "format" ];
231+
232+ postPatch =
233+ if (stdenv.isHurd
234+ || (libcCross != null # e.g., building `gcc.crossDrv'
235+ && libcCross ? crossConfig
236+ && libcCross.crossConfig == "i586-pc-gnu")
237+ || (crossGNU && libcCross != null))
238+ then
239+ # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
240+ # in glibc, so add the right `-I' flags to the default spec string.
241+ assert libcCross != null -> libpthreadCross != null;
242+ let
243+ libc = if libcCross != null then libcCross else stdenv.glibc;
244+ gnu_h = "gcc/config/gnu.h";
245+ extraCPPDeps =
246+ libc.propagatedBuildInputs
247+ ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
248+ ++ stdenv.lib.optional (libpthread != null) libpthread;
249+ extraCPPSpec =
250+ concatStrings (intersperse " "
251+ (map (x: "-I${x.dev or x}/include") extraCPPDeps));
252+ extraLibSpec =
253+ if libpthreadCross != null
254+ then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
255+ else "-L${libpthread}/lib";
256+ in
257+ '' echo "augmenting \`CPP_SPEC' in \`${gnu_h}' with \`${extraCPPSpec}'..."
258+ sed -i "${gnu_h}" \
259+ -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
260+
261+ echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
262+ sed -i "${gnu_h}" \
263+ -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
264+
265+ echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..."
266+ sed -i "${gnu_h}" \
267+ -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
268+ ''
269+ else if cross != null || stdenv.cc.libc != null then
270+ # On NixOS, use the right path to the dynamic linker instead of
271+ # `/lib/ld*.so'.
272+ let
273+ libc = if libcCross != null then libcCross else stdenv.cc.libc;
274+ in
275+ '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
276+ for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
277+ do
278+ grep -q LIBC_DYNAMIC_LINKER "$header" || continue
279+ echo " fixing \`$header'..."
280+ sed -i "$header" \
281+ -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'
282+ done
283+ ''
284+ else null;
285+
286+ inherit noSysDirs staticCompiler langJava crossStageStatic
287+ libcCross crossMingw;
288+
289+ nativeBuildInputs = [ texinfo which gettext ]
290+ ++ (optional (perl != null) perl)
291+ ++ (optional javaAwtGtk pkgconfig);
292+
293+ buildInputs = [ gmp mpfr libmpc libelf flex ]
294+ ++ (optional (isl != null) isl)
295+ ++ (optional (zlib != null) zlib)
296+ ++ (optionals langJava [ boehmgc zip unzip ])
297+ ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
298+ ++ (optionals (cross != null) [binutils])
299+ ++ (optionals langAda [gnatboot])
300+ ++ (optionals langVhdl [gnat])
301+
302+ # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
303+ # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
304+ ++ (optional stdenv.isDarwin gnused)
305+ ++ (optional stdenv.isDarwin binutils)
306+ ;
307+
308+ NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-lm -ldl";
309+
310+ preConfigure = stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) ''
311+ export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
312+ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
313+ export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
314+ export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
315+ '';
316+
317+ dontDisableStatic = true;
318+
319+ configureFlags = "
320+ ${if stdenv.isSunOS then
321+ " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
322+ # On Illumos/Solaris GNU as is preferred
323+ " --with-gnu-as --without-gnu-ld "
324+ else ""}
325+ --enable-lto
326+ ${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"}
327+ ${if enableShared then "" else "--disable-shared"}
328+ ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
329+ ${optionalString (isl != null) "--with-isl=${isl}"}
330+ ${if langJava then
331+ "--with-ecj-jar=${javaEcj} " +
332+
333+ # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
334+ # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
335+ "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
336+ else ""}
337+ ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
338+ ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""}
339+ --with-gmp-include=${gmp.dev}/include
340+ --with-gmp-lib=${gmp.out}/lib
341+ --with-mpfr-include=${mpfr.dev}/include
342+ --with-mpfr-lib=${mpfr.out}/lib
343+ --with-mpc=${libmpc}
344+ ${if libelf != null then "--with-libelf=${libelf}" else ""}
345+ --disable-libstdcxx-pch
346+ --without-included-gettext
347+ --with-system-zlib
348+ --enable-static
349+ --enable-languages=${
350+ concatStrings (intersperse ","
351+ ( optional langC "c"
352+ ++ optional langCC "c++"
353+ ++ optional langFortran "fortran"
354+ ++ optional langJava "java"
355+ ++ optional langAda "ada"
356+ ++ optional langVhdl "vhdl"
357+ ++ optional langGo "go"
358+ ++ optional langObjC "objc"
359+ ++ optional langObjCpp "obj-c++"
360+ ++ optionals crossDarwin [ "objc" "obj-c++" ]
361+ )
362+ )
363+ }
364+ ${if cross == null
365+ then if stdenv.isDarwin
366+ then " --with-native-system-header-dir=${darwin.usr-include}"
367+ else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
368+ else ""}
369+ ${if langAda then " --enable-libada" else ""}
370+ ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
371+ ${if cross != null then crossConfigureFlags else ""}
372+ ${if !bootstrap then "--disable-bootstrap" else ""}
373+ ${if cross == null then platformFlags else ""}
374+ ";
375+
376+ targetConfig = if cross != null then cross.config else null;
377+
378+ buildFlags = if bootstrap then
379+ (if profiledCompiler then "profiledbootstrap" else "bootstrap")
380+ else "";
381+
382+ installTargets =
383+ if stripped
384+ then "install-strip"
385+ else "install";
386+
387+ crossAttrs = let
388+ xgccArch = targetPlatform.gcc.arch or null;
389+ xgccCpu = targetPlatform.gcc.cpu or null;
390+ xgccAbi = targetPlatform.gcc.abi or null;
391+ xgccFpu = targetPlatform.gcc.fpu or null;
392+ xgccFloat = targetPlatform.gcc.float or null;
393+ xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
394+ xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
395+ xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
396+ xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
397+ xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
398+ in {
399+ AR = "${targetPlatform.config}-ar";
400+ LD = "${targetPlatform.config}-ld";
401+ CC = "${targetPlatform.config}-gcc";
402+ CXX = "${targetPlatform.config}-gcc";
403+ AR_FOR_TARGET = "${targetPlatform.config}-ar";
404+ LD_FOR_TARGET = "${targetPlatform.config}-ld";
405+ CC_FOR_TARGET = "${targetPlatform.config}-gcc";
406+ NM_FOR_TARGET = "${targetPlatform.config}-nm";
407+ CXX_FOR_TARGET = "${targetPlatform.config}-g++";
408+ # If we are making a cross compiler, cross != null
409+ NIX_CC_CROSS = if cross == null then "${stdenv.ccCross}" else "";
410+ dontStrip = true;
411+ configureFlags = ''
412+ ${if enableMultilib then "" else "--disable-multilib"}
413+ ${if enableShared then "" else "--disable-shared"}
414+ ${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""}
415+ ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
416+ ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""}
417+ --with-gmp=${gmp.crossDrv}
418+ --with-mpfr=${mpfr.crossDrv}
419+ --with-mpc=${libmpc.crossDrv}
420+ --disable-libstdcxx-pch
421+ --without-included-gettext
422+ --with-system-zlib
423+ --enable-languages=${
424+ concatStrings (intersperse ","
425+ ( optional langC "c"
426+ ++ optional langCC "c++"
427+ ++ optional langFortran "fortran"
428+ ++ optional langJava "java"
429+ ++ optional langAda "ada"
430+ ++ optional langVhdl "vhdl"
431+ ++ optional langGo "go"
432+ )
433+ )
434+ }
435+ ${if langAda then " --enable-libada" else ""}
436+ --target=${targetPlatform.config}
437+ ${xwithArch}
438+ ${xwithCpu}
439+ ${xwithAbi}
440+ ${xwithFpu}
441+ ${xwithFloat}
442+ '';
443+ buildFlags = "";
444+ };
445+
446+
447+ # Needed for the cross compilation to work
448+ AR = "ar";
449+ LD = "ld";
450+ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
451+ CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc";
452+
453+ # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
454+ # the library headers and binaries, regarless of the language being
455+ # compiled.
456+
457+ # Note: When building the Java AWT GTK+ peer, the build system doesn't
458+ # honor `--with-gmp' et al., e.g., when building
459+ # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
460+ # add them to $CPATH and $LIBRARY_PATH in this case.
461+ #
462+ # Likewise, the LTO code doesn't find zlib.
463+
464+ CPATH = makeSearchPathOutput "dev" "include" ([]
465+ ++ optional (zlib != null) zlib
466+ ++ optional langJava boehmgc
467+ ++ optionals javaAwtGtk xlibs
468+ ++ optionals javaAwtGtk [ gmp mpfr ]
469+ ++ optional (libpthread != null) libpthread
470+ ++ optional (libpthreadCross != null) libpthreadCross
471+
472+ # On GNU/Hurd glibc refers to Mach & Hurd
473+ # headers.
474+ ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs")
475+ libcCross.propagatedBuildInputs);
476+
477+ LIBRARY_PATH = makeLibraryPath ([]
478+ ++ optional (zlib != null) zlib
479+ ++ optional langJava boehmgc
480+ ++ optionals javaAwtGtk xlibs
481+ ++ optionals javaAwtGtk [ gmp mpfr ]
482+ ++ optional (libpthread != null) libpthread);
483+
484+ EXTRA_TARGET_CFLAGS =
485+ if cross != null && libcCross != null then [
486+ "-idirafter ${getDev libcCross}/include"
487+ ]
488+ ++ optionals (! crossStageStatic) [
489+ "-B${libcCross.out}/lib"
490+ ]
491+ else null;
492+
493+ EXTRA_TARGET_LDFLAGS =
494+ if cross != null && libcCross != null then [
495+ "-Wl,-L${libcCross.out}/lib"
496+ ]
497+ ++ (if crossStageStatic then [
498+ "-B${libcCross.out}/lib"
499+ ] else [
500+ "-Wl,-rpath,${libcCross.out}/lib"
501+ "-Wl,-rpath-link,${libcCross.out}/lib"
502+ ])
503+ ++ optionals (libpthreadCross != null) [
504+ "-L${libpthreadCross}/lib"
505+ "-Wl,${libpthreadCross.TARGET_LDFLAGS}"
506+ ]
507+ else null;
508+
509+ passthru =
510+ { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; };
511+
512+ inherit enableParallelBuilding enableMultilib;
513+
514+ inherit (stdenv) is64bit;
515+
516+ meta = {
517+ homepage = http://gcc.gnu.org/;
518+ license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+
519+ description = "GNU Compiler Collection, version ${version}"
520+ + (if stripped then "" else " (with debugging info)");
521+
522+ longDescription = ''
523+ The GNU Compiler Collection includes compiler front ends for C, C++,
524+ Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
525+ as libraries for these languages (libstdc++, libgcj, libgomp,...).
526+
527+ GCC development is a part of the GNU Project, aiming to improve the
528+ compiler used in the GNU system including the GNU/Linux variant.
529+ '';
530+
531+ maintainers = with stdenv.lib.maintainers; [ ];
532+
533+ # gnatboot is not available out of linux platforms, so we disable the darwin build
534+ # for the gnat (ada compiler).
535+ platforms =
536+ stdenv.lib.platforms.linux ++
537+ stdenv.lib.platforms.freebsd ++
538+ optionals (langAda == false) stdenv.lib.platforms.darwin;
539+ };
540+}
541+
542+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
543+ makeFlags = [ "all-gcc" "all-target-libgcc" ];
544+ installTargets = "install-gcc install-target-libgcc";
545+}
546+
547+# Strip kills static libs of other archs (hence cross != null)
548+// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
549+
550+// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
551+)