Search code examples
gcccudathrustnvcc

Overriding header search order for nvcc


I have a CUDA project that uses Thrust. Thrust comes with the CUDA Toolkit but I'd like to use a more recent version I've checked out.

I invoke nvcc with -isystem=/path/to/thrust but the underlying compiler invocation looks like

gcc ... "-I/usr/local/cuda-10.1/bin/../targets/x86_64-linux/include"  -isystem "/path/to/thrust"

Since gcc searches directories from left to right, that means that the Toolkit's Thrust headers are found first.

Can I override this behavior to find my Thrust checkout first without modifying the CUDA Toolkit or writing a compiler wrapper script?


Solution

  • I simply needed to use -I instead of -isystem.

    I also learned that -Xcompiler --foo,--bar allows me to inject other arguments should I need them.