Pcl: Build error with clang because nvcc uses gcc anyway

Created on 25 Jan 2014  Â·  5Comments  Â·  Source: PointCloudLibrary/pcl

When I

export CC=clang
export CXX=clang++

and build GPU-related things, nvcc fails with gcc: error: unrecognised command line option ‘-Qunused-arguments’ because it is called with -ccbin /usr/bin/gcc (it should be clang here).

The relevant files:

CMakeLists.txt:

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  SET(CMAKE_COMPILER_IS_CLANG 1)
  if("${CMAKE_C_FLAGS}" STREQUAL "")
    SET(CMAKE_C_FLAGS "-Qunused-arguments")
  endif()

cmake/pcl_find_cuda.cmake:

Recent versions of cmake set CUDA_HOST_COMPILER to CMAKE_C_COMPILER which
# on OSX defaults to clang (/usr/bin/cc), but this is not a supported cuda
# compiler.  So, here we will preemptively set CUDA_HOST_COMPILER to gcc if
# that compiler exists in /usr/bin.

My cmake output:

cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DOPENNI_LIBRARY=/data/nh910/src/pcl-deps/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10/Lib/libOpenNI.so -DOPENNI_INCLUDE_DIR=/data/nh910/src/pcl-deps/OpenNI/Platform/Linux/Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10/Include -DBUILD_visualization=ON -DBUILD_apps=ON -DBUILD_CUDA=ON -DBUILD_GPU=ON -DBUILD_gpu_kinfu=ON -DBUILD_gpu_kinfu_large_scale=ON -DCMAKE_BUILD_TYPE=Debug
-- The C compiler identification is Clang 3.2.0            
-- The CXX compiler identification is Clang 3.2.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works

Most helpful comment

Closing since this is most likely obsolete.

For what it's worth, I had exactly the same problem with nvcc, clang and "-Qunused-arguments" last week in a different project. So it looks like it's still topical.

All 5 comments

Also, https://github.com/niwibe/phantompy/issues/8 seems to describe the same problem. The linked thread seems to explain what is going on, especially this post, which is followd by a fix that removes:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")

PCL has something similar in cmake/pcl_find_qt5.cmake:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${qt5_module}_EXECUTABLE_COMPILE_FLAGS}")

Closing since this is most likely obsolete. Sorry for the lack of attention from the maintainers.

Closing since this is most likely obsolete.

For what it's worth, I had exactly the same problem with nvcc, clang and "-Qunused-arguments" last week in a different project. So it looks like it's still topical.

The excerpt from cmake/pcl_find_cuda.cmake that you posted in the issue description is not present anymore, i.e. we respect the user's choice of compiler and don't force CUDA_HOST_COMPILER to be GCC. This means that our compiler option list now matches the actual compiler used.

I tried to compile PCL HEAD with Clang and CUDA 10.2 and did not face this problem. (Though there was some other issue with Eigen includes, but that's a different topic.)

@taketwo That is great, perhaps the project I had this problem with used an older copy of find_cuda.cmake.

Was this page helpful?
0 / 5 - 0 ratings