NVIDIA / nvbench

CUDA Kernel Benchmarking Library
Apache License 2.0
528 stars 66 forks source link

Project assumes CXX compiler and and CUDACXXHOST compiler are the same #126

Open theHamsta opened 1 year ago

theHamsta commented 1 year ago

When using this project as a with CUDAHOSTCXX=g++-11 and CXX=clang++-17 as dependency, I'm getting the following compilation error.

FAILED: _deps/nvbench-build/nvbench/CMakeFiles/nvbench.dir/blocking_kernel.cu.o 
ccache /usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -ccbin=/usr/lib/ccache/g++ -Dnvbench_EXPORTS -I/home/stephan/projects/proviz-app-samples/debug/_deps/nvbench-src -I/home/stephan/projects/proviz-app-samples/debug/_deps/nvbench-build -I/home/stephan/projects/proviz-app-samples/debug/_deps/fmt-src/include -I/home/stephan/projects/proviz-app-samples/debug/_deps/nvbench-build/nvbench/detail -isystem=/usr/local/cuda/include -isystem=/home/stephan/projects/proviz-app-samples/debug/_deps/nlohmann_json-src/include -Wno-deprecated-gpu-targets -allow-unsupported-compiler -arch=native -lineinfo -g -Xcompiler=-fPIC -Wall -Wextra -Wpedantic -Xcompiler=-Wall -Xcompiler=-Wextra -Xcompiler=-Wconversion -Xcompiler=-Woverloaded-virtual -Xcompiler=-Wcast-qual -Xcompiler=-Wpointer-arith -Xcompiler=-Wunused-local-typedef -Xcompiler=-Wunused-parameter -Xcompiler=-Wvla -Xcompiler=-Wgnu -Xcudafe=--display_error_number -Wno-deprecated-gpu-targets -std=c++17 -MD -MT _deps/nvbench-build/nvbench/CMakeFiles/nvbench.dir/blocking_kernel.cu.o -MF _deps/nvbench-build/nvbench/CMakeFiles/nvbench.dir/blocking_kernel.cu.o.d -x cu -c /home/stephan/projects/proviz-app-samples/debug/_deps/nvbench-src/nvbench/blocking_kernel.cu -o _deps/nvbench-build/nvbench/CMakeFiles/nvbench.dir/blocking_kernel.cu.o
g++: error: unrecognized command-line option ‘-Wunused-local-typedef’; did you mean ‘-Wunused-local-typedefs’?
g++: error: unrecognized command-line option ‘-Wgnu’

This seems to be the case because it is implicitly assumed here

https://github.com/NVIDIA/nvbench/blob/e477bb386289a11ad8d7e358cff6527cfc593974/cmake/NVBenchConfigTarget.cmake#L28-L34

that the CUDA host compiler will accept any flags that the CXX compiler accepts.

I'm also not sure whether the second ${} for the if is necessary as if will implicitly resolve the variable https://github.com/NVIDIA/nvbench/blob/e477bb386289a11ad8d7e358cff6527cfc593974/cmake/NVBenchConfigTarget.cmake#L28

This project also fails to build with NVBench_TOPLEVEL_PROJECT (and thus NVBench_ENABLE_WERROR because it causes a lot of clang warnings. Since I'm using nvbench as a dependency WERROR doesn't cause problems for me.

A simplified solution to this problem could be to disable the CUDA host compiler warnings if CUDA host C++ compiler and C++ compiler are not the same.