1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 21:21:06 +00:00

clang_6: fix sanitizers under libstdc++

This commit is contained in:
Benjamin Saunders 2018-05-24 14:43:31 -07:00
parent 11d26c797f
commit b0d0b1adfe
3 changed files with 11 additions and 8 deletions

View file

@ -9,7 +9,7 @@
, stdenvNoCC, nativeTools, propagateDoc ? !nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" , stdenvNoCC, nativeTools, propagateDoc ? !nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell , cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell
, extraPackages ? [], extraBuildCommands ? "" , extraPackages ? [], extraBuildCommands ? ""
, isGNU ? false, isClang ? cc.isClang or false, isCompilerRT ? false, gnugrep ? null , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {} , buildPackages ? {}
}: }:
@ -90,7 +90,7 @@ stdenv.mkDerivation {
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an # Binutils, and Apple's "cctools"; "bintools" as an attempt to find an
# unused middle-ground name that evokes both. # unused middle-ground name that evokes both.
inherit bintools; 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: '' emacsBufferSetup = pkgs: ''
; We should handle propagation here too ; We should handle propagation here too

View file

@ -38,10 +38,16 @@ let
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
libstdcxxClang = wrapCCWith { libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped; cc = tools.clang-unwrapped;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook targetLlvmLibraries.compiler-rt ];
extraBuildCommands = stdenv.lib.optionalString stdenv.targetPlatform.isLinux '' 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 echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
''; '';
}; };
@ -53,7 +59,6 @@ let
targetLlvmLibraries.libcxxabi targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt targetLlvmLibraries.compiler-rt
]; ];
isCompilerRT = true;
extraBuildCommands = '' extraBuildCommands = ''
rsrc="$out/resource-root" rsrc="$out/resource-root"
mkdir "$rsrc" mkdir "$rsrc"

View file

@ -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} NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c}
./ldflags-check ./ldflags-check
'' + stdenv.lib.optionalString (stdenv.cc.isCompilerRT or false) ''
$CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c} $CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c}
./sanitizers ./sanitizers
'' + ''
touch $out touch $out
''; '';