diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-05-23 00:00:35 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-05-29 19:58:11 +0300 |
| commit | 23f177d86d05c8076c692e1c07e325b2161ae893 (patch) | |
| tree | 56c888eda6a47c942b4e01a91878d1a33e19e50a | |
| parent | b0ce4164f09be1221d004c4b84e49bdcbf973194 (diff) | |
| download | rust-23f177d86d05c8076c692e1c07e325b2161ae893.tar.gz rust-23f177d86d05c8076c692e1c07e325b2161ae893.zip | |
rustc_session: Feature gate linker flavors for tier 3 targets
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 15 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.bpf.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.ptx.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/unstable-flavor.rs | 10 |
4 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 6c8c8e484f9..0ce83e79097 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -12,7 +12,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; use rustc_target::abi::Align; -use rustc_target::spec::{PanicStrategy, SanitizerSet, SplitDebuginfo}; +use rustc_target::spec::{LinkerFlavorCli, PanicStrategy, SanitizerSet, SplitDebuginfo}; use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS}; use crate::parse::{CrateCheckConfig, CrateConfig}; @@ -2525,6 +2525,19 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } } + if let Some(flavor) = cg.linker_flavor { + if matches!(flavor, LinkerFlavorCli::BpfLinker | LinkerFlavorCli::PtxLinker) + && !nightly_options::is_unstable_enabled(matches) + { + let msg = format!( + "linker flavor `{}` is unstable, `-Z unstable-options` \ + flag must also be passed to explicitly use it", + flavor.desc() + ); + early_error(error_format, msg); + } + } + let prints = collect_print_requests(&mut cg, &mut unstable_opts, matches, error_format); let cg = cg; diff --git a/tests/ui/linkage-attr/unstable-flavor.bpf.stderr b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr new file mode 100644 index 00000000000..3346d12c20e --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr @@ -0,0 +1,2 @@ +error: linker flavor `bpf-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it + diff --git a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr new file mode 100644 index 00000000000..03ca2a01246 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr @@ -0,0 +1,2 @@ +error: linker flavor `ptx-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it + diff --git a/tests/ui/linkage-attr/unstable-flavor.rs b/tests/ui/linkage-attr/unstable-flavor.rs new file mode 100644 index 00000000000..5487882dc24 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.rs @@ -0,0 +1,10 @@ +// revisions: bpf ptx +// [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf-linker --crate-type=rlib +// [bpf] error-pattern: linker flavor `bpf-linker` is unstable, `-Z unstable-options` flag +// [bpf] needs-llvm-components: +// [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx-linker --crate-type=rlib +// [ptx] error-pattern: linker flavor `ptx-linker` is unstable, `-Z unstable-options` flag +// [ptx] needs-llvm-components: + +#![feature(no_core)] +#![no_core] |
