Skip to content

Commit

Permalink
Enable building with clang (limit strict error checking to GCC) (#1452)
Browse files Browse the repository at this point in the history
Compiling RAFT with a non-GCC compiler can be tricky as there is very strict error checking (`-Werror=all-warnings` for instance) and therefore, the build is almost guaranteed to fail due to warnings elevated to errors. 

I am sometimes building RAFT with clang because of its `-ftime-trace` feature, which helps find code that increases compile times.

This PR contains the changes I typically make to the CMakeLists.txt to enable clang compilation. With this change, strict error checking is only performed when the host compiler is GCC.

Tested with clang version 11.1.

Authors:
  - Allard Hendriksen (https://github.com/ahendriksen)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1452
  • Loading branch information
ahendriksen authored Apr 25, 2023
1 parent 1866120 commit de19c17
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cpp/cmake/modules/ConfigureCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ if(DISABLE_DEPRECATION_WARNINGS)
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=-Wno-deprecated-declarations)
endif()

# Be very strict when compiling with GCC as host compiler (and thus more lenient when compiling with
# clang)
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND RAFT_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations)
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)

# set warnings as errors
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0)
list(APPEND RAFT_CUDA_FLAGS -Werror=all-warnings)
endif()
endif()

if(CUDA_LOG_COMPILE_TIME)
Expand All @@ -31,12 +39,6 @@ list(APPEND RAFT_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
# make sure we produce smallest binary size
list(APPEND RAFT_CUDA_FLAGS -Xfatbin=-compress-all)

# set warnings as errors
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0)
list(APPEND RAFT_CUDA_FLAGS -Werror=all-warnings)
endif()
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)

# Option to enable line info in CUDA device compilation to allow introspection when profiling /
# memchecking
if(CUDA_ENABLE_LINEINFO)
Expand Down

0 comments on commit de19c17

Please sign in to comment.