Skip to content

Commit 50e380c

Browse files
Rollup merge of rust-lang#119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb
Add missing feature gate for sanitizer CFI cfgs Found during the review of rust-lang#118494 in rust-lang#118494 (comment). cc `@rcvalle`
2 parents e1fadb2 + c88b021 commit 50e380c

9 files changed

+41
-1
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const GATED_CFGS: &[GatedCfg] = &[
3636
(sym::sanitize, sym::cfg_sanitize, cfg_fn!(cfg_sanitize)),
3737
(sym::version, sym::cfg_version, cfg_fn!(cfg_version)),
3838
(sym::relocation_model, sym::cfg_relocation_model, cfg_fn!(cfg_relocation_model)),
39+
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
40+
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
3941
];
4042

4143
/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ declare_features! (
371371
(unstable, cfg_relocation_model, "1.73.0", Some(114929)),
372372
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
373373
(unstable, cfg_sanitize, "1.41.0", Some(39699)),
374+
/// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`.
375+
(unstable, cfg_sanitizer_cfi, "CURRENT_RUSTC_VERSION", Some(89653)),
374376
/// Allows `cfg(target_abi = "...")`.
375377
(unstable, cfg_target_abi, "1.55.0", Some(80970)),
376378
/// Allows `cfg(target(abi = "..."))`.

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ symbols! {
498498
cfg_panic,
499499
cfg_relocation_model,
500500
cfg_sanitize,
501+
cfg_sanitizer_cfi,
501502
cfg_target_abi,
502503
cfg_target_compact,
503504
cfg_target_feature,

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
//
266266
// Language features:
267267
// tidy-alphabetical-start
268+
#![cfg_attr(not(bootstrap), feature(cfg_sanitizer_cfi))]
268269
#![feature(alloc_error_handler)]
269270
#![feature(allocator_internals)]
270271
#![feature(allow_internal_unsafe)]

library/std/src/sys/unix/thread_local_dtor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Note, however, that we run on lots older linuxes, as well as cross
1212
// compiling from a newer linux to an older linux, so we also have a
1313
// fallback implementation to use as well.
14-
#[allow(unexpected_cfgs)]
14+
#[cfg_attr(bootstrap, allow(unexpected_cfgs))]
1515
#[cfg(any(
1616
target_os = "linux",
1717
target_os = "android",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[cfg(sanitizer_cfi_generalize_pointers)]
2+
//~^ `cfg(sanitizer_cfi_generalize_pointers)` is experimental
3+
fn foo() {}
4+
5+
#[cfg(sanitizer_cfi_normalize_integers)]
6+
//~^ `cfg(sanitizer_cfi_normalize_integers)` is experimental
7+
fn bar() {}
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: `cfg(sanitizer_cfi_generalize_pointers)` is experimental and subject to change
2+
--> $DIR/feature-gate-cfg-sanitizer_cfi.rs:1:7
3+
|
4+
LL | #[cfg(sanitizer_cfi_generalize_pointers)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information
8+
= help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable
9+
10+
error[E0658]: `cfg(sanitizer_cfi_normalize_integers)` is experimental and subject to change
11+
--> $DIR/feature-gate-cfg-sanitizer_cfi.rs:5:7
12+
|
13+
LL | #[cfg(sanitizer_cfi_normalize_integers)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information
17+
= help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0658`.

tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
// check-pass
66
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
77

8+
#![feature(cfg_sanitizer_cfi)]
9+
810
#[cfg(sanitizer_cfi_generalize_pointers)]
911
fn main() {}

tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
// check-pass
66
// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
77

8+
#![feature(cfg_sanitizer_cfi)]
9+
810
#[cfg(sanitizer_cfi_normalize_integers)]
911
fn main() {}

0 commit comments

Comments
 (0)