rustc_session: Feature gate linker flavors for tier 3 targets

This commit is contained in:
Vadim Petrochenkov 2023-05-23 00:00:35 +03:00
parent b0ce4164f0
commit 23f177d86d
4 changed files with 28 additions and 1 deletions

View File

@ -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;

View File

@ -0,0 +1,2 @@
error: linker flavor `bpf-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it

View File

@ -0,0 +1,2 @@
error: linker flavor `ptx-linker` is unstable, `-Z unstable-options` flag must also be passed to explicitly use it

View File

@ -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]