Skip to content

compiler: Use -T instead of --script for linker scripts #142445

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

workingjubilee
Copy link
Member

Note that our run-make test suite uses -T and not --script, interestingly enough:

run-make/rust-lld-link-script-provide/rmake.rs
2:// when the symbols in the `PROVIDE` of the link script can be eliminated.
16:        .link_arg("-Tscript.t")

Fixes #127183

@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2025

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

cmd.link_arg("--script").link_arg(path);
// "--script" feels nice and explicit, but -T is supported by gcc **and clang**.
// Amusingly, lld supports --script just fine, it's only clang that doesn't.
cmd.link_arg("-T").link_arg(path);
Copy link
Contributor

Choose a reason for hiding this comment

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

link_arg("-T") will emit -Wl,-T on command line, so it will go directly to linker and clang won't see it, so the explanation doesn't seem right.

Copy link
Member Author

Choose a reason for hiding this comment

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

wait, then why is it broken for them?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It must be something about building specifically for a custom target. Thanks for catching this, I'll take a closer look. This patch's code change might still be correct but it might be for a weird reason.

Copy link
Member

@Noratrieb Noratrieb Jun 13, 2025

Choose a reason for hiding this comment

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

gcc does not support --script either. I suspect the people in #127183 configured their target incorrectly such that cc was invoked with ld-style arguments

@WaffleLapkin
Copy link
Member

r? @petrochenkov
since you seem to have context here

@rustbot rustbot assigned petrochenkov and unassigned WaffleLapkin Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clang linker script support - incorrect argument
5 participants