diff options
author | John Ericson <git@JohnEricson.me> | 2023-05-08 06:55:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 06:55:52 -0400 |
commit | f4868c6c7da2f28aca762f69759f07ffe9536356 (patch) | |
tree | d2b15595a645d054c9c05d319f904528ea6e7503 /pkgs/test/cc-wrapper | |
parent | e7799046c76fc7105e859ef50c2e5f8f8872a0b2 (diff) | |
parent | 40c914f1be018545992a5b2e3182f3b940f907ce (diff) |
Merge pull request #229754 from rrbutani/fix/cc-wrapper-extra-positional-args
Support `--` in `cc-wrapper`
Diffstat (limited to 'pkgs/test/cc-wrapper')
-rw-r--r-- | pkgs/test/cc-wrapper/default.nix | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 6fd7d9f45db87..43e8e7a214268 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -13,6 +13,8 @@ in stdenv.mkDerivation { name = "cc-wrapper-test"; buildCommand = '' + set -o pipefail + NIX_DEBUG=1 $CC -v NIX_DEBUG=1 $CXX -v @@ -43,6 +45,27 @@ in stdenv.mkDerivation { ''} ''} + ${# See: https://github.com/llvm/llvm-project/commit/ed1d07282cc9d8e4c25d585e03e5c8a1b6f63a74 + # `gcc` does not support this so we gate the test on `clang` + lib.optionalString stdenv.cc.isClang '' + printf "checking whether cc-wrapper accepts -- followed by positional (file) args..." >&2 + mkdir -p positional + + # Make sure `--` is not parsed as a "non flag arg"; we should get an + # input file error here and *not* a linker error. + { ! $CC --; } |& grep -q "no input files" + + # And that positional file args _must_ be files (this is just testing + # that we remembered to put the `--` back in the args to the compiler): + { ! $CC -c -- -o foo ${./foo.c}; } \ + |& grep -q "no such file or directory: '-o'" + + # Now check that we accept single and multiple positional file args: + $CC -c -DVALUE=42 -o positional/foo.o -- ${./foo.c} + $CC -o positional/main -- positional/foo.o ${./ldflags-main.c} + ${emulator} ./positional/main + ''} + printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2 mkdir -p foo/include cp ${./foo.c} foo/include/foo.h |