diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index aa8ecc62e55ad87..ae4ef6bddf676ae 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -66,7 +66,6 @@ let "--disable-threads" "--disable-libgomp" "--disable-libquadmath" - "--disable-shared" "--disable-libatomic" # requires libc "--disable-decimal-float" # requires libc "--disable-libmpx" # requires libc diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix index 58e44b96b5d34e2..bfdab20df1a2a43 100644 --- a/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -1,10 +1,13 @@ -{ lib, version, buildPlatform, hostPlatform, targetPlatform +{ lib +, stdenv +, version, buildPlatform, hostPlatform, targetPlatform , gnat-bootstrap ? null , langAda ? false , langJava ? false , langJit ? false , langGo -, crossStageStatic +, withoutTargetLibc +, enableShared , enableMultilib }: @@ -109,6 +112,17 @@ in lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' export inhibit_libc=true '' +# Trick to build a gcc that is capable of emitting shared libraries *without* having the +# targetPlatform libc available beforehand. Taken from: +# https://web.archive.org/web/20170222224855/http://frank.harvard.edu/~coldwell/toolchain/ +# https://web.archive.org/web/20170224235700/http://frank.harvard.edu/~coldwell/toolchain/t-linux.diff ++ lib.optionalString (targetPlatform != hostPlatform && withoutTargetLibc && enableShared) + (lib.optionalString (!stdenv.targetPlatform.isPower) '' + echo 'libgcc.a: crti.o crtn.o' >> libgcc/Makefile.in + '' + '' + echo 'SHLIB_LC=' >> libgcc/Makefile.in + '') + + lib.optionalString (!enableMultilib && hostPlatform.is64bit && !hostPlatform.isMips64n32) '' export linkLib64toLib=1 '' diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index 8d6dd50548e5151..12859de8a20fe8b 100644 --- a/pkgs/os-specific/windows/default.nix +++ b/pkgs/os-specific/windows/default.nix @@ -20,7 +20,7 @@ lib.makeScope newScope (self: with self; { crossThreadsStdenv = overrideCC crossLibcStdenv (if stdenv.hostPlatform.useLLVM or false then buildPackages.llvmPackages_8.clangNoLibcxx - else buildPackages.gccCrossStageStatic.override (old: { + else buildPackages.gccWithoutTargetLibc.override (old: { bintools = old.bintools.override { libc = libcCross; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index faa09a9732f4e62..ff0b9db18e3aad2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14346,7 +14346,7 @@ with pkgs; xbursttools = callPackage ../tools/misc/xburst-tools { # It needs a cross compiler for mipsel to build the firmware it will # load into the Ben Nanonote - gccCross = pkgsCross.ben-nanonote.buildPackages.gccCrossStageStatic; + gccCross = pkgsCross.ben-nanonote.buildPackages.gccWithoutTargetLibc; autoconf = buildPackages.autoconf269; }; @@ -15266,7 +15266,7 @@ with pkgs; dontStrip = true; }))); - gccCrossLibcStdenv = overrideCC stdenv buildPackages.gccCrossStageStatic; + gccCrossLibcStdenv = overrideCC stdenv buildPackages.gccWithoutTargetLibc; crossLibcStdenv = if stdenv.hostPlatform.useLLVM or false || stdenv.hostPlatform.isDarwin @@ -15275,7 +15275,7 @@ with pkgs; # The GCC used to build libc for the target platform. Normal gccs will be # built with, and use, that cross-compiled libc. - gccCrossStageStatic = assert stdenv.targetPlatform != stdenv.hostPlatform; let + gccWithoutTargetLibc = assert stdenv.targetPlatform != stdenv.hostPlatform; let libcCross1 = binutilsNoLibc.libc; in wrapCCWith { cc = gccFun { @@ -15292,7 +15292,6 @@ with pkgs; langCC = false; libcCross = libcCross1; targetPackages.stdenv.cc.bintools = binutilsNoLibc; - enableShared = false; }; bintools = binutilsNoLibc; libc = libcCross1;