Skip to content

Commit 49dd168

Browse files
committed
Allow LLD to be enabled on aarch64-unknown-linux-gnu
1 parent f3fd3ef commit 49dd168

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

bootstrap.example.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,12 @@
759759
#rust.codegen-backends = ["llvm"]
760760

761761
# Indicates whether LLD will be compiled and made available in the sysroot for rustc to execute, and
762-
# whether to set it as rustc's default linker on `x86_64-unknown-linux-gnu`. This will also only be
763-
# when *not* building an external LLVM (so only when using `download-ci-llvm` or building LLVM from
764-
# the in-tree source): setting `llvm-config` in the `[target.x86_64-unknown-linux-gnu]` section will
765-
# make this default to false.
766-
#rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true
762+
# whether to set it as rustc's default linker on `x86_64-unknown-linux-gnu` and
763+
# `aarch64-unknown-linux-gnu`. This will also only be when *not* building an external LLVM (so only
764+
# when using `download-ci-llvm` or building LLVM from the in-tree source): setting `llvm-config` in
765+
# the `[target.x86_64-unknown-linux-gnu]` or `[target.aarch64-unknown-linux-gnu`] section will make
766+
# this default to false.
767+
#rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` and `aarch64-unknown-linux-gnu` as described above, where it is true
767768

768769
# Indicates whether LLD will be used to link Rust crates during bootstrap on
769770
# supported platforms.
Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
11
use crate::spec::{
2-
FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
2+
Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata,
3+
TargetOptions, base,
34
};
45

56
pub(crate) fn target() -> Target {
7+
let mut base = TargetOptions {
8+
features: "+v8a,+outline-atomics".into(),
9+
// the AAPCS64 expects use of non-leaf frame pointers per
10+
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
11+
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
12+
frame_pointer: FramePointer::NonLeaf,
13+
mcount: "\u{1}_mcount".into(),
14+
max_atomic_width: Some(128),
15+
stack_probes: StackProbeType::Inline,
16+
supported_sanitizers: SanitizerSet::ADDRESS
17+
| SanitizerSet::CFI
18+
| SanitizerSet::KCFI
19+
| SanitizerSet::LEAK
20+
| SanitizerSet::MEMORY
21+
| SanitizerSet::MEMTAG
22+
| SanitizerSet::THREAD
23+
| SanitizerSet::HWADDRESS,
24+
supports_xray: true,
25+
..base::linux_gnu::opts()
26+
};
27+
28+
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
29+
// linker flavor, and self-contained linker component.
30+
if option_env!("CFG_USE_SELF_CONTAINED_LINKER").is_some() {
31+
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
32+
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
33+
}
34+
635
Target {
736
llvm_target: "aarch64-unknown-linux-gnu".into(),
837
metadata: TargetMetadata {
@@ -14,25 +43,6 @@ pub(crate) fn target() -> Target {
1443
pointer_width: 64,
1544
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
1645
arch: "aarch64".into(),
17-
options: TargetOptions {
18-
features: "+v8a,+outline-atomics".into(),
19-
// the AAPCS64 expects use of non-leaf frame pointers per
20-
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
21-
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
22-
frame_pointer: FramePointer::NonLeaf,
23-
mcount: "\u{1}_mcount".into(),
24-
max_atomic_width: Some(128),
25-
stack_probes: StackProbeType::Inline,
26-
supported_sanitizers: SanitizerSet::ADDRESS
27-
| SanitizerSet::CFI
28-
| SanitizerSet::KCFI
29-
| SanitizerSet::LEAK
30-
| SanitizerSet::MEMORY
31-
| SanitizerSet::MEMTAG
32-
| SanitizerSet::THREAD
33-
| SanitizerSet::HWADDRESS,
34-
supports_xray: true,
35-
..base::linux_gnu::opts()
36-
},
46+
options: base,
3747
}
3848
}

0 commit comments

Comments
 (0)