FindMPI+CUDA: insufficient compiler flags escaping for nvcc?
setup:
Ubuntu 20.04
MPI implementation: mpich (from apt install mpich
)
cmake version 3.19.6 (from https://conan.io/center/cmake)
CUDA 11.2 (from docker pull nvidia/cuda:11.2.1-devel-ubuntu20.04
)
CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(test LANGUAGES CUDA CXX)
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
find_package(MPI REQUIRED COMPONENTS CXX)
add_executable(test test.cu)
target_link_libraries(test MPI::MPI_CXX)
test.cu — empty file
configure:
# mkdir build && cd build && cmake ..
-- The CUDA compiler identification is NVIDIA 11.2.142
-- The CXX compiler identification is GNU 9.3.0
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found MPI_CXX: /usr/lib/x86_64-linux-gnu/libmpichcxx.so (found version "3.1")
-- Found MPI: TRUE (found version "3.1") found components: CXX
-- Configuring done
-- Generating done
-- Build files have been written to: /root/test/build
build:
# make VERBOSE=1
/root/.conan/data/cmake/3.19.6/_/_/package/5c09c752508b674ca5cb1f2d327b5a2d582866c8/bin/cmake -S/root/oops -B/root/oops/build --check-build-system CMakeFiles/Makefile.cmake 0
/root/.conan/data/cmake/3.19.6/_/_/package/5c09c752508b674ca5cb1f2d327b5a2d582866c8/bin/cmake -E cmake_progress_start /root/oops/build/CMakeFiles /root/oops/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/root/oops/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory '/root/oops/build'
cd /root/oops/build && /root/.conan/data/cmake/3.19.6/_/_/package/5c09c752508b674ca5cb1f2d327b5a2d582866c8/bin/cmake -E cmake_depends "Unix Makefiles" /root/oops /root/oops /root/oops/build /root/oops/build /root/oops/build/CMakeFiles/test.dir/DependInfo.cmake --color=
Dependee "/root/oops/build/CMakeFiles/test.dir/DependInfo.cmake" is newer than depender "/root/oops/build/CMakeFiles/test.dir/depend.internal".
Dependee "/root/oops/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/root/oops/build/CMakeFiles/test.dir/depend.internal".
Scanning dependencies of target test
make[2]: Leaving directory '/root/oops/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory '/root/oops/build'
[ 33%] Building CUDA object CMakeFiles/test.dir/test.cu.o
/usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -isystem=/usr/include/x86_64-linux-gnu/mpich --generate-code=arch=compute_52,code=[compute_52,sm_52] -std=c++14 -x cu -dc /root/oops/test.cu -o CMakeFiles/test.dir/test.cu.o
[ 66%] Linking CUDA device code CMakeFiles/test.dir/cmake_device_link.o
/root/.conan/data/cmake/3.19.6/_/_/package/5c09c752508b674ca5cb1f2d327b5a2d582866c8/bin/cmake -E cmake_link_script CMakeFiles/test.dir/dlink.txt --verbose=1
/usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler=-Wl,-Bsymbolic-functions -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/test.dir/test.cu.o -o CMakeFiles/test.dir/cmake_device_link.o -lcudadevrt -lcudart_static -lrt -lpthread -ldl
gcc: error: unrecognized command line option '-Wl'; did you mean '-W'?
make[2]: *** [CMakeFiles/test.dir/build.make:105: CMakeFiles/test.dir/cmake_device_link.o] Error 1
make[2]: Leaving directory '/root/oops/build'
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory '/root/oops/build'
make: *** [Makefile:103: all] Error 2
Linking CUDA device code
step fails with gcc: error: unrecognized command line option '-Wl'; did you mean '-W'?
presumably because of -Xcompiler=-Wl,-Bsymbolic-functions
argument.
-Wl,-Bsymbolic-functions
flag gets there from INTERFACE_LINK_OPTIONS
of MPI::MPI_CXX
.
Trying command manually with -Xcompiler=\"-Wl,-Bsymbolic-functions\"
instead passes successfully (assuming that flag should be there for device code linking phase?).