Skip to content

Commit 8df4b4e

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Prefer command line supplied linker script over embedded one
1 parent b352f4e commit 8df4b4e

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+6
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,14 +1870,19 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)
18701870
cmd.args(&sess.opts.unstable_opts.pre_link_args);
18711871
}
18721872

1873-
/// Add a link script embedded in the target, if applicable.
1873+
/// Add a link script embedded in the target, if applicable and not found in the command line.
18741874
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
18751875
match (crate_type, &sess.target.link_script) {
18761876
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
18771877
if !sess.target.linker_flavor.is_gnu() {
18781878
sess.dcx().emit_fatal(errors::LinkScriptUnavailable);
18791879
}
18801880

1881+
if sess.opts.cg.link_args.contains(&String::from("--script"))
1882+
|| sess.opts.cg.link_args.contains(&String::from("-T")) {
1883+
return;
1884+
}
1885+
18811886
let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-");
18821887

18831888
let path = tmpdir.join(file_name);

0 commit comments

Comments
 (0)