Skip to content

Commit 8e49c84

Browse files
committed
XRay support flag in TargetOptions
Specify where XRay is supported. I only test ARM64 and x86_64, but hey those others should work too, right? LLVM documentation says that MIPS and PPC are also supported, but I don't have the hardware, so I won't pretend. Naturally, more targets can be added later with more testing.
1 parent 0fef658 commit 8e49c84

10 files changed

+15
-0
lines changed

compiler/rustc_target/src/spec/aarch64_linux_android.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
| SanitizerSet::MEMTAG
2020
| SanitizerSet::SHADOWCALLSTACK
2121
| SanitizerSet::ADDRESS,
22+
supports_xray: true,
2223
..super::android_base::opts()
2324
},
2425
}

compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn target() -> Target {
1717
| SanitizerSet::MEMTAG
1818
| SanitizerSet::THREAD
1919
| SanitizerSet::HWADDRESS,
20+
supports_xray: true,
2021
..super::linux_gnu_base::opts()
2122
},
2223
}

compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::spec::{Target, TargetOptions};
33
pub fn target() -> Target {
44
let mut base = super::linux_musl_base::opts();
55
base.max_atomic_width = Some(128);
6+
base.supports_xray = true;
67

78
Target {
89
llvm_target: "aarch64-unknown-linux-musl".into(),

compiler/rustc_target/src/spec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,9 @@ pub struct TargetOptions {
17181718
/// The ABI of entry function.
17191719
/// Default value is `Conv::C`, i.e. C call convention
17201720
pub entry_abi: Conv,
1721+
1722+
/// Whether the target supports XRay instrumentation.
1723+
pub supports_xray: bool,
17211724
}
17221725

17231726
/// Add arguments for the given flavor and also for its "twin" flavors
@@ -1937,6 +1940,7 @@ impl Default for TargetOptions {
19371940
supports_stack_protector: true,
19381941
entry_name: "main".into(),
19391942
entry_abi: Conv::C,
1943+
supports_xray: false,
19401944
}
19411945
}
19421946
}
@@ -2592,6 +2596,7 @@ impl Target {
25922596
key!(supports_stack_protector, bool);
25932597
key!(entry_name);
25942598
key!(entry_abi, Conv)?;
2599+
key!(supports_xray, bool);
25952600

25962601
if base.is_builtin {
25972602
// This can cause unfortunate ICEs later down the line.
@@ -2845,6 +2850,7 @@ impl ToJson for Target {
28452850
target_option_val!(supports_stack_protector);
28462851
target_option_val!(entry_name);
28472852
target_option_val!(entry_abi);
2853+
target_option_val!(supports_xray);
28482854

28492855
if let Some(abi) = self.default_adjusted_cabi {
28502856
d.insert("default-adjusted-cabi".into(), Abi::name(abi).to_json());

compiler/rustc_target/src/spec/x86_64_linux_android.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub fn target() -> Target {
88
base.max_atomic_width = Some(64);
99
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
1010
base.stack_probes = StackProbeType::X86;
11+
base.supports_xray = true;
1112

1213
Target {
1314
llvm_target: "x86_64-linux-android".into(),

compiler/rustc_target/src/spec/x86_64_unknown_freebsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub fn target() -> Target {
88
base.stack_probes = StackProbeType::X86;
99
base.supported_sanitizers =
1010
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::MEMORY | SanitizerSet::THREAD;
11+
base.supports_xray = true;
1112

1213
Target {
1314
llvm_target: "x86_64-unknown-freebsd".into(),

compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn target() -> Target {
1212
| SanitizerSet::LEAK
1313
| SanitizerSet::MEMORY
1414
| SanitizerSet::THREAD;
15+
base.supports_xray = true;
1516

1617
Target {
1718
llvm_target: "x86_64-unknown-linux-gnu".into(),

compiler/rustc_target/src/spec/x86_64_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn target() -> Target {
1212
| SanitizerSet::LEAK
1313
| SanitizerSet::MEMORY
1414
| SanitizerSet::THREAD;
15+
base.supports_xray = true;
1516

1617
Target {
1718
llvm_target: "x86_64-unknown-linux-musl".into(),

compiler/rustc_target/src/spec/x86_64_unknown_netbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub fn target() -> Target {
1111
| SanitizerSet::LEAK
1212
| SanitizerSet::MEMORY
1313
| SanitizerSet::THREAD;
14+
base.supports_xray = true;
1415

1516
Target {
1617
llvm_target: "x86_64-unknown-netbsd".into(),

compiler/rustc_target/src/spec/x86_64_unknown_openbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
88
base.stack_probes = StackProbeType::X86;
9+
base.supports_xray = true;
910

1011
Target {
1112
llvm_target: "x86_64-unknown-openbsd".into(),

0 commit comments

Comments
 (0)