Support -m elf_x86_64_sol2#1197
Conversation
|
Should |
|
No, it need not set those defaults because those defaults are there to work
around the bugs and FIXME’s in Clang’s Solaris driver. #1173 should be
reverted once my fix lands in Clang because it will no longer be necessary.
…On Sun, 12 Oct 2025 at 09:30, Mateusz Mikuła ***@***.***> wrote:
*mati865* left a comment (wild-linker/wild#1197)
<#1197 (comment)>
Should elf_x86_64_sol2 set the defaults from #1173
<#1173> or are they supposed
to be also set for elf_x86_64 on Solaris/Illumos?
—
Reply to this email directly, view it on GitHub
<#1197 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG6HLXFTRWPX2AQ6UQNTWD3XH7SLAVCNFSM6AAAAACI6OR2TKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJUGAZDMNJTGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Ignoring |
|
Ah, you are correct. |
|
Do you think we should make it so that |
|
FWIW, I made this change: And all our tests and mold tests still pass, so maybe there should be a default value for all platforms? I have checked Clang binary linked on Linux with ld with EDIT: In any case, I can align the Linux one and add a test later. I can also refactor it if necessary. |
Yes, I do. While @mati865 has identified a viable alternative for |
|
Mold makes inferences if |
|
So does lld: https://github.com/llvm/llvm-project/blob/4c8275470465528c469436d37b9aaf71d6598899/lld/ELF/Driver.cpp#L2209. For the record, I'm not interested in cargo culting the behavior of existing linkers but it does corroborate @davidlattimore instinct that |
|
Aside: 67d998c says that printing supported emulations in |
|
Gah, this is horrible. We will do this more neatly in Wild. |
|
Do you want to make the changes in this PR? I don't think it should be an especially big change - just delete the |
Yes, made the small change. |
| "elf_x86_64_sol2", | ||
| "x86-64 ELF target (Solaris)", | ||
| |args, _modifier_stack, _value| { | ||
| args.dynamic_linker = Some(Path::new("/lib/amd64/ld.so.1").into()); |
There was a problem hiding this comment.
If we always set args.dynamic linker then that means that --dynamic-linker=/some/path -m elf_x86_64_sol2 will give a different outcome to -m elf_x86_64_sol2 --dynamic-linker=/some/path. i.e. the -m being later will override the earlier --dynamic-linker flag, which I don't think is what we want. Easiest fix is probably to check if args.dynamic_linker is already set and leave it as-is if so.
There was a problem hiding this comment.
D'oh. Good catch.
|
Unbroke the test (I missed a branch in the old |
|
I'm not convinced whether it's sensible to complicate the code by setting the default dynamic linker for each architecture. On Linux, passing Without having a proper interpreter configured, the binary won't run: |
Emphasis mine. I agree. But, we are not setting the default dynamic linker based on architecture. We're setting the default dynamic linker based on the Indeed, if you run Unfortunately, it seems that the various open-source toolchains have taken a dependency on this convention, and they expect the 'emulation' flag to require the linker to find the right dynamic linker unless otherwise explicitly provided. |
|
My bad, I meant emulation rather than architecture. So, my point is on x86_64 Linux you cannot assume the linker will use the correct interpreter (because it will not), and the caller has to supply it anyway. |
Currently, we have a somewhat janky workaround for getting Wild to work on Illumos: #1173
I've opened a PR in Clang to bring the Solaris (Illumos) driver up to parity with the others: llvm/llvm-project#163000. Once this lands, it will be possible to use the
--ld-pathargument identically to other platforms. This benefits all linkers - including lld, Gold, Mold and Wild. That is, Clang will start to supply GNU ld-compatible flags if an unknown, non-Solaris Link Editor is supplied.Of course, we need to then support the "emulation"
elf_x86_64_sol2. Testing Wild with this change, and Clang with my change above, I have been able to link a couple of Rust programs, including ripgrep. Excitingly, it also links LLVM itself. Finally, I confirmed with DTrace that the arguments were expected.