[PATCH] D151013: [CMake] Add option to link LLVM/subproject executables
Aiden Grossman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 27 19:57:41 PDT 2023
aidengrossman updated this revision to Diff 526304.
aidengrossman edited the summary of this revision.
aidengrossman added a comment.
Changed from building libc as a project and linking against that to linking against the LLVM libc overaly if available from the system. This prevents building something that should be built as a runtime as a project, ensuring that we have an up to date compiler.
In order to effectively do multi-stage builds https://reviews.llvm.org/D151624 needs to land.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151013/new/
https://reviews.llvm.org/D151013
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/docs/CMake.rst
Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -509,6 +509,11 @@
passed to invocations of both so that the project is built using libc++
instead of stdlibc++. Defaults to OFF.
+**LLVM_ENABLE_LLVM_LIBC**: BOOL
+ If the LLVM libc overlay is installed in a location where the host linker
+ can access it, all built executables will be linked against the LLVM libc
+ overlay before linking against the system libc. Defaults to OFF.
+
**LLVM_ENABLE_LIBPFM**:BOOL
Enable building with libpfm to support hardware counter measurements in LLVM
tools.
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1300,3 +1300,13 @@
set(LLVM_THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party CACHE STRING
"Directory containing third party software used by LLVM (e.g. googletest)")
+
+set(LLVM_ENABLE_LLVM_LIBC OFF CACHE BOOL "Set to on to link all LLVM executables against LLVM libc, assuming it is accessible by the host compiler")
+
+if(LLVM_ENABLE_LLVM_LIBC)
+ include(CheckCXXCompilerFlag)
+ llvm_check_linker_flag(CXX "-lllvmlibc" CXX_LINKER_SUPPORTS_LLVM_LIBC)
+ if(NOT CXX_LINKER_SUPPORTS_LLVM_LIBC)
+ message(WARNING "Unable to link against LLVM libc. LLVM will be built without linking against the LLVM libc overlay.")
+ endif()
+endif()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1029,6 +1029,10 @@
target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
endif()
+ if(CXX_LINKER_SUPPORTS_LLVM_LIBC)
+ target_link_libraries(${name} PRIVATE llvmlibc)
+ endif()
+
llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH})
endmacro(add_llvm_executable name)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151013.526304.patch
Type: text/x-patch
Size: 2046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230528/ead71c53/attachment.bin>
More information about the llvm-commits
mailing list