[libc-commits] [libc] 781d5cf - [libc][startup] check that we're cross compiling and using LLD (#96357)
via libc-commits
libc-commits at lists.llvm.org
Fri Jun 21 14:33:30 PDT 2024
Author: Nick Desaulniers (paternity leave)
Date: 2024-06-21T14:33:27-07:00
New Revision: 781d5cf32a2512b8010831df750daa8003d6bf5a
URL: https://github.com/llvm/llvm-project/commit/781d5cf32a2512b8010831df750daa8003d6bf5a
DIFF: https://github.com/llvm/llvm-project/commit/781d5cf32a2512b8010831df750daa8003d6bf5a.diff
LOG: [libc][startup] check that we're cross compiling and using LLD (#96357)
We only need to set `--target=` for LLD when cross compiling. This should fix
the host build using BFD or targeting the host.
Fixes: #96342
Added:
Modified:
libc/startup/linux/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 31c0ada31aebd..f041a4826dc94 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -26,7 +26,11 @@ function(merge_relocatable_object name)
)
# Pass -r to the driver is much cleaner than passing -Wl,-r: the compiler knows it is
# a relocatable linking and will not pass other irrelevant flags to the linker.
- target_link_options(${relocatable_target} PRIVATE -r -nostdlib --target=${explicit_target_triple})
+ set(link_opts -r -nostdlib)
+ if (explicit_target_triple AND LLVM_ENABLE_LLD)
+ list(APPEND link_opts --target=${explicit_target_triple})
+ endif()
+ target_link_options(${relocatable_target} PRIVATE ${link_opts})
set_target_properties(
${relocatable_target}
PROPERTIES
More information about the libc-commits
mailing list