mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
gcc: set up sysroot for the Darwin SDK
The GCC bootstrap builds each stage with an unwrapped GCC, which needs to correctly handle looking for libraries and headers in sysroot. Setting the native header folder to `/usr/include` will actually cause GCC to search `<sysroot>/usr/include`, which is the SDKROOT in nixpkgs.
This commit is contained in:
parent
a77d0eb819
commit
e50074418d
@ -5,7 +5,7 @@
|
||||
, threadsCross
|
||||
, version
|
||||
|
||||
, binutils, gmp, mpfr, libmpc, isl
|
||||
, apple-sdk, binutils, gmp, mpfr, libmpc, isl
|
||||
|
||||
, enableLTO
|
||||
, enableMultilib
|
||||
@ -112,7 +112,11 @@ let
|
||||
]
|
||||
++ lib.optionals (!withoutTargetLibc) [
|
||||
(if libcCross == null
|
||||
then "--with-native-system-header-dir=${lib.getDev stdenv.cc.libc}/include"
|
||||
then (
|
||||
# GCC will search for the headers relative to SDKROOT on Darwin, so it will find them in the store.
|
||||
if targetPlatform.isDarwin then "--with-native-system-header-dir=/usr/include"
|
||||
else "--with-native-system-header-dir=${lib.getDev stdenv.cc.libc}/include"
|
||||
)
|
||||
else "--with-native-system-header-dir=${lib.getDev libcCross}${libcCross.incdir or "/include"}")
|
||||
# gcc builds for cross-compilers (build != host) or cross-built
|
||||
# gcc (host != target) always apply the offset prefix to disentangle
|
||||
@ -132,7 +136,8 @@ let
|
||||
#
|
||||
# We pick "/" path to effectively avoid sysroot offset and make it work
|
||||
# as a native case.
|
||||
"--with-build-sysroot=/"
|
||||
# Darwin requires using the SDK as the sysroot for `SDKROOT` to work correctly.
|
||||
"--with-build-sysroot=${if targetPlatform.isDarwin then apple-sdk.sdkroot else "/"}"
|
||||
# Same with the stdlibc++ headers embedded in the gcc output
|
||||
"--with-gxx-include-dir=${placeholder "out"}/include/c++/${version}/"
|
||||
]
|
||||
|
@ -34,6 +34,7 @@
|
||||
, nukeReferences
|
||||
, callPackage
|
||||
, majorMinorVersion
|
||||
, apple-sdk
|
||||
, cctools
|
||||
, darwin
|
||||
}:
|
||||
@ -105,6 +106,7 @@ let
|
||||
;
|
||||
# inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gcc${majorVersion}.cc.override)" | jq '.[]' --raw-output'
|
||||
inherit
|
||||
apple-sdk
|
||||
binutils
|
||||
buildPackages
|
||||
cargo
|
||||
|
Loading…
Reference in New Issue
Block a user