git.iko.soy/typeable/nixpkgs
on master help sign in
Merge #87237: gcc10, gfortran10, gnat10: init at 10.1.0
commit2e192dc5dbfb144d5ca38e42cc4b5dac668140b3 authorVladimír Čunát <v@cunat.cz> dateSun 10 May 2020, 08:03 (7 years ago) parente5e3090da59984
2 files changed+317
pkgs/development/compilers/gcc/10/default.nix+285 pkgs/top-level/all-packages.nix+32
pkgs/development/compilers/gcc/10/default.nixnew file+285
@@ -0,0 +1,285 @@
1+{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
2+, langC ? true, langCC ? true, langFortran ? false
3+, langAda ? false
4+, langObjC ? stdenv.targetPlatform.isDarwin
5+, langObjCpp ? stdenv.targetPlatform.isDarwin
6+, langGo ? false
7+, profiledCompiler ? false
8+, staticCompiler ? false
9+, enableShared ? true
10+, enableLTO ? true
11+, texinfo ? null
12+, perl ? null # optional, for texi2pod (then pod2man)
13+, gmp, mpfr, libmpc, gettext, which
14+, libelf # optional, for link-time optimizations (LTO)
15+, isl ? null # optional, for the Graphite optimization framework.
16+, zlib ? null
17+, gnatboot ? null
18+, enableMultilib ? false
19+, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins
20+, name ? "gcc"
21+, libcCross ? null
22+, threadsCross ? null # for MinGW
23+, crossStageStatic ? false
24+, # Strip kills static libs of other archs (hence no cross)
25+ stripped ? stdenv.hostPlatform == stdenv.buildPlatform
26+ && stdenv.targetPlatform == stdenv.hostPlatform
27+, gnused ? null
28+, cloog # unused; just for compat with gcc4, as we override the parameter on some places
29+, buildPackages
30+}:
31+
32+# LTO needs libelf and zlib.
33+assert libelf != null -> zlib != null;
34+
35+# Make sure we get GNU sed.
36+assert stdenv.hostPlatform.isDarwin -> gnused != null;
37+
38+# The go frontend is written in c++
39+assert langGo -> langCC;
40+assert langAda -> gnatboot != null;
41+
42+# threadsCross is just for MinGW
43+assert threadsCross != null -> stdenv.targetPlatform.isWindows;
44+
45+with stdenv.lib;
46+with builtins;
47+
48+let majorVersion = "10";
49+ version = "${majorVersion}.1.0";
50+
51+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
52+
53+ patches =
54+ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
55+ ++ optional noSysDirs ../no-sys-dirs.patch
56+ /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
57+ url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
58+ sha256 = ""; # TODO: uncomment and check hash when available.
59+ }) */
60+ ++ optional langAda ../gnat-cflags.patch
61+ ++ optional langFortran ../gfortran-driving.patch
62+ ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
63+ ++ optional (!crossStageStatic && targetPlatform.isMinGW) (fetchpatch {
64+ url = "https://raw.githubusercontent.com/lhmouse/MINGW-packages/${import ../common/mfcgthreads-patches-repo.nix}/mingw-w64-gcc-git/9000-gcc-${majorVersion}-branch-Added-mcf-thread-model-support-from-mcfgthread.patch";
65+ sha256 = "1in5kvcknlpi9z1vvjw6jfmwy8k12zvbqlqfnq84qpm99r0rh00a";
66+ });
67+
68+ /* Cross-gcc settings (build == host != target) */
69+ crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
70+ stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
71+ crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";
72+
73+in
74+
75+stdenv.mkDerivation ({
76+ pname = "${crossNameAddon}${name}${if stripped then "" else "-debug"}";
77+ inherit version;
78+
79+ builder = ../builder.sh;
80+
81+ src = fetchurl {
82+ url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
83+ sha256 = "b6898a23844b656f1b68691c5c012036c2e694ac4b53a8918d4712ad876e7ea2";
84+ };
85+
86+ inherit patches;
87+
88+ outputs = [ "out" "lib" "man" "info" ];
89+ setOutputFlags = false;
90+ NIX_NO_SELF_RPATH = true;
91+
92+ libc_dev = stdenv.cc.libc_dev;
93+
94+ hardeningDisable = [ "format" "pie" ];
95+
96+ # This should kill all the stdinc frameworks that gcc and friends like to
97+ # insert into default search paths.
98+ prePatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
99+ substituteInPlace gcc/config/darwin-c.c \
100+ --replace 'if (stdinc)' 'if (0)'
101+
102+ substituteInPlace libgcc/config/t-slibgcc-darwin \
103+ --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)"
104+
105+ substituteInPlace libgfortran/configure \
106+ --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
107+ '';
108+
109+ postPatch = ''
110+ configureScripts=$(find . -name configure)
111+ for configureScript in $configureScripts; do
112+ patchShebangs $configureScript
113+ done
114+ '' + (
115+ if targetPlatform != hostPlatform || stdenv.cc.libc != null then
116+ # On NixOS, use the right path to the dynamic linker instead of
117+ # `/lib/ld*.so'.
118+ let
119+ libc = if libcCross != null then libcCross else stdenv.cc.libc;
120+ in
121+ (
122+ '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..."
123+ for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
124+ do
125+ grep -q _DYNAMIC_LINKER "$header" || continue
126+ echo " fixing \`$header'..."
127+ sed -i "$header" \
128+ -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \
129+ -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g'
130+ done
131+ ''
132+ + stdenv.lib.optionalString (targetPlatform.libc == "musl")
133+ ''
134+ sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR'
135+ ''
136+ )
137+ else "")
138+ + stdenv.lib.optionalString targetPlatform.isAvr ''
139+ makeFlagsArray+=(
140+ 'LIMITS_H_TEST=false'
141+ )
142+ '';
143+
144+ inherit noSysDirs staticCompiler crossStageStatic
145+ libcCross crossMingw;
146+
147+ depsBuildBuild = [ buildPackages.stdenv.cc ];
148+ nativeBuildInputs = [ texinfo which gettext ]
149+ ++ (optional (perl != null) perl);
150+
151+ # For building runtime libs
152+ depsBuildTarget =
153+ if hostPlatform == buildPlatform then [
154+ targetPackages.stdenv.cc.bintools # newly-built gcc will be used
155+ ] else assert targetPlatform == hostPlatform; [ # build != host == target
156+ stdenv.cc
157+ ];
158+
159+ buildInputs = [
160+ gmp mpfr libmpc libelf
161+ targetPackages.stdenv.cc.bintools # For linking code at run-time
162+ ] ++ (optional (isl != null) isl)
163+ ++ (optional (zlib != null) zlib)
164+ # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
165+ # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
166+ ++ (optional hostPlatform.isDarwin gnused)
167+ ++ (optional langAda gnatboot)
168+ ;
169+
170+ depsTargetTarget = optional (!crossStageStatic && threadsCross != null) threadsCross;
171+
172+ NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl";
173+
174+ preConfigure = import ../common/pre-configure.nix {
175+ inherit (stdenv) lib;
176+ inherit version hostPlatform gnatboot langAda langGo;
177+ };
178+
179+ dontDisableStatic = true;
180+
181+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
182+ configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
183+
184+ configureFlags = import ../common/configure-flags.nix {
185+ inherit
186+ stdenv
187+ targetPackages
188+ crossStageStatic libcCross
189+ version
190+
191+ gmp mpfr libmpc libelf isl
192+
193+ enableLTO
194+ enableMultilib
195+ enablePlugin
196+ enableShared
197+
198+ langC
199+ langCC
200+ langFortran
201+ langAda
202+ langGo
203+ langObjC
204+ langObjCpp
205+ ;
206+ };
207+
208+ targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
209+
210+ buildFlags = optional
211+ (targetPlatform == hostPlatform && hostPlatform == buildPlatform)
212+ (if profiledCompiler then "profiledbootstrap" else "bootstrap");
213+
214+ dontStrip = !stripped;
215+
216+ installTargets = optional stripped "install-strip";
217+
218+ # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
219+ ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64";
220+
221+ # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the
222+ # library headers and binaries, regarless of the language being compiled.
223+ #
224+ # Likewise, the LTO code doesn't find zlib.
225+ #
226+ # Cross-compiling, we need gcc not to read ./specs in order to build the g++
227+ # compiler (after the specs for the cross-gcc are created). Having
228+ # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks.
229+
230+ CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([]
231+ ++ optional (zlib != null) zlib
232+ ));
233+
234+ LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib));
235+
236+ inherit
237+ (import ../common/extra-target-flags.nix {
238+ inherit stdenv crossStageStatic libcCross threadsCross;
239+ })
240+ EXTRA_TARGET_FLAGS
241+ EXTRA_TARGET_LDFLAGS
242+ ;
243+
244+ passthru = {
245+ inherit langC langCC langObjC langObjCpp langAda langFortran langGo version;
246+ isGNU = true;
247+ };
248+
249+ enableParallelBuilding = true;
250+ inherit enableMultilib;
251+
252+ inherit (stdenv) is64bit;
253+
254+ meta = {
255+ homepage = "https://gcc.gnu.org/";
256+ license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+
257+ description = "GNU Compiler Collection, version ${version}"
258+ + (if stripped then "" else " (with debugging info)");
259+
260+ longDescription = ''
261+ The GNU Compiler Collection includes compiler front ends for C, C++,
262+ Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as
263+ libraries for these languages (libstdc++, libgomp,...).
264+
265+ GCC development is a part of the GNU Project, aiming to improve the
266+ compiler used in the GNU system including the GNU/Linux variant.
267+ '';
268+
269+ maintainers = with stdenv.lib.maintainers; [ synthetica ];
270+
271+ platforms =
272+ stdenv.lib.platforms.linux ++
273+ stdenv.lib.platforms.freebsd ++
274+ stdenv.lib.platforms.illumos ++
275+ stdenv.lib.platforms.darwin;
276+ };
277+}
278+
279+// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
280+ makeFlags = [ "all-gcc" "all-target-libgcc" ];
281+ installTargets = "install-gcc install-target-libgcc";
282+}
283+
284+// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
285+)
pkgs/top-level/all-packages.nix+32
@@ -8197,6 +8197,7 @@ in
81978197 gcc7Stdenv = overrideCC gccStdenv buildPackages.gcc7;
81988198 gcc8Stdenv = overrideCC gccStdenv buildPackages.gcc8;
81998199 gcc9Stdenv = overrideCC gccStdenv buildPackages.gcc9;
8200+ gcc10Stdenv = overrideCC gccStdenv buildPackages.gcc10;
82008201
82018202 wrapCCMulti = cc:
82028203 if stdenv.targetPlatform.system == "x86_64-linux" then let
@@ -8364,6 +8365,20 @@ in
83648365 isl = if !stdenv.isDarwin then isl_0_17 else null;
83658366 }));
83668367
8368+ gcc10 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/10 {
8369+ inherit noSysDirs;
8370+
8371+ # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
8372+ profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
8373+
8374+ enableLTO = !stdenv.isi686;
8375+
8376+ libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
8377+ threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
8378+
8379+ isl = if !stdenv.isDarwin then isl_0_17 else null;
8380+ }));
8381+
83678382 gfortran = gfortran9;
83688383
83698384 gfortran48 = wrapCC (gcc48.cc.override {
@@ -8414,6 +8429,14 @@ in
84148429 profiledCompiler = false;
84158430 });
84168431
8432+ gfortran10 = wrapCC (gcc10.cc.override {
8433+ name = "gfortran";
8434+ langFortran = true;
8435+ langCC = false;
8436+ langC = false;
8437+ profiledCompiler = false;
8438+ });
8439+
84178440 gcj = gcj6;
84188441 gcj6 = wrapCC (gcc6.cc.override {
84198442 name = "gcj";
@@ -8446,6 +8469,15 @@ in
84468469 gnatboot = gnat6;
84478470 });
84488471
8472+ gnat10 = wrapCC (gcc10.cc.override {
8473+ name = "gnat";
8474+ langC = true;
8475+ langCC = false;
8476+ langAda = true;
8477+ profiledCompiler = false;
8478+ gnatboot = gnat6;
8479+ });
8480+
84498481 gnatboot = wrapCC (callPackage ../development/compilers/gnatboot { });
84508482
84518483 gnu-smalltalk = callPackage ../development/compilers/gnu-smalltalk { };