[libc-commits] [libc] [libc][startup] check that we're cross compiling and using LLD (PR #96357)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Jun 21 13:49:57 PDT 2024
https://github.com/nickdesaulniers updated https://github.com/llvm/llvm-project/pull/96357
>From 0e4d0852568f93614523b3f22d3fbb2ba15b838d Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Fri, 21 Jun 2024 13:40:23 -0700
Subject: [PATCH] [libc][startup] check that we're cross compiling and using
LLD
We only need to set `--target=` for LLD when cross compiling. This should fix
the host build using BFD.
Fixes: #96342
---
libc/startup/linux/CMakeLists.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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