Skip to content

Conversation

@Un1q32
Copy link
Contributor

@Un1q32 Un1q32 commented Sep 21, 2025

Makes more sense to choose the linker based on binary format instead of OS

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Sep 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 21, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: None (Un1q32)

Changes

Makes more sense to choose the linker based on binary format instead of OS


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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChain.cpp (+1-1)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index a9041d26c7ba4..66902fd8f2621 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1149,7 +1149,7 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
       return std::string(UseLinker);
   } else {
     llvm::SmallString<8> LinkerName;
-    if (Triple.isOSDarwin())
+    if (Triple.isOSBinFormatMachO())
       LinkerName.append("ld64.");
     else
       LinkerName.append("ld.");

Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this? I would think so but not sure.

We should have a release note.

@Un1q32
Copy link
Contributor Author

Un1q32 commented Nov 14, 2025

// foo.c
int main(void) { return 0; }

clang -target x86_64-macho foo.c -fuse-ld=lld -v

Clang will either use ld64.lld or ld.lld.

@DanielCChen
Copy link
Contributor

I have no objection to the change.
I will leave the approval to other reviewers since I am not familiar with the platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants