<commit_before>{ runCommand
, lib
, llvm
, clang
, binutils
, stdenv
, coreutils
, gnugrep
, targetPlatform
}:

/* As of this writing, known-good prefix/arch/simulator triples:
 * aarch64-apple-darwin14 | arm64  | false
 * arm-apple-darwin10     | armv7  | false
 * i386-apple-darwin11    | i386   | true
 * x86_64-apple-darwin14  | x86_64 | true
 */

let

  prefix = targetPlatform.config;
  inherit (targetPlatform) arch;
  simulator = targetPlatform.isiPhoneSimulator or false;

  sdkType = if simulator then "Simulator" else "OS";

  sdkVer = "10.2";

  sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk";

  /* TODO: Properly integrate with gcc-cross-wrapper */
  wrapper = import ../../../build-support/cc-wrapper {
    inherit stdenv coreutils gnugrep;
    nativeTools = false;
    nativeLibc = false;
    inherit binutils;
    libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}";
    cc = clang;
    extraBuildCommands = ''
      if ! [ -d ${sdk} ]; then
          echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2
          exit 1
      fi
      # ugh
      tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp
      mv cc-cflags.tmp $out/nix-support/cc-cflags
      echo "-target ${prefix} -arch ${arch} -idirafter ${sdk}/usr/include ${if simulator then "-mios-simulator-version-min=7.0" else "-miphoneos-version-min=7.0"}" >> $out/nix-support/cc-cflags

      # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust
      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
    '';
  };
in {
  cc = runCommand "${prefix}-cc" { passthru = { inherit sdkType sdkVer sdk; }; } ''
    mkdir -p $out/bin
    ln -sv ${wrapper}/bin/clang $out/bin/${prefix}-cc
    mkdir -p $out/nix-support
    echo ${llvm} > $out/nix-support/propagated-native-build-inputs
    cat > $out/nix-support/setup-hook <<EOF
    if test "\$dontSetConfigureCross" != "1"; then
        configureFlags="\$configureFlags --host=${prefix}"
    fi
    EOF
    fixupPhase
  '';

  binutils = runCommand "${prefix}-binutils" {} ''
    mkdir -p $out/bin
    ln -sv ${wrapper}/bin/ld $out/bin/${prefix}-ld
    for prog in ar nm ranlib; do
      ln -s ${binutils}/bin/$prog $out/bin/${prefix}-$prog
    done
    fixupPhase
  '';
}<commit_msg>ios-cross: Just properly use the cc-wrapper<commit_after>{ runCommand
, lib
, llvm
, clang
, binutils
, stdenv
, coreutils
, gnugrep
, hostPlatform, targetPlatform
}:

/* As of this writing, known-good prefix/arch/simulator triples:
 * aarch64-apple-darwin14 | arm64  | false
 * arm-apple-darwin10     | armv7  | false
 * i386-apple-darwin11    | i386   | true
 * x86_64-apple-darwin14  | x86_64 | true
 */

let

  prefix = targetPlatform.config;
  inherit (targetPlatform) arch;
  simulator = targetPlatform.isiPhoneSimulator or false;

  sdkType = if simulator then "Simulator" else "OS";

  sdkVer = "10.2";

  sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk";

in (import ../../../build-support/cc-wrapper {
    inherit stdenv coreutils gnugrep runCommand;
    nativeTools = false;
    nativeLibc = false;
    inherit binutils;
    libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}";
    inherit (clang) cc;
    inherit hostPlatform targetPlatform;
    extraBuildCommands = ''
      if ! [ -d ${sdk} ]; then
          echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2
          exit 1
      fi
      # ugh
      tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp
      mv cc-cflags.tmp $out/nix-support/cc-cflags
      echo "-target ${prefix} -arch ${arch} -idirafter ${sdk}/usr/include ${if simulator then "-mios-simulator-version-min=7.0" else "-miphoneos-version-min=7.0"}" >> $out/nix-support/cc-cflags

      # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust
      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
    '';
  }) // {
    inherit sdkType sdkVer sdk;
  }
{'fraction_non_alphanumeric': 0.1491882404563405, 'fraction_numerical': 0.01733216322948662, 'mean_word_length': 3.1332728921124207, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2549730', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1543, 'n_words': 370}