aboutsummaryrefslogtreecommitdiff
path: root/libc/include/CMakeLists.txt
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-02-22 15:29:29 -0600
committerGitHub <noreply@github.com>2024-02-22 15:29:29 -0600
commit47b7c91abe7af3133a591aa2e73fffa30826f986 (patch)
tree43e35c3d4c203b54fb5882f10c655e7d49ceed6c /libc/include/CMakeLists.txt
parent45fe67dd61a6ac7df84d3a586e41c36a4767757f (diff)
downloadllvm-47b7c91abe7af3133a591aa2e73fffa30826f986.zip
llvm-47b7c91abe7af3133a591aa2e73fffa30826f986.tar.gz
llvm-47b7c91abe7af3133a591aa2e73fffa30826f986.tar.bz2
[libc] Rework the GPU build to be a regular target (#81921)
Summary: This is a massive patch because it reworks the entire build and everything that depends on it. This is not split up because various bots would fail otherwise. I will attempt to describe the necessary changes here. This patch completely reworks how the GPU build is built and targeted. Previously, we used a standard runtimes build and handled both NVPTX and AMDGPU in a single build via multi-targeting. This added a lot of divergence in the build system and prevented us from doing various things like building for the CPU / GPU at the same time, or exporting the startup libraries or running tests without a full rebuild. The new appraoch is to handle the GPU builds as strict cross-compiling runtimes. The first step required https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC` target to build for the GPU without touching the other targets. This means that the GPU uses all the same handling as the other builds in `libc`. The new expected way to build the GPU libc is with `LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`. The second step was reworking how we generated the embedded GPU library by moving it into the library install step. Where we previously had one `libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This patch includes the necessary clang / OpenMP changes to make that not break the bots when this lands. We unfortunately still require that the NVPTX target has an `internal` target for tests. This is because the NVPTX target needs to do LTO for the provided version (The offloading toolchain can handle it) but cannot use it for the native toolchain which is used for making tests. This approach is vastly superior in every way, allowing us to treat the GPU as a standard cross-compiling target. We can now install the GPU utilities to do things like use the offload tests and other fun things. Some certain utilities need to be built with `--target=${LLVM_HOST_TRIPLE}` as well. I think this is a fine workaround as we will always assume that the GPU `libc` is a cross-build with a functioning host. Depends on https://github.com/llvm/llvm-project/pull/81557
Diffstat (limited to 'libc/include/CMakeLists.txt')
-rw-r--r--libc/include/CMakeLists.txt6
1 files changed, 3 insertions, 3 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index dc3c9b8..9090b3b 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -4,7 +4,7 @@ set(LIBC_INCLUDE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
include(LLVMLibCHeaderRules)
# The GPU build wants to install files in the compiler's resource directory.
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+if(LIBC_TARGET_OS_IS_GPU)
include(GetClangResourceDir)
endif()
@@ -586,7 +586,7 @@ add_gen_header(
.llvm-libc-types.wchar_t
)
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+if(LIBC_TARGET_OS_IS_GPU)
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/gpu)
add_gen_header(
@@ -638,7 +638,7 @@ foreach(target IN LISTS all_install_header_targets)
# The GPU optionally provides the supported declarations externally so
# offloading languages like CUDA and OpenMP know what is supported by libc. We
# install these in the compiler's resource directory at a preset location.
- if(LIBC_TARGET_ARCHITECTURE_IS_GPU AND PACKAGE_VERSION)
+ if(LIBC_TARGET_OS_IS_GPU AND PACKAGE_VERSION)
get_target_property(decls_file ${target} DECLS_FILE_PATH)
if(NOT decls_file)
continue()