cmake ../llvm -G Ninja -DLLVM_ENABLE_PROJECTS="libc" \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=<Debug|Release> \ # Select build type
-DCMAKE_INSTALL_PREFIX=<Your prefix of choice>
should lead to the ability to create an overlay mode for the libc.
We should then be able to build libc with the ninja libc command, then to install an overlay version with the ninja install-llvmlibc one.
however, there is no PHONY named 'install-llvmlibc' generated. And so, ninja asks us if we meant install-llvmlib, which is not the same thing.
Additionally, if we simply attempt to install libc with the ninja install-libc command, ninja wants to install libc-startup as dependency to libc.
However, libc-startup is supposed to be build only if LLVM_LIBC_FULL_BUILD is set to true, which is neither the case in overlay mode, nor the default value case
The solution
From what I understood during a quick search, the problem would come from the llvm-project/libc/lib/CMakeLists.txt file because a unconditional dependancy is set on a variable named startup_target for different custom targets (namely install-libc and install-libc-stripped )and, all that because the startup_target is systematically set to libc-startup if libc isn't build for barmetal.
IMO, this dependency should not be set, at least on linux, when building libc in overlay mode.
Heer is a patch this unerequired dependency:
diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index af7ef2de93dd..dc54648ef2bb 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -60,7 +60,12 @@ if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
# and install it as part of the libc installation.
set(startup_target "libc-startup")
endif()
-
+# We should not depend on libc-startup in overlay mode
+if(NOT ${LLVM_LIBC_FULL_BUILD})
+ # Works at least on linux, but requires more investigations
+ # for other platforms
+ set(startup_target "")
+endif()
if(LLVM_LIBC_FULL_BUILD)
set(header_install_target install-libc-headers)
endif()
"Fun fact" being that it makes makes libllvmlibc.a automatically installed with the ninja install-libc command .
Thanks for reading
PS: Excuse me for my poor English, I usually speak in French
Hello,
The problem
OCCURES When building llvmorg-18.1.5 tag from sources on linux.
According to the doc, CMake command as simple as
should lead to the ability to create an overlay mode for the libc. We should then be able to build libc with the
ninja libc
command, then to install an overlay version with the ninja install-llvmlibc
one.however, there is no PHONY named 'install-llvmlibc' generated. And so, ninja asks us if we meant
install-llvmlib
, which is not the same thing.Additionally, if we simply attempt to install libc with the
ninja install-libc
command, ninja wants to installlibc-startup
as dependency to libc. However,libc-startup
is supposed to be build only ifLLVM_LIBC_FULL_BUILD
is set totrue
, which is neither the case in overlay mode, nor the default value caseThe solution
From what I understood during a quick search, the problem would come from the
llvm-project/libc/lib/CMakeLists.txt
file because a unconditional dependancy is set on a variable namedstartup_target
for different custom targets (namelyinstall-libc
andinstall-libc-stripped
)and, all that because thestartup_target
is systematically set tolibc-startup
if libc isn't build for barmetal. IMO, this dependency should not be set, at least on linux, when building libc in overlay mode. Heer is a patch this unerequired dependency:"Fun fact" being that it makes makes libllvmlibc.a automatically installed with the
ninja install-libc
command .Thanks for reading PS: Excuse me for my poor English, I usually speak in French