try to infer linker flavor from linker name and vice versa#52101
try to infer linker flavor from linker name and vice versa#52101bors merged 9 commits intorust-lang:masterfrom
Conversation
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
There was a problem hiding this comment.
Stylistically I might recommend instead of a cps style to instead do something like:
- Emit only fatal errors here via
sess(it doesn't look like the error is ever "caught"?) - Return
Optioninstead ofResult - Instead do something like:
if let Some(ret) = locate_linker(&sess.opts) {
return Some(ret)
}
if let Some(ret) = locate_linker(&sess.target.target) {
return Some(ret)
}
sess.fatal("...")There was a problem hiding this comment.
I think this is losing the logic of locating link.exe on MSVC which may cause issues there?
There was a problem hiding this comment.
The logic is in get_linker which is called with the values this function returns. I think that function will locate link.exe even with these changes.
There was a problem hiding this comment.
I think this may have accidentally lost the logic of emcc.bat on Windows?
There was a problem hiding this comment.
You can probably remove the intermediate closure here, I don't think it's serving much purpose any more
There was a problem hiding this comment.
This runs the risk of being a breaking change by accident if someone's passing in a "flavorful" linker because currently we can't error today I think? Perhaps this could fall back to the target spec's linker flavor and if that's not present emit an error?
|
☔ The latest upstream changes (presumably #52268) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Ping from triage, @japaric: There are some review comments on your PR. |
|
It'll take me a while to get back to this so I'm going to close the PR in the meantime. |
|
re-r? @alexcrichton I believe I have addressed all your comments. |
| return ret; | ||
| } | ||
|
|
||
| sess.fatal("Not enough information provided to determine how to invoke the linker"); |
There was a problem hiding this comment.
I believe, today, this is effectively unreachable because linker flavor is a mandatory field of target specifications. Should this be bug instead of fatal?
|
I realized (too late) that these changes are not enough to use rustc LLD with the What we could do to correctly support |
|
Ok looks great to me! I agree yeah changing the |
this field defaults to the LD / GNU flavor
|
@alexcrichton OK, done. r? |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
@bors: r+ 👍 |
|
📌 Commit 4bbedd7 has been approved by |
|
@bors r=alexcrichton |
|
📌 Commit 98e4cd5 has been approved by |
|
⌛ Testing commit 98e4cd5 with merge 403324fa238c45b1739855f384b945c2c31045e4... |
|
💔 Test failed - status-travis |
This comment has been minimized.
This comment has been minimized.
|
expands logs
What? What happened? cc @rust-lang/infra |
|
⌛ Testing commit 98e4cd5 with merge e2fdc33267255d50a849a7eae7aa87b56f38b6b8... |
|
💔 Test failed - status-appveyor |
|
@bors r=alexcrichton |
|
📌 Commit a6f4ae8 has been approved by |
try to infer linker flavor from linker name and vice versa This is a second take on PR #50359 that implements the logic proposed in #50359 (review) With this change it would become possible to link `thumb*` binaries using GNU's LD on stable as `-C linker=arm-none-eabi-ld` would be enough to change both the linker and the linker flavor from their default values of `arm-none-eabi-gcc` and `gcc`. To link `thumb*` binaries using rustc's LLD on stable `-Z linker-flavor` would need to be stabilized as `-C linker=rust-lld -Z linker-flavor=ld.lld` are both required to change the linker and the linker flavor, but this PR doesn't propose that. We would probably need some sort of stability guarantee around `rust-lld`'s name and availability to make linking with rustc's LLD truly stable. With this change it would also be possible to link `thumb*` binaries using a system installed LLD on stable using the `-C linker=ld.lld` flag (provided that `ld.lld` is a symlink to the system installed LLD). r? @alexcrichton
|
☀️ Test successful - status-appveyor, status-travis |
This is a second take on PR #50359 that implements the logic proposed in #50359 (review)
With this change it would become possible to link
thumb*binaries using GNU's LD on stable as-C linker=arm-none-eabi-ldwould be enough to change both the linker and the linker flavor from their default values ofarm-none-eabi-gccandgcc.To link
thumb*binaries using rustc's LLD on stable-Z linker-flavorwould need to be stabilized as-C linker=rust-lld -Z linker-flavor=ld.lldare both required to change the linker and the linker flavor, but this PR doesn't propose that. We would probably need some sort of stability guarantee aroundrust-lld's name and availability to make linking with rustc's LLD truly stable.With this change it would also be possible to link
thumb*binaries using a system installed LLD on stable using the-C linker=ld.lldflag (provided thatld.lldis a symlink to the system installed LLD).r? @alexcrichton