Skip to content

[libc][startup] check that we're cross compiling and using LLD #96357

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

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

nickdesaulniers
Copy link
Member

@nickdesaulniers nickdesaulniers commented Jun 21, 2024

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

@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (paternity leave) (nickdesaulniers)

Changes

We only need to set --target= for LLD when cross compiling. This should fix
the host build using BFD.

Fixes: #96342


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

1 Files Affected:

  • (modified) libc/startup/linux/CMakeLists.txt (+5-1)
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 31c0ada31aebd..ece88c25a4aa8 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)
+    list(APPEND link_opts --target=${explicit_target_triple})
+  endif()
+  target_link_options(${relocatable_target} PRIVATE ${link_opts})
   set_target_properties(
     ${relocatable_target}
     PROPERTIES

We only need to set `--target=` for LLD when cross compiling. This should fix
the host build using BFD.

Fixes: llvm#96342
@nickdesaulniers nickdesaulniers merged commit 781d5cf into llvm:main Jun 21, 2024
4 of 5 checks passed
@nickdesaulniers nickdesaulniers deleted the arm_runtimes_cross3 branch June 21, 2024 21:33
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…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
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.

3 participants