From 77550df8e68b5034d6a434c709be69adee1940cc Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 26 Jan 2019 10:17:57 -0500 Subject: [PATCH] cc-wrapper: add libcxx for libcxxClang clang needs to find headers + libraries for compiling with libc++. We need to add a libcxx argument to cc-wrapper. This means you do not have to pass in c++ headers directly. This resolves the last case remaining of #30670. Darwin clang++ now works properly. Fixes #30670 --- pkgs/build-support/cc-wrapper/default.nix | 14 +++++++++----- pkgs/development/compilers/llvm/5/default.nix | 1 + pkgs/development/compilers/llvm/6/default.nix | 1 + pkgs/development/compilers/llvm/7/default.nix | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 47c992d1f6ba..75a05d5277bf 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -13,6 +13,7 @@ , extraPackages ? [], extraBuildCommands ? "" , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , buildPackages ? {} +, libcxx ? null }: with stdenvNoCC.lib; @@ -44,8 +45,11 @@ let # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. coreutils_bin = if nativeTools then "" else getBin coreutils; - default_cxx_stdlib_compile = optionalString (targetPlatform.isLinux && !(cc.isGNU or false) && !nativeTools && cc ? gcc) - "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)"; + default_cxx_stdlib_compile = if (targetPlatform.isLinux && !(cc.isGNU or false) && !nativeTools && cc ? gcc) then + "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)" + else if targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false) then + "-isystem ${libcxx}/include/c++/v1" + else ""; # The "infix salt" is a arbitrary string added in the middle of env vars # defined by cc-wrapper's hooks so that multiple cc-wrappers can be used @@ -256,9 +260,9 @@ stdenv.mkDerivation { echo "$ccLDFlags" > $out/nix-support/cc-ldflags echo "$ccCFlags" > $out/nix-support/cc-cflags - '' - - + optionalString propagateDoc '' + '' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) '' + echo " -L${libcxx}/lib" >> $out/nix-support/cc-ldflags + '' + optionalString propagateDoc '' ## ## Man page and info support ## diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix index 68ee80fa7a62..6807240df81e 100644 --- a/pkgs/development/compilers/llvm/5/default.nix +++ b/pkgs/development/compilers/llvm/5/default.nix @@ -59,6 +59,7 @@ let libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index 5ee551f6b6b1..ae51c19ec728 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -59,6 +59,7 @@ let libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix index 47c6e9e383f3..3f1192d96263 100644 --- a/pkgs/development/compilers/llvm/7/default.nix +++ b/pkgs/development/compilers/llvm/7/default.nix @@ -59,6 +59,7 @@ let libcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi