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

Rollup of 10 pull requests #137877

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1cac5fa
Look for `python3` first on MacOS, not `py`
jyn514 Feb 13, 2025
477a2ee
std::fs: slightly reformat `remove_dir_all` error docs
jieyouxu Feb 18, 2025
2bead27
remove : from stack-protector-heuristics-effect.rs filecheck
mustartt Feb 12, 2025
2c752bc
Undeprecate env::home_dir
arlosi Feb 20, 2025
fb8c993
fix label suffix
mustartt Feb 20, 2025
bf26f24
Clarify/update comments in `BufRead::read_line`'s default body
steffahn Feb 20, 2025
f65277c
Simplify parallelization in test-float-parse
tgross35 Dec 31, 2024
762fdf6
default to `-znostart-stop-gc`
lqd Feb 26, 2025
1528cc2
`librustdoc`: 2024 edition! 🎊
yotamofek Feb 27, 2025
7d263b0
Adapt `librustdoc` to 2024 edition lifetieme capture rules
yotamofek Feb 27, 2025
396c2a8
Stop using `hash_raw_entry` in `CodegenCx::const_str`
cuviper Feb 27, 2025
ea13ff7
add exclude to config.toml
Shourya742 Feb 16, 2025
d9ceab9
add test for exclude feature
Shourya742 Feb 16, 2025
9206960
Add change info to change tracker
Shourya742 Feb 16, 2025
bd05d77
Rollup merge of #136938 - mustartt:fix-stack-protector-filecheck, r=M…
matthiaskrgr Mar 2, 2025
fed5666
Rollup merge of #136975 - jyn514:macos-x, r=Mark-Simulacrum
matthiaskrgr Mar 2, 2025
08109d3
Rollup merge of #137147 - Shourya742:2025-02-16-support-exclude-in-co…
matthiaskrgr Mar 2, 2025
335bf51
Rollup merge of #137240 - jieyouxu:remove_dir_all, r=Mark-Simulacrum
matthiaskrgr Mar 2, 2025
28917f4
Rollup merge of #137327 - arlosi:home-dir, r=Mark-Simulacrum
matthiaskrgr Mar 2, 2025
16950f4
Rollup merge of #137375 - steffahn:clarify-read_line-comment, r=Mark-…
matthiaskrgr Mar 2, 2025
20695b5
Rollup merge of #137525 - tgross35:test-float-parse-less-parallelizat…
matthiaskrgr Mar 2, 2025
de4256b
Rollup merge of #137685 - lqd:nostart-stop-gc, r=petrochenkov
matthiaskrgr Mar 2, 2025
84eab4b
Rollup merge of #137722 - yotamofek:pr/rustdoc/edition-2024, r=notriddle
matthiaskrgr Mar 2, 2025
9cade29
Rollup merge of #137741 - cuviper:const_str-raw_entry, r=Mark-Simulacrum
matthiaskrgr Mar 2, 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
13 changes: 6 additions & 7 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,12 @@ impl<'gcc, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}

fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
let str_global = *self
.const_str_cache
.borrow_mut()
.raw_entry_mut()
.from_key(s)
.or_insert_with(|| (s.to_owned(), self.global_string(s)))
.1;
let mut const_str_cache = self.const_str_cache.borrow_mut();
let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| {
let g = self.global_string(s);
const_str_cache.insert(s.to_owned(), g);
g
});
let len = s.len();
let cs = self.const_ptrcast(
str_global.get_address(None),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(rustc_private, decl_macro, never_type, trusted_len, hash_raw_entry, let_chains)]
#![feature(rustc_private, decl_macro, never_type, trusted_len, let_chains)]
#![allow(broken_intra_doc_links)]
#![recursion_limit = "256"]
#![warn(rust_2018_idioms)]
Expand Down
40 changes: 18 additions & 22 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,24 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}

fn const_str(&self, s: &str) -> (&'ll Value, &'ll Value) {
let str_global = *self
.const_str_cache
.borrow_mut()
.raw_entry_mut()
.from_key(s)
.or_insert_with(|| {
let sc = self.const_bytes(s.as_bytes());
let sym = self.generate_local_symbol_name("str");
let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
bug!("symbol `{}` is already defined", sym);
});
llvm::set_initializer(g, sc);
unsafe {
llvm::LLVMSetGlobalConstant(g, True);
llvm::LLVMSetUnnamedAddress(g, llvm::UnnamedAddr::Global);
}
llvm::set_linkage(g, llvm::Linkage::InternalLinkage);
// Cast to default address space if globals are in a different addrspace
let g = self.const_pointercast(g, self.type_ptr());
(s.to_owned(), g)
})
.1;
let mut const_str_cache = self.const_str_cache.borrow_mut();
let str_global = const_str_cache.get(s).copied().unwrap_or_else(|| {
let sc = self.const_bytes(s.as_bytes());
let sym = self.generate_local_symbol_name("str");
let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
bug!("symbol `{}` is already defined", sym);
});
llvm::set_initializer(g, sc);
unsafe {
llvm::LLVMSetGlobalConstant(g, True);
llvm::LLVMSetUnnamedAddress(g, llvm::UnnamedAddr::Global);
}
llvm::set_linkage(g, llvm::Linkage::InternalLinkage);
// Cast to default address space if globals are in a different addrspace
let g = self.const_pointercast(g, self.type_ptr());
const_str_cache.insert(s.to_owned(), g);
g
});
let len = s.len();
(str_global, self.const_usize(len as u64))
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![feature(exact_size_is_empty)]
#![feature(extern_types)]
#![feature(file_buffered)]
#![feature(hash_raw_entry)]
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)]
#![feature(iter_intersperse)]
Expand Down
26 changes: 26 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3438,6 +3438,32 @@ fn add_lld_args(
// this, `wasm-component-ld`, which is overridden if this option is passed.
if !sess.target.is_like_wasm {
cmd.cc_arg("-fuse-ld=lld");

// GNU ld and LLD have opposite defaults on some section garbage-collection features. For
// example, the somewhat popular `linkme` crate and its dependents rely in practice on this
// difference: when using lld, they need `-z nostart-stop-gc` to prevent encapsulation
// symbols and sections from being garbage-collected.
//
// More information about all this can be found in:
// - https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order
// - https://lld.llvm.org/ELF/start-stop-gc
//
// So when using lld, we restore, for now, the traditional behavior to help migration, but
// will remove it in the future.
// Since this only disables an optimization, it shouldn't create issues, but is in theory
// slightly suboptimal. However, it:
// - doesn't have any visible impact on our benchmarks
// - reduces the need to disable lld for the crates that depend on this
//
// Note that lld can detect some cases where this difference is relied on, and emits a
// dedicated error to add this link arg. We could make use of this error to emit an FCW. As
// of writing this, we don't do it, because lld is already enabled by default on nightly
// without this mitigation: no working project would see the FCW, so we do this to help
// stabilization.
//
// FIXME: emit an FCW if linking fails due its absence, and then remove this link-arg in the
// future.
cmd.link_arg("-znostart-stop-gc");
}

if !flavor.is_gnu() {
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_data_structures/src/captures.rs

This file was deleted.

1 change: 0 additions & 1 deletion compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size;
pub mod aligned;
pub mod base_n;
pub mod binary_search_util;
pub mod captures;
pub mod fingerprint;
pub mod flat_map_in_place;
pub mod flock;
Expand Down
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
# a specific version.
#ccache = false

# List of paths to exclude from the build and test processes.
# For example, exclude = ["tests/ui", "src/tools/tidy"].
#exclude = []

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
5 changes: 0 additions & 5 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@ impl Error for JoinPathsError {
/// None => println!("Impossible to get your home dir!"),
/// }
/// ```
#[deprecated(
since = "1.29.0",
note = "This function's behavior may be unexpected on Windows. \
Consider using a crate from crates.io instead."
)]
#[must_use]
#[stable(feature = "env", since = "1.0.0")]
pub fn home_dir() -> Option<PathBuf> {
Expand Down
8 changes: 5 additions & 3 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2857,9 +2857,11 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
///
/// See [`fs::remove_file`] and [`fs::remove_dir`].
///
/// `remove_dir_all` will fail if `remove_dir` or `remove_file` fail on any constituent paths, including the root `path`.
/// As a result, the directory you are deleting must exist, meaning that this function is not idempotent.
/// Additionally, `remove_dir_all` will also fail if the `path` is not a directory.
/// [`remove_dir_all`] will fail if [`remove_dir`] or [`remove_file`] fail on *any* constituent
/// paths, *including* the root `path`. Consequently,
///
/// - The directory you are deleting *must* exist, meaning that this function is *not idempotent*.
/// - [`remove_dir_all`] will fail if the `path` is *not* a directory.
///
/// Consider ignoring the error if validating the removal is not required for your use case.
///
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,7 +2534,7 @@ pub trait BufRead: Read {
fn read_line(&mut self, buf: &mut String) -> Result<usize> {
// Note that we are not calling the `.read_until` method here, but
// rather our hardcoded implementation. For more details as to why, see
// the comments in `read_to_end`.
// the comments in `default_read_to_string`.
unsafe { append_to_string(buf, |b| read_until(self, b'\n', b)) }
}

Expand Down
38 changes: 22 additions & 16 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ define_config! {
jobs: Option<u32> = "jobs",
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
ccache: Option<StringOrBool> = "ccache",
exclude: Option<Vec<PathBuf>> = "exclude",
}
}

Expand Down Expand Up @@ -1372,22 +1373,6 @@ impl Config {
"flags.exclude" = ?flags.exclude
);

config.skip = flags
.skip
.into_iter()
.chain(flags.exclude)
.map(|p| {
// Never return top-level path here as it would break `--skip`
// logic on rustc's internal test framework which is utilized
// by compiletest.
if cfg!(windows) {
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
} else {
p
}
})
.collect();

#[cfg(feature = "tracing")]
span!(
target: "CONFIG_HANDLING",
Expand Down Expand Up @@ -1632,8 +1617,29 @@ impl Config {
jobs,
compiletest_diff_tool,
mut ccache,
exclude,
} = toml.build.unwrap_or_default();

let mut paths: Vec<PathBuf> = flags.skip.into_iter().chain(flags.exclude).collect();

if let Some(exclude) = exclude {
paths.extend(exclude);
}

config.skip = paths
.into_iter()
.map(|p| {
// Never return top-level path here as it would break `--skip`
// logic on rustc's internal test framework which is utilized
// by compiletest.
if cfg!(windows) {
PathBuf::from(p.to_str().unwrap().replace('/', "\\"))
} else {
p
}
})
.collect();

config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));

if let Some(file_build) = build {
Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,17 @@ fn test_explicit_stage() {
assert!(!config.explicit_stage_from_config);
assert!(!config.is_explicit_stage());
}

#[test]
fn test_exclude() {
let config = parse("build.exclude=[\"test/codegen\"]");

let first_excluded = config
.skip
.first()
.expect("Expected at least one excluded path")
.to_str()
.expect("Failed to convert excluded path to string");

assert_eq!(first_excluded, "test/codegen");
}
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "`rust.channel` now supports \"auto-detect\" to load the channel from `src/ci/channel`",
},
ChangeInfo {
change_id: 137147,
severity: ChangeSeverity::Info,
summary: "New option `build.exclude` that adds support for excluding test.",
},
];
3 changes: 1 addition & 2 deletions src/etc/test-float-parse/src/gen/exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ impl<F: Float> Generator<F> for Exhaustive<F>
where
RangeInclusive<F::Int>: Iterator<Item = F::Int>,
{
const NAME: &'static str = "exhaustive";
const SHORT_NAME: &'static str = "exhaustive";

type WriteCtx = F;

fn total_tests() -> u64 {
F::Int::MAX.try_into().unwrap_or(u64::MAX)
1u64.checked_shl(F::Int::BITS).expect("More than u64::MAX tests")
}

fn new() -> Self {
Expand Down
1 change: 0 additions & 1 deletion src/etc/test-float-parse/src/gen/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ impl<F: Float> Generator<F> for Fuzz<F>
where
Standard: Distribution<<F as Float>::Int>,
{
const NAME: &'static str = "fuzz";
const SHORT_NAME: &'static str = "fuzz";

type WriteCtx = F;
Expand Down
1 change: 0 additions & 1 deletion src/etc/test-float-parse/src/gen/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl<F: Float> Generator<F> for FewOnesInt<F>
where
<F::Int as TryFrom<u128>>::Error: std::fmt::Debug,
{
const NAME: &'static str = "few ones int";
const SHORT_NAME: &'static str = "few ones int";

type WriteCtx = F::Int;
Expand Down
Loading
Loading