diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 5be64bebcd4d..98060f864f91 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -214,13 +214,10 @@ stdenv.mkDerivation (rec { '' + lib.optionalString useLLVM '' export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" - '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let - # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. - # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - clang = if targetCC.isClang then targetCC else llvmPackages.clang; - in '' - export CLANG="${clang}/bin/${clang.targetPrefix}clang" - '') + '' + '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' + # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm + export CLANG="${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang" + '' + '' echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index ffa2c473eec6..f865ce0b2933 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -219,13 +219,10 @@ stdenv.mkDerivation (rec { '' + lib.optionalString useLLVM '' export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" - '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let - # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. - # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - clang = if targetCC.isClang then targetCC else llvmPackages.clang; - in '' - export CLANG="${clang}/bin/${clang.targetPrefix}clang" - '') + '' + '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' + # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm + export CLANG="${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang" + '' + '' echo -n "${buildMK dontStrip}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix index d377328692cb..ac319ec130e6 100644 --- a/pkgs/development/compilers/ghc/9.0.1.nix +++ b/pkgs/development/compilers/ghc/9.0.1.nix @@ -180,13 +180,10 @@ stdenv.mkDerivation (rec { '' + lib.optionalString useLLVM '' export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" - '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let - # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. - # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - clang = if targetCC.isClang then targetCC else llvmPackages.clang; - in '' - export CLANG="${clang}/bin/${clang.targetPrefix}clang" - '') + '' + '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' + # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm + export CLANG="${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang" + '' + '' echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/9.2.1.nix b/pkgs/development/compilers/ghc/9.2.1.nix index 20062358db50..23158fe07aec 100644 --- a/pkgs/development/compilers/ghc/9.2.1.nix +++ b/pkgs/development/compilers/ghc/9.2.1.nix @@ -180,13 +180,10 @@ stdenv.mkDerivation (rec { '' + lib.optionalString useLLVM '' export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" - '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let - # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. - # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - clang = if targetCC.isClang then targetCC else llvmPackages.clang; - in '' - export CLANG="${clang}/bin/${clang.targetPrefix}clang" - '') + '' + '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' + # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm + export CLANG="${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang" + '' + '' echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 537b735b4a21..a0ffddf33f11 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -194,13 +194,10 @@ stdenv.mkDerivation (rec { '' + lib.optionalString useLLVM '' export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" - '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let - # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. - # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - clang = if targetCC.isClang then targetCC else llvmPackages.clang; - in '' - export CLANG="${clang}/bin/${clang.targetPrefix}clang" - '') + '' + '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' + # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm + export CLANG="${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang" + '' + '' # otherwise haddock fails when generating the compiler docs export LANG=C.UTF-8