-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[libc][startup] set --target= for linker when cross compiling #96342
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][startup] set --target= for linker when cross compiling #96342
Conversation
Otherwise the startup objects will fail to link since they were cross compiled, but the linker is not informed of the intent to cross compile, which results in linker errors when the host architecture does not match the target architecture.
@llvm/pr-subscribers-libc Author: Nick Desaulniers (paternity leave) (nickdesaulniers) ChangesOtherwise the startup objects will fail to link since they were cross compiled, Full diff: https://github.com/llvm/llvm-project/pull/96342.diff 1 Files Affected:
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 68f68ff45aa9e..31c0ada31aebd 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -26,7 +26,7 @@ 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_link_options(${relocatable_target} PRIVATE -r -nostdlib --target=${explicit_target_triple})
set_target_properties(
${relocatable_target}
PROPERTIES
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/541 Here is the relevant piece of the build log for the reference:
|
That's an interesting error, it's probably using the fallback GCC toolchain in clang since it can't fully parse the triple or something. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/131/builds/532 Here is the relevant piece of the build log for the reference:
|
Will revert for now. Perhaps related to runtimes build vs not. |
Is the command invocation on the failing buildbot, implying that |
ah, the GCC build is failing for the host build. We don't set |
We only need to set `--target=` for LLD when cross compiling. This should fix the host build using BFD. Fixes: llvm#96342
#96357 is the fix for GCC host builds. Another one inbound for aarch64. |
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
…6342) Otherwise the startup objects will fail to link since they were cross compiled, but the linker is not informed of the intent to cross compile, which results in linker errors when the host architecture does not match the target architecture.
…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
Otherwise the startup objects will fail to link since they were cross compiled,
but the linker is not informed of the intent to cross compile, which results in
linker errors when the host architecture does not match the target
architecture.