From dde70f937826f5a3545a6e52eed8303740237abf Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Sat, 7 Sep 2013 11:02:32 +0200 Subject: [PATCH] clang-wrapper: Optionally use libc++ instead of libstdc++. --- pkgs/build-support/clang-wrapper/builder.sh | 3 +++ pkgs/build-support/clang-wrapper/clang-wrapper.sh | 5 ++++- pkgs/build-support/clang-wrapper/default.nix | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/clang-wrapper/builder.sh b/pkgs/build-support/clang-wrapper/builder.sh index 9f1542e04113..3f90b9d32bd0 100644 --- a/pkgs/build-support/clang-wrapper/builder.sh +++ b/pkgs/build-support/clang-wrapper/builder.sh @@ -58,11 +58,14 @@ fi doSubstitute() { local src=$1 local dst=$2 + local uselibcxx= + if test -n "$libcxx" && echo $dst | fgrep ++; then uselibcxx=$libcxx; fi # Can't use substitute() here, because replace may not have been # built yet (in the bootstrap). sed \ -e "s^@out@^$out^g" \ -e "s^@shell@^$shell^g" \ + -e "s^@libcxx@^$uselibcxx^g" \ -e "s^@clang@^$clang^g" \ -e "s^@clangProg@^$clangProg^g" \ -e "s^@binutils@^$binutils^g" \ diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh index 4f710856868b..84067844cad8 100644 --- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh +++ b/pkgs/build-support/clang-wrapper/clang-wrapper.sh @@ -52,7 +52,6 @@ if test "$nonFlagArgs" = "0"; then dontLink=1 fi - # Optionally filter out paths not refering to the store. params=("$@") if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then @@ -79,6 +78,10 @@ if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then params=("${rest[@]}") fi +if test -n "@libcxx@"; then + NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem@libcxx@/include/c++/v1 -stdlib=libc++" + NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxx@/lib -stdlib=libc++ -lc++abi" +fi # Add the flags for the C compiler proper. extraAfter=($NIX_CFLAGS_COMPILE) diff --git a/pkgs/build-support/clang-wrapper/default.nix b/pkgs/build-support/clang-wrapper/default.nix index 9f560d0d2fba..1b2a02fa86a4 100644 --- a/pkgs/build-support/clang-wrapper/default.nix +++ b/pkgs/build-support/clang-wrapper/default.nix @@ -7,7 +7,7 @@ { name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" , clang ? null, libc ? null, binutils ? null, coreutils ? null, shell ? "" -, zlib ? null +, zlib ? null, libcxx ? null }: assert nativeTools -> nativePrefix != ""; @@ -33,7 +33,7 @@ stdenv.mkDerivation { utils = ./utils.sh; addFlags = ./add-flags; - inherit nativeTools nativeLibc nativePrefix clang clangVersion; + inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx; gcc = clang.gcc; libc = if nativeLibc then null else libc; binutils = if nativeTools then null else binutils;