Skip to content

Commit 4792ae5

Browse files
authored
[libc] Fix building the RPC server with LIBC_NAMESPACE (#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.
1 parent 11d5c7b commit 4792ae5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libc/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
1919

2020
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")
2121

22+
# Defining a global namespace to enclose all libc functions.
23+
set(LIBC_NAMESPACE "__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}"
24+
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
25+
)
26+
2227
if(LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
2328
if(NOT LIBC_HDRGEN_EXE)
2429
# We need to set up hdrgen first since other targets depend on it.
@@ -49,11 +54,6 @@ option(LIBC_CMAKE_VERBOSE_LOGGING
4954
# Path libc/scripts directory.
5055
set(LIBC_BUILD_SCRIPTS_DIR "${LIBC_SOURCE_DIR}/utils/build_scripts")
5156

52-
# Defining a global namespace to enclose all libc functions.
53-
set(LIBC_NAMESPACE "__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}"
54-
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
55-
)
56-
5757
if(NOT LIBC_NAMESPACE MATCHES "^__llvm_libc")
5858
message(FATAL_ERROR "Invalid LIBC_NAMESPACE. Must start with '__llvm_libc' was '${LIBC_NAMESPACE}'")
5959
endif()

libc/utils/gpu/server/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ target_include_directories(llvmlibc_rpc_server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR
88
# Ignore unsupported clang attributes if we're using GCC.
99
target_compile_options(llvmlibc_rpc_server PUBLIC
1010
$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>)
11+
target_compile_definitions(llvmlibc_rpc_server PUBLIC
12+
LIBC_NAMESPACE=${LIBC_NAMESPACE})
1113

1214
# Install the server and associated header.
1315
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/rpc_server.h

0 commit comments

Comments
 (0)