From 96092dc93640b8ad6520a8bae6f78d62eaba0ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 1 Jul 2020 21:55:06 +0100 Subject: stdenv: make -nostdinc work as intended Right now we add glibc to search path also -nostdinc was provided, which breaks projects providing their own gcc. --- pkgs/test/cc-wrapper/default.nix | 8 ++++++++ pkgs/test/cc-wrapper/nostdinc-main.c | 8 ++++++++ pkgs/test/cc-wrapper/stdio.h | 1 + 3 files changed, 17 insertions(+) create mode 100644 pkgs/test/cc-wrapper/nostdinc-main.c create mode 100644 pkgs/test/cc-wrapper/stdio.h (limited to 'pkgs/test') diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 7bd82b4ab2a5..c0c89d63ffff 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -45,6 +45,14 @@ in 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 + printf "Check whether -nostdinc and -nostdinc++ is handled correctly" >&2 + mkdir -p std-include + cp ${./stdio.h} std-include/stdio.h + NIX_DEBUG=1 $CC -I std-include -nostdinc -o nostdinc-main ${./nostdinc-main.c} + ./nostdinc-main + $CXX -I std-include -nostdinc++ -o nostdinc-main++ ${./nostdinc-main.c} + ./nostdinc-main++ + ${optionalString sanitizersWorking '' printf "checking whether sanitizers are fully functional... ">&2 $CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c} diff --git a/pkgs/test/cc-wrapper/nostdinc-main.c b/pkgs/test/cc-wrapper/nostdinc-main.c new file mode 100644 index 000000000000..f71d155b1b27 --- /dev/null +++ b/pkgs/test/cc-wrapper/nostdinc-main.c @@ -0,0 +1,8 @@ +// This one should not come from libc because of -nostdinc +#include + +int main(int argc, char *argv[]) { + // provided by our own stdio.h + foo(); + return 0; +} diff --git a/pkgs/test/cc-wrapper/stdio.h b/pkgs/test/cc-wrapper/stdio.h new file mode 100644 index 000000000000..4bddf1d9d486 --- /dev/null +++ b/pkgs/test/cc-wrapper/stdio.h @@ -0,0 +1 @@ +static void foo(void) {} -- cgit v1.2.3