Skip to content

Rollup of 11 pull requests #145450

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

Merged
merged 27 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
75b7d24
ci: clean windows disk space in background
marcoieni Aug 14, 2025
5d01d90
std: thread: Return error if setting thread stack size fails
Gelbpunkt Jul 20, 2025
8b387d8
Deduplicate `-L` paths passed to rustc
Kobzol Aug 14, 2025
fd5b737
Do not pass duplicated `-L` arguments to merged doctests
Kobzol Aug 14, 2025
2355563
Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThr…
tgross35 Aug 15, 2025
ffdc40f
bootstrap: Switch from fd-lock to native locking in std
joshtriplett Aug 15, 2025
56b33cd
bootstrap: Remove dependency on xattr
joshtriplett Aug 15, 2025
2a2903c
Split codegen backend check step into two and don't run it with `x ch…
Kobzol Aug 13, 2025
8a7be4a
Rename `compiler` to `build_compiler` in the `compile::Std` step
Kobzol Aug 12, 2025
d8a51f5
Remove usage of `compiler_for` from the `compile::Std` step
Kobzol Aug 13, 2025
36dfed6
Remove usage of `compiler_for` from the `compile::Rustc` step
Kobzol Aug 13, 2025
f2c2d3e
Clarify that `build.full-bootstrap` is only used to affect uplifting,…
Kobzol Aug 12, 2025
cda2114
Fix typos in bootstrap.example.toml
AMS21 Aug 15, 2025
ae4eeb9
Fix wrong spans with external macros in the `dropping_copy_types` lint
Urgau Aug 15, 2025
dbd5add
Enhance UI test output handling for runtime errors
AMS21 Aug 15, 2025
26817ee
Autolabel `src/tools/{rustfmt,rust-analyzer}` changes with `T-{rustfm…
jieyouxu Aug 15, 2025
a676c48
Rollup merge of #144210 - Gelbpunkt:thread-stack-size-musl, r=jhpratt
Kobzol Aug 15, 2025
87d677b
Rollup merge of #145310 - Kobzol:compiler-for-revamp, r=jieyouxu
Kobzol Aug 15, 2025
b474f89
Rollup merge of #145311 - marcoieni:clean-disk-in-background-windows,…
Kobzol Aug 15, 2025
0734cbd
Rollup merge of #145340 - Kobzol:bootstrap-codegen-backend-check-spli…
Kobzol Aug 15, 2025
30c967d
Rollup merge of #145408 - Kobzol:deduplicate-search-paths, r=petroche…
Kobzol Aug 15, 2025
7c93af0
Rollup merge of #145412 - tgross35:win-tid, r=ChrisDenton
Kobzol Aug 15, 2025
82c6ad3
Rollup merge of #145413 - joshtriplett:bootstrap-reduce-deps, r=clubb…
Kobzol Aug 15, 2025
501837f
Rollup merge of #145426 - AMS21:fix_typos_bootstrap_example, r=lqd
Kobzol Aug 15, 2025
c97a9c8
Rollup merge of #145430 - Urgau:drop_forget_useless-145427, r=lqd
Kobzol Aug 15, 2025
b979a31
Rollup merge of #145431 - AMS21:fix_141531, r=jieyouxu
Kobzol Aug 15, 2025
9bf76ab
Rollup merge of #145448 - jieyouxu:rustfmt-labels, r=fmease
Kobzol Aug 15, 2025
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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ jobs:
cd src/ci/citool
CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build
- name: wait for Windows disk cleanup to finish
if: ${{ matrix.free_disk && startsWith(matrix.os, 'windows-') }}
run: |
python3 src/ci/scripts/free-disk-space-windows-wait.py
- name: run the build
run: |
set +e
Expand Down
10 changes: 5 additions & 5 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# a custom configuration file can also be specified with `--config` to the build
# system.
#
# Note that the following are equivelent, for more details see <https://toml.io/en/v1.0.0>.
# Note that the following are equivalent, for more details see <https://toml.io/en/v1.0.0>.
#
# build.verbose = 1
#
Expand Down Expand Up @@ -345,9 +345,9 @@
# want to use vendoring. See https://forge.rust-lang.org/infra/other-installation-methods.html#source-code.
#build.vendor = if "is a tarball source" && "vendor" dir exists && ".cargo/config.toml" file exists { true } else { false }

# Typically the build system will build the Rust compiler twice. The second
# compiler, however, will simply use its own libraries to link against. If you
# would rather to perform a full bootstrap, compiling the compiler three times,
# If you build the compiler more than twice (stage3+) or the standard library more than once
# (stage 2+), the third compiler and second library will get uplifted from stage2 and stage1,
# respectively. If you would like to disable this uplifting, and rather perform a full bootstrap,
# then you can set this option to true.
#
# This is only useful for verifying that rustc generates reproducible builds.
Expand Down Expand Up @@ -482,7 +482,7 @@
# Use `--extra-checks=''` to temporarily disable all extra checks.
#
# Automatically enabled in the "tools" profile.
# Set to the empty string to force disable (recommeded for hdd systems).
# Set to the empty string to force disable (recommended for hdd systems).
#build.tidy-extra-checks = ""

# Indicates whether ccache is used when building certain artifacts (e.g. LLVM).
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/drop_forget_useless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
&& let Node::Stmt(stmt) = node
&& let StmtKind::Semi(e) = stmt.kind
&& e.hir_id == expr.hir_id
&& let Some(arg_span) = arg.span.find_ancestor_inside(expr.span)
&& let Some(arg_span) = arg.span.find_ancestor_inside_same_ctxt(expr.span)
{
UseLetUnderscoreIgnoreSuggestion::Suggestion {
start_span: expr.span.shrink_to_lo().until(arg_span),
Expand Down
31 changes: 21 additions & 10 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2847,16 +2847,27 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
// This is the location used by the `rustc-dev` `rustup` component.
real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs");

let mut search_paths = vec![];
for s in &matches.opt_strs("L") {
search_paths.push(SearchPath::from_cli_opt(
sysroot.path(),
&target_triple,
early_dcx,
s,
unstable_opts.unstable_options,
));
}
// We eagerly scan all files in each passed -L path. If the same directory is passed multiple
// times, and the directory contains a lot of files, this can take a lot of time.
// So we remove -L paths that were passed multiple times, and keep only the first occurrence.
// We still have to keep the original order of the -L arguments.
let search_paths: Vec<SearchPath> = {
let mut seen_search_paths = FxHashSet::default();
let search_path_matches: Vec<String> = matches.opt_strs("L");
search_path_matches
.iter()
.filter(|p| seen_search_paths.insert(*p))
.map(|path| {
SearchPath::from_cli_opt(
sysroot.path(),
&target_triple,
early_dcx,
&path,
unstable_opts.unstable_options,
)
})
.collect()
};

let working_dir = std::env::current_dir().unwrap_or_else(|e| {
early_dcx.early_fatal(format!("Current directory is invalid: {e}"));
Expand Down
13 changes: 12 additions & 1 deletion library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ impl Thread {
let page_size = os::page_size();
let stack_size =
(stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1);
assert_eq!(libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size), 0);

// Some libc implementations, e.g. musl, place an upper bound
// on the stack size, in which case we can only gracefully return
// an error here.
if libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size) != 0 {
assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0);
drop(Box::from_raw(data));
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"invalid stack size"
));
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/c/bindings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,7 @@ GetCurrentDirectoryW
GetCurrentProcess
GetCurrentProcessId
GetCurrentThread
GetCurrentThreadId
GetEnvironmentStringsW
GetEnvironmentVariableW
GetExitCodeProcess
Expand Down Expand Up @@ -2185,7 +2186,6 @@ GetSystemInfo
GetSystemTimeAsFileTime
GetSystemTimePreciseAsFileTime
GetTempPathW
GetThreadId
GetUserProfileDirectoryW
GetWindowsDirectoryW
HANDLE
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/c/windows_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetCurrentDirectoryW(nbufferle
windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcess() -> HANDLE);
windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcessId() -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetCurrentThread() -> HANDLE);
windows_targets::link!("kernel32.dll" "system" fn GetCurrentThreadId() -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentStringsW() -> PWSTR);
windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentVariableW(lpname : PCWSTR, lpbuffer : PWSTR, nsize : u32) -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetExitCodeProcess(hprocess : HANDLE, lpexitcode : *mut u32) -> BOOL);
Expand All @@ -61,7 +62,6 @@ windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : *
windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME));
windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME));
windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32);
windows_targets::link!("kernel32.dll" "system" fn GetThreadId(thread : HANDLE) -> u32);
windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL);
windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32);
windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL);
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Thread {

pub(crate) fn current_os_id() -> Option<u64> {
// SAFETY: FFI call with no preconditions.
let id: u32 = unsafe { c::GetThreadId(c::GetCurrentThread()) };
let id: u32 = unsafe { c::GetCurrentThreadId() };

// A return value of 0 indicates failed lookup.
if id == 0 { None } else { Some(id.into()) }
Expand Down
27 changes: 2 additions & 25 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ dependencies = [
"clap",
"clap_complete",
"cmake",
"fd-lock",
"home",
"ignore",
"insta",
Expand Down Expand Up @@ -268,17 +267,6 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"

[[package]]
name = "fd-lock"
version = "4.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78"
dependencies = [
"cfg-if",
"rustix",
"windows-sys 0.59.0",
]

[[package]]
name = "filetime"
version = "0.2.25"
Expand Down Expand Up @@ -759,13 +747,12 @@ dependencies = [

[[package]]
name = "tar"
version = "0.4.43"
version = "0.4.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6"
checksum = "1d863878d212c87a19c1a610eb53bb01fe12951c0501cf5a0d65f724914a667a"
dependencies = [
"filetime",
"libc",
"xattr",
]

[[package]]
Expand Down Expand Up @@ -1147,16 +1134,6 @@ dependencies = [
"bitflags",
]

[[package]]
name = "xattr"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d65cbf2f12c15564212d48f4e3dfb87923d25d611f2aed18f4cb23f0413d89e"
dependencies = [
"libc",
"rustix",
]

[[package]]
name = "xz2"
version = "0.1.7"
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ cmake = "=0.1.54"
build_helper = { path = "../build_helper" }
clap = { version = "4.4", default-features = false, features = ["std", "usage", "help", "derive", "error-context"] }
clap_complete = "4.4"
fd-lock = "4.0"
home = "0.5"
ignore = "0.4"
libc = "0.2"
Expand All @@ -51,7 +50,7 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = "0.10"
tar = "0.4"
tar = { version = "0.4.44", default-features = false }
termcolor = "1.4"
toml = "0.5"
walkdir = "2.4"
Expand Down
46 changes: 21 additions & 25 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//! parent directory, and otherwise documentation can be found throughout the `build`
//! directory in each respective module.
use std::fs::{self, OpenOptions};
use std::io::{self, BufRead, BufReader, IsTerminal, Write};
use std::fs::{self, OpenOptions, TryLockError};
use std::io::{self, BufRead, BufReader, IsTerminal, Read, Write};
use std::path::Path;
use std::str::FromStr;
use std::time::Instant;
Expand Down Expand Up @@ -39,38 +39,34 @@ fn main() {
let config = Config::parse(flags);

let mut build_lock;
let _build_lock_guard;

if !config.bypass_bootstrap_lock {
// Display PID of process holding the lock
// PID will be stored in a lock file
let lock_path = config.out.join("lock");
let pid = fs::read_to_string(&lock_path);

build_lock = fd_lock::RwLock::new(t!(fs::OpenOptions::new()
build_lock = t!(fs::OpenOptions::new()
.read(true)
.write(true)
.truncate(true)
.create(true)
.open(&lock_path)));
_build_lock_guard = match build_lock.try_write() {
Ok(mut lock) => {
t!(lock.write(process::id().to_string().as_ref()));
lock
.truncate(false)
.open(&lock_path));
t!(build_lock.try_lock().or_else(|e| {
if let TryLockError::Error(e) = e {
return Err(e);
}
err => {
drop(err);
// #135972: We can reach this point when the lock has been taken,
// but the locker has not yet written its PID to the file
if let Some(pid) = pid.ok().filter(|pid| !pid.is_empty()) {
println!("WARNING: build directory locked by process {pid}, waiting for lock");
} else {
println!("WARNING: build directory locked, waiting for lock");
}
let mut lock = t!(build_lock.write());
t!(lock.write(process::id().to_string().as_ref()));
lock
let mut pid = String::new();
t!(build_lock.read_to_string(&mut pid));
// #135972: We can reach this point when the lock has been taken,
// but the locker has not yet written its PID to the file
if !pid.is_empty() {
println!("WARNING: build directory locked by process {pid}, waiting for lock");
} else {
println!("WARNING: build directory locked, waiting for lock");
}
};
build_lock.lock()
}));
t!(build_lock.set_len(0));
t!(build_lock.write_all(process::id().to_string().as_bytes()));
}

// check_version warnings are not printed during setup, or during CI
Expand Down
Loading
Loading