Skip to content

Commit 781d5cf

Browse files
[libc][startup] check that we're cross compiling and using LLD (llvm#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: llvm#96342
1 parent b9c7d60 commit 781d5cf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libc/startup/linux/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function(merge_relocatable_object name)
2626
)
2727
# Pass -r to the driver is much cleaner than passing -Wl,-r: the compiler knows it is
2828
# a relocatable linking and will not pass other irrelevant flags to the linker.
29-
target_link_options(${relocatable_target} PRIVATE -r -nostdlib --target=${explicit_target_triple})
29+
set(link_opts -r -nostdlib)
30+
if (explicit_target_triple AND LLVM_ENABLE_LLD)
31+
list(APPEND link_opts --target=${explicit_target_triple})
32+
endif()
33+
target_link_options(${relocatable_target} PRIVATE ${link_opts})
3034
set_target_properties(
3135
${relocatable_target}
3236
PROPERTIES

0 commit comments

Comments
 (0)