Skip to content

Commit 278cc74

Browse files
[libc] support fully oot build
1 parent c99bd3c commit 278cc74

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

libc/CMakeLists.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.20.0)
22
set(LLVM_SUBPROJECT_TITLE "libc")
33

4+
include(CheckCXXCompilerFlag)
5+
46
# Include LLVM's cmake policies.
57
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
68
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -53,18 +55,19 @@ set(LIBC_NAMESPACE ${default_namespace}
5355

5456
add_subdirectory(newhdrgen)
5557

56-
57-
if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
58-
if(NOT LIBC_HDRGEN_EXE)
59-
# We need to set up hdrgen first since other targets depend on it.
60-
add_subdirectory(utils/LibcTableGenUtil)
61-
add_subdirectory(utils/HdrGen)
62-
# Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in
63-
# PARENT_SCOPE which get lost until saved in the cache.
64-
set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "")
65-
set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "")
66-
else()
67-
message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.")
58+
if(NOT LIBC_USE_NEW_HEADER_GEN)
59+
if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)
60+
if(NOT LIBC_HDRGEN_EXE)
61+
# We need to set up hdrgen first since other targets depend on it.
62+
add_subdirectory(utils/LibcTableGenUtil)
63+
add_subdirectory(utils/HdrGen)
64+
# Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in
65+
# PARENT_SCOPE which get lost until saved in the cache.
66+
set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "")
67+
set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "")
68+
else()
69+
message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.")
70+
endif()
6871
endif()
6972
endif()
7073
# We will build the GPU utilities if we are not doing a runtimes build.
@@ -327,7 +330,9 @@ endif()
327330

328331
option(LLVM_LIBC_INCLUDE_SCUDO "Include the SCUDO standalone as the allocator for LLVM libc" OFF)
329332
if(LLVM_LIBC_INCLUDE_SCUDO)
330-
if (NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES))
333+
if (LLVM_LIBC_COMPILER_RT_PATH)
334+
add_subdirectory(${LLVM_LIBC_COMPILER_RT_PATH} ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt)
335+
elseif(NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES))
331336
message(FATAL_ERROR "SCUDO cannot be included without adding compiler-rt to LLVM_ENABLE_PROJECTS or LLVM_ENABLE_RUNTIMES")
332337
endif()
333338
endif()

libc/newhdrgen/yaml_to_classes.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# ===- Generate headers for libc functions -------------------*- python -*--==#
44
#

0 commit comments

Comments
 (0)