gcc-4.8: Hook in cross-darwin libc and binutils.
Let's finally hook everything into the existing cross-building infrastructure. We're using --with-sysroot instead of --with-headers here, because the XCode SDK contains references to /usr/lib. I've tried to patch those references, but unfortunately (at least with install_name_tool) it isn't possible to change those refernces in stub dylibs. So after bugging @tpoechtrager with annoying questions (thanks again), I think my initial approach (patching the SDK itself and/or regenerating the dylib stubs) was way to complicated so I ended up with this implementation. Also, I've added a condition to binutilsCross to use cctools if the libc is set to libSystem. This might need some cleanups someday, mainly to figure out how to properly bridge cctools and binutils. So, as an example on how to cross-compile GNU Hello to Darwin, you can use something like this: (import <nixpkgs> { crossSystem = { config = "x86_64-apple-darwin13"; arch = "x86_64"; libc = "libSystem"; platform = {}; }; }).hello.crossDrv Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
dd10bb3181
commit
9a0a85827c
2 changed files with 19 additions and 8 deletions
|
@ -117,7 +117,8 @@ let version = "4.8.2";
|
||||||
withMode;
|
withMode;
|
||||||
|
|
||||||
/* Cross-gcc settings */
|
/* Cross-gcc settings */
|
||||||
crossMingw = (cross != null && cross.libc == "msvcrt");
|
crossMingw = cross != null && cross.libc == "msvcrt";
|
||||||
|
crossDarwin = cross != null && cross.libc == "libSystem";
|
||||||
crossConfigureFlags = let
|
crossConfigureFlags = let
|
||||||
gccArch = stdenv.cross.gcc.arch or null;
|
gccArch = stdenv.cross.gcc.arch or null;
|
||||||
gccCpu = stdenv.cross.gcc.cpu or null;
|
gccCpu = stdenv.cross.gcc.cpu or null;
|
||||||
|
@ -161,7 +162,12 @@ let version = "4.8.2";
|
||||||
" --disable-shared" +
|
" --disable-shared" +
|
||||||
" --disable-decimal-float" # libdecnumber requires libc
|
" --disable-decimal-float" # libdecnumber requires libc
|
||||||
else
|
else
|
||||||
" --with-headers=${libcCross}/include" +
|
(if crossDarwin then
|
||||||
|
" --with-sysroot=${libcCross}/share/sysroot" +
|
||||||
|
" --with-as=${binutilsCross}/bin/${cross.config}-as" +
|
||||||
|
" --with-ld=${binutilsCross}/bin/${cross.config}-ld"
|
||||||
|
else
|
||||||
|
" --with-headers=${libcCross}/include") +
|
||||||
" --enable-__cxa_atexit" +
|
" --enable-__cxa_atexit" +
|
||||||
" --enable-long-long" +
|
" --enable-long-long" +
|
||||||
(if crossMingw then
|
(if crossMingw then
|
||||||
|
|
|
@ -2430,8 +2430,10 @@ let
|
||||||
gccCrossStageStatic = let
|
gccCrossStageStatic = let
|
||||||
isMingw = (stdenv.cross.libc == "msvcrt");
|
isMingw = (stdenv.cross.libc == "msvcrt");
|
||||||
isMingw64 = isMingw && stdenv.cross.config == "x86_64-w64-mingw32";
|
isMingw64 = isMingw && stdenv.cross.config == "x86_64-w64-mingw32";
|
||||||
|
isDarwin = stdenv.cross.libc == "libSystem";
|
||||||
libcCross1 = if isMingw64 then windows.mingw_w64_headers else
|
libcCross1 = if isMingw64 then windows.mingw_w64_headers else
|
||||||
if isMingw then windows.mingw_headers1 else null;
|
if isMingw then windows.mingw_headers1 else
|
||||||
|
if isDarwin then darwin.xcode else null;
|
||||||
in
|
in
|
||||||
wrapGCCCross {
|
wrapGCCCross {
|
||||||
gcc = forceNativeDrv (lib.addMetaAttrs { hydraPlatforms = []; } (
|
gcc = forceNativeDrv (lib.addMetaAttrs { hydraPlatforms = []; } (
|
||||||
|
@ -3452,11 +3454,13 @@ let
|
||||||
gold = false;
|
gold = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
binutilsCross = lowPrio (forceNativeDrv (import ../development/tools/misc/binutils {
|
binutilsCross =
|
||||||
inherit stdenv fetchurl zlib;
|
if crossSystem != null && crossSystem.libc == "libSystem" then darwin.cctools
|
||||||
noSysDirs = true;
|
else lowPrio (forceNativeDrv (import ../development/tools/misc/binutils {
|
||||||
cross = assert crossSystem != null; crossSystem;
|
inherit stdenv fetchurl zlib;
|
||||||
}));
|
noSysDirs = true;
|
||||||
|
cross = assert crossSystem != null; crossSystem;
|
||||||
|
}));
|
||||||
|
|
||||||
bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };
|
bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };
|
||||||
bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { };
|
bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { };
|
||||||
|
@ -4249,6 +4253,7 @@ let
|
||||||
else if name == "msvcrt" && stdenv.cross.config == "x86_64-w64-mingw32" then
|
else if name == "msvcrt" && stdenv.cross.config == "x86_64-w64-mingw32" then
|
||||||
windows.mingw_w64
|
windows.mingw_w64
|
||||||
else if name == "msvcrt" then windows.mingw_headers3
|
else if name == "msvcrt" then windows.mingw_headers3
|
||||||
|
else if name == "libSystem" then darwin.xcode
|
||||||
else throw "Unknown libc";
|
else throw "Unknown libc";
|
||||||
|
|
||||||
libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc;
|
libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc;
|
||||||
|
|
Loading…
Reference in a new issue