Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] incorrect dependencies in overlay mode #92337

Open
DunskiPhilippe opened this issue May 16, 2024 · 1 comment
Open

[libc] incorrect dependencies in overlay mode #92337

DunskiPhilippe opened this issue May 16, 2024 · 1 comment
Labels
cmake Build system in general and CMake in particular libc

Comments

@DunskiPhilippe
Copy link

DunskiPhilippe commented May 16, 2024

Hello,

The problem

OCCURES When building llvmorg-18.1.5 tag from sources on linux.

According to the doc, CMake command as simple as

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

@github-actions github-actions bot added the libc label May 16, 2024
@EugeneZelenko EugeneZelenko added the cmake Build system in general and CMake in particular label May 16, 2024
@nickdesaulniers
Copy link
Member

I've yet to try ninja install-llvmlibc in either mode. I wonder where cmake would install those headers to?

cc @petrhosek @jhuber6 in case they have thoughts here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular libc
Projects
None yet
Development

No branches or pull requests

3 participants