Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 459352a

Browse files
authoredMar 14, 2025
Rollup merge of #136892 - erickt:fuchsia-target, r=jieyouxu
Sync Fuchsia target spec with clang Fuchsia driver This updates the Fuchsia target spec with the [Clang Fuchsia driver], which picks up a few changes: * Adds `-z start-stop-visibility=hidden` and `-z rel` to the pre link arguments. * Adds `--execute-only` and `--fix-cortex-a53-843419` for `aarch64-unknown-fuchsia`. * Enables the equivalent cpu features for `x86-64-v2` for `x86_64-unknown-fuchsia`, which is our minimum supported x86_64 platform according to [RFC-0073]. try-job: x86_64-fuchsia [Clang Fuchsia driver]: https://github.com/llvm/llvm-project/blob/8374d421861cd3d47e21ae7889ba0b4c498e8d85/clang/lib/Driver/ToolChains/Fuchsia.cpp [RFC-0073]: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0073_x86_64_platform_requirement
2 parents 595c624 + 746b0f6 commit 459352a

File tree

4 files changed

+45
-22
lines changed

4 files changed

+45
-22
lines changed
 

‎compiler/rustc_target/src/spec/base/fuchsia.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) fn opts() -> TargetOptions {
77
// now. When using clang as the linker it will supply these options for us,
88
// so we only list them for ld/lld.
99
//
10-
// https://github.com/llvm/llvm-project/blob/db9322b2066c55254e7691efeab863f43bfcc084/clang/lib/Driver/ToolChains/Fuchsia.cpp#L31
10+
// https://github.com/llvm/llvm-project/blob/0419db6b95e246fe9dc90b5795beb77c393eb2ce/clang/lib/Driver/ToolChains/Fuchsia.cpp#L32
1111
let pre_link_args = TargetOptions::link_args(
1212
LinkerFlavor::Gnu(Cc::No, Lld::No),
1313
&[
@@ -18,9 +18,13 @@ pub(crate) fn opts() -> TargetOptions {
1818
"-z",
1919
"now",
2020
"-z",
21+
"start-stop-visibility=hidden",
22+
"-z",
2123
"rodynamic",
2224
"-z",
2325
"separate-loadable-segments",
26+
"-z",
27+
"rel",
2428
"--pack-dyn-relocs=relr",
2529
],
2630
);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1-
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};
1+
use crate::spec::{
2+
Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base,
3+
};
24

35
pub(crate) fn target() -> Target {
6+
let mut base = base::fuchsia::opts();
7+
base.cpu = "generic".into();
8+
base.features = "+v8a,+crc,+aes,+sha2,+neon".into();
9+
base.max_atomic_width = Some(128);
10+
base.stack_probes = StackProbeType::Inline;
11+
base.supported_sanitizers = SanitizerSet::ADDRESS
12+
| SanitizerSet::CFI
13+
| SanitizerSet::LEAK
14+
| SanitizerSet::SHADOWCALLSTACK;
15+
base.supports_xray = true;
16+
17+
base.add_pre_link_args(
18+
LinkerFlavor::Gnu(Cc::No, Lld::No),
19+
&[
20+
"--execute-only",
21+
// Enable the Cortex-A53 errata 843419 mitigation by default
22+
"--fix-cortex-a53-843419",
23+
],
24+
);
25+
426
Target {
527
llvm_target: "aarch64-unknown-fuchsia".into(),
628
metadata: TargetMetadata {
@@ -12,14 +34,6 @@ pub(crate) fn target() -> Target {
1234
pointer_width: 64,
1335
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(),
1436
arch: "aarch64".into(),
15-
options: TargetOptions {
16-
features: "+v8a".into(),
17-
max_atomic_width: Some(128),
18-
stack_probes: StackProbeType::Inline,
19-
supported_sanitizers: SanitizerSet::ADDRESS
20-
| SanitizerSet::CFI
21-
| SanitizerSet::SHADOWCALLSTACK,
22-
..base::fuchsia::opts()
23-
},
37+
options: base,
2438
}
2539
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
use crate::spec::{CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base};
1+
use crate::spec::{CodeModel, SanitizerSet, StackProbeType, Target, TargetMetadata, base};
22

33
pub(crate) fn target() -> Target {
4+
let mut base = base::fuchsia::opts();
5+
base.code_model = Some(CodeModel::Medium);
6+
base.cpu = "generic-rv64".into();
7+
base.features = "+m,+a,+f,+d,+c".into();
8+
base.llvm_abiname = "lp64d".into();
9+
base.max_atomic_width = Some(64);
10+
base.stack_probes = StackProbeType::Inline;
11+
base.supported_sanitizers = SanitizerSet::SHADOWCALLSTACK;
12+
base.supports_xray = true;
13+
414
Target {
515
llvm_target: "riscv64-unknown-fuchsia".into(),
616
metadata: TargetMetadata {
@@ -12,14 +22,6 @@ pub(crate) fn target() -> Target {
1222
pointer_width: 64,
1323
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
1424
arch: "riscv64".into(),
15-
options: TargetOptions {
16-
code_model: Some(CodeModel::Medium),
17-
cpu: "generic-rv64".into(),
18-
features: "+m,+a,+f,+d,+c".into(),
19-
llvm_abiname: "lp64d".into(),
20-
max_atomic_width: Some(64),
21-
supported_sanitizers: SanitizerSet::SHADOWCALLSTACK,
22-
..base::fuchsia::opts()
23-
},
25+
options: base,
2426
}
2527
}

‎compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ pub(crate) fn target() -> Target {
44
let mut base = base::fuchsia::opts();
55
base.cpu = "x86-64".into();
66
base.plt_by_default = false;
7-
base.max_atomic_width = Some(64);
7+
// See https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0073_x86_64_platform_requirement,
8+
// which corresponds to x86-64-v2.
9+
base.features = "+cx16,+sahf,+popcnt,+sse3,+sse4.1,+sse4.2,+ssse3".into();
10+
base.max_atomic_width = Some(128);
811
base.stack_probes = StackProbeType::Inline;
912
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK;
1013
base.supports_xray = true;

0 commit comments

Comments
 (0)
Failed to load comments.