Skip to content

Commit 37cd39f

Browse files
committed
handle cfg bootstrap on compiler and miri
Signed-off-by: onur-ozkan <[email protected]>
1 parent 613eceb commit 37cd39f

File tree

8 files changed

+66
-8
lines changed

8 files changed

+66
-8
lines changed

compiler/rustc_data_structures/src/flock.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
//! green/native threading. This is just a bare-bones enough solution for
55
//! librustdoc, it is not production quality at all.
66
7-
cfg_select! {
7+
// cfg(bootstrap)
8+
macro_rules! cfg_select_dispatch {
9+
($($tokens:tt)*) => {
10+
#[cfg(bootstrap)]
11+
cfg_match! { $($tokens)* }
12+
13+
#[cfg(not(bootstrap))]
14+
cfg_select! { $($tokens)* }
15+
};
16+
}
17+
18+
cfg_select_dispatch! {
819
target_os = "linux" => {
920
mod linux;
1021
use linux as imp;

compiler/rustc_data_structures/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#![allow(internal_features)]
1111
#![allow(rustc::default_hash_types)]
1212
#![allow(rustc::potential_query_instability)]
13+
#![cfg_attr(bootstrap, feature(cfg_match))]
14+
#![cfg_attr(not(bootstrap), feature(cfg_select))]
1315
#![deny(unsafe_op_in_unsafe_fn)]
1416
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1517
#![doc(rust_logo)]
@@ -19,7 +21,6 @@
1921
#![feature(ascii_char_variants)]
2022
#![feature(assert_matches)]
2123
#![feature(auto_traits)]
22-
#![feature(cfg_select)]
2324
#![feature(core_intrinsics)]
2425
#![feature(dropck_eyepatch)]
2526
#![feature(extend_one)]

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,19 @@ fn get_thread_id() -> u32 {
859859
std::thread::current().id().as_u64().get() as u32
860860
}
861861

862+
// cfg(bootstrap)
863+
macro_rules! cfg_select_dispatch {
864+
($($tokens:tt)*) => {
865+
#[cfg(bootstrap)]
866+
cfg_match! { $($tokens)* }
867+
868+
#[cfg(not(bootstrap))]
869+
cfg_select! { $($tokens)* }
870+
};
871+
}
872+
862873
// Memory reporting
863-
cfg_select! {
874+
cfg_select_dispatch! {
864875
windows => {
865876
pub fn get_resident_set_size() -> Option<usize> {
866877
use windows::{

compiler/rustc_span/src/analyze_source_file.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@ pub(crate) fn analyze_source_file(src: &str) -> (Vec<RelativeBytePos>, Vec<Multi
2929
(lines, multi_byte_chars)
3030
}
3131

32-
cfg_select! {
32+
// cfg(bootstrap)
33+
macro_rules! cfg_select_dispatch {
34+
($($tokens:tt)*) => {
35+
#[cfg(bootstrap)]
36+
cfg_match! { $($tokens)* }
37+
38+
#[cfg(not(bootstrap))]
39+
cfg_select! { $($tokens)* }
40+
};
41+
}
42+
43+
cfg_select_dispatch! {
3344
any(target_arch = "x86", target_arch = "x86_64") => {
3445
fn analyze_source_file_dispatch(
3546
src: &str,

compiler/rustc_span/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
1818
// tidy-alphabetical-start
1919
#![allow(internal_features)]
20+
#![cfg_attr(bootstrap, feature(cfg_match))]
21+
#![cfg_attr(not(bootstrap), feature(cfg_select))]
2022
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2123
#![doc(rust_logo)]
2224
#![feature(array_windows)]
23-
#![feature(cfg_select)]
2425
#![feature(core_io_borrowed_buf)]
2526
#![feature(hash_set_entry)]
2627
#![feature(if_let_guard)]

src/tools/miri/src/concurrency/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ pub mod thread;
88
mod vector_clock;
99
pub mod weak_memory;
1010

11+
// cfg(bootstrap)
12+
macro_rules! cfg_select_dispatch {
13+
($($tokens:tt)*) => {
14+
#[cfg(bootstrap)]
15+
cfg_match! { $($tokens)* }
16+
17+
#[cfg(not(bootstrap))]
18+
cfg_select! { $($tokens)* }
19+
};
20+
}
21+
1122
// Import either the real genmc adapter or a dummy module.
12-
cfg_select! {
23+
cfg_select_dispatch! {
1324
feature = "genmc" => {
1425
mod genmc;
1526
pub use self::genmc::{GenmcCtx, GenmcConfig};

src/tools/miri/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#![cfg_attr(bootstrap, feature(cfg_match))]
2+
#![cfg_attr(not(bootstrap), feature(cfg_select))]
13
#![feature(rustc_private)]
2-
#![feature(cfg_select)]
34
#![feature(float_gamma)]
45
#![feature(float_erf)]
56
#![feature(map_try_insert)]

src/tools/miri/src/shims/unix/fs.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,19 @@ impl UnixFileDescription for FileHandle {
8989
communicate_allowed: bool,
9090
op: FlockOp,
9191
) -> InterpResult<'tcx, io::Result<()>> {
92+
// cfg(bootstrap)
93+
macro_rules! cfg_select_dispatch {
94+
($($tokens:tt)*) => {
95+
#[cfg(bootstrap)]
96+
cfg_match! { $($tokens)* }
97+
98+
#[cfg(not(bootstrap))]
99+
cfg_select! { $($tokens)* }
100+
};
101+
}
102+
92103
assert!(communicate_allowed, "isolation should have prevented even opening a file");
93-
cfg_select! {
104+
cfg_select_dispatch! {
94105
all(target_family = "unix", not(target_os = "solaris")) => {
95106
use std::os::fd::AsRawFd;
96107

0 commit comments

Comments
 (0)