Skip to content

Commit c9a9d02

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 ebdcb76 commit c9a9d02

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libcxx/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,13 @@ include(HandleLibcxxFlags)
472472
# 'config-ix' use them during feature checks. It also adds them to both
473473
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
474474

475+
# These are required to make CMake flag checking work.
476+
if (${LLVM_RUNTIMES_TARGET} MATCHES "^amdgcn")
477+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
478+
elseif (${LLVM_RUNTIMES_TARGET} MATCHES "^nvptx")
479+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument")
480+
endif()
481+
475482
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
476483
add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
477484
set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)

0 commit comments

Comments
 (0)