Skip to content

Commit 6ffab47

Browse files
committed
Use lld with non-LLVM backends
On arm64, Cranelift used to produce object files that don't work with lld. This has since been fixed. The GCC backend should always produce object files that work with lld unless lld for whatever reason drops GCC support. Most of the other more niche backends don't use cg_ssa's linker code at all. If they do and don't work with lld, they can always disable lld usage using a cli argument. Without this commit using cg_clif is by default in a non-trivial amount of cases a perf regression on Linux due to ld.bfd being a fair bit slower than lld. It is possible to explicitly enable it without this commit, but most users are unlikely to do this.
1 parent 209799f commit 6ffab47

File tree

1 file changed

+0
-17
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+0
-17
lines changed

Diff for: compiler/rustc_codegen_ssa/src/back/link.rs

-17
Original file line numberDiff line numberDiff line change
@@ -3305,23 +3305,6 @@ fn add_lld_args(
33053305
let self_contained_cli = sess.opts.cg.link_self_contained.is_linker_enabled();
33063306
let self_contained_target = self_contained_components.is_linker_enabled();
33073307

3308-
// FIXME: in the future, codegen backends may need to have more control over this process: they
3309-
// don't always support all the features the linker expects here, and vice versa. For example,
3310-
// at the time of writing this, lld expects a newer style of aarch64 TLS relocations that
3311-
// cranelift doesn't implement yet. That in turn can impact whether linking would succeed on
3312-
// such a target when using the `cg_clif` backend and lld.
3313-
//
3314-
// Until interactions between backends and linker features are expressible, we limit target
3315-
// specs to opt-in to lld only when we're on the llvm backend, where it's expected to work and
3316-
// tested on CI. As usual, the CLI still has precedence over this, so that users and developers
3317-
// can still override this default when needed (e.g. for tests).
3318-
let uses_llvm_backend =
3319-
matches!(sess.opts.unstable_opts.codegen_backend.as_deref(), None | Some("llvm"));
3320-
if !uses_llvm_backend && !self_contained_cli && sess.opts.cg.linker_flavor.is_none() {
3321-
// We bail if we're not using llvm and lld was not explicitly requested on the CLI.
3322-
return;
3323-
}
3324-
33253308
let self_contained_linker = self_contained_cli || self_contained_target;
33263309
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
33273310
let mut linker_path_exists = false;

0 commit comments

Comments
 (0)