Skip to content

Commit c0efcc0

Browse files
[libc] support fully OOT build (#101287)
Fully OOT build along with SCUDO: ``` mkdir oot cp -r cmake libc compiler-rt oot cp ./llvm/cmake/modules/* ./oot/cmake/Modules/ cd oot mkdir build cd build cmake ../libc -DLIBC_USE_NEW_HEADER_GEN=On -DLLVM_LIBC_FULL_BUILD=On -DLLVM_LIBC_FULL_BUILD=On -DLLVM_LIBC_INCLUDE_SCUDO=On -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=On -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=Off -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DLLVM_LIBC_COMPILER_RT_PATH=../compiler-rt/ -DCOMPILER_RT_STANDALONE_BUILD=On -GNinja -DLLVM_COMPILER_IS_GCC_COMPATIBLE=On -DLLVM_RUNTIMES_BUILD=On ```
1 parent 201f4f6 commit c0efcc0

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
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.
@@ -353,7 +356,9 @@ endif()
353356

354357
option(LLVM_LIBC_INCLUDE_SCUDO "Include the SCUDO standalone as the allocator for LLVM libc" OFF)
355358
if(LLVM_LIBC_INCLUDE_SCUDO)
356-
if (NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES))
359+
if (LLVM_LIBC_COMPILER_RT_PATH)
360+
add_subdirectory(${LLVM_LIBC_COMPILER_RT_PATH} ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt)
361+
elseif(NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES))
357362
message(FATAL_ERROR "SCUDO cannot be included without adding compiler-rt to LLVM_ENABLE_PROJECTS or LLVM_ENABLE_RUNTIMES")
358363
endif()
359364
endif()

libc/newhdrgen/yaml_to_classes.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)