Skip to content

Commit

Permalink
clang_6: fix sanitizers under libstdc++
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed May 24, 2018
1 parent 11d26c7 commit b0d0b1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
, stdenvNoCC, nativeTools, propagateDoc ? !nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell
, extraPackages ? [], extraBuildCommands ? ""
, isGNU ? false, isClang ? cc.isClang or false, isCompilerRT ? false, gnugrep ? null
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {}
}:

Expand Down Expand Up @@ -90,7 +90,7 @@ stdenv.mkDerivation {
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an
# unused middle-ground name that evokes both.
inherit bintools;
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang isCompilerRT default_cxx_stdlib_compile;
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile;

emacsBufferSetup = pkgs: ''
; We should handle propagation here too
Expand Down
13 changes: 9 additions & 4 deletions pkgs/development/compilers/llvm/6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ let

clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;

libstdcxxClang = wrapCCWith {
libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
extraPackages = [ libstdcxxHook ];
extraBuildCommands = stdenv.lib.optionalString stdenv.targetPlatform.isLinux ''
extraPackages = [ libstdcxxHook targetLlvmLibraries.compiler-rt ];
extraBuildCommands = ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString stdenv.targetPlatform.isLinux ''
echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
'';
};
Expand All @@ -53,7 +59,6 @@ let
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
];
isCompilerRT = true;
extraBuildCommands = ''
rsrc="$out/resource-root"
mkdir "$rsrc"
Expand Down
2 changes: 0 additions & 2 deletions pkgs/test/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ stdenv.mkDerivation {
NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c}
./ldflags-check
'' + stdenv.lib.optionalString (stdenv.cc.isCompilerRT or false) ''
$CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c}
./sanitizers
'' + ''
touch $out
'';
Expand Down

0 comments on commit b0d0b1a

Please sign in to comment.