Skip to content

Commit ea8e124

Browse files
committed
gcc: always enable inhibit_libc=true for --without-headers builds
It's a follow-up to the breakage caused by 21966e1 ("gcc: pass --with-build-sysroot=/"). It caused `pkgsLLVM` cross-toolchain bootstrap breakage: $ nix build --no-link -f. pkgsLLVM.hello ... failed: /nix/store/...-x86_64-unknown-linux-gnu-stage-static-gcc-13.0.0.drv: ... configure flags: ... --enable-languages=c --disable-multilib \ --disable-shared --enable-plugin ... --disable-libssp --disable-nls \ --without-headers --disable-threads --disable-libgomp --disable-libquadmath \ --disable-shared --disable-libatomic --disable-decimal-float --disable-libmpx \ --disable-bootstrap \ \ --build=x86_64-unknown-linux-gnu \ --host=x86_64-unknown-linux-gnu \ --target=x86_64-unknown-linux-gnu ... The directory that should contain system headers does not exist: /usr/include make[2]: *** [Makefile:3279: stmp-fixinc] Error 1 shuffle=1658621302 rm gfdl.pod gcc.pod gcov-dump.pod gcov-tool.pod fsf-funding.pod gpl.pod cpp.pod gcov.pod lto-dump.pod make[2]: Leaving directory '/build/build/gcc' Note: it's a no-libc build. It's not expected to use any libc headers. But in this case fixincludes tries to run and uses default /usr/include location. Fixinsludes is not normally expected to run during cross-compilation on --without-headers. gcc/configure.ac: : ${inhibit_libc=false} if { { test x$host != x$target && test "x$with_sysroot" = x ; } || test x$with_newlib = xyes ; } && { test "x$with_headers" = xno || test ! -f "$target_header_dir/stdio.h"; } ; then inhibit_libc=true fi The change explicitly passes inhibit_libc=true to configure to disable include fixing on such cases. Fixed `nix build --no-link -f. pkgsLLVM.hello` toolchain bootstrap.
1 parent 21966e1 commit ea8e124

10 files changed

Lines changed: 21 additions & 10 deletions

File tree

pkgs/development/compilers/gcc/10/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ stdenv.mkDerivation ({
191191

192192
preConfigure = import ../common/pre-configure.nix {
193193
inherit lib;
194-
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit;
194+
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic;
195195
};
196196

197197
dontDisableStatic = true;

pkgs/development/compilers/gcc/11/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ stdenv.mkDerivation ({
199199

200200
preConfigure = import ../common/pre-configure.nix {
201201
inherit lib;
202-
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit;
202+
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic;
203203
};
204204

205205
dontDisableStatic = true;

pkgs/development/compilers/gcc/12/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ stdenv.mkDerivation ({
194194

195195
preConfigure = import ../common/pre-configure.nix {
196196
inherit lib;
197-
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit;
197+
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic;
198198
};
199199

200200
dontDisableStatic = true;

pkgs/development/compilers/gcc/4.8/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ stdenv.mkDerivation ({
198198

199199
preConfigure = import ../common/pre-configure.nix {
200200
inherit lib;
201-
inherit version targetPlatform hostPlatform langJava langGo;
201+
inherit version targetPlatform hostPlatform langJava langGo crossStageStatic;
202202
};
203203

204204
dontDisableStatic = true;

pkgs/development/compilers/gcc/4.9/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ stdenv.mkDerivation ({
218218

219219
preConfigure = import ../common/pre-configure.nix {
220220
inherit lib;
221-
inherit version targetPlatform hostPlatform langJava langGo;
221+
inherit version targetPlatform hostPlatform langJava langGo crossStageStatic;
222222
};
223223

224224
dontDisableStatic = true;

pkgs/development/compilers/gcc/6/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ stdenv.mkDerivation ({
230230

231231
preConfigure = import ../common/pre-configure.nix {
232232
inherit lib;
233-
inherit version targetPlatform hostPlatform gnatboot langJava langAda langGo;
233+
inherit version targetPlatform hostPlatform gnatboot langJava langAda langGo crossStageStatic;
234234
};
235235

236236
dontDisableStatic = true;

pkgs/development/compilers/gcc/7/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ stdenv.mkDerivation ({
197197

198198
preConfigure = import ../common/pre-configure.nix {
199199
inherit lib;
200-
inherit version targetPlatform hostPlatform langGo;
200+
inherit version targetPlatform hostPlatform langGo crossStageStatic;
201201
};
202202

203203
dontDisableStatic = true;

pkgs/development/compilers/gcc/8/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ stdenv.mkDerivation ({
180180

181181
preConfigure = import ../common/pre-configure.nix {
182182
inherit lib;
183-
inherit version targetPlatform hostPlatform langGo;
183+
inherit version targetPlatform hostPlatform langGo crossStageStatic;
184184
};
185185

186186
dontDisableStatic = true;

pkgs/development/compilers/gcc/9/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ stdenv.mkDerivation ({
193193

194194
preConfigure = import ../common/pre-configure.nix {
195195
inherit lib;
196-
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit;
196+
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic;
197197
};
198198

199199
dontDisableStatic = true;

pkgs/development/compilers/gcc/common/pre-configure.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
, langAda ? false
44
, langJava ? false
55
, langJit ? false
6-
, langGo }:
6+
, langGo
7+
, crossStageStatic
8+
}:
79

810
assert langJava -> lib.versionOlder version "7";
911
assert langAda -> gnatboot != null; let
@@ -67,3 +69,12 @@ in lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
6769
+ lib.optionalString (targetPlatform.config == hostPlatform.config && targetPlatform != hostPlatform) ''
6870
substituteInPlace configure --replace is_cross_compiler=no is_cross_compiler=yes
6971
''
72+
73+
# Normally (for host != target case) --without-headers automatically
74+
# enables 'inhibit_libc=true' in gcc's gcc/configure.ac. But case of
75+
# gcc->clang "cross"-compilation manages to evade it: there
76+
# hostPlatform != targetPlatform, hostPlatform.config == targetPlatform.config.
77+
# We explicitly inhibit libc headers use in this case as well.
78+
+ lib.optionalString (targetPlatform != hostPlatform && crossStageStatic) ''
79+
export inhibit_libc=true
80+
''

0 commit comments

Comments
 (0)