Merge pull request #26471 from obsidiansystems/gcc7-no-cross-arg
gcc 7: Remove `cross` arguments and don't use stdenv.is*
This commit is contained in:
commit
2f348884b8
@ -1,7 +1,7 @@
|
|||||||
{ stdenv, fetchurl, noSysDirs
|
{ stdenv, fetchurl, noSysDirs
|
||||||
, langC ? true, langCC ? true, langFortran ? false
|
, langC ? true, langCC ? true, langFortran ? false
|
||||||
, langObjC ? stdenv.isDarwin
|
, langObjC ? targetPlatform.isDarwin
|
||||||
, langObjCpp ? stdenv.isDarwin
|
, langObjCpp ? targetPlatform.isDarwin
|
||||||
, langJava ? false
|
, langJava ? false
|
||||||
, langAda ? false
|
, langAda ? false
|
||||||
, langVhdl ? false
|
, langVhdl ? false
|
||||||
@ -25,7 +25,6 @@
|
|||||||
, enableMultilib ? false
|
, enableMultilib ? false
|
||||||
, enablePlugin ? true # whether to support user-supplied plug-ins
|
, enablePlugin ? true # whether to support user-supplied plug-ins
|
||||||
, name ? "gcc"
|
, name ? "gcc"
|
||||||
, cross ? null
|
|
||||||
, libcCross ? null
|
, libcCross ? null
|
||||||
, crossStageStatic ? true
|
, crossStageStatic ? true
|
||||||
, gnat ? null
|
, gnat ? null
|
||||||
@ -49,10 +48,10 @@ assert langVhdl -> gnat != null;
|
|||||||
assert libelf != null -> zlib != null;
|
assert libelf != null -> zlib != null;
|
||||||
|
|
||||||
# Make sure we get GNU sed.
|
# Make sure we get GNU sed.
|
||||||
assert stdenv.isDarwin -> gnused != null;
|
assert hostPlatform.isDarwin -> gnused != null;
|
||||||
|
|
||||||
# Need c++filt on darwin
|
# Need c++filt on darwin
|
||||||
assert stdenv.isDarwin -> binutils != null;
|
assert hostPlatform.isDarwin -> binutils != null;
|
||||||
|
|
||||||
# The go frontend is written in c++
|
# The go frontend is written in c++
|
||||||
assert langGo -> langCC;
|
assert langGo -> langCC;
|
||||||
@ -63,13 +62,13 @@ with builtins;
|
|||||||
let version = "7.1.0";
|
let version = "7.1.0";
|
||||||
|
|
||||||
# Whether building a cross-compiler for GNU/Hurd.
|
# Whether building a cross-compiler for GNU/Hurd.
|
||||||
crossGNU = cross != null && cross.config == "i586-pc-gnu";
|
crossGNU = targetPlatform != hostPlatform && targetPlatform.config == "i586-pc-gnu";
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
patches =
|
patches =
|
||||||
[ ]
|
[ ]
|
||||||
++ optional (cross != null) ../libstdc++-target.patch
|
++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
|
||||||
++ optional noSysDirs ../no-sys-dirs.patch
|
++ optional noSysDirs ../no-sys-dirs.patch
|
||||||
# The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
|
# The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
|
||||||
# target libraries and tools.
|
# target libraries and tools.
|
||||||
@ -122,8 +121,8 @@ let version = "7.1.0";
|
|||||||
withMode;
|
withMode;
|
||||||
|
|
||||||
/* Cross-gcc settings */
|
/* Cross-gcc settings */
|
||||||
crossMingw = cross != null && cross.libc == "msvcrt";
|
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
|
||||||
crossDarwin = cross != null && cross.libc == "libSystem";
|
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
|
||||||
crossConfigureFlags = let
|
crossConfigureFlags = let
|
||||||
gccArch = targetPlatform.gcc.arch or null;
|
gccArch = targetPlatform.gcc.arch or null;
|
||||||
gccCpu = targetPlatform.gcc.cpu or null;
|
gccCpu = targetPlatform.gcc.cpu or null;
|
||||||
@ -138,7 +137,7 @@ let version = "7.1.0";
|
|||||||
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
|
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
|
||||||
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
|
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
|
||||||
in
|
in
|
||||||
"--target=${cross.config}" +
|
"--target=${targetPlatform.config}" +
|
||||||
withArch +
|
withArch +
|
||||||
withCpu +
|
withCpu +
|
||||||
withAbi +
|
withAbi +
|
||||||
@ -146,8 +145,8 @@ let version = "7.1.0";
|
|||||||
withFloat +
|
withFloat +
|
||||||
withMode +
|
withMode +
|
||||||
# Ensure that -print-prog-name is able to find the correct programs.
|
# Ensure that -print-prog-name is able to find the correct programs.
|
||||||
" --with-as=${binutils}/bin/${cross.config}-as" +
|
" --with-as=${binutils}/bin/${targetPlatform.config}-as" +
|
||||||
" --with-ld=${binutils}/bin/${cross.config}-ld" +
|
" --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
|
||||||
(if crossMingw && crossStageStatic then
|
(if crossMingw && crossStageStatic then
|
||||||
" --with-headers=${libcCross}/include" +
|
" --with-headers=${libcCross}/include" +
|
||||||
" --with-gcc" +
|
" --with-gcc" +
|
||||||
@ -188,7 +187,7 @@ let version = "7.1.0";
|
|||||||
" --disable-shared" +
|
" --disable-shared" +
|
||||||
# To keep ABI compatibility with upstream mingw-w64
|
# To keep ABI compatibility with upstream mingw-w64
|
||||||
" --enable-fully-dynamic-string"
|
" --enable-fully-dynamic-string"
|
||||||
else (if cross.libc == "uclibc" then
|
else (if targetPlatform.libc == "uclibc" then
|
||||||
# libsanitizer requires netrom/netrom.h which is not
|
# libsanitizer requires netrom/netrom.h which is not
|
||||||
# available in uclibc.
|
# available in uclibc.
|
||||||
" --disable-libsanitizer" +
|
" --disable-libsanitizer" +
|
||||||
@ -200,9 +199,9 @@ let version = "7.1.0";
|
|||||||
" --disable-decimal-float") # No final libdecnumber (it may work only in 386)
|
" --disable-decimal-float") # No final libdecnumber (it may work only in 386)
|
||||||
);
|
);
|
||||||
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
|
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
|
||||||
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
|
crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
|
||||||
|
|
||||||
bootstrap = cross == null;
|
bootstrap = targetPlatform == hostPlatform;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ stdenv.mkDerivation ({
|
|||||||
hardeningDisable = [ "format" ];
|
hardeningDisable = [ "format" ];
|
||||||
|
|
||||||
postPatch =
|
postPatch =
|
||||||
if (stdenv.isHurd
|
if (hostPlatform.isHurd
|
||||||
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
|| (libcCross != null # e.g., building `gcc.crossDrv'
|
||||||
&& libcCross ? crossConfig
|
&& libcCross ? crossConfig
|
||||||
&& libcCross.crossConfig == "i586-pc-gnu")
|
&& libcCross.crossConfig == "i586-pc-gnu")
|
||||||
@ -266,7 +265,7 @@ stdenv.mkDerivation ({
|
|||||||
sed -i "${gnu_h}" \
|
sed -i "${gnu_h}" \
|
||||||
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
|
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g'
|
||||||
''
|
''
|
||||||
else if cross != null || stdenv.cc.libc != null then
|
else if targetPlatform != hostPlatform || stdenv.cc.libc != null then
|
||||||
# On NixOS, use the right path to the dynamic linker instead of
|
# On NixOS, use the right path to the dynamic linker instead of
|
||||||
# `/lib/ld*.so'.
|
# `/lib/ld*.so'.
|
||||||
let
|
let
|
||||||
@ -295,19 +294,19 @@ stdenv.mkDerivation ({
|
|||||||
++ (optional (zlib != null) zlib)
|
++ (optional (zlib != null) zlib)
|
||||||
++ (optionals langJava [ boehmgc zip unzip ])
|
++ (optionals langJava [ boehmgc zip unzip ])
|
||||||
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
|
++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
|
||||||
++ (optionals (cross != null) [binutils])
|
++ (optionals (targetPlatform != hostPlatform) [binutils])
|
||||||
++ (optionals langAda [gnatboot])
|
++ (optionals langAda [gnatboot])
|
||||||
++ (optionals langVhdl [gnat])
|
++ (optionals langVhdl [gnat])
|
||||||
|
|
||||||
# The builder relies on GNU sed (for instance, Darwin's `sed' fails with
|
# The builder relies on GNU sed (for instance, Darwin's `sed' fails with
|
||||||
# "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
|
# "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
|
||||||
++ (optional stdenv.isDarwin gnused)
|
++ (optional hostPlatform.isDarwin gnused)
|
||||||
++ (optional stdenv.isDarwin binutils)
|
++ (optional hostPlatform.isDarwin binutils)
|
||||||
;
|
;
|
||||||
|
|
||||||
NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-lm -ldl";
|
NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl";
|
||||||
|
|
||||||
preConfigure = stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) ''
|
preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
|
||||||
export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
|
export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
|
||||||
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
|
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
|
||||||
export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
|
export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
|
||||||
@ -317,7 +316,7 @@ stdenv.mkDerivation ({
|
|||||||
dontDisableStatic = true;
|
dontDisableStatic = true;
|
||||||
|
|
||||||
configureFlags = "
|
configureFlags = "
|
||||||
${if stdenv.isSunOS then
|
${if hostPlatform.isSunOS then
|
||||||
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
|
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
|
||||||
# On Illumos/Solaris GNU as is preferred
|
# On Illumos/Solaris GNU as is preferred
|
||||||
" --with-gnu-as --without-gnu-ld "
|
" --with-gnu-as --without-gnu-ld "
|
||||||
@ -361,19 +360,19 @@ stdenv.mkDerivation ({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
${if cross == null
|
${if targetPlatform == hostPlatform
|
||||||
then if stdenv.isDarwin
|
then if hostPlatform.isDarwin
|
||||||
then " --with-native-system-header-dir=${darwin.usr-include}"
|
then " --with-native-system-header-dir=${darwin.usr-include}"
|
||||||
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
|
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
|
||||||
else ""}
|
else ""}
|
||||||
${if langAda then " --enable-libada" else ""}
|
${if langAda then " --enable-libada" else ""}
|
||||||
${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
|
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
|
||||||
${if cross != null then crossConfigureFlags else ""}
|
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
|
||||||
${if !bootstrap then "--disable-bootstrap" else ""}
|
${if !bootstrap then "--disable-bootstrap" else ""}
|
||||||
${if cross == null then platformFlags else ""}
|
${if targetPlatform == hostPlatform then platformFlags else ""}
|
||||||
";
|
";
|
||||||
|
|
||||||
targetConfig = if cross != null then cross.config else null;
|
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
|
||||||
|
|
||||||
buildFlags = if bootstrap then
|
buildFlags = if bootstrap then
|
||||||
(if profiledCompiler then "profiledbootstrap" else "bootstrap")
|
(if profiledCompiler then "profiledbootstrap" else "bootstrap")
|
||||||
@ -405,8 +404,8 @@ stdenv.mkDerivation ({
|
|||||||
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
|
CC_FOR_TARGET = "${targetPlatform.config}-gcc";
|
||||||
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
NM_FOR_TARGET = "${targetPlatform.config}-nm";
|
||||||
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
CXX_FOR_TARGET = "${targetPlatform.config}-g++";
|
||||||
# If we are making a cross compiler, cross != null
|
# If we are making a cross compiler, targetPlatform != hostPlatform
|
||||||
NIX_CC_CROSS = if cross == null then "${stdenv.ccCross}" else "";
|
NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else "";
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
configureFlags = ''
|
configureFlags = ''
|
||||||
${if enableMultilib then "" else "--disable-multilib"}
|
${if enableMultilib then "" else "--disable-multilib"}
|
||||||
@ -482,7 +481,7 @@ stdenv.mkDerivation ({
|
|||||||
++ optional (libpthread != null) libpthread);
|
++ optional (libpthread != null) libpthread);
|
||||||
|
|
||||||
EXTRA_TARGET_CFLAGS =
|
EXTRA_TARGET_CFLAGS =
|
||||||
if cross != null && libcCross != null then [
|
if targetPlatform != hostPlatform && libcCross != null then [
|
||||||
"-idirafter ${getDev libcCross}/include"
|
"-idirafter ${getDev libcCross}/include"
|
||||||
]
|
]
|
||||||
++ optionals (! crossStageStatic) [
|
++ optionals (! crossStageStatic) [
|
||||||
@ -491,7 +490,7 @@ stdenv.mkDerivation ({
|
|||||||
else null;
|
else null;
|
||||||
|
|
||||||
EXTRA_TARGET_LDFLAGS =
|
EXTRA_TARGET_LDFLAGS =
|
||||||
if cross != null && libcCross != null then [
|
if targetPlatform != hostPlatform && libcCross != null then [
|
||||||
"-Wl,-L${libcCross.out}/lib"
|
"-Wl,-L${libcCross.out}/lib"
|
||||||
]
|
]
|
||||||
++ (if crossStageStatic then [
|
++ (if crossStageStatic then [
|
||||||
@ -539,13 +538,13 @@ stdenv.mkDerivation ({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
|
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) {
|
||||||
makeFlags = [ "all-gcc" "all-target-libgcc" ];
|
makeFlags = [ "all-gcc" "all-target-libgcc" ];
|
||||||
installTargets = "install-gcc install-target-libgcc";
|
installTargets = "install-gcc install-target-libgcc";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Strip kills static libs of other archs (hence cross != null)
|
# Strip kills static libs of other archs (hence targetPlatform != hostPlatform)
|
||||||
// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
|
// optionalAttrs (!stripped || targetPlatform != hostPlatform) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
|
||||||
|
|
||||||
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
|
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
|
||||||
)
|
)
|
||||||
|
@ -5247,10 +5247,6 @@ with pkgs;
|
|||||||
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
|
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
|
||||||
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
|
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
|
||||||
|
|
||||||
# When building `gcc.crossDrv' (a "Canadian cross", with host == target
|
|
||||||
# and host != build), `cross' must be null but the cross-libc must still
|
|
||||||
# be passed.
|
|
||||||
cross = null;
|
|
||||||
libcCross = if targetPlatform != buildPlatform then libcCross else null;
|
libcCross = if targetPlatform != buildPlatform then libcCross else null;
|
||||||
|
|
||||||
isl = if !stdenv.isDarwin then isl_0_17 else null;
|
isl = if !stdenv.isDarwin then isl_0_17 else null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user