diff options
author | Schrodinger ZHU Yifan <yifanzhu@rochester.edu> | 2024-11-20 14:12:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 14:12:25 -0500 |
commit | c0efcc08e67325dc813d9acb7cc3560fd444fc8f (patch) | |
tree | 35168b1470951aee0f02d877d36c8dc9cc5d7d98 | |
parent | 201f4f6bcccf3f0ac0c9d3e8c484fb2c53bfb016 (diff) | |
download | llvm-c0efcc08e67325dc813d9acb7cc3560fd444fc8f.zip llvm-c0efcc08e67325dc813d9acb7cc3560fd444fc8f.tar.gz llvm-c0efcc08e67325dc813d9acb7cc3560fd444fc8f.tar.bz2 |
[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
```
-rw-r--r-- | libc/CMakeLists.txt | 31 | ||||
-rwxr-xr-x[-rw-r--r--] | libc/newhdrgen/yaml_to_classes.py | 0 |
2 files changed, 18 insertions, 13 deletions
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 77b659b..d416e1e 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) set(LLVM_SUBPROJECT_TITLE "libc") +include(CheckCXXCompilerFlag) + # Include LLVM's cmake policies. if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -53,18 +55,19 @@ set(LIBC_NAMESPACE ${default_namespace} add_subdirectory(newhdrgen) - -if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD) - if(NOT LIBC_HDRGEN_EXE) - # We need to set up hdrgen first since other targets depend on it. - add_subdirectory(utils/LibcTableGenUtil) - add_subdirectory(utils/HdrGen) - # Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in - # PARENT_SCOPE which get lost until saved in the cache. - set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "") - set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "") - else() - message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.") +if(NOT LIBC_USE_NEW_HEADER_GEN) + if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD) + if(NOT LIBC_HDRGEN_EXE) + # We need to set up hdrgen first since other targets depend on it. + add_subdirectory(utils/LibcTableGenUtil) + add_subdirectory(utils/HdrGen) + # Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in + # PARENT_SCOPE which get lost until saved in the cache. + set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "") + set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "") + else() + message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.") + endif() endif() endif() # We will build the GPU utilities if we are not doing a runtimes build. @@ -353,7 +356,9 @@ endif() option(LLVM_LIBC_INCLUDE_SCUDO "Include the SCUDO standalone as the allocator for LLVM libc" OFF) if(LLVM_LIBC_INCLUDE_SCUDO) - if (NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)) + if (LLVM_LIBC_COMPILER_RT_PATH) + add_subdirectory(${LLVM_LIBC_COMPILER_RT_PATH} ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt) + elseif(NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES)) message(FATAL_ERROR "SCUDO cannot be included without adding compiler-rt to LLVM_ENABLE_PROJECTS or LLVM_ENABLE_RUNTIMES") endif() endif() diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py index 0e8ca2d..0e8ca2d 100644..100755 --- a/libc/newhdrgen/yaml_to_classes.py +++ b/libc/newhdrgen/yaml_to_classes.py |