From ccc5b08f203bf76d37717e04738bcb56576c9959 Mon Sep 17 00:00:00 2001 From: cidkidnix Date: Tue, 27 Jun 2023 17:27:35 -0500 Subject: [PATCH 1/3] Ensure we use LLVM on x86_64 iOS too --- pkgs/development/compilers/ghc/8.10.7.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 5badd8ca7e52f..2f359fd51a27f 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -10,7 +10,7 @@ , # GHC can be built with system libffi or a bundled one. libffi ? null -, useLLVM ? !stdenv.targetPlatform.isx86 +, useLLVM ? stdenv.targetPlatform.useiOSPrebuilt || !stdenv.targetPlatform.isx86 , # LLVM is conceptually a run-time-only depedendency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a # build-time dependency too. @@ -248,7 +248,10 @@ stdenv.mkDerivation (rec { buildInputs = [ perl bash ] ++ (libDeps hostPlatform); propagatedBuildInputs = [ targetPackages.stdenv.cc ] - ++ lib.optional useLLVM llvmPackages.llvm; + ++ lib.optionals useLLVM [ + llvmPackages.llvm + llvmPackages.llvm.out + ]; depsTargetTarget = map lib.getDev (libDeps targetPlatform); depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); From 1b8131b286ad031ad185f90fa8f9c03a0d8c95e8 Mon Sep 17 00:00:00 2001 From: cidkidnix Date: Thu, 29 Jun 2023 00:56:37 -0500 Subject: [PATCH 2/3] Make iOSSimulator build again --- pkgs/os-specific/darwin/xcode/sdk-pkgs.nix | 2 ++ pkgs/stdenv/cross/default.nix | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix index 6d8ed9f532260..a84914e0cd96d 100644 --- a/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix +++ b/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix @@ -22,6 +22,8 @@ rec { type = "derivation"; outPath = xcode + "/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${version}.sdk"; + iPhoneOSRoot = xcode + "/Contents/Developer/Platforms/iPhoneOS.platform"; + platform = targetPlatform.xcodePlatform; version = targetPlatform.sdkVer; }; diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index ef088bec75d7b..4844dc6f9ec7b 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -84,8 +84,13 @@ in lib.init bootStages ++ [ ++ lib.optional (hostPlatform.config == "x86_64-w64-mingw32") buildPackages.file ; + + # temp hack to avoid ios macos clash - preHook = lib.concatStringsSep "\n" + preHook = lib.optionalString (crossSystem.useiOSPrebuilt && crossSystem.isx86_64) '' + export DYLD_ROOT_PATH=${buildPackages.darwin.iosSdkPkgs.sdk.iPhoneOSRoot}/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot + echo -e "\n!! iOS Simulator in use !!\nDYLD_ROOT_PATH: $DYLD_ROOT_PATH\n!! iOS Simulator !!\n" + '' + lib.concatStringsSep "\n" (lib.filter (l: ! lib.strings.hasInfix "-sdk_version" l) (lib.strings.splitString "\n" old.preHook)); From 466d823b4deafd1159c5e8fb05a257a7792d31e0 Mon Sep 17 00:00:00 2001 From: cidkidnix Date: Tue, 11 Jul 2023 15:05:25 -0500 Subject: [PATCH 3/3] Fix GHC wrapper DYLD_ROOT_PATH --- .../haskell-modules/with-packages-wrapper.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix index 8c8833ad82e83..ac6e2b13525ba 100644 --- a/pkgs/development/haskell-modules/with-packages-wrapper.nix +++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, ghc, llvmPackages, packages, symlinkJoin, makeWrapper +{ lib, stdenv, ghc, darwin, llvmPackages, packages, symlinkJoin, makeWrapper , withLLVM ? !(stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isPowerPC) , postBuild ? "" , ghcLibdir ? null # only used by ghcjs, when resolving plugins @@ -44,6 +44,10 @@ let packageCfgDir = "${libDir}/package.conf.d"; paths = lib.filter (x: x ? isHaskellLibrary) (lib.closePropagation packages); hasLibraries = lib.any (x: x.isHaskellLibrary) paths; + + dyld_root_path = "${darwin.iosSdkPkgs.sdk.iPhoneOSRoot}/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot"; + isSimulator = stdenv.targetPlatform.isiOS && stdenv.targetPlatform.isx86_64; + # CLang is needed on Darwin for -fllvm to work: # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm llvm = lib.makeBinPath @@ -73,6 +77,9 @@ symlinkJoin { ${lib.optionalString (ghc.isGhcjs or false) ''--set NODE_PATH "${ghc.socket-io}/lib/node_modules"'' } \ + ${lib.optionalString (isSimulator) + ''--set DYLD_ROOT_PATH "${dyld_root_path}" \'' + } ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''} fi done @@ -92,7 +99,7 @@ symlinkJoin { for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do if [[ -x "${ghc}/bin/$prg" ]]; then rm -f $out/bin/$prg - makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" + makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" ${lib.optionalString (isSimulator) ''--set DYLD_ROOT_PATH "${dyld_root_path}"''} fi done