gcc: Refactor treatment of configure flags

Previously configureFlags was defined as one giant interpolated string.
Here we refactor this definition to instead use the usual stdenv string
combinators. This seems more in-line with the average nixpkgs expression
and it seems a bit more natural to things of these as lists of flags
rather than monolithic strings.
This commit is contained in:
Ben Gamari 2017-11-14 16:08:46 -05:00 committed by John Ericson
parent eaacf47ff4
commit 1c1207220f
7 changed files with 1190 additions and 1147 deletions

View File

@ -67,55 +67,53 @@ let version = "4.5.4";
gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null targetPlatform; gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null targetPlatform;
gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null targetPlatform; gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null targetPlatform;
gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null targetPlatform; gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null targetPlatform;
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 = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"); crossMingw = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt");
crossConfigureFlags = crossConfigureFlags =
withArch + optional (gccArch != null) "--with-arch=${gccArch}" ++
withCpu + optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withAbi + optional (gccAbi != null) "--with-abi=${gccAbi}" ++
# 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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then [
" --with-headers=${libcCross}/include" + "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then [
" --disable-libssp --disable-nls" + "--disable-libssp --disable-nls"
" --without-headers" + "--without-headers"
" --disable-threads " + "--disable-threads"
" --disable-libmudflap " + "--disable-libmudflap"
" --disable-libgomp " + "--disable-libgomp "
" --disable-shared" + "--disable-shared"
" --disable-decimal-float" # libdecnumber requires libc "--disable-decimal-float" # libdecnumber requires libc
else ] else [
" --with-headers=${libcCross}/include" + "--with-headers=${libcCross}/include"
" --enable-__cxa_atexit" + "--enable-__cxa_atexit"
" --enable-long-long" + "--enable-long-long"
(if crossMingw then ] ++ (if crossMingw then [
" --enable-threads=win32" + "--enable-threads=win32"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-hash-synchronization" + "--enable-hash-synchronization"
" --enable-version-specific-runtime-libs" + "--enable-version-specific-runtime-libs"
" --disable-libssp" + "--disable-libssp"
" --disable-nls" + "--disable-nls"
" --with-dwarf2" "--with-dwarf2"
else ] else [
" --enable-threads=posix" + "--enable-threads=posix"
" --enable-nls" + "--enable-nls"
" --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 stageNameAddon = if crossStageStatic then "-stage-static" else
"-stage-final"; "-stage-final";
crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
@ -241,44 +239,61 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if enableMultilib then "" else "--disable-multilib"} # Basic dependencies
${if enableShared then "" else "--disable-shared"} [
${if ppl != null then "--with-ppl=${ppl}" else ""} "--with-gmp=${gmp.dev}"
${if cloogppl != null then "--with-cloog=${cloogppl}" else ""} "--with-mpfr=${mpfr.dev}"
${if langJava then "--with-mpc=${libmpc}"
"--with-ecj-jar=${javaEcj} " + ] ++
optional (libelf != null) "--with-libelf=${libelf}" ++
# Basic configuration
[
"--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 langAda "ada"
++ optional langVhdl "vhdl"
)
)
}"
] ++
optional (!enableMultilib) "--disable-multilib" ++
optional (!enableShared) "--disable-shared" ++
# Optional features
optional (cloogppl != null) "--with-cloog=${cloogppl}" ++
optional (ppl != null) "--with-ppl=${ppl}" ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp=${gmp.dev}
--with-mpfr=${mpfr.dev} # Ada
--with-mpc=${libmpc} optional langAda "--enable-libada" ++
${if libelf != null then "--with-libelf=${libelf}" else ""}
--disable-libstdcxx-pch # Cross-compilation
--without-included-gettext optional (targetPlatform != hostPlatform) crossConfigureFlags ++
--with-system-zlib
--enable-languages=${ # Platform-specific flags
concatStrings (intersperse "," optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
( optional langC "c" # Trick that should be taken out once we have a mips64el-linux not loongson2f
++ optional langCC "c++" optional (targetPlatform == hostPlatform && stdenv.system == "mips64el-linux") "--with-arch=loongson2f"
++ optional langFortran "fortran" ;
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
)
)
}
${ # Trick that should be taken out once we have a mips64el-linux not loongson2f
if targetPlatform == hostPlatform && stdenv.system == "mips64el-linux" then "--with-arch=loongson2f" else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -295,35 +310,39 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if ppl != null then "--with-ppl=${ppl.crossDrv}" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if cloogppl != null then "--with-cloog=${cloogppl.crossDrv}" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional (ppl != null) "--with-ppl=${ppl.crossDrv}" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (cloogppl != null) "--with-cloog=${cloogppl.crossDrv}" ++
--with-gmp=${gmp.crossDrv}
--with-mpfr=${mpfr.crossDrv} [
--with-mpc=${libmpc.crossDrv} "--with-gmp=${gmp.crossDrv}"
--disable-libstdcxx-pch "--with-mpfr=${mpfr.crossDrv}"
--without-included-gettext "--with-mpc=${libmpc.crossDrv}"
--with-system-zlib "--disable-libstdcxx-pch"
--enable-languages=${ "--without-included-gettext"
concatStrings (intersperse "," "--with-system-zlib"
( optional langC "c" "--enable-languages=${
++ optional langCC "c++" concatStrings (intersperse ","
++ optional langFortran "fortran" ( optional langC "c"
++ optional langJava "java" ++ optional langCC "c++"
++ optional langAda "ada" ++ optional langFortran "fortran"
++ optional langVhdl "vhdl" ++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${if targetplatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
${if targetPlatform != hostPlatform then crossConfigureFlags else ""} optional (targetPlatform != hostPlatform) crossConfigureFlags
''; ;
}; };

View File

@ -108,102 +108,83 @@ let version = "4.8.5";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; in
withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; optional (gccArch != null) "--with-arch=${gccArch}" ++
withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; optional (gccFloat != null) "--with-float=${gccFloat}" ++
in optional (gccMode != null) "--with-mode=${gccMode}";
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
withMode;
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then
" --disable-libssp --disable-nls" + [ "--disable-libssp --disable-nls"
" --without-headers" + "--without-headers"
" --disable-threads " + "--disable-threads "
" --disable-libmudflap " + "--disable-libgomp "
" --disable-libgomp " + "--disable-libquadmath"
" --disable-libquadmath" + "--disable-shared"
" --disable-shared" + "--disable-libatomic " # libatomic requires libc
" --disable-libatomic " + # libatomic requires libc "--disable-decimal-float" # libdecnumber requires libc
" --disable-decimal-float" # libdecnumber requires libc ] else
else (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
(if crossDarwin then " --with-sysroot=${libcCross.out}/share/sysroot" else ["--with-headers=${getDev libcCross}/include"]) ++
else " --with-headers=${libcCross.dev}/include") + [ "--enable-__cxa_atexit"
# Ensure that -print-prog-name is able to find the correct programs. "--enable-long-long"
" --enable-__cxa_atexit" + ] ++
" --enable-long-long" + (if crossMingw then [
(if crossMingw then "--enable-threads=win32"
" --enable-threads=win32" + "--enable-sjlj-exceptions"
" --enable-sjlj-exceptions" + "--enable-hash-synchronization"
" --enable-hash-synchronization" + "--disable-libssp"
" --disable-libssp" + "--disable-nls"
" --disable-nls" + "--with-dwarf2"
" --with-dwarf2" +
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
optionals (targetPlatform.libc == "uclibc") [
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
" --disable-libgomp" else "") + "--disable-libgomp"
" --enable-threads=posix" + ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
); "--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
@ -329,63 +310,87 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr-include=${mpfr.dev}/include"
--enable-lto "--with-mpfr-lib=${mpfr.out}/lib"
${if enableMultilib then "--disable-libquadmath" else "--disable-multilib"} "--with-mpc=${libmpc}"
${if enableShared then "" else "--disable-shared"} ] ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"} optional (libelf != null) "--with-libelf=${libelf}" ++
${optionalString (isl != null) "--with-isl=${isl}"}
${optionalString (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"} # Basic configuration
${if langJava then [
"--with-ecj-jar=${javaEcj} " + "--enable-lto"
"--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
optional (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl" ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp-include=${gmp.dev}/include
--with-gmp-lib=${gmp.out}/lib # Ada
--with-mpfr-include=${mpfr.dev}/include optional langAda "--enable-libada" ++
--with-mpfr-lib=${mpfr.out}/lib
--with-mpc=${libmpc} # Cross-compilation
${if libelf != null then "--with-libelf=${libelf}" else ""} optional (targetPlatform == hostPlatform) (
--disable-libstdcxx-pch let incDir = if hostPlatform.isDarwin
--without-included-gettext then "${darwin.usr-include}"
--with-system-zlib else "${getDev stdenv.cc.libc}/include";
--enable-static in "--with-native-system-header-dir=${incDir}"
--enable-languages=${ ) ++
concatStrings (intersperse ","
( optional langC "c" optional (targetPlatform == hostPlatform) (mkPlatformFlags stdenv.platform) ++
++ optional langCC "c++" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langFortran "fortran" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langJava "java"
++ optional langAda "ada" # Platform-specific flags
++ optional langVhdl "vhdl" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langGo "go" optionals hostPlatform.isSunOS [
++ optional langObjC "objc" "--enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
++ optional langObjCpp "obj-c++" # On Illumos/Solaris GNU as is preferred
++ optionals crossDarwin [ "objc" "obj-c++" ] "--with-gnu-as --without-gnu-ld"
) ]
) ;
}
${if targetPlatform == hostPlatform
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -404,11 +409,6 @@ stdenv.mkDerivation ({
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -422,38 +422,40 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if cloog != null then "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (cloog != null) "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };

View File

@ -99,107 +99,90 @@ let version = "4.9.4";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; in
withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; optional (gccArch != null) "--with-arch=${gccArch}" ++
withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; optional (gccFloat != null) "--with-float=${gccFloat}" ++
in optional (gccMode != null) "--with-mode=${gccMode}";
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
withMode;
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then
" --disable-libssp --disable-nls" + [ "--disable-libssp"
" --without-headers" + "--disable-nls"
" --disable-threads " + "--without-headers"
" --disable-libgomp " + "--disable-threads "
" --disable-libquadmath" + "--disable-libgomp "
" --disable-shared" + "--disable-libquadmath"
" --disable-libatomic " + # libatomic requires libc "--disable-shared"
" --disable-decimal-float" # libdecnumber requires libc "--disable-libatomic " # libatomic requires libc
else "--disable-decimal-float" # libdecnumber requires libc
(if crossDarwin then " --with-sysroot=${libcCross.out}/share/sysroot" ] else
else " --with-headers=${libcCross.dev}/include") + (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
" --enable-__cxa_atexit" + else ["--with-headers=${getDev libcCross}/include"]) ++
" --enable-long-long" + [ "--enable-__cxa_atexit"
(if crossMingw then "--enable-long-long"
" --enable-threads=win32" + ] ++
" --enable-sjlj-exceptions" +
" --enable-hash-synchronization" + (if crossMingw then [
" --disable-libssp" + "--enable-threads=win32"
" --disable-nls" + "--enable-sjlj-exceptions"
" --with-dwarf2" + "--enable-hash-synchronization"
"--disable-libssp"
"--disable-nls"
"--with-dwarf2"
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
optionals (targetPlatform.libc == "uclibc") [
# 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"
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
" --disable-libgomp" else "") + "--disable-libgomp"
" --enable-threads=posix" + ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
"--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
bootstrap = targetPlatform == hostPlatform; bootstrap = targetPlatform == hostPlatform;
in in
@ -326,61 +309,86 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr=${mpfr.dev}"
--enable-lto "--with-mpc=${libmpc}"
${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"} ] ++
${if enableShared then "" else "--disable-shared"} optional (libelf != null) "--with-libelf=${libelf}" ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
${optionalString (isl != null) "--with-isl=${isl}"} # Basic configuration
${optionalString (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"} [
${if langJava then "--enable-lto"
"--with-ecj-jar=${javaEcj} " + "--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
optional (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl" ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp=${gmp.dev}
--with-mpfr=${mpfr.dev} # Ada
--with-mpc=${libmpc} optional langAda "--enable-libada" ++
${if libelf != null then "--with-libelf=${libelf}" else ""}
--disable-libstdcxx-pch # Cross-compilation
--without-included-gettext optional (targetPlatform == hostPlatform) (
--with-system-zlib let incDir = if hostPlatform.isDarwin
--enable-static then "${darwin.usr-include}"
--enable-languages=${ else "${getDev stdenv.cc.libc}/include";
concatStrings (intersperse "," in "--with-native-system-header-dir=${incDir}"
( optional langC "c" ) ++
++ optional langCC "c++"
++ optional langFortran "fortran" optional (targetPlatform == hostPlatform) (mkPlatformFlags stdenv.platform) ++
++ optional langJava "java" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langAda "ada" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langVhdl "vhdl"
++ optional langGo "go" # Platform-specific flags
++ optional langObjC "objc" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langObjCpp "obj-c++" optionals hostPlatform.isSunOS [
++ optionals crossDarwin [ "objc" "obj-c++" ] "--enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
) # On Illumos/Solaris GNU as is preferred
) "--with-gnu-as --without-gnu-ld"
} ]
${if targetPlatform == hostPlatform ;
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -393,17 +401,13 @@ stdenv.mkDerivation ({
then "install-strip" then "install-strip"
else "install"; else "install";
/* For cross-built gcc (build != host == target) */
crossAttrs = let crossAttrs = let
xgccArch = targetPlatform.gcc.arch or null; xgccArch = targetPlatform.gcc.arch or null;
xgccCpu = targetPlatform.gcc.cpu or null; xgccCpu = targetPlatform.gcc.cpu or null;
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -417,38 +421,40 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if cloog != null then "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (cloog != null) "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };

View File

@ -103,107 +103,89 @@ let version = "5.5.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; in
withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; optional (gccArch != null) "--with-arch=${gccArch}" ++
withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; optional (gccFloat != null) "--with-float=${gccFloat}" ++
in optional (gccMode != null) "--with-mode=${gccMode}";
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
withMode;
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then
" --disable-libssp --disable-nls" + [ "--disable-libssp --disable-nls"
" --without-headers" + "--without-headers"
" --disable-threads " + "--disable-threads "
" --disable-libgomp " + "--disable-libgomp "
" --disable-libquadmath" + "--disable-libquadmath"
" --disable-shared" + "--disable-shared"
" --disable-libatomic " + # libatomic requires libc "--disable-libatomic " # libatomic requires libc
" --disable-decimal-float" # libdecnumber requires libc "--disable-decimal-float" # libdecnumber requires libc
else ] else
(if crossDarwin then " --with-sysroot=${getLib libcCross}/share/sysroot" (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
else " --with-headers=${getDev libcCross}/include") + else ["--with-headers=${getDev libcCross}/include"]) ++
" --enable-__cxa_atexit" + [ "--enable-__cxa_atexit"
" --enable-long-long" + "--enable-long-long"
(if crossMingw then ] ++
" --enable-threads=win32" + (if crossMingw then [
" --enable-sjlj-exceptions" + "--enable-threads=win32"
" --enable-hash-synchronization" + "--enable-sjlj-exceptions"
" --disable-libssp" + "--enable-hash-synchronization"
" --disable-nls" + "--disable-libssp"
" --with-dwarf2" + "--disable-nls"
"--with-dwarf2"
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
optionals (targetPlatform.libc == "uclibc") [
# 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"
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
" --disable-libgomp" else "") + "--disable-libgomp"
" --enable-threads=posix" + ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
); "--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
bootstrap = targetPlatform == hostPlatform; bootstrap = targetPlatform == hostPlatform;
in in
@ -340,62 +322,86 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr-include=${mpfr.dev}/include"
--enable-lto "--with-mpfr-lib=${mpfr.out}/lib"
${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"} "--with-mpc=${libmpc}"
${if enableShared then "" else "--disable-shared"} ] ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"} optional (libelf != null) "--with-libelf=${libelf}" ++
${optionalString (isl != null) "--with-isl=${isl}"}
${if langJava then # Basic configuration
"--with-ecj-jar=${javaEcj} " + [
"--enable-lto"
"--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp-include=${gmp.dev}/include
--with-gmp-lib=${gmp.out}/lib # Ada
--with-mpfr-include=${mpfr.dev}/include optional langAda "--enable-libada" ++
--with-mpfr-lib=${mpfr.out}/lib
--with-mpc=${libmpc} # Cross-compilation
${if libelf != null then "--with-libelf=${libelf}" else ""} optional (targetPlatform == hostPlatform) (
--disable-libstdcxx-pch let incDir = if hostPlatform.isDarwin
--without-included-gettext then "${darwin.usr-include}"
--with-system-zlib else "${getDev stdenv.cc.libc}/include";
--enable-static in "--with-native-system-header-dir=${incDir}"
--enable-languages=${ ) ++
concatStrings (intersperse ","
( optional langC "c" optional (targetPlatform == hostPlatform) (mkPlatformFlags stdenv.platform) ++
++ optional langCC "c++" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langFortran "fortran" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langJava "java"
++ optional langAda "ada" # Platform-specific flags
++ optional langVhdl "vhdl" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langGo "go" optionals hostPlatform.isSunOS [
++ optional langObjC "objc" "--enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
++ optional langObjCpp "obj-c++" # On Illumos/Solaris GNU as is preferred
++ optionals crossDarwin [ "objc" "obj-c++" ] "--with-gnu-as --without-gnu-ld"
) ]
) ;
}
${if targetPlatform == hostPlatform
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -408,17 +414,13 @@ stdenv.mkDerivation ({
then "install-strip" then "install-strip"
else "install"; else "install";
/* For cross-built gcc (build != host == target) */
crossAttrs = let crossAttrs = let
xgccArch = targetPlatform.gcc.arch or null; xgccArch = targetPlatform.gcc.arch or null;
xgccCpu = targetPlatform.gcc.cpu or null; xgccCpu = targetPlatform.gcc.cpu or null;
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -432,37 +434,39 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };

View File

@ -100,103 +100,86 @@ let version = "6.4.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in in
withArch + optional (gccArch != null) "--with-arch=${gccArch}" ++
withCpu + optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withAbi + optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFpu + optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withFloat + optional (gccFloat != null) "--with-float=${gccFloat}" ++
withMode; optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then [
" --disable-libssp --disable-nls" + "--disable-libssp"
" --without-headers" + "--disable-nls"
" --disable-threads " + "--without-headers"
" --disable-libgomp " + "--disable-threads"
" --disable-libquadmath" + "--disable-libgomp"
" --disable-shared" + "--disable-libquadmath"
" --disable-libatomic " + # libatomic requires libc "--disable-shared"
" --disable-decimal-float" # libdecnumber requires libc "--disable-libatomic" # libatomic requires libc
else "--disable-decimal-float" # libdecnumber requires libc
(if crossDarwin then " --with-sysroot=${getLib libcCross}/share/sysroot" ] else
else " --with-headers=${getDev libcCross}/include") + (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
" --enable-__cxa_atexit" + else ["--with-headers=${getDev libcCross}/include"]) ++
" --enable-long-long" +
(if crossMingw then [ "--enable-__cxa_atexit"
" --enable-threads=win32" + "--enable-long-long"
" --enable-sjlj-exceptions" + ] ++
" --enable-hash-synchronization" +
" --disable-libssp" + (if crossMingw then [
" --disable-nls" + "--enable-threads=win32"
" --with-dwarf2" + "--enable-sjlj-exceptions"
"--enable-hash-synchronization"
"--disable-libssp"
"--disable-nls"
"--with-dwarf2"
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
# libsanitizer requires netrom/netrom.h which is not optionals (targetPlatform.libc == "uclibc") [
# available in uclibc. # libsanitizer requires netrom/netrom.h which is not
" --disable-libsanitizer" + # available in uclibc.
# In uclibc cases, libgomp needs an additional '-ldl' "--disable-libsanitizer"
# and as I don't know how to pass it, I disable libgomp. # In uclibc cases, libgomp needs an additional '-ldl'
" --disable-libgomp" else "") + # and as I don't know how to pass it, I disable libgomp.
" --enable-threads=posix" + "--disable-libgomp" ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
); "--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
@ -341,85 +324,104 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr-include=${mpfr.dev}/include"
--enable-lto "--with-mpfr-lib=${mpfr.out}/lib"
${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"} "--with-mpc=${libmpc}"
${if enableShared then "" else "--disable-shared"} ] ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"} optional (libelf != null) "--with-libelf=${libelf}" ++
${optionalString (isl != null) "--with-isl=${isl}"}
${if langJava then # Basic configuration
"--with-ecj-jar=${javaEcj} " + [
"--enable-lto"
"--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home"
else ""} "--with-java-home=\${prefix}/lib/jvm/jre"
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} ] ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
--with-gmp-include=${gmp.dev}/include optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp-lib=${gmp.out}/lib
--with-mpfr-include=${mpfr.dev}/include # Ada
--with-mpfr-lib=${mpfr.out}/lib optional langAda "--enable-libada" ++
--with-mpc=${libmpc}
${if libelf != null then "--with-libelf=${libelf}" else ""} # Cross compilation
--disable-libstdcxx-pch optional (targetPlatform == hostPlatform) (
--without-included-gettext let incDir = if hostPlatform.isDarwin
--with-system-zlib then "${darwin.usr-include}"
--enable-static else "${getDev stdenv.cc.libc}/include";
--enable-languages=${ in "--with-native-system-header-dir=${incDir}"
concatStrings (intersperse "," ) ++
( optional langC "c"
++ optional langCC "c++" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langFortran "fortran" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langJava "java"
++ optional langAda "ada" # Platform-specific flags
++ optional langVhdl "vhdl" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langGo "go" optionals (hostPlatform.isSunOS) [
++ optional langObjC "objc" " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
++ optional langObjCpp "obj-c++" # On Illumos/Solaris GNU as is preferred
++ optionals crossDarwin [ "objc" "obj-c++" ] " --with-gnu-as --without-gnu-ld"
) ]
) ;
}
${if targetPlatform == hostPlatform
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
buildFlags = if bootstrap then buildFlags =
(if profiledCompiler then "profiledbootstrap" else "bootstrap") optional bootstrap (if profiledCompiler then "profiledbootstrap" else "bootstrap");
else "";
installTargets = installTargets =
if stripped if stripped
then "install-strip" then "install-strip"
else "install"; else "install";
/* For cross-built gcc (build != host == target) */
crossAttrs = let crossAttrs = let
xgccArch = targetPlatform.gcc.arch or null; xgccArch = targetPlatform.gcc.arch or null;
xgccCpu = targetPlatform.gcc.cpu or null; xgccCpu = targetPlatform.gcc.cpu or null;
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -433,37 +435,39 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };

View File

@ -98,108 +98,90 @@ let version = "7.2.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; in
withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; optional (gccArch != null) "--with-arch=${gccArch}" ++
withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; optional (gccFloat != null) "--with-float=${gccFloat}" ++
in optional (gccMode != null) "--with-mode=${gccMode}";
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
withMode;
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then
" --disable-libssp --disable-nls" + [ "--disable-libssp"
" --without-headers" + "--disable-nls"
" --disable-threads " + "--without-headers"
" --disable-libgomp " + "--disable-threads "
" --disable-libquadmath" + "--disable-libgomp "
" --disable-shared" + "--disable-libquadmath"
" --disable-libatomic " + # libatomic requires libc "--disable-shared"
" --disable-decimal-float" # libdecnumber requires libc "--disable-libatomic " # libatomic requires libc
else "--disable-decimal-float" # libdecnumber requires libc
(if crossDarwin then " --with-sysroot=${getLib libcCross}/share/sysroot" ] else
else " --with-headers=${getDev libcCross}/include") + (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
# Ensure that -print-prog-name is able to find the correct programs. else ["--with-headers=${getDev libcCross}/include"]) ++
" --enable-__cxa_atexit" + [ "--enable-__cxa_atexit"
" --enable-long-long" + "--enable-long-long"
(if crossMingw then ] ++
" --enable-threads=win32" +
" --enable-sjlj-exceptions" + (if crossMingw then [
" --enable-hash-synchronization" + "--enable-threads=win32"
" --disable-libssp" + "--enable-sjlj-exceptions"
" --disable-nls" + "--enable-hash-synchronization"
" --with-dwarf2" + "--disable-libssp"
"--disable-nls"
"--with-dwarf2"
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
optionals (targetPlatform.libc == "uclibc") [
# 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"
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
" --disable-libgomp" else "") + "--disable-libgomp"
" --enable-threads=posix" + ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
"--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
bootstrap = targetPlatform == hostPlatform; bootstrap = targetPlatform == hostPlatform;
in in
@ -335,62 +317,86 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr-include=${mpfr.dev}/include"
--enable-lto "--with-mpfr-lib=${mpfr.out}/lib"
${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"} "--with-mpc=${libmpc}"
${if enableShared then "" else "--disable-shared"} ] ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"} optional (libelf != null) "--with-libelf=${libelf}" ++
${optionalString (isl != null) "--with-isl=${isl}"}
${if langJava then # Basic configuration
"--with-ecj-jar=${javaEcj} " + [
"--enable-lto"
"--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp-include=${gmp.dev}/include
--with-gmp-lib=${gmp.out}/lib # Ada
--with-mpfr-include=${mpfr.dev}/include optional langAda "--enable-libada" ++
--with-mpfr-lib=${mpfr.out}/lib
--with-mpc=${libmpc} # Cross-compilation
${if libelf != null then "--with-libelf=${libelf}" else ""} optional (targetPlatform == hostPlatform) (
--disable-libstdcxx-pch let incDir = if hostPlatform.isDarwin
--without-included-gettext then "${darwin.usr-include}"
--with-system-zlib else "${getDev stdenv.cc.libc}/include";
--enable-static in "--with-native-system-header-dir=${incDir}"
--enable-languages=${ ) ++
concatStrings (intersperse ","
( optional langC "c" optional (targetPlatform == hostPlatform) (mkPlatformFlags stdenv.platform) ++
++ optional langCC "c++" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langFortran "fortran" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langJava "java"
++ optional langAda "ada" # Platform-specific flags
++ optional langVhdl "vhdl" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langGo "go" optionals hostPlatform.isSunOS [
++ optional langObjC "objc" "--enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
++ optional langObjCpp "obj-c++" # On Illumos/Solaris GNU as is preferred
++ optionals crossDarwin [ "objc" "obj-c++" ] "--with-gnu-as --without-gnu-ld"
) ]
) ;
}
${if targetPlatform == hostPlatform
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -403,17 +409,13 @@ stdenv.mkDerivation ({
then "install-strip" then "install-strip"
else "install"; else "install";
/* For cross-built gcc (build != host == target) */
crossAttrs = let crossAttrs = let
xgccArch = targetPlatform.gcc.arch or null; xgccArch = targetPlatform.gcc.arch or null;
xgccCpu = targetPlatform.gcc.cpu or null; xgccCpu = targetPlatform.gcc.cpu or null;
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -427,37 +429,39 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, targetPlatform != hostPlatform # If we are making a cross compiler, targetPlatform != hostPlatform
NIX_CC_CROSS = if targetPlatform == hostPlatform 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"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };

View File

@ -98,108 +98,90 @@ let version = "7-20170409";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */ /* Platform flags */
platformFlags = let mkPlatformFlags = platform: let
gccArch = stdenv.platform.gcc.arch or null; gccArch = platform.gcc.arch or null;
gccCpu = stdenv.platform.gcc.cpu or null; gccCpu = platform.gcc.cpu or null;
gccAbi = stdenv.platform.gcc.abi or null; gccAbi = platform.gcc.abi or null;
gccFpu = stdenv.platform.gcc.fpu or null; gccFpu = platform.gcc.fpu or null;
gccFloat = stdenv.platform.gcc.float or null; gccFloat = platform.gcc.float or null;
gccMode = stdenv.platform.gcc.mode or null; gccMode = platform.gcc.mode or null;
withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; in
withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; optional (gccArch != null) "--with-arch=${gccArch}" ++
withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; optional (gccAbi != null) "--with-abi=${gccAbi}" ++
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; optional (gccFloat != null) "--with-float=${gccFloat}" ++
in optional (gccMode != null) "--with-mode=${gccMode}";
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
withMode;
/* Cross-gcc settings */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
crossConfigureFlags = let crossConfigureFlags =
gccArch = targetPlatform.gcc.arch or null; mkPlatformFlags targetPlatform ++
gccCpu = targetPlatform.gcc.cpu or null;
gccAbi = targetPlatform.gcc.abi or null;
gccFpu = targetPlatform.gcc.fpu or null;
gccFloat = targetPlatform.gcc.float or null;
gccMode = targetPlatform.gcc.mode or null;
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 "";
withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
in
withArch +
withCpu +
withAbi +
withFpu +
withFloat +
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=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
" --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++
(if crossMingw && crossStageStatic then (if crossMingw && crossStageStatic then
" --with-headers=${libcCross}/include" + [ "--with-headers=${libcCross}/include"
" --with-gcc" + "--with-gcc"
" --with-gnu-as" + "--with-gnu-as"
" --with-gnu-ld" + "--with-gnu-ld"
" --with-gnu-ld" + "--with-gnu-ld"
" --disable-shared" + "--disable-shared"
" --disable-nls" + "--disable-nls"
" --disable-debug" + "--disable-debug"
" --enable-sjlj-exceptions" + "--enable-sjlj-exceptions"
" --enable-threads=win32" + "--enable-threads=win32"
" --disable-win32-registry" "--disable-win32-registry"
else if crossStageStatic then ] else if crossStageStatic then
" --disable-libssp --disable-nls" + [ "--disable-libssp"
" --without-headers" + "--disable-nls"
" --disable-threads " + "--without-headers"
" --disable-libgomp " + "--disable-threads "
" --disable-libquadmath" + "--disable-libgomp "
" --disable-shared" + "--disable-libquadmath"
" --disable-libatomic " + # libatomic requires libc "--disable-shared"
" --disable-decimal-float" # libdecnumber requires libc "--disable-libatomic " # libatomic requires libc
else "--disable-decimal-float" # libdecnumber requires libc
(if crossDarwin then " --with-sysroot=${getLib libcCross}/share/sysroot" ] else
else " --with-headers=${getDev libcCross}/include") + (if crossDarwin then ["--with-sysroot=${getLib libcCross}/share/sysroot"]
# Ensure that -print-prog-name is able to find the correct programs. else ["--with-headers=${getDev libcCross}/include"]) ++
" --enable-__cxa_atexit" + [ "--enable-__cxa_atexit"
" --enable-long-long" + "--enable-long-long"
(if crossMingw then ] ++
" --enable-threads=win32" +
" --enable-sjlj-exceptions" + (if crossMingw then [
" --enable-hash-synchronization" + "--enable-threads=win32"
" --disable-libssp" + "--enable-sjlj-exceptions"
" --disable-nls" + "--enable-hash-synchronization"
" --with-dwarf2" + "--disable-libssp"
"--disable-nls"
"--with-dwarf2"
# I think noone uses shared gcc libs in mingw, so we better do the same. # I think noone uses shared gcc libs in mingw, so we better do the same.
# In any case, mingw32 g++ linking is broken by default with shared libs, # In any case, mingw32 g++ linking is broken by default with shared libs,
# unless adding "-lsupc++" to any linking command. I don't know why. # unless adding "-lsupc++" to any linking command. I don't know why.
" --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 targetPlatform.libc == "uclibc" then ] else
optionals (targetPlatform.libc == "uclibc") [
# 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"
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
" --disable-libgomp" else "") + "--disable-libgomp"
" --enable-threads=posix" + ] ++
" --enable-nls" + [ "--enable-threads=posix"
" --disable-decimal-float") # No final libdecnumber (it may work only in 386) "--enable-nls"
"--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 targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else "";
bootstrap = targetPlatform == hostPlatform; bootstrap = targetPlatform == hostPlatform;
in in
@ -322,62 +304,86 @@ stdenv.mkDerivation ({
then [] then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = " configureFlags =
${if hostPlatform.isSunOS then # Basic dependencies
" --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + [
# On Illumos/Solaris GNU as is preferred "--with-gmp-include=${gmp.dev}/include"
" --with-gnu-as --without-gnu-ld " "--with-gmp-lib=${gmp.out}/lib"
else ""} "--with-mpfr-include=${mpfr.dev}/include"
--enable-lto "--with-mpfr-lib=${mpfr.out}/lib"
${if enableMultilib then "--enable-multilib --disable-libquadmath" else "--disable-multilib"} "--with-mpc=${libmpc}"
${if enableShared then "" else "--disable-shared"} ] ++
${if enablePlugin then "--enable-plugin" else "--disable-plugin"} optional (libelf != null) "--with-libelf=${libelf}" ++
${optionalString (isl != null) "--with-isl=${isl}"}
${if langJava then # Basic configuration
"--with-ecj-jar=${javaEcj} " + [
"--enable-lto"
"--disable-libstdcxx-pch"
"--without-included-gettext"
"--with-system-zlib"
"--enable-static"
"--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langJava "java"
++ optional langAda "ada"
++ optional langVhdl "vhdl"
++ optional langGo "go"
++ optional langObjC "objc"
++ optional langObjCpp "obj-c++"
++ optionals crossDarwin [ "objc" "obj-c++" ]
)
)
}"
] ++
(if enableMultilib
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"]) ++
optional (!enableShared) "--disable-shared" ++
(if enablePlugin
then ["--enable-plugin"]
else ["--disable-plugin"]) ++
# Optional features
optional (isl != null) "--with-isl=${isl}" ++
# Java options
optionals langJava [
"--with-ecj-jar=${javaEcj} "
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
"--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre " "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
else ""} ] ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
--with-gmp-include=${gmp.dev}/include
--with-gmp-lib=${gmp.out}/lib # Ada
--with-mpfr-include=${mpfr.dev}/include optional langAda "--enable-libada" ++
--with-mpfr-lib=${mpfr.out}/lib
--with-mpc=${libmpc} # Cross-compilation
${if libelf != null then "--with-libelf=${libelf}" else ""} optional (targetPlatform == hostPlatform) (
--disable-libstdcxx-pch let incDir = if hostPlatform.isDarwin
--without-included-gettext then "${darwin.usr-include}"
--with-system-zlib else "${getDev stdenv.cc.libc}/include";
--enable-static in "--with-native-system-header-dir=${incDir}"
--enable-languages=${ ) ++
concatStrings (intersperse ","
( optional langC "c" optional (targetPlatform == hostPlatform) (mkPlatformFlags stdenv.platform) ++
++ optional langCC "c++" optional (targetPlatform != hostPlatform) crossConfigureFlags ++
++ optional langFortran "fortran" optional (!bootstrap) "--disable-bootstrap" ++
++ optional langJava "java"
++ optional langAda "ada" # Platform-specific flags
++ optional langVhdl "vhdl" optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++
++ optional langGo "go" optionals hostPlatform.isSunOS [
++ optional langObjC "objc" "--enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit"
++ optional langObjCpp "obj-c++" # On Illumos/Solaris GNU as is preferred
++ optionals crossDarwin [ "objc" "obj-c++" ] "--with-gnu-as --without-gnu-ld"
) ]
) ;
}
${if targetPlatform == hostPlatform
then if hostPlatform.isDarwin
then " --with-native-system-header-dir=${darwin.usr-include}"
else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include"
else ""}
${if langAda then " --enable-libada" else ""}
${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""}
${if targetPlatform != hostPlatform then crossConfigureFlags else ""}
${if !bootstrap then "--disable-bootstrap" else ""}
${if targetPlatform == hostPlatform then platformFlags else ""}
";
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
@ -390,17 +396,13 @@ stdenv.mkDerivation ({
then "install-strip" then "install-strip"
else "install"; else "install";
/* For cross-built gcc (build != host == target) */
crossAttrs = let crossAttrs = let
xgccArch = targetPlatform.gcc.arch or null; xgccArch = targetPlatform.gcc.arch or null;
xgccCpu = targetPlatform.gcc.cpu or null; xgccCpu = targetPlatform.gcc.cpu or null;
xgccAbi = targetPlatform.gcc.abi or null; xgccAbi = targetPlatform.gcc.abi or null;
xgccFpu = targetPlatform.gcc.fpu or null; xgccFpu = targetPlatform.gcc.fpu or null;
xgccFloat = targetPlatform.gcc.float or null; xgccFloat = targetPlatform.gcc.float or null;
xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
in { in {
AR = "${targetPlatform.config}-ar"; AR = "${targetPlatform.config}-ar";
LD = "${targetPlatform.config}-ld"; LD = "${targetPlatform.config}-ld";
@ -414,37 +416,39 @@ stdenv.mkDerivation ({
# If we are making a cross compiler, cross != null # If we are making a cross compiler, cross != null
NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc;
dontStrip = true; dontStrip = true;
configureFlags = '' configureFlags =
${if enableMultilib then "" else "--disable-multilib"} optional (!enableMultilib) "--disable-multilib" ++
${if enableShared then "" else "--disable-shared"} optional (!enableShared) "--disable-shared" ++
${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""} optional langJava "--with-ecj-jar=${javaEcj.crossDrv}" ++
${if javaAwtGtk then "--enable-java-awt=gtk" else ""} optional javaAwtGtk "--enable-java-awt=gtk" ++
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""} optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr.crossDrv}" ++
--with-gmp=${gmp.crossDrv} [
--with-mpfr=${mpfr.crossDrv} "--with-gmp=${gmp.crossDrv}"
--with-mpc=${libmpc.crossDrv} "--with-mpfr=${mpfr.crossDrv}"
--disable-libstdcxx-pch "--with-mpc=${libmpc.crossDrv}"
--without-included-gettext "--disable-libstdcxx-pch"
--with-system-zlib "--without-included-gettext"
--enable-languages=${ "--with-system-zlib"
concatStrings (intersperse "," "--enable-languages=${
( optional langC "c" concatStrings (intersperse ","
++ optional langCC "c++" ( optional langC "c"
++ optional langFortran "fortran" ++ optional langCC "c++"
++ optional langJava "java" ++ optional langFortran "fortran"
++ optional langAda "ada" ++ optional langJava "java"
++ optional langVhdl "vhdl" ++ optional langAda "ada"
++ optional langGo "go" ++ optional langVhdl "vhdl"
++ optional langGo "go"
)
) )
) }"
} ] ++
${if langAda then " --enable-libada" else ""} optional langAda "--enable-libada" ++
${xwithArch} optional (xgccArch != null) "--with-arch=${xgccArch}" ++
${xwithCpu} optional (xgccCpu != null) "--with-cpu=${xgccCpu}" ++
${xwithAbi} optional (xgccAbi != null) "--with-abi=${xgccAbi}" ++
${xwithFpu} optional (xgccFpu != null) "--with-fpu=${xgccFpu}" ++
${xwithFloat} optional (xgccFloat != null) "--with-float=${xgccFloat}"
''; ;
buildFlags = ""; buildFlags = "";
}; };