[libc-commits] [PATCH] D140309: [libc][gpu][NFC] Move CMake logic to prepare GPU build to a separate file.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Dec 19 10:20:31 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d681955b876: [libc][gpu][NFC] Move CMake logic to prepare GPU build to a separate file. (authored by sivachandra).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140309/new/

https://reviews.llvm.org/D140309

Files:
  libc/CMakeLists.txt
  libc/cmake/modules/prepare_libc_gpu_build.cmake


Index: libc/cmake/modules/prepare_libc_gpu_build.cmake
===================================================================
--- /dev/null
+++ libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -0,0 +1,26 @@
+# Set up the target architectures to build the GPU libc for.
+set(all_gpu_architectures "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62;"
+                          "sm_70;sm_72;sm_75;sm_80;sm_86;gfx700;gfx701;gfx801;"
+                          "gfx803;gfx900;gfx902;gfx906;gfx908;gfx90a;gfx90c;"
+                          "gfx940;gfx1010;gfx1030;gfx1031;gfx1032;gfx1033;"
+                          "gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;"
+                          "gfx1103")
+set(LIBC_GPU_ARCHITECTURES ${all_gpu_architectures} CACHE STRING
+    "List of GPU architectures to build the libc for.")
+if(LIBC_GPU_ARCHITECTURES STREQUAL "all")
+  set(LIBC_GPU_ARCHITECTURES ${all_gpu_architectures} FORCE)
+endif()
+
+# Ensure the compiler is a valid clang when building the GPU target.
+set(req_ver "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU AND
+   NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND
+       ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${req_ver}"))
+  message(FATAL_ERROR "Cannot build libc for GPU. CMake compiler "
+                      "'${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' "
+                      " is not `Clang ${req_ver}.")
+endif()
+if(LLVM_LIBC_FULL_BUILD)
+  message(FATAL_ERROR "LLVM_LIBC_FULL_BUILD must be enabled to build libc for "
+                      "GPU.")
+endif()
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -55,15 +55,6 @@
 option(LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR "Build LLVM libc tests assuming our implementation-defined behavior" ON)
 option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" OFF)
 
-# Set up the target architectures to build for the GPU
-set(ALL_GPU_ARCHITECTURES "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62;sm_70;sm_72;sm_75;sm_80;sm_86;gfx700;gfx701;gfx801;gfx803;gfx900;gfx902;gfx906;gfx908;gfx90a;gfx90c;gfx940;gfx1010;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103")
-set(LLVM_LIBC_GPU_ARCHITECTURES ${ALL_GPU_ARCHITECTURES} CACHE STRING "List of GPU architectures to support in LLVM libc")
-if (LLVM_LIBC_GPU_ARCHITECTURES STREQUAL "all")
-  set(LIBC_GPU_ARCHITECTURES ${ALL_GPU_ARCHITECTURES})
-else()
-  set(LIBC_GPU_ARCHITECTURES ${LLVM_LIBC_GPU_ARCHITECTURES})
-endif()
-
 set(LLVM_LIBC_TARGET_OS ${CMAKE_SYSTEM_NAME} CACHE STRING "Target operating system for LLVM libc")
 string(TOLOWER ${LLVM_LIBC_TARGET_OS} LIBC_TARGET_OS)
 
@@ -71,13 +62,8 @@
 include(LLVMLibCArchitectures)
 include(LLVMLibCCheckMPFR)
 
-# Ensure the compiler is a valid clang when building the GPU target.
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND 
-  ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}"))
-  message(FATAL_ERROR "Cannot build GPU library, CMake compiler '${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' is not `Clang ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}`")
-endif()
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU AND NOT LLVM_LIBC_FULL_BUILD)
-  message(FATAL_ERROR "Cannot build GPU library, LLVM_LIBC_FULL_BUILD must be enabled")
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  include(prepare_libc_gpu_build)
 endif()
 
 if(LLVM_LIBC_CLANG_TIDY)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140309.483997.patch
Type: text/x-patch
Size: 3621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221219/d6a99b8c/attachment.bin>


More information about the libc-commits mailing list