-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
clang -fuse-ld=lld --target= prefers target-prefixed lld binaries over non-prefixed lld in its own directory #133709
Comments
@llvm/issue-subscribers-clang-driver Author: Hans Wennborg (zmodem)
clang's `--target` flag affects which `lld` binary it chooses. That seems reasonable, but it can lead to surprising behaviour if there are multiple toolchains available.
Let's pretend we have some old crosscompiling toolchain in our PATH:
clang will normally prefer the lld installed right next to itself:
However, if we pass a
That seems potentially surprising! It seems there are two criteria at play here:
It seems that 2) currently takes precedence. Maybe it should be the other way around? |
+cc @nico @inglorion |
Maybe d6efc98 changed things to the current state? @DavidSpickett The relevant code is |
That revision is a reland of 028571d which points at https://llvm.org/PR45693 / #45038 as motivation for the current behavior. |
Aha, and that points to an RFC about exactly this: https://discourse.llvm.org/t/rfc-changing-tool-search-path-priority/55341 |
Yes, Clang currently starts with the most specific name and looks for that in its install directory and then on PATH. If that fails, it looks for the next name in both places and so on.
At the time, my opinion was that for the use case in the bug report, 2) then 1) made the most sense. Though I could see how you would disagree if file system "distance" is the first criteria in your mental model of this. (and to be honest, I can't remember what I thought it would be, prior to seeing that bug report) In the situation where you need a cross compiler gcc, it was finding Not sure how to proceed here. One way might be to look at the workaround that the original bug report would have to have done (a couple were suggested at the time), vs. what your use case(s) would have to do. As I am clearly too biased to be saying which strategy makes more sense intuitively. |
Yeah, I'm not sure either. We worked around this on our end, but it was definitely a surprise, so I figured it made sense to raise it. |
clang's
--target
flag affects whichlld
binary it chooses. That seems reasonable, but it can lead to surprising behaviour if there are multiple toolchains available.Let's pretend we have some old crosscompiling toolchain in our PATH:
clang will normally prefer the lld installed right next to itself:
However, if we pass a
--target
flag, it prefers the lld version that has that target prefix even if this is not in the clang directory:That seems potentially surprising!
It seems there are two criteria at play here:
It seems that 2) currently takes precedence. Maybe it should be the other way around?
The text was updated successfully, but these errors were encountered: