Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,16 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)

/// Add a link script embedded in the target, if applicable.
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
fn is_script_arg(arg: &str) -> bool {
arg.starts_with("--script")
|| arg.starts_with("-T")
|| arg.starts_with("--default-script")
|| arg.starts_with("-dT")
}
// Omit the embedded linker script if a user supplied one
if sess.opts.cg.link_args.iter().any(|arg| is_script_arg(arg)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rustc should not try interpreting raw linker arguments.

Maybe rustc can use --default-script for the target-specified script to be overridable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should probably use --default-script, but lld doesn't support it yet so that would break the workflow for the psp target so I'll close this PR for now.

return;
}
match (crate_type, &sess.target.link_script) {
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
if !sess.target.linker_is_gnu {
Expand Down