Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing feature gate for sanitizer CFI cfgs #119235

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const GATED_CFGS: &[GatedCfg] = &[
(sym::sanitize, sym::cfg_sanitize, cfg_fn!(cfg_sanitize)),
(sym::version, sym::cfg_version, cfg_fn!(cfg_version)),
(sym::relocation_model, sym::cfg_relocation_model, cfg_fn!(cfg_relocation_model)),
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
];

/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ declare_features! (
(unstable, cfg_relocation_model, "1.73.0", Some(114929)),
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
(unstable, cfg_sanitize, "1.41.0", Some(39699)),
/// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`.
(unstable, cfg_sanitizer_cfi, "CURRENT_RUSTC_VERSION", Some(89653)),
/// Allows `cfg(target_abi = "...")`.
(unstable, cfg_target_abi, "1.55.0", Some(80970)),
/// Allows `cfg(target(abi = "..."))`.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ symbols! {
cfg_panic,
cfg_relocation_model,
cfg_sanitize,
cfg_sanitizer_cfi,
cfg_target_abi,
cfg_target_compact,
cfg_target_feature,
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(not(bootstrap), feature(cfg_sanitizer_cfi))]
#![feature(alloc_error_handler)]
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/thread_local_dtor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Note, however, that we run on lots older linuxes, as well as cross
// compiling from a newer linux to an older linux, so we also have a
// fallback implementation to use as well.
#[allow(unexpected_cfgs)]
#[cfg_attr(bootstrap, allow(unexpected_cfgs))]
#[cfg(any(
target_os = "linux",
target_os = "android",
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[cfg(sanitizer_cfi_generalize_pointers)]
//~^ `cfg(sanitizer_cfi_generalize_pointers)` is experimental
fn foo() {}

#[cfg(sanitizer_cfi_normalize_integers)]
//~^ `cfg(sanitizer_cfi_normalize_integers)` is experimental
fn bar() {}

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0658]: `cfg(sanitizer_cfi_generalize_pointers)` is experimental and subject to change
--> $DIR/feature-gate-cfg-sanitizer_cfi.rs:1:7
|
LL | #[cfg(sanitizer_cfi_generalize_pointers)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information
= help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable

error[E0658]: `cfg(sanitizer_cfi_normalize_integers)` is experimental and subject to change
--> $DIR/feature-gate-cfg-sanitizer_cfi.rs:5:7
|
LL | #[cfg(sanitizer_cfi_normalize_integers)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information
= help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
// check-pass
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers

#![feature(cfg_sanitizer_cfi)]

#[cfg(sanitizer_cfi_generalize_pointers)]
fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
// check-pass
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers

#![feature(cfg_sanitizer_cfi)]

#[cfg(sanitizer_cfi_normalize_integers)]
fn main() {}
Loading