From 46eeef1898ffbf57330ec31b96a6c2d89f8fcb36 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Mon, 7 May 2018 13:22:50 -0700 Subject: [PATCH] tests.cc-wrapper: verify building with sanitizers --- pkgs/build-support/cc-wrapper/default.nix | 4 ++-- pkgs/development/compilers/llvm/6/default.nix | 1 + pkgs/test/cc-wrapper/default.nix | 5 +++++ pkgs/test/cc-wrapper/sanitizers.c | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 pkgs/test/cc-wrapper/sanitizers.c diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 43cd87fb459..8f99da805ec 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -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, gnugrep ? null +, isGNU ? false, isClang ? cc.isClang or false, isCompilerRT ? false, gnugrep ? null , buildPackages ? {} }: @@ -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 default_cxx_stdlib_compile; + inherit libc nativeTools nativeLibc nativePrefix isGNU isClang isCompilerRT default_cxx_stdlib_compile; emacsBufferSetup = pkgs: '' ; We should handle propagation here too diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index 81d41673b25..da5a97a9bba 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -53,6 +53,7 @@ let targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]; + isCompilerRT = true; extraBuildCommands = '' rsrc="$out/resource-root" mkdir "$rsrc" diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 41a7685ed2e..06113e40561 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -38,6 +38,11 @@ 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 ''; diff --git a/pkgs/test/cc-wrapper/sanitizers.c b/pkgs/test/cc-wrapper/sanitizers.c new file mode 100644 index 00000000000..93dd78a903c --- /dev/null +++ b/pkgs/test/cc-wrapper/sanitizers.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char **argv) +{ + fprintf(stderr, "ok\n"); + return 0; +}