Skip to content

Commit b2de19e

Browse files
committed
Update bootstrap to edition 2024
1 parent 91a0e16 commit b2de19e

6 files changed

Lines changed: 51 additions & 24 deletions

File tree

‎src/bootstrap/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bootstrap"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
build = "build.rs"
66
default-run = "bootstrap"
77

‎src/bootstrap/src/bin/sccache-plus-cl.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ use std::process::{self, Command};
44
fnmain(){
55
let target = env::var("SCCACHE_TARGET").unwrap();
66
// Locate the actual compiler that we're invoking
7-
env::set_var("CC", env::var_os("SCCACHE_CC").unwrap());
8-
env::set_var("CXX", env::var_os("SCCACHE_CXX").unwrap());
7+
8+
// SAFETY: we're in main, there are no other threads
9+
unsafe{
10+
env::set_var("CC", env::var_os("SCCACHE_CC").unwrap());
11+
env::set_var("CXX", env::var_os("SCCACHE_CXX").unwrap());
12+
}
13+
914
letmut cfg = cc::Build::new();
1015
cfg.cargo_metadata(false)
1116
.out_dir("/")

‎src/bootstrap/src/core/build_steps/format.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn rustfmt(
2727
rustfmt:&Path,
2828
paths:&[PathBuf],
2929
check:bool,
30-
) -> implFnMut(bool) -> RustfmtStatus{
30+
) -> implFnMut(bool) -> RustfmtStatus+ use<> {
3131
letmut cmd = Command::new(rustfmt);
3232
// Avoid the submodule config paths from coming into play. We only allow a single global config
3333
// for the workspace for now.

‎src/bootstrap/src/utils/cc_detect/tests.rs‎

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@ use crate::{Build, Config, Flags};
99
fntest_cc2ar_env_specific(){
1010
let triple = "x86_64-unknown-linux-gnu";
1111
let key = "AR_x86_64_unknown_linux_gnu";
12-
env::set_var(key,"custom-ar");
12+
// SAFETY: bootstrap tests run on a single thread
13+
unsafe{ env::set_var(key,"custom-ar")};
1314
let target = TargetSelection::from_user(triple);
1415
let cc = Path::new("/usr/bin/clang");
1516
let default_ar = PathBuf::from("default-ar");
1617
let result = cc2ar(cc, target, default_ar);
17-
env::remove_var(key);
18+
// SAFETY: bootstrap tests run on a single thread
19+
unsafe{ env::remove_var(key)};
1820
assert_eq!(result,Some(PathBuf::from("custom-ar")));
1921
}
2022

2123
#[test]
2224
fntest_cc2ar_musl(){
2325
let triple = "x86_64-unknown-linux-musl";
24-
env::remove_var("AR_x86_64_unknown_linux_musl");
25-
env::remove_var("AR");
26+
// SAFETY: bootstrap tests run on a single thread
27+
unsafe{ env::remove_var("AR_x86_64_unknown_linux_musl")};
28+
// SAFETY: bootstrap tests run on a single thread
29+
unsafe{ env::remove_var("AR")};
2630
let target = TargetSelection::from_user(triple);
2731
let cc = Path::new("/usr/bin/clang");
2832
let default_ar = PathBuf::from("default-ar");
@@ -33,8 +37,10 @@ fn test_cc2ar_musl() {
3337
#[test]
3438
fntest_cc2ar_openbsd(){
3539
let triple = "x86_64-unknown-openbsd";
36-
env::remove_var("AR_x86_64_unknown_openbsd");
37-
env::remove_var("AR");
40+
// SAFETY: bootstrap tests run on a single thread
41+
unsafe{ env::remove_var("AR_x86_64_unknown_openbsd")};
42+
// SAFETY: bootstrap tests run on a single thread
43+
unsafe{ env::remove_var("AR")};
3844
let target = TargetSelection::from_user(triple);
3945
let cc = Path::new("/usr/bin/cc");
4046
let default_ar = PathBuf::from("default-ar");
@@ -45,8 +51,10 @@ fn test_cc2ar_openbsd() {
4551
#[test]
4652
fntest_cc2ar_vxworks(){
4753
let triple = "armv7-wrs-vxworks";
48-
env::remove_var("AR_armv7_wrs_vxworks");
49-
env::remove_var("AR");
54+
// SAFETY: bootstrap tests run on a single thread
55+
unsafe{ env::remove_var("AR_armv7_wrs_vxworks")};
56+
// SAFETY: bootstrap tests run on a single thread
57+
unsafe{ env::remove_var("AR")};
5058
let target = TargetSelection::from_user(triple);
5159
let cc = Path::new("/usr/bin/clang");
5260
let default_ar = PathBuf::from("default-ar");
@@ -57,8 +65,10 @@ fn test_cc2ar_vxworks() {
5765
#[test]
5866
fntest_cc2ar_nto_i586(){
5967
let triple = "i586-unknown-nto-something";
60-
env::remove_var("AR_i586_unknown_nto_something");
61-
env::remove_var("AR");
68+
// SAFETY: bootstrap tests run on a single thread
69+
unsafe{ env::remove_var("AR_i586_unknown_nto_something")};
70+
// SAFETY: bootstrap tests run on a single thread
71+
unsafe{ env::remove_var("AR")};
6272
let target = TargetSelection::from_user(triple);
6373
let cc = Path::new("/usr/bin/clang");
6474
let default_ar = PathBuf::from("default-ar");
@@ -69,8 +79,10 @@ fn test_cc2ar_nto_i586() {
6979
#[test]
7080
fntest_cc2ar_nto_aarch64(){
7181
let triple = "aarch64-unknown-nto-something";
72-
env::remove_var("AR_aarch64_unknown_nto_something");
73-
env::remove_var("AR");
82+
// SAFETY: bootstrap tests run on a single thread
83+
unsafe{ env::remove_var("AR_aarch64_unknown_nto_something")};
84+
// SAFETY: bootstrap tests run on a single thread
85+
unsafe{ env::remove_var("AR")};
7486
let target = TargetSelection::from_user(triple);
7587
let cc = Path::new("/usr/bin/clang");
7688
let default_ar = PathBuf::from("default-ar");
@@ -81,8 +93,10 @@ fn test_cc2ar_nto_aarch64() {
8193
#[test]
8294
fntest_cc2ar_nto_x86_64(){
8395
let triple = "x86_64-unknown-nto-something";
84-
env::remove_var("AR_x86_64_unknown_nto_something");
85-
env::remove_var("AR");
96+
// SAFETY: bootstrap tests run on a single thread
97+
unsafe{ env::remove_var("AR_x86_64_unknown_nto_something")};
98+
// SAFETY: bootstrap tests run on a single thread
99+
unsafe{ env::remove_var("AR")};
86100
let target = TargetSelection::from_user(triple);
87101
let cc = Path::new("/usr/bin/clang");
88102
let default_ar = PathBuf::from("default-ar");
@@ -94,8 +108,10 @@ fn test_cc2ar_nto_x86_64() {
94108
#[should_panic(expected = "Unknown architecture, cannot determine archiver for Neutrino QNX")]
95109
fntest_cc2ar_nto_unknown(){
96110
let triple = "powerpc-unknown-nto-something";
97-
env::remove_var("AR_powerpc_unknown_nto_something");
98-
env::remove_var("AR");
111+
// SAFETY: bootstrap tests run on a single thread
112+
unsafe{ env::remove_var("AR_powerpc_unknown_nto_something")};
113+
// SAFETY: bootstrap tests run on a single thread
114+
unsafe{ env::remove_var("AR")};
99115
let target = TargetSelection::from_user(triple);
100116
let cc = Path::new("/usr/bin/clang");
101117
let default_ar = PathBuf::from("default-ar");
@@ -177,7 +193,8 @@ fn test_default_compiler_wasi() {
177193
let build = Build::new(Config{ ..Config::parse(Flags::parse(&["check".to_owned()]))});
178194
let target = TargetSelection::from_user("wasm32-wasi");
179195
let wasi_sdk = PathBuf::from("/wasi-sdk");
180-
env::set_var("WASI_SDK_PATH",&wasi_sdk);
196+
// SAFETY: bootstrap tests run on a single thread
197+
unsafe{ env::set_var("WASI_SDK_PATH",&wasi_sdk)};
181198
letmut cfg = cc::Build::new();
182199
ifletSome(result) = default_compiler(&mut cfg,Language::C, target.clone(),&build){
183200
let expected = {
@@ -190,7 +207,10 @@ fn test_default_compiler_wasi() {
190207
"default_compiler should return a compiler path for wasi target when WASI_SDK_PATH is set"
191208
);
192209
}
193-
env::remove_var("WASI_SDK_PATH");
210+
// SAFETY: bootstrap tests run on a single thread
211+
unsafe{
212+
env::remove_var("WASI_SDK_PATH");
213+
}
194214
}
195215

196216
#[test]

‎src/bootstrap/src/utils/helpers.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn output(cmd: &mut Command) -> String {
286286
/// to finish and then return its output. This allows the spawned process
287287
/// to do work without immediately blocking bootstrap.
288288
#[track_caller]
289-
pubfnstart_process(cmd:&mutCommand) -> implFnOnce() -> String{
289+
pubfnstart_process(cmd:&mutCommand) -> implFnOnce() -> String+ use<> {
290290
let child = match cmd.stderr(Stdio::inherit()).stdout(Stdio::piped()).spawn(){
291291
Ok(child) => child,
292292
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nERROR: {e}")),

‎src/bootstrap/src/utils/job.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ pub unsafe fn setup(_build: &mut crate::Build) {}
77
#[cfg(all(unix, not(target_os = "haiku")))]
88
pubunsafefnsetup(build:&mutcrate::Build){
99
if build.config.low_priority{
10-
libc::setpriority(libc::PRIO_PGRPas_,0,10);
10+
unsafe{
11+
libc::setpriority(libc::PRIO_PGRPas_,0,10);
12+
}
1113
}
1214
}
1315

0 commit comments

Comments
 (0)