[libcxx-commits] [libcxx] [libcxx] Add necessary compile flags for targeting the GPU (PR #99333)
Joseph Huber via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 31 07:26:30 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/99333
>From c9a9d02343e911d255485a09105ea777b1912af8 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 17 Jul 2024 09:43:56 -0500
Subject: [PATCH] [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.
---
libcxx/CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 08406076236e9..1f4170fea0c88 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -472,6 +472,13 @@ include(HandleLibcxxFlags)
# 'config-ix' use them during feature checks. It also adds them to both
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
+# These are required to make CMake flag checking work.
+if (${LLVM_RUNTIMES_TARGET} MATCHES "^amdgcn")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
+elseif (${LLVM_RUNTIMES_TARGET} MATCHES "^nvptx")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument")
+endif()
+
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
add_flags_if_supported("-mdefault-visibility-export-mapping=explicit")
set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF)
More information about the libcxx-commits
mailing list