Skip to content

[libc] Fix install-libc to work with LLVM_LIBC_FULL_BUILD=OFF#197366

Merged
lntue merged 1 commit into
llvm:mainfrom
lu-zero:unbreak-overlay-libc
May 16, 2026
Merged

[libc] Fix install-libc to work with LLVM_LIBC_FULL_BUILD=OFF#197366
lntue merged 1 commit into
llvm:mainfrom
lu-zero:unbreak-overlay-libc

Conversation

@lu-zero

@lu-zero lu-zero commented May 13, 2026

Copy link
Copy Markdown
Contributor

Initialize variables that are conditionally set to avoid undefined references in install-libc and install-libc-stripped targets:

  • Initialize added_bitcode_targets to empty string (may be undefined when LIBC_TARGET_OS_IS_GPU=OFF)
  • Initialize startup_target to empty string and only set to "libc-startup" when both LLVM_LIBC_FULL_BUILD=ON and NOT baremetal (startup directory is only included in full builds)
  • Initialize header_install_target to empty string (may be undefined when LLVM_LIBC_FULL_BUILD=OFF)

Initialize variables that are conditionally set to avoid undefined
references in install-libc and install-libc-stripped targets:

- Initialize added_bitcode_targets to empty string (may be undefined
  when LIBC_TARGET_OS_IS_GPU=OFF)
- Initialize startup_target to empty string and only set to
  "libc-startup" when both LLVM_LIBC_FULL_BUILD=ON and NOT baremetal
  (startup directory is only included in full builds)
- Initialize header_install_target to empty string (may be undefined
  when LLVM_LIBC_FULL_BUILD=OFF)
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-libc

Author: Luca Barbato (lu-zero)

Changes

Initialize variables that are conditionally set to avoid undefined references in install-libc and install-libc-stripped targets:

  • Initialize added_bitcode_targets to empty string (may be undefined when LIBC_TARGET_OS_IS_GPU=OFF)
  • Initialize startup_target to empty string and only set to "libc-startup" when both LLVM_LIBC_FULL_BUILD=ON and NOT baremetal (startup directory is only included in full builds)
  • Initialize header_install_target to empty string (may be undefined when LLVM_LIBC_FULL_BUILD=OFF)

Full diff: https://github.com/llvm/llvm-project/pull/197366.diff

1 Files Affected:

  • (modified) libc/lib/CMakeLists.txt (+4-1)
diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index 19751a9cc0736..08026e937be94 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -13,6 +13,7 @@ else()
 endif()
 
 set(added_archive_targets "")
+set(added_bitcode_targets "")
 foreach(archive IN ZIP_LISTS
         libc_archive_names libc_archive_targets libc_archive_entrypoint_lists)
   if(NOT ${archive_2})
@@ -69,13 +70,15 @@ foreach(file ${added_bitcode_targets})
   )
 endforeach()
 
-if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
+set(startup_target "")
+if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_BAREMETAL)
   # For now we will disable libc-startup installation for baremetal. The
   # correct way to do it would be to make a hookable startup for baremetal
   # and install it as part of the libc installation.
   set(startup_target "libc-startup")
 endif()
 
+set(header_install_target "")
 if(LLVM_LIBC_FULL_BUILD)
   set(header_install_target install-libc-headers)
 endif()

@SchrodingerZhu SchrodingerZhu requested review from jhuber6 and lntue May 13, 2026 18:59
@lntue lntue merged commit 0320f03 into llvm:main May 16, 2026
33 of 34 checks passed
pedroMVicente pushed a commit to pedroMVicente/llvm-project that referenced this pull request May 19, 2026
…97366)

Initialize variables that are conditionally set to avoid undefined
references in install-libc and install-libc-stripped targets:

- Initialize added_bitcode_targets to empty string (may be undefined
when LIBC_TARGET_OS_IS_GPU=OFF)
- Initialize startup_target to empty string and only set to
"libc-startup" when both LLVM_LIBC_FULL_BUILD=ON and NOT baremetal
(startup directory is only included in full builds)
- Initialize header_install_target to empty string (may be undefined
when LLVM_LIBC_FULL_BUILD=OFF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants