Skip to content

Commit 0e47f19

Browse files
committed
Specify linker scripts after user link args
1 parent dbb8190 commit 0e47f19

File tree

1 file changed

+7
-2
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+7
-2
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,13 @@ fn linker_with_args(
24352435
// Passed after compiler-generated options to support manual overriding when necessary.
24362436
add_user_defined_link_args(cmd, sess);
24372437

2438+
// ------------ Builtin configurable linker scripts ------------
2439+
// The user's link args should be able to overwrite symbols in the compiler's
2440+
// linker script that were weakly defined (i.e. defined with `PROVIDE()`). For this
2441+
// to work correctly, the user needs to be able to specify linker arguments like
2442+
// `--defsym` and `--script` *before* any builtin linker scripts are evaluated.
2443+
add_link_script(cmd, sess, tmpdir, crate_type);
2444+
24382445
// ------------ Object code and libraries, order-dependent ------------
24392446

24402447
// Post-link CRT objects.
@@ -2469,8 +2476,6 @@ fn add_order_independent_options(
24692476

24702477
let apple_sdk_root = add_apple_sdk(cmd, sess, flavor);
24712478

2472-
add_link_script(cmd, sess, tmpdir, crate_type);
2473-
24742479
if sess.target.os == "fuchsia"
24752480
&& crate_type == CrateType::Executable
24762481
&& !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))

0 commit comments

Comments
 (0)