mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #149357 - arielb1:enforce-partial-mitigations, r=rcvalle
Implement `-Z allow-partial-mitigations` (RFC 3855) This implements `-Z allow-partial-mitigations` as an unstable option, currently with support for control-flow-guard and stack-protector. As a difference from the RFC, we have `-Z allow-partial-mitigations=!foo` rather than `-Z deny-partial-mitigations=foo`, since I couldn't find an easy way to have an allow/deny pair of flags where the latter flag wins. To allow for stabilization, this is only enabled starting from the next edition. Maybe a better policy is possible (bikeshed). r? @rcvalle
This commit is contained in:
@@ -304,8 +304,7 @@ fn configure_and_expand(
|
||||
|
||||
resolver.resolve_crate(&krate);
|
||||
|
||||
CStore::from_tcx(tcx).report_incompatible_target_modifiers(tcx, &krate);
|
||||
CStore::from_tcx(tcx).report_incompatible_async_drop_feature(tcx, &krate);
|
||||
CStore::from_tcx(tcx).report_session_incompatibilities(tcx, &krate);
|
||||
krate
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Validates all used crates and extern libraries and loads their metadata
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
@@ -23,6 +24,7 @@
|
||||
use rustc_middle::ty::data_structures::IndexSet;
|
||||
use rustc_middle::ty::{TyCtxt, TyCtxtFeed};
|
||||
use rustc_proc_macro::bridge::client::ProcMacro;
|
||||
use rustc_session::config::mitigation_coverage::DeniedPartialMitigationLevel;
|
||||
use rustc_session::config::{
|
||||
CrateType, ExtendedTargetModifierInfo, ExternLocation, Externs, OptionsTargetModifiers,
|
||||
TargetModifier,
|
||||
@@ -463,6 +465,12 @@ fn report_target_modifiers_extended(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn report_session_incompatibilities(&self, tcx: TyCtxt<'_>, krate: &Crate) {
|
||||
self.report_incompatible_target_modifiers(tcx, krate);
|
||||
self.report_incompatible_partial_mitigations(tcx, krate);
|
||||
self.report_incompatible_async_drop_feature(tcx, krate);
|
||||
}
|
||||
|
||||
pub fn report_incompatible_target_modifiers(&self, tcx: TyCtxt<'_>, krate: &Crate) {
|
||||
for flag_name in &tcx.sess.opts.cg.unsafe_allow_abi_mismatch {
|
||||
if !OptionsTargetModifiers::is_target_modifier(flag_name) {
|
||||
@@ -484,6 +492,43 @@ pub fn report_incompatible_target_modifiers(&self, tcx: TyCtxt<'_>, krate: &Crat
|
||||
}
|
||||
}
|
||||
|
||||
pub fn report_incompatible_partial_mitigations(&self, tcx: TyCtxt<'_>, krate: &Crate) {
|
||||
let my_mitigations = tcx.sess.gather_enabled_denied_partial_mitigations();
|
||||
let mut my_mitigations: BTreeMap<_, _> =
|
||||
my_mitigations.iter().map(|mitigation| (mitigation.kind, mitigation)).collect();
|
||||
for skipped_mitigation in tcx.sess.opts.allowed_partial_mitigations(tcx.sess.edition()) {
|
||||
my_mitigations.remove(&skipped_mitigation);
|
||||
}
|
||||
const MAX_ERRORS_PER_MITIGATION: usize = 5;
|
||||
let mut errors_per_mitigation = BTreeMap::new();
|
||||
for (_cnum, data) in self.iter_crate_data() {
|
||||
if data.is_proc_macro_crate() {
|
||||
continue;
|
||||
}
|
||||
let their_mitigations = data.enabled_denied_partial_mitigations();
|
||||
for my_mitigation in my_mitigations.values() {
|
||||
let their_mitigation = their_mitigations
|
||||
.iter()
|
||||
.find(|mitigation| mitigation.kind == my_mitigation.kind)
|
||||
.map_or(DeniedPartialMitigationLevel::Enabled(false), |m| m.level);
|
||||
if their_mitigation < my_mitigation.level {
|
||||
let errors = errors_per_mitigation.entry(my_mitigation.kind).or_insert(0);
|
||||
if *errors >= MAX_ERRORS_PER_MITIGATION {
|
||||
continue;
|
||||
}
|
||||
*errors += 1;
|
||||
|
||||
tcx.dcx().emit_err(errors::MitigationLessStrictInDependency {
|
||||
span: krate.spans.inner_span.shrink_to_lo(),
|
||||
mitigation_name: my_mitigation.kind.to_string(),
|
||||
mitigation_level: my_mitigation.level.level_str().to_string(),
|
||||
extern_crate: data.name(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Report about async drop types in dependency if async drop feature is disabled
|
||||
pub fn report_incompatible_async_drop_feature(&self, tcx: TyCtxt<'_>, krate: &Crate) {
|
||||
if tcx.features().async_drop() {
|
||||
|
||||
@@ -696,3 +696,21 @@ pub(crate) struct UnusedCrateDependency {
|
||||
pub extern_crate: Symbol,
|
||||
pub local_crate: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(
|
||||
"your program uses the crate `{$extern_crate}`, that is not compiled with `{$mitigation_name}{$mitigation_level}` enabled"
|
||||
)]
|
||||
#[note(
|
||||
"recompile `{$extern_crate}` with `{$mitigation_name}{$mitigation_level}` enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation partially enabled "
|
||||
)]
|
||||
#[help(
|
||||
"it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z deny-partial-mitigations={$mitigation_name}`"
|
||||
)]
|
||||
pub struct MitigationLessStrictInDependency {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub mitigation_name: String,
|
||||
pub mitigation_level: String,
|
||||
pub extern_crate: Symbol,
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
use rustc_serialize::opaque::MemDecoder;
|
||||
use rustc_serialize::{Decodable, Decoder};
|
||||
use rustc_session::config::TargetModifier;
|
||||
use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
|
||||
use rustc_session::cstore::{CrateSource, ExternCrate};
|
||||
use rustc_span::hygiene::HygieneDecodeContext;
|
||||
use rustc_span::{
|
||||
@@ -78,9 +79,15 @@ pub(crate) fn bytes(&self) -> &OwnedSlice {
|
||||
/// own crate numbers.
|
||||
pub(crate) type CrateNumMap = IndexVec<CrateNum, CrateNum>;
|
||||
|
||||
/// Target modifiers - abi or exploit mitigations flags
|
||||
/// Target modifiers - abi or exploit mitigations options that may cause unsoundness when mixed or
|
||||
/// partially enabled.
|
||||
pub(crate) type TargetModifiers = Vec<TargetModifier>;
|
||||
|
||||
/// The set of mitigations that cannot be partially enabled (see
|
||||
/// [RFC 3855](https://github.com/rust-lang/rfcs/pull/3855)), but are currently enabled for this
|
||||
/// crate.
|
||||
pub(crate) type DeniedPartialMitigations = Vec<DeniedPartialMitigation>;
|
||||
|
||||
pub(crate) struct CrateMetadata {
|
||||
/// The primary crate data - binary metadata blob.
|
||||
blob: MetadataBlob,
|
||||
@@ -959,6 +966,13 @@ pub(crate) fn decode_target_modifiers<'a>(
|
||||
) -> impl ExactSizeIterator<Item = TargetModifier> {
|
||||
self.target_modifiers.decode(metadata)
|
||||
}
|
||||
|
||||
pub(crate) fn decode_denied_partial_mitigations<'a>(
|
||||
&self,
|
||||
metadata: &'a MetadataBlob,
|
||||
) -> impl ExactSizeIterator<Item = DeniedPartialMitigation> {
|
||||
self.denied_partial_mitigations.decode(metadata)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CrateMetadataRef<'a> {
|
||||
@@ -1941,6 +1955,10 @@ pub(crate) fn target_modifiers(&self) -> TargetModifiers {
|
||||
self.root.decode_target_modifiers(&self.blob).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn enabled_denied_partial_mitigations(&self) -> DeniedPartialMitigations {
|
||||
self.root.decode_denied_partial_mitigations(&self.blob).collect()
|
||||
}
|
||||
|
||||
/// Keep `new_extern_crate` if it looks better in diagnostics
|
||||
pub(crate) fn update_extern_crate_diagnostics(
|
||||
&mut self,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
use rustc_middle::ty::fast_reject::{self, TreatParams};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque};
|
||||
use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
|
||||
use rustc_session::config::{CrateType, OptLevel, TargetModifier};
|
||||
use rustc_span::hygiene::HygieneEncodeContext;
|
||||
use rustc_span::{
|
||||
@@ -715,6 +716,8 @@ macro_rules! stat {
|
||||
// `SourceFiles` we actually need to encode.
|
||||
let source_map = stat!("source-map", || self.encode_source_map());
|
||||
let target_modifiers = stat!("target-modifiers", || self.encode_target_modifiers());
|
||||
let denied_partial_mitigations = stat!("denied-partial-mitigations", || self
|
||||
.encode_enabled_denied_partial_mitigations());
|
||||
|
||||
let root = stat!("final", || {
|
||||
let attrs = tcx.hir_krate_attrs();
|
||||
@@ -758,6 +761,7 @@ macro_rules! stat {
|
||||
foreign_modules,
|
||||
source_map,
|
||||
target_modifiers,
|
||||
denied_partial_mitigations,
|
||||
traits,
|
||||
impls,
|
||||
incoherent_impls,
|
||||
@@ -2107,6 +2111,12 @@ fn encode_target_modifiers(&mut self) -> LazyArray<TargetModifier> {
|
||||
self.lazy_array(tcx.sess.opts.gather_target_modifiers())
|
||||
}
|
||||
|
||||
fn encode_enabled_denied_partial_mitigations(&mut self) -> LazyArray<DeniedPartialMitigation> {
|
||||
empty_proc_macro!(self);
|
||||
let tcx = self.tcx;
|
||||
self.lazy_array(tcx.sess.gather_enabled_denied_partial_mitigations())
|
||||
}
|
||||
|
||||
fn encode_lib_features(&mut self) -> LazyArray<(Symbol, FeatureStability)> {
|
||||
empty_proc_macro!(self);
|
||||
let tcx = self.tcx;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_serialize::opaque::FileEncoder;
|
||||
use rustc_session::config::mitigation_coverage::DeniedPartialMitigation;
|
||||
use rustc_session::config::{SymbolManglingVersion, TargetModifier};
|
||||
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
|
||||
use rustc_span::edition::Edition;
|
||||
@@ -286,6 +287,7 @@ pub(crate) struct CrateRoot {
|
||||
|
||||
source_map: LazyTable<u32, Option<LazyValue<rustc_span::SourceFile>>>,
|
||||
target_modifiers: LazyArray<TargetModifier>,
|
||||
denied_partial_mitigations: LazyArray<DeniedPartialMitigation>,
|
||||
|
||||
compiler_builtins: bool,
|
||||
needs_allocator: bool,
|
||||
|
||||
@@ -120,6 +120,7 @@ impl ParameterizedOverTcx for $ty {
|
||||
rustc_middle::ty::adjustment::CoerceUnsizedInfo,
|
||||
rustc_middle::ty::fast_reject::SimplifiedType,
|
||||
rustc_session::config::TargetModifier,
|
||||
rustc_session::config::mitigation_coverage::DeniedPartialMitigation,
|
||||
rustc_session::cstore::ForeignModule,
|
||||
rustc_session::cstore::LinkagePreference,
|
||||
rustc_session::cstore::NativeLib,
|
||||
|
||||
@@ -1449,6 +1449,7 @@ fn default() -> Options {
|
||||
logical_env: FxIndexMap::default(),
|
||||
verbose: false,
|
||||
target_modifiers: BTreeMap::default(),
|
||||
mitigation_coverage_map: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2469,9 +2470,9 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
|
||||
.unwrap_or_else(|e| early_dcx.early_fatal(e));
|
||||
|
||||
let mut target_modifiers = BTreeMap::<OptionsTargetModifiers, String>::new();
|
||||
let mut collected_options = Default::default();
|
||||
|
||||
let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut target_modifiers);
|
||||
let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut collected_options);
|
||||
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
|
||||
|
||||
if !unstable_opts.unstable_options && json_timings {
|
||||
@@ -2487,7 +2488,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
|
||||
let output_types = parse_output_types(early_dcx, &unstable_opts, matches);
|
||||
|
||||
let mut cg = CodegenOptions::build(early_dcx, matches, &mut target_modifiers);
|
||||
let mut cg = CodegenOptions::build(early_dcx, matches, &mut collected_options);
|
||||
let (disable_local_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto(
|
||||
early_dcx,
|
||||
&output_types,
|
||||
@@ -2638,7 +2639,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
// -Zretpoline-external-thunk also requires -Zretpoline
|
||||
if unstable_opts.retpoline_external_thunk {
|
||||
unstable_opts.retpoline = true;
|
||||
target_modifiers.insert(
|
||||
collected_options.target_modifiers.insert(
|
||||
OptionsTargetModifiers::UnstableOptions(UnstableOptionsTargetModifiers::retpoline),
|
||||
"true".to_string(),
|
||||
);
|
||||
@@ -2798,7 +2799,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
||||
color,
|
||||
logical_env,
|
||||
verbose,
|
||||
target_modifiers,
|
||||
target_modifiers: collected_options.target_modifiers,
|
||||
mitigation_coverage_map: collected_options.mitigations,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ pub struct TargetModifier {
|
||||
pub value_name: String,
|
||||
}
|
||||
|
||||
pub mod mitigation_coverage;
|
||||
|
||||
mod target_modifier_consistency_check {
|
||||
use super::*;
|
||||
pub(super) fn sanitizer(l: &TargetModifier, r: Option<&TargetModifier>) -> bool {
|
||||
@@ -198,15 +200,15 @@ macro_rules! gather_tmods {
|
||||
tmod_push!($struct_name, $tmod_enum_name, $opt_name, $opt_expr, $init, $mods, $tmod_vals)
|
||||
};
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
|
||||
[SUBSTRUCT], []) => {
|
||||
[SUBSTRUCT], [$(MITIGATION)?]) => {
|
||||
$opt_expr.gather_target_modifiers($mods, $tmod_vals);
|
||||
};
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
|
||||
[UNTRACKED], []) => {{}};
|
||||
[UNTRACKED], [$(MITIGATION)?]) => {{}};
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
|
||||
[TRACKED], []) => {{}};
|
||||
[TRACKED], [$(MITIGATION)?]) => {{}};
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt_name:ident, $opt_expr:expr, $init:expr, $mods:expr, $tmod_vals:expr,
|
||||
[TRACKED_NO_CRATE_HASH], []) => {{}};
|
||||
[TRACKED_NO_CRATE_HASH], [$(MITIGATION)?]) => {{}};
|
||||
}
|
||||
|
||||
macro_rules! gather_tmods_top_level {
|
||||
@@ -216,7 +218,7 @@ macro_rules! gather_tmods_top_level {
|
||||
($opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [$non_substruct:ident TARGET_MODIFIER]) => {
|
||||
compile_error!("Top level option can't be target modifier");
|
||||
};
|
||||
($opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [$non_substruct:ident]) => {};
|
||||
($opt_name:ident, $opt_expr:expr, $mods:expr, $tmod_vals:expr, [$non_substruct:ident $(MITIGATION)?]) => {};
|
||||
}
|
||||
|
||||
/// Macro for generating OptionsTargetsModifiers top-level enum with impl.
|
||||
@@ -321,6 +323,7 @@ pub struct Options {
|
||||
pub $opt: $t
|
||||
),*,
|
||||
pub target_modifiers: BTreeMap<OptionsTargetModifiers, String>,
|
||||
pub mitigation_coverage_map: mitigation_coverage::MitigationCoverageMap,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@@ -503,11 +506,20 @@ pub struct Options {
|
||||
}
|
||||
);
|
||||
|
||||
macro_rules! mitigation_enum_opt {
|
||||
($opt:ident, MITIGATION) => {
|
||||
Some(mitigation_coverage::DeniedPartialMitigationKind::$opt)
|
||||
};
|
||||
($opt:ident, $(TARGET_MODIFIER)?) => {
|
||||
None
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! tmod_enum_opt {
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt:ident, $v:ident) => {
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt:ident, TARGET_MODIFIER) => {
|
||||
Some(OptionsTargetModifiers::$struct_name($tmod_enum_name::$opt))
|
||||
};
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt:ident, ) => {
|
||||
($struct_name:ident, $tmod_enum_name:ident, $opt:ident, $(MITIGATION)?) => {
|
||||
None
|
||||
};
|
||||
}
|
||||
@@ -579,7 +591,7 @@ pub fn is_target_modifier(flag_name: &str) -> bool {
|
||||
(
|
||||
$tmod_enum_name:ident, $prefix:expr,
|
||||
@parse {$($eout:tt)*}, ($puser_value:ident){$($pout:tt)*};
|
||||
$opt:ident, $parse:ident, $t:ty, [] |
|
||||
$opt:ident, $parse:ident, $t:ty, [$(MITIGATION)?] |
|
||||
$($tail:tt)*
|
||||
) => {
|
||||
tmod_enum! {
|
||||
@@ -596,6 +608,47 @@ pub fn is_target_modifier(flag_name: &str) -> bool {
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CollectedOptions {
|
||||
pub target_modifiers: BTreeMap<OptionsTargetModifiers, String>,
|
||||
pub mitigations: mitigation_coverage::MitigationCoverageMap,
|
||||
}
|
||||
|
||||
macro_rules! setter_for {
|
||||
// the allow/deny-mitigations options use collected/index instead of the cg, since they
|
||||
// work across option groups
|
||||
(allow_partial_mitigations, $struct_name:ident, $parse:ident) => {
|
||||
pub(super) fn allow_partial_mitigations(
|
||||
_cg: &mut super::$struct_name,
|
||||
collected: &mut super::CollectedOptions,
|
||||
v: Option<&str>,
|
||||
index: usize,
|
||||
) -> bool {
|
||||
collected.mitigations.handle_allowdeny_mitigation_option(v, index, true)
|
||||
}
|
||||
};
|
||||
(deny_partial_mitigations, $struct_name:ident, $parse:ident) => {
|
||||
pub(super) fn deny_partial_mitigations(
|
||||
_cg: &mut super::$struct_name,
|
||||
collected: &mut super::CollectedOptions,
|
||||
v: Option<&str>,
|
||||
index: usize,
|
||||
) -> bool {
|
||||
collected.mitigations.handle_allowdeny_mitigation_option(v, index, false)
|
||||
}
|
||||
};
|
||||
($opt:ident, $struct_name:ident, $parse:ident) => {
|
||||
pub(super) fn $opt(
|
||||
cg: &mut super::$struct_name,
|
||||
_collected: &mut super::CollectedOptions,
|
||||
v: Option<&str>,
|
||||
_index: usize,
|
||||
) -> bool {
|
||||
super::parse::$parse(&mut redirect_field!(cg.$opt), v)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Defines all `CodegenOptions`/`DebuggingOptions` fields and parsers all at once. The goal of this
|
||||
/// macro is to define an interface that can be programmatically used by the option parser
|
||||
/// to initialize the struct without hardcoding field names all over the place.
|
||||
@@ -609,7 +662,7 @@ macro_rules! options {
|
||||
$($( #[$attr:meta] )* $opt:ident : $t:ty = (
|
||||
$init:expr,
|
||||
$parse:ident,
|
||||
[$dep_tracking_marker:ident $( $tmod:ident )?],
|
||||
[$dep_tracking_marker:ident $( $modifier_kind:ident )?],
|
||||
$desc:expr
|
||||
$(, removed: $removed:ident )?)
|
||||
),* ,) =>
|
||||
@@ -618,7 +671,7 @@ macro_rules! options {
|
||||
#[rustc_lint_opt_ty]
|
||||
pub struct $struct_name { $( $( #[$attr] )* pub $opt: $t),* }
|
||||
|
||||
tmod_enum!( $tmod_enum_name, $prefix, {$($opt, $parse, $t, [$($tmod),*])|*} );
|
||||
tmod_enum!( $tmod_enum_name, $prefix, {$($opt, $parse, $t, [$($modifier_kind),*])|*} );
|
||||
|
||||
impl Default for $struct_name {
|
||||
fn default() -> $struct_name {
|
||||
@@ -630,7 +683,7 @@ impl $struct_name {
|
||||
pub fn build(
|
||||
early_dcx: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
target_modifiers: &mut BTreeMap<OptionsTargetModifiers, String>,
|
||||
target_modifiers: &mut CollectedOptions,
|
||||
) -> $struct_name {
|
||||
build_options(early_dcx, matches, target_modifiers, $stat, $prefix, $outputname)
|
||||
}
|
||||
@@ -660,7 +713,7 @@ pub fn gather_target_modifiers(
|
||||
) {
|
||||
$({
|
||||
gather_tmods!($struct_name, $tmod_enum_name, $opt, &self.$opt, $init, _mods, _tmod_vals,
|
||||
[$dep_tracking_marker], [$($tmod),*]);
|
||||
[$dep_tracking_marker], [$($modifier_kind),*]);
|
||||
})*
|
||||
}
|
||||
}
|
||||
@@ -668,13 +721,13 @@ pub fn gather_target_modifiers(
|
||||
pub const $stat: OptionDescrs<$struct_name> =
|
||||
&[ $( OptionDesc{ name: stringify!($opt), setter: $optmod::$opt,
|
||||
type_desc: desc::$parse, desc: $desc, removed: None $( .or(Some(RemovedOption::$removed)) )?,
|
||||
tmod: tmod_enum_opt!($struct_name, $tmod_enum_name, $opt, $($tmod),*) } ),* ];
|
||||
tmod: tmod_enum_opt!($struct_name, $tmod_enum_name, $opt, $($modifier_kind),*),
|
||||
mitigation: mitigation_enum_opt!($opt, $($modifier_kind),*),
|
||||
} ),* ];
|
||||
|
||||
mod $optmod {
|
||||
$(
|
||||
pub(super) fn $opt(cg: &mut super::$struct_name, v: Option<&str>) -> bool {
|
||||
super::parse::$parse(&mut redirect_field!(cg.$opt), v)
|
||||
}
|
||||
setter_for!($opt, $struct_name, $parse);
|
||||
)*
|
||||
}
|
||||
|
||||
@@ -702,7 +755,7 @@ macro_rules! redirect_field {
|
||||
};
|
||||
}
|
||||
|
||||
type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
|
||||
type OptionSetter<O> = fn(&mut O, &mut CollectedOptions, v: Option<&str>, pos: usize) -> bool;
|
||||
type OptionDescrs<O> = &'static [OptionDesc<O>];
|
||||
|
||||
/// Indicates whether a removed option should warn or error.
|
||||
@@ -720,6 +773,7 @@ pub struct OptionDesc<O> {
|
||||
desc: &'static str,
|
||||
removed: Option<RemovedOption>,
|
||||
tmod: Option<OptionsTargetModifiers>,
|
||||
mitigation: Option<mitigation_coverage::DeniedPartialMitigationKind>,
|
||||
}
|
||||
|
||||
impl<O> OptionDesc<O> {
|
||||
@@ -735,13 +789,13 @@ pub fn desc(&self) -> &'static str {
|
||||
fn build_options<O: Default>(
|
||||
early_dcx: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
target_modifiers: &mut BTreeMap<OptionsTargetModifiers, String>,
|
||||
collected_options: &mut CollectedOptions,
|
||||
descrs: OptionDescrs<O>,
|
||||
prefix: &str,
|
||||
outputname: &str,
|
||||
) -> O {
|
||||
let mut op = O::default();
|
||||
for option in matches.opt_strs(prefix) {
|
||||
for (index, option) in matches.opt_strs_pos(prefix) {
|
||||
let (key, value) = match option.split_once('=') {
|
||||
None => (option, None),
|
||||
Some((k, v)) => (k.to_string(), Some(v)),
|
||||
@@ -749,7 +803,7 @@ fn build_options<O: Default>(
|
||||
|
||||
let option_to_lookup = key.replace('-', "_");
|
||||
match descrs.iter().find(|opt_desc| opt_desc.name == option_to_lookup) {
|
||||
Some(OptionDesc { name: _, setter, type_desc, desc, removed, tmod }) => {
|
||||
Some(OptionDesc { name: _, setter, type_desc, desc, removed, tmod, mitigation }) => {
|
||||
if let Some(removed) = removed {
|
||||
// deprecation works for prefixed options only
|
||||
assert!(!prefix.is_empty());
|
||||
@@ -762,7 +816,7 @@ fn build_options<O: Default>(
|
||||
}
|
||||
}
|
||||
}
|
||||
if !setter(&mut op, value) {
|
||||
if !setter(&mut op, collected_options, value, index) {
|
||||
match value {
|
||||
None => early_dcx.early_fatal(
|
||||
format!(
|
||||
@@ -778,7 +832,10 @@ fn build_options<O: Default>(
|
||||
}
|
||||
if let Some(tmod) = *tmod {
|
||||
let v = value.map_or(String::new(), ToOwned::to_owned);
|
||||
target_modifiers.insert(tmod, v);
|
||||
collected_options.target_modifiers.insert(tmod, v);
|
||||
}
|
||||
if let Some(mitigation) = mitigation {
|
||||
collected_options.mitigations.reset_mitigation(*mitigation, index);
|
||||
}
|
||||
}
|
||||
None => early_dcx.early_fatal(format!("unknown {outputname} option: `{key}`")),
|
||||
@@ -889,6 +946,10 @@ mod desc {
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
|
||||
pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 2^29";
|
||||
pub(crate) const parse_assert_incr_state: &str = "one of: `loaded`, `not-loaded`";
|
||||
pub(crate) const parse_allow_partial_mitigations: &str =
|
||||
super::mitigation_coverage::DeniedPartialMitigationKind::KINDS;
|
||||
pub(crate) const parse_deny_partial_mitigations: &str =
|
||||
super::mitigation_coverage::DeniedPartialMitigationKind::KINDS;
|
||||
}
|
||||
|
||||
pub mod parse {
|
||||
@@ -2095,7 +2156,7 @@ pub(crate) fn parse_assert_incr_state(
|
||||
collapse_macro_debuginfo: CollapseMacroDebuginfo = (CollapseMacroDebuginfo::Unspecified,
|
||||
parse_collapse_macro_debuginfo, [TRACKED],
|
||||
"set option to collapse debuginfo for macros"),
|
||||
control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
|
||||
control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED MITIGATION],
|
||||
"use Windows Control Flow Guard (default: no)"),
|
||||
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"explicitly enable the `cfg(debug_assertions)` directive"),
|
||||
@@ -2237,6 +2298,10 @@ pub(crate) fn parse_assert_incr_state(
|
||||
// tidy-alphabetical-start
|
||||
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
|
||||
"only allow the listed language features to be enabled in code (comma separated)"),
|
||||
// the real parser is at the `setter_for` macro, to allow `-Z` and `-C` options to
|
||||
// work together.
|
||||
allow_partial_mitigations: () = ((), parse_allow_partial_mitigations, [UNTRACKED],
|
||||
"Allow mitigations not enabled for all dependency crates (comma separated list)"),
|
||||
always_encode_mir: bool = (false, parse_bool, [TRACKED],
|
||||
"encode MIR of all functions into the crate metadata (default: no)"),
|
||||
annotate_moves: AnnotateMoves = (AnnotateMoves::Disabled, parse_annotate_moves, [TRACKED],
|
||||
@@ -2304,6 +2369,8 @@ pub(crate) fn parse_assert_incr_state(
|
||||
"deduplicate identical diagnostics (default: yes)"),
|
||||
default_visibility: Option<SymbolVisibility> = (None, parse_opt_symbol_visibility, [TRACKED],
|
||||
"overrides the `default_visibility` setting of the target"),
|
||||
deny_partial_mitigations: () = ((), parse_deny_partial_mitigations, [UNTRACKED],
|
||||
"Deny mitigations not enabled for all dependency crates (comma separated list)"),
|
||||
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
|
||||
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
|
||||
themselves (default: no)"),
|
||||
@@ -2693,7 +2760,7 @@ pub(crate) fn parse_assert_incr_state(
|
||||
src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
|
||||
"hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
|
||||
#[rustc_lint_opt_deny_field_access("use `Session::stack_protector` instead of this field")]
|
||||
stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
|
||||
stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED MITIGATION],
|
||||
"control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
|
||||
staticlib_allow_rdylib_deps: bool = (false, parse_bool, [TRACKED],
|
||||
"allow staticlibs to have rust dylib dependencies"),
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::str::FromStr;
|
||||
|
||||
use rustc_macros::{BlobDecodable, Encodable};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_target::spec::StackProtector;
|
||||
|
||||
use crate::Session;
|
||||
use crate::config::Options;
|
||||
use crate::options::CFGuard;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, BlobDecodable)]
|
||||
pub enum DeniedPartialMitigationLevel {
|
||||
// Enabled(false) should be the bottom of the Ord hierarchy
|
||||
Enabled(bool),
|
||||
StackProtector(StackProtector),
|
||||
}
|
||||
|
||||
impl DeniedPartialMitigationLevel {
|
||||
pub fn level_str(&self) -> &'static str {
|
||||
match self {
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::All) => "=all",
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::Basic) => "=basic",
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::Strong) => "=strong",
|
||||
// currently `=disabled` should not appear
|
||||
DeniedPartialMitigationLevel::Enabled(false) => "=disabled",
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::None)
|
||||
| DeniedPartialMitigationLevel::Enabled(true) => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DeniedPartialMitigationLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::All) => {
|
||||
write!(f, "all")
|
||||
}
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::Basic) => {
|
||||
write!(f, "basic")
|
||||
}
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::Strong) => {
|
||||
write!(f, "strong")
|
||||
}
|
||||
DeniedPartialMitigationLevel::Enabled(true) => {
|
||||
write!(f, "enabled")
|
||||
}
|
||||
DeniedPartialMitigationLevel::StackProtector(StackProtector::None)
|
||||
| DeniedPartialMitigationLevel::Enabled(false) => {
|
||||
write!(f, "disabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bool> for DeniedPartialMitigationLevel {
|
||||
fn from(value: bool) -> Self {
|
||||
DeniedPartialMitigationLevel::Enabled(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StackProtector> for DeniedPartialMitigationLevel {
|
||||
fn from(value: StackProtector) -> Self {
|
||||
DeniedPartialMitigationLevel::StackProtector(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct MitigationStatus {
|
||||
// This is the index of the option in the command line. This is needed because
|
||||
// re-enabling a mitigation resets the partial mitigation status if it's later in the command
|
||||
// line, and this works across `-C` and `-Z` args.
|
||||
//
|
||||
// e.g. `-Z stack-protector=strong` resets `-C allow-partial-mitigations=stack-protector`.
|
||||
index: usize,
|
||||
allowed: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct MitigationCoverageMap {
|
||||
map: BTreeMap<DeniedPartialMitigationKind, MitigationStatus>,
|
||||
}
|
||||
|
||||
impl MitigationCoverageMap {
|
||||
fn apply_mitigation(
|
||||
&mut self,
|
||||
kind: DeniedPartialMitigationKind,
|
||||
index: usize,
|
||||
allowed: Option<bool>,
|
||||
) {
|
||||
self.map
|
||||
.entry(kind)
|
||||
.and_modify(|e| {
|
||||
if index >= e.index {
|
||||
*e = MitigationStatus { index, allowed }
|
||||
}
|
||||
})
|
||||
.or_insert(MitigationStatus { index, allowed });
|
||||
}
|
||||
|
||||
pub(crate) fn handle_allowdeny_mitigation_option(
|
||||
&mut self,
|
||||
v: Option<&str>,
|
||||
index: usize,
|
||||
allowed: bool,
|
||||
) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
for sub in s.split(',') {
|
||||
match sub.parse() {
|
||||
Ok(kind) => self.apply_mitigation(kind, index, Some(allowed)),
|
||||
Err(_) => return false,
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn reset_mitigation(&mut self, kind: DeniedPartialMitigationKind, index: usize) {
|
||||
self.apply_mitigation(kind, index, None);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DeniedPartialMitigationKindParseError;
|
||||
|
||||
macro_rules! intersperse {
|
||||
($sep:expr, ($first:expr $(, $rest:expr)* $(,)?)) => {
|
||||
concat!($first $(, $sep, $rest)*)
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! denied_partial_mitigations {
|
||||
([$self:ident] enum $kind:ident {$(($name:ident, $text:expr, $since:ident, $code:expr)),*}) => {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Encodable, BlobDecodable)]
|
||||
pub enum DeniedPartialMitigationKind {
|
||||
$($name),*
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DeniedPartialMitigationKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
$(DeniedPartialMitigationKind::$name => write!(f, $text)),*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DeniedPartialMitigationKind {
|
||||
pub(crate) const KINDS: &'static str = concat!("comma-separated list of mitigation kinds (available: ",
|
||||
intersperse!(", ", ($(concat!("`", $text, "`")),*)), ")");
|
||||
}
|
||||
|
||||
impl FromStr for DeniedPartialMitigationKind {
|
||||
type Err = DeniedPartialMitigationKindParseError;
|
||||
|
||||
fn from_str(v: &str) -> Result<DeniedPartialMitigationKind, DeniedPartialMitigationKindParseError> {
|
||||
match v {
|
||||
$($text => Ok(DeniedPartialMitigationKind::$name)),*
|
||||
,
|
||||
_ => Err(DeniedPartialMitigationKindParseError),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
impl DeniedPartialMitigationKind {
|
||||
pub fn allowed_by_default_at(&self, edition: Edition) -> bool {
|
||||
let denied_since = match self {
|
||||
// Should change the denied-since edition of StackProtector to 2015
|
||||
// (all editions) when `-C stack-protector` is stabilized.
|
||||
$(DeniedPartialMitigationKind::$name => Edition::$since),*
|
||||
};
|
||||
edition < denied_since
|
||||
}
|
||||
}
|
||||
|
||||
impl Options {
|
||||
pub fn all_denied_partial_mitigations(&self) -> impl Iterator<Item = DeniedPartialMitigationKind> {
|
||||
[$(DeniedPartialMitigationKind::$name),*].into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn gather_enabled_denied_partial_mitigations(&$self) -> Vec<DeniedPartialMitigation> {
|
||||
let mut mitigations = [
|
||||
$(
|
||||
DeniedPartialMitigation {
|
||||
kind: DeniedPartialMitigationKind::$name,
|
||||
level: From::from($code),
|
||||
}
|
||||
),*
|
||||
];
|
||||
mitigations.sort();
|
||||
mitigations.into_iter().collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
denied_partial_mitigations! {
|
||||
[self]
|
||||
enum DeniedPartialMitigationKind {
|
||||
// The mitigation name should match the option name in rustc_session::options,
|
||||
// to allow for resetting the mitigation
|
||||
(stack_protector, "stack-protector", EditionFuture, self.stack_protector()),
|
||||
(control_flow_guard, "control-flow-guard", EditionFuture, self.opts.cg.control_flow_guard == CFGuard::Checks)
|
||||
}
|
||||
}
|
||||
|
||||
/// A mitigation that cannot be partially enabled (see
|
||||
/// [RFC 3855](https://github.com/rust-lang/rfcs/pull/3855)), but are currently enabled for this
|
||||
/// crate.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, BlobDecodable)]
|
||||
pub struct DeniedPartialMitigation {
|
||||
pub kind: DeniedPartialMitigationKind,
|
||||
pub level: DeniedPartialMitigationLevel,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
// Return the list of mitigations that are allowed to be partial
|
||||
pub fn allowed_partial_mitigations(
|
||||
&self,
|
||||
edition: Edition,
|
||||
) -> impl Iterator<Item = DeniedPartialMitigationKind> {
|
||||
let mut result: BTreeSet<_> = self
|
||||
.all_denied_partial_mitigations()
|
||||
.filter(|mitigation| mitigation.allowed_by_default_at(edition))
|
||||
.collect();
|
||||
for (kind, MitigationStatus { index: _, allowed }) in &self.mitigation_coverage_map.map {
|
||||
match allowed {
|
||||
Some(true) => {
|
||||
result.insert(*kind);
|
||||
}
|
||||
Some(false) => {
|
||||
result.remove(kind);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
result.into_iter()
|
||||
}
|
||||
}
|
||||
@@ -1347,6 +1347,7 @@ pub fn ratchet(&mut self, rhs: FramePointer) -> FramePointer {
|
||||
|
||||
crate::target_spec_enum! {
|
||||
/// Controls use of stack canaries.
|
||||
#[derive(Encodable, BlobDecodable, HashStable_Generic)]
|
||||
pub enum StackProtector {
|
||||
/// Disable stack canary generation.
|
||||
None = "none",
|
||||
|
||||
@@ -413,9 +413,9 @@ pub(crate) fn from_matches(
|
||||
config::parse_error_format(early_dcx, matches, color, json_color, json_rendered);
|
||||
let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_default();
|
||||
|
||||
let mut target_modifiers = BTreeMap::<OptionsTargetModifiers, String>::new();
|
||||
let codegen_options = CodegenOptions::build(early_dcx, matches, &mut target_modifiers);
|
||||
let unstable_opts = UnstableOptions::build(early_dcx, matches, &mut target_modifiers);
|
||||
let mut collected_options = Default::default();
|
||||
let codegen_options = CodegenOptions::build(early_dcx, matches, &mut collected_options);
|
||||
let unstable_opts = UnstableOptions::build(early_dcx, matches, &mut collected_options);
|
||||
|
||||
let remap_path_prefix = match parse_remap_path_prefix(matches) {
|
||||
Ok(prefix_mappings) => prefix_mappings,
|
||||
@@ -894,7 +894,7 @@ fn println_condition(condition: Condition) {
|
||||
scrape_examples_options,
|
||||
unstable_features,
|
||||
doctest_build_args,
|
||||
target_modifiers,
|
||||
target_modifiers: collected_options.target_modifiers,
|
||||
};
|
||||
let render_options = RenderOptions {
|
||||
output,
|
||||
|
||||
@@ -22,6 +22,12 @@ These tests exercise `#![feature(allocator_api)]` and the `#[global_allocator]`
|
||||
|
||||
See [Allocator traits and `std::heap` #32838](https://github.com/rust-lang/rust/issues/32838).
|
||||
|
||||
## `tests/ui/allow-partial-mitigations`
|
||||
|
||||
These tests exercise the support for mitigation coverage and the `allow-partial-mitigations` and `deny-partial-mitigations` options.
|
||||
|
||||
See [RFC 3855](https://github.com/rust-lang/rfcs/pull/3855).
|
||||
|
||||
## `tests/ui/annotate-moves`
|
||||
|
||||
These tests exercise the `annotate-moves` feature.
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ revisions: stack-protector-future stack-protector-future-explicit-deny stack-protector-future-deny-reset-by-mitigation stack-protector-allow-then-deny stack-protector-but-allow-control-flow-guard control-flow-guard-future-allow-reset-by-mitigation stack-protector-future-allow-reset-by-mitigation stack-protector-future-deny-allow-reset-by-mitigation
|
||||
//@ check-fail
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
//@ edition:future
|
||||
|
||||
// msvc has an extra unwind dependency of std, normalize it in the error messages
|
||||
//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc"
|
||||
|
||||
// test that stack-protector is denied-partial in edition=future
|
||||
//@ [stack-protector-future] compile-flags: -Z unstable-options -Z stack-protector=all
|
||||
|
||||
// same, but with explicit deny
|
||||
//@ [stack-protector-future-explicit-deny] compile-flags: -Z unstable-options -Z stack-protector=all -Z deny-partial-mitigations=stack-protector
|
||||
|
||||
// same, but with explicit deny before the enable. The `-Z stack-protector=all` resets the mitigation status
|
||||
// to default which is deny at edition=future.
|
||||
// at edition=2024, this would be allowed, see ok-allow-partial-mitigations-current-edition scenario stack-protector-future-deny-reset-by-mitigation
|
||||
//@ [stack-protector-future-deny-reset-by-mitigation] compile-flags: -Z unstable-options -Z deny-partial-mitigations=stack-protector -Z stack-protector=all
|
||||
|
||||
// same, but with explicit allow followed by explicit deny
|
||||
//@ [stack-protector-allow-then-deny] compile-flags: -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=stack-protector -Z deny-partial-mitigations=stack-protector
|
||||
|
||||
// check that allowing an unrelated mitigation (control-flow-guard) does not allow a different mitigation (stack-protector)
|
||||
//@ [stack-protector-but-allow-control-flow-guard] compile-flags: -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=control-flow-guard
|
||||
|
||||
// check that `-C control-flow-guard` overrides the `-Z allow-partial-mitigations=control-flow-guard` (to the default, which is deny at edition=future)
|
||||
//@ [control-flow-guard-future-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=control-flow-guard -C control-flow-guard=on
|
||||
|
||||
// check that `-Z stack-protector` overrides the `-Z allow-partial-mitigations=stack-protector` (to the default, which is deny at edition=future)
|
||||
//@ [stack-protector-future-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z stack-protector=all
|
||||
|
||||
// check that this is the case even if there was a "deny" before the "allow"
|
||||
//@ [stack-protector-future-deny-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z deny-partial-mitigations=stack-protector -Z allow-partial-mitigations=stack-protector -Z stack-protector=all
|
||||
|
||||
fn main() {}
|
||||
//~^ ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-1-error.rs:37:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ revisions: both enable-separately-disable-together enable-together-disable-separately
|
||||
//@ check-fail
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
//@ edition:future
|
||||
|
||||
// msvc has an extra unwind dependency of std, normalize it in the error messages
|
||||
//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc"
|
||||
|
||||
// just use 2 partial mitigations, without any allow/deny flag. Should be denied at edition=future.
|
||||
//@ [both] compile-flags: -Z unstable-options -C control-flow-guard=on -Z stack-protector=all
|
||||
|
||||
// check that mitigations are denied if they are enabled separately and then disabled in a single command,
|
||||
// to test the "foo,bar" syntax
|
||||
//@ [enable-separately-disable-together] compile-flags: -Z unstable-options -C control-flow-guard=on -Z stack-protector=all -Z allow-partial-mitigations=stack-protector -Z allow-partial-mitigations=control-flow-guard -Z deny-partial-mitigations=control-flow-guard,stack-protector
|
||||
|
||||
// same, but for allow
|
||||
//@ [enable-together-disable-separately] compile-flags: -Z unstable-options -C control-flow-guard=on -Z stack-protector=all -Z allow-partial-mitigations=stack-protector,control-flow-guard -Z deny-partial-mitigations=control-flow-guard -Z deny-partial-mitigations=stack-protector
|
||||
|
||||
fn main() {}
|
||||
//~^ ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
@@ -0,0 +1,12 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ check-fail
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
//@ edition:future
|
||||
//@ compile-flags: -Z unstable-options -Z deny-partial-mitigations=garbage
|
||||
|
||||
// test that the list of mitigations in the error message is generated correctly
|
||||
|
||||
//~? ERROR incorrect value `garbage` for unstable option `deny-partial-mitigations` - comma-separated list of mitigation kinds (available:
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,2 @@
|
||||
error: incorrect value `garbage` for unstable option `deny-partial-mitigations` - comma-separated list of mitigation kinds (available: `stack-protector`, `control-flow-guard`) was expected
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled
|
||||
--> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^
|
||||
|
|
||||
= note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled
|
||||
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ revisions: control-flow-2024-explicit-deny
|
||||
//@ check-fail
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
//@ edition: 2024
|
||||
|
||||
// msvc has an extra unwind dependency of std, normalize it in the error messages
|
||||
//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc"
|
||||
|
||||
// check that in edition 2024, it is still possible to explicitly
|
||||
// disallow partial mitigations (in edition=future, they are
|
||||
// disallowed by default)
|
||||
|
||||
//@ [control-flow-2024-explicit-deny] compile-flags: -C control-flow-guard=on -Z deny-partial-mitigations=control-flow-guard
|
||||
|
||||
|
||||
fn main() {}
|
||||
//~^ ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
//~| ERROR that is not compiled with
|
||||
@@ -0,0 +1,25 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ revisions: control-flow-guard-2024-default control-flow-guard-2024-deny-reset-by-mitigation stack-protector-2024-deny-reset-by-mitigation stack-protector-2024-allow-deny-reset-by-mitigation
|
||||
//@ check-pass
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
//@ edition: 2024
|
||||
|
||||
// check that the `-C control-flow-guard=on` overrides the `-Z deny-partial-mitigations=control-flow-guard`,
|
||||
// which in edition 2024 leads to partial mitigations being allowed. Test with both an explicit
|
||||
// deny and without one.
|
||||
|
||||
// just test control-flow-guard at edition 2024. allowed-partial due to backwards compatibility.
|
||||
//@ [control-flow-guard-2024-default] compile-flags: -C control-flow-guard=on
|
||||
|
||||
// test that -C control-flow-guard=on resets -Z deny-partial-mitigations=control-flow-guard
|
||||
//@ [control-flow-guard-2024-deny-reset-by-mitigation] compile-flags: -Z deny-partial-mitigations=control-flow-guard -C control-flow-guard=on
|
||||
|
||||
// same but for stack-protector, to match the stack-protector-future-deny-reset-by-mitigation test in
|
||||
// err-allow-partial-mitigations-1-error (which has the same args but on edition=future).
|
||||
//@ [stack-protector-2024-deny-reset-by-mitigation] compile-flags: -Z deny-partial-mitigations=stack-protector -Z stack-protector=all
|
||||
|
||||
// check that this is the case even if there was an "allow" then a "deny"
|
||||
//@ [stack-protector-2024-allow-deny-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z deny-partial-mitigations=stack-protector -Z stack-protector=all
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,18 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ check-pass
|
||||
//@ add-minicore
|
||||
//@ edition:future
|
||||
//@ revisions: default deny
|
||||
//@[default] compile-flags: -Z unstable-options -Z stack-protector=all
|
||||
//@[deny] compile-flags: -Z deny-partial-mitigations=stack-protector -Z unstable-options -Z stack-protector=all
|
||||
|
||||
// ^ enables stack-protector for both minicore and this crate
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(no_core)]
|
||||
#![no_std]
|
||||
#![no_core]
|
||||
|
||||
extern crate minicore;
|
||||
|
||||
pub fn foo() {}
|
||||
@@ -0,0 +1,18 @@
|
||||
// ignore-tidy-linelength
|
||||
//@ revisions: stack-protector-explicit-allow stack-protector-and-control-flow-guard-explicit-allow stack-protector-deny-then-allow
|
||||
//@ check-pass
|
||||
//@ edition:future
|
||||
//@ ignore-nvptx64 stack protector is not supported
|
||||
//@ ignore-wasm32-unknown-unknown stack protector is not supported
|
||||
|
||||
// requesting both stack-protector and control-flow-guard and then allow-partial-mitigations it
|
||||
//@ [stack-protector-and-control-flow-guard-explicit-allow] compile-flags: -Z unstable-options -Z stack-protector=all -C control-flow-guard=on -Z allow-partial-mitigations=stack-protector,control-flow-guard
|
||||
|
||||
// requesting stack-protector and then allow-partial-mitigations it
|
||||
//@ [stack-protector-explicit-allow] compile-flags: -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=stack-protector
|
||||
|
||||
// testing that the later allow-partial-mitigations overrides the earlier deny-partial-mitigations
|
||||
// see also the stack-protector-allow-then-deny test (in the error tests) for the other order
|
||||
//@ [stack-protector-deny-then-allow] compile-flags: -Z unstable-options -Z stack-protector=all -Z deny-partial-mitigations=stack-protector -Z allow-partial-mitigations=stack-protector
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user