Skip to content

Commit 77be018

Browse files
committed
[libcxx] Add necessary compile flags for targeting the GPU
Summary: The GPU target will always be a sufficiently new `clang`, so we can assume these flags are present. We need to first set `CMAKE_REQUIRED_FLAGS` to these values so that the `check_cxx_compile_flag` utilities work. Then, we need to add several things to the compiler flags that are necessary for correctness and optimal code output.
1 parent 8393ea5 commit 77be018

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libcxx/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,15 @@ include(HandleLibcxxFlags)
491491
# 'config-ix' use them during feature checks. It also adds them to both
492492
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
493493

494+
# Targeting the GPU requires a clang compiler and several extra flags.
495+
if (${LLVM_RUNTIMES_TARGET} MATCHES "^amdgcn")
496+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
497+
add_flags("-nogpulib" "-flto" "-fconvergent-functions" "-Xclang" "-mcode-object-version=none")
498+
elseif (${LLVM_RUNTIMES_TARGET} MATCHES "^nvptx")
499+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument")
500+
add_flags("-nogpulib" "-flto" "-fconvergent-functions" "--cuda-feature=+ptx63")
501+
endif()
502+
494503
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
495504
add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
496505
set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)

0 commit comments

Comments
 (0)