[libc-commits] [libc] [libc] Add CMake cache file for the GPU build (PR #124589)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jan 27 09:02:09 PST 2025


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/124589

Summary:
This introduces libc cache files and adds one for building the GPU
support. The cache files will set defaults for these arguments which can
be overridden if the user needs to. They also serve as documentation for
how the builid is expected to look.


>From 197086eca8de6800b507af74066aeb58a9a54cb0 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 27 Jan 2025 10:58:39 -0600
Subject: [PATCH] [libc] Add CMake cache file for the GPU build

Summary:
This introduces libc cache files and adds one for building the GPU
support. The cache files will set defaults for these arguments which can
be overridden if the user needs to. They also serve as documentation for
how the builid is expected to look.
---
 libc/cmake/caches/gpu.cmake | 4 ++++
 libc/docs/gpu/building.rst  | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 libc/cmake/caches/gpu.cmake

diff --git a/libc/cmake/caches/gpu.cmake b/libc/cmake/caches/gpu.cmake
new file mode 100644
index 00000000000000..1867db9ffa12e7
--- /dev/null
+++ b/libc/cmake/caches/gpu.cmake
@@ -0,0 +1,4 @@
+set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_RUNTIME_TARGETS default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda CACHE STRING "") 
+set(RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "compiler-rt;libc" CACHE STRING "")
+set(RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "compiler-rt;libc" CACHE STRING "")
diff --git a/libc/docs/gpu/building.rst b/libc/docs/gpu/building.rst
index 88643575ae4d93..94d3f1f644e5ca 100644
--- a/libc/docs/gpu/building.rst
+++ b/libc/docs/gpu/building.rst
@@ -58,7 +58,8 @@ OpenMP support. We then set ``RUNTIMES_<triple>_LLVM_ENABLE_RUNTIMES`` to enable
 ``libc`` for the GPU targets. The ``LLVM_RUNTIME_TARGETS`` sets the enabled
 targets to build, in this case we want the default target and the GPU targets.
 Note that if ``libc`` were included in ``LLVM_ENABLE_RUNTIMES`` it would build
-targeting the default host environment as well.
+targeting the default host environment as well. Alternatively, you can point
+your build towards the ``libc/cmake/caches/gpu.cmake`` cache file with ``-C``.
 
 Runtimes cross build
 --------------------



More information about the libc-commits mailing list