From c876c7498eee66ae77f49b0075e3217f7625f1b2 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 30 Nov 2021 22:51:52 +0100 Subject: [PATCH] haskell.compiler.*: only set CLANG to match llc/opt * By taking clang from llvmPackages we make sure there is no version mismatch between LLVM (where llc and opt come from) and clang (which previously would be taken from stdenv on darwin for example). * Only pass CLANG if useLLVM is true. Previously we also set this if targetCC was clang. This would cause potentially confusing behavior if llc and opt as well as clang are provided via PATH (and GHC is compiled with useLLVM == false), because clang from PATH would be ignored, but not llc and opt. --- pkgs/development/compilers/ghc/8.10.7.nix | 11 ++++------- pkgs/development/compilers/ghc/8.8.4.nix | 11 ++++------- pkgs/development/compilers/ghc/9.0.1.nix | 11 ++++------- pkgs/development/compilers/ghc/9.2.1.nix | 11 ++++------- pkgs/development/compilers/ghc/head.nix | 11 ++++------- 5 files changed, 20 insertions(+), 35 deletions(-) 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