[libcxx-commits] [libcxx] [libcxx] Add necessary compile flags for targeting the GPU (PR #99333)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 17 07:51:31 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/99333.diff
1 Files Affected:
- (modified) libcxx/CMakeLists.txt (+9)
``````````diff
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 190a97db9462f..a72e5aca0903f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -491,6 +491,15 @@ include(HandleLibcxxFlags)
# 'config-ix' use them during feature checks. It also adds them to both
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
+# Targeting the GPU requires a clang compiler and several extra flags.
+if (${LLVM_RUNTIMES_TARGET} MATCHES "^amdgcn")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
+ add_flags("-nogpulib" "-flto" "-fconvergent-functions" "-Xclang" "-mcode-object-version=none")
+elseif (${LLVM_RUNTIMES_TARGET} MATCHES "^nvptx")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument")
+ add_flags("-nogpulib" "-flto" "-fconvergent-functions" "--cuda-feature=+ptx63")
+endif()
+
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)
``````````
</details>
https://github.com/llvm/llvm-project/pull/99333
More information about the libcxx-commits
mailing list