[libc-commits] [libc] [libc] Fix building the RPC server with LIBC_NAMESPACE (PR #65642)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Thu Sep 7 10:14:41 PDT 2023
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/65642:
A recent patch required the implementation to define `LIBC_NAMESPACE`.
For GPU offloading we provide a static library whose internal
implementation relies on the `libc` headers. This is a separate library
that is constructed during the "bootstrap" phase. This patch moves the
definition of the `LIBC_NAMESPACE` CMake variable up so its available
during bootstrapping and adds it to the definition of the RPC server.
>From d2f4ac04afa5d464d15af8ed7c3469f3f096204a Mon Sep 17 00:00:00 2001
From: Joseph Huber <jhuber6 at vols.utk.edu>
Date: Thu, 7 Sep 2023 12:08:12 -0500
Subject: [PATCH] [libc] Fix building the RPC server with LIBC_NAMESPACE
Summary:
A recent patch required the implementation to define `LIBC_NAMESPACE`.
For GPU offloading we provide a static library whose internal
implementation relies on the `libc` headers. This is a separate library
that is constructed during the "bootstrap" phase. This patch moves the
definition of the `LIBC_NAMESPACE` CMake variable up so its available
during bootstrapping and adds it to the definition of the RPC server.
---
libc/CMakeLists.txt | 10 +++++-----
libc/utils/gpu/server/CMakeLists.txt | 2 ++
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index b2ad91828dce8d3..0665cf0f7a1d900 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -19,6 +19,11 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
+# Defining a global namespace to enclose all libc functions.
+set(LIBC_NAMESPACE "__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}"
+ CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
+)
+
if(LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
if(NOT LIBC_HDRGEN_EXE)
# We need to set up hdrgen first since other targets depend on it.
@@ -49,11 +54,6 @@ option(LIBC_CMAKE_VERBOSE_LOGGING
# Path libc/scripts directory.
set(LIBC_BUILD_SCRIPTS_DIR "${LIBC_SOURCE_DIR}/utils/build_scripts")
-# Defining a global namespace to enclose all libc functions.
-set(LIBC_NAMESPACE "__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}"
- CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
-)
-
if(NOT LIBC_NAMESPACE MATCHES "^__llvm_libc")
message(FATAL_ERROR "Invalid LIBC_NAMESPACE. Must start with '__llvm_libc' was '${LIBC_NAMESPACE}'")
endif()
diff --git a/libc/utils/gpu/server/CMakeLists.txt b/libc/utils/gpu/server/CMakeLists.txt
index c802d79e63644a6..a1c4229d386f899 100644
--- a/libc/utils/gpu/server/CMakeLists.txt
+++ b/libc/utils/gpu/server/CMakeLists.txt
@@ -8,6 +8,8 @@ target_include_directories(llvmlibc_rpc_server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR
# Ignore unsupported clang attributes if we're using GCC.
target_compile_options(llvmlibc_rpc_server PUBLIC
$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>)
+target_compile_definitions(llvmlibc_rpc_server PUBLIC
+ LIBC_NAMESPACE=${LIBC_NAMESPACE})
# Install the server and associated header.
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/rpc_server.h
More information about the libc-commits
mailing list