@@ -6,7 +6,7 @@
66, stdenv
77, coreutils
88, gnugrep
9−, targetPlatform
9+, hostPlatform, targetPlatform
1010}:
1111
1212/* As of this writing, known-good prefix/arch/simulator triples:
@@ -28,14 +28,14 @@ let
2828
2929 sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk";
3030
31− /* TODO: Properly integrate with gcc-cross-wrapper */
32− wrapper = import ../../../build-support/cc-wrapper {
33− inherit stdenv coreutils gnugrep;
31+in (import ../../../build-support/cc-wrapper {
32+ inherit stdenv coreutils gnugrep runCommand;
3433 nativeTools = false;
3534 nativeLibc = false;
3635 inherit binutils;
3736 libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}";
38− cc = clang;
37+ inherit (clang) cc;
38+ inherit hostPlatform targetPlatform;
3939 extraBuildCommands = ''
4040 if ! [ -d ${sdk} ]; then
4141 echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2
@@ -49,27 +49,6 @@ let
4949 # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust
5050 echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before
5151 '';
52− };
53−in {
54− cc = runCommand "${prefix}-cc" { passthru = { inherit sdkType sdkVer sdk; }; } ''
55− mkdir -p $out/bin
56− ln -sv ${wrapper}/bin/clang $out/bin/${prefix}-cc
57− mkdir -p $out/nix-support
58− echo ${llvm} > $out/nix-support/propagated-native-build-inputs
59− cat > $out/nix-support/setup-hook <<EOF
60− if test "\$dontSetConfigureCross" != "1"; then
61− configureFlags="\$configureFlags --host=${prefix}"
62− fi
63− EOF
64− fixupPhase
65− '';
66−
67− binutils = runCommand "${prefix}-binutils" {} ''
68− mkdir -p $out/bin
69− ln -sv ${wrapper}/bin/ld $out/bin/${prefix}-ld
70− for prog in ar nm ranlib; do
71− ln -s ${binutils}/bin/$prog $out/bin/${prefix}-$prog
72− done
73− fixupPhase
74− '';
75−}
52+ }) // {
53+ inherit sdkType sdkVer sdk;
54+ }