Skip to content

Commit

Permalink
Auto merge of rust-lang#138006 - jieyouxu:rollup-av2viwz, r=jieyouxu
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - rust-lang#134063 (dec2flt: Clean up float parsing modules)
 - rust-lang#136662 (Count char width at most once in `Formatter::pad`)
 - rust-lang#137011 (Promote ohos targets to tier2 with host tools.)
 - rust-lang#137077 (Postprocess bootstrap metrics into GitHub job summary)
 - rust-lang#137327 (Undeprecate env::home_dir)
 - rust-lang#137373 (Compile run-make-support and run-make tests with the bootstrap compiler)
 - rust-lang#137463 ([illumos] attempt to use posix_spawn to spawn processes)
 - rust-lang#137477 (uefi: Add Service Binding Protocol abstraction)
 - rust-lang#137569 (Stablize `string_extend_from_within`)
 - rust-lang#137667 (Add `dist::Gcc` build step)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 4, 2025
2 parents f9e0239 + 41b6c76 commit 3c361f7
Show file tree
Hide file tree
Showing 61 changed files with 1,506 additions and 1,001 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ jobs:
- name: show the current environment
run: src/ci/scripts/dump-environment.sh

# Pre-build citool before the following step uninstalls rustup
# Build is into the build directory, to avoid modifying sources
- name: build citool
run: |
cd src/ci/citool
CARGO_TARGET_DIR=../../../build/citool cargo build
- name: run the build
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
run: src/ci/scripts/run-build-from-ci.sh 2>&1
Expand Down Expand Up @@ -218,6 +225,16 @@ jobs:
# erroring about invalid credentials instead.
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'

- name: postprocess metrics into the summary
run: |
if [ -f build/metrics.json ]; then
./build/citool/debug/citool postprocess-metrics build/metrics.json ${GITHUB_STEP_SUMMARY}
elif [ -f obj/build/metrics.json ]; then
./build/citool/debug/citool postprocess-metrics obj/build/metrics.json ${GITHUB_STEP_SUMMARY}
else
echo "No metrics.json found"
fi
- name: upload job metrics to DataDog
if: needs.calculate_matrix.outputs.run_type != 'pr'
env:
Expand Down
23 changes: 18 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,20 @@ dependencies = [
"smallvec",
]

[[package]]
name = "measureme"
version = "12.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "570a507d8948a66a97f42cbbaf8a6bb9516a51017d4ee949502ad7a10a864395"
dependencies = [
"log",
"memmap2",
"parking_lot",
"perf-event-open-sys",
"rustc-hash 1.1.0",
"smallvec",
]

[[package]]
name = "memchr"
version = "2.7.4"
Expand Down Expand Up @@ -2261,7 +2275,7 @@ dependencies = [
"libc",
"libffi",
"libloading",
"measureme",
"measureme 11.0.1",
"rand 0.9.0",
"regex",
"rustc_version",
Expand Down Expand Up @@ -3365,7 +3379,7 @@ dependencies = [
"gimli 0.30.0",
"itertools",
"libc",
"measureme",
"measureme 12.0.1",
"object 0.36.7",
"rustc-demangle",
"rustc_abi",
Expand Down Expand Up @@ -3483,7 +3497,7 @@ dependencies = [
"indexmap",
"jobserver",
"libc",
"measureme",
"measureme 12.0.1",
"memmap2",
"parking_lot",
"portable-atomic",
Expand Down Expand Up @@ -4249,8 +4263,7 @@ dependencies = [
name = "rustc_query_impl"
version = "0.0.0"
dependencies = [
"measureme",
"rustc_attr_data_structures",
"measureme 12.0.1",
"rustc_data_structures",
"rustc_errors",
"rustc_hashes",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bitflags = "2.4.1"
gimli = "0.30"
itertools = "0.12"
libc = "0.2"
measureme = "11"
measureme = "12.0.1"
object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
rustc-demangle = "0.1.21"
rustc_abi = { path = "../rustc_abi" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ elsa = "1.11.0"
ena = "0.14.3"
indexmap = "2.4.0"
jobserver_crate = { version = "0.1.28", package = "jobserver" }
measureme = "11"
measureme = "12.0.1"
rustc-hash = "2.0.0"
rustc-rayon = { version = "0.5.1", features = ["indexmap"] }
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn main() {
println!("cargo:rustc-link-lib=kstat");
}

if (target.starts_with("arm") && !target.contains("freebsd"))
if (target.starts_with("arm") && !target.contains("freebsd")) && !target.contains("ohos")
|| target.starts_with("mips-")
|| target.starts_with("mipsel-")
|| target.starts_with("powerpc-")
Expand Down Expand Up @@ -371,6 +371,7 @@ fn main() {
|| target.contains("freebsd")
|| target.contains("windows-gnullvm")
|| target.contains("aix")
|| target.contains("ohos")
{
"c++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_query_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ edition = "2024"

[dependencies]
# tidy-alphabetical-start
measureme = "11"
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
measureme = "12.0.1"
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_hashes = { path = "../rustc_hashes" }
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.169"
version = "0.2.170"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
3 changes: 1 addition & 2 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@ impl String {
/// # Examples
///
/// ```
/// #![feature(string_extend_from_within)]
/// let mut string = String::from("abcde");
///
/// string.extend_from_within(2..);
Expand All @@ -1147,7 +1146,7 @@ impl String {
/// assert_eq!(string, "abcdecdeabecde");
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "string_extend_from_within", issue = "103806")]
#[stable(feature = "string_extend_from_within", since = "CURRENT_RUSTC_VERSION")]
pub fn extend_from_within<R>(&mut self, src: R)
where
R: RangeBounds<usize>,
Expand Down
66 changes: 29 additions & 37 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,49 +1693,41 @@ impl<'a> Formatter<'a> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pad(&mut self, s: &str) -> Result {
// Make sure there's a fast path up front
// Make sure there's a fast path up front.
if self.options.width.is_none() && self.options.precision.is_none() {
return self.buf.write_str(s);
}
// The `precision` field can be interpreted as a `max-width` for the

// The `precision` field can be interpreted as a maximum width for the
// string being formatted.
let s = if let Some(max) = self.options.precision {
// If our string is longer that the precision, then we must have
// truncation. However other flags like `fill`, `width` and `align`
// must act as always.
if let Some((i, _)) = s.char_indices().nth(max) {
// LLVM here can't prove that `..i` won't panic `&s[..i]`, but
// we know that it can't panic. Use `get` + `unwrap_or` to avoid
// `unsafe` and otherwise don't emit any panic-related code
// here.
s.get(..i).unwrap_or(s)
} else {
&s
}
let (s, char_count) = if let Some(max_char_count) = self.options.precision {
let mut iter = s.char_indices();
let remaining = match iter.advance_by(max_char_count) {
Ok(()) => 0,
Err(remaining) => remaining.get(),
};
// SAFETY: The offset of `.char_indices()` is guaranteed to be
// in-bounds and between character boundaries.
let truncated = unsafe { s.get_unchecked(..iter.offset()) };
(truncated, max_char_count - remaining)
} else {
&s
// Use the optimized char counting algorithm for the full string.
(s, s.chars().count())
};
// The `width` field is more of a `min-width` parameter at this point.
match self.options.width {
// If we're under the maximum length, and there's no minimum length
// requirements, then we can just emit the string
None => self.buf.write_str(s),
Some(width) => {
let chars_count = s.chars().count();
// If we're under the maximum width, check if we're over the minimum
// width, if so it's as easy as just emitting the string.
if chars_count >= width {
self.buf.write_str(s)
}
// If we're under both the maximum and the minimum width, then fill
// up the minimum width with the specified string + some alignment.
else {
let align = Alignment::Left;
let post_padding = self.padding(width - chars_count, align)?;
self.buf.write_str(s)?;
post_padding.write(self)
}
}

// The `width` field is more of a minimum width parameter at this point.
if let Some(width) = self.options.width
&& char_count < width
{
// If we're under the minimum width, then fill up the minimum width
// with the specified string + some alignment.
let post_padding = self.padding(width - char_count, Alignment::Left)?;
self.buf.write_str(s)?;
post_padding.write(self)
} else {
// If we're over the minimum width or there is no minimum width, we
// can just emit the string.
self.buf.write_str(s)
}
}

Expand Down
27 changes: 15 additions & 12 deletions library/core/src/num/dec2flt/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ pub(crate) trait ByteSlice {
/// Writes a 64-bit integer as 8 bytes in little-endian order.
fn write_u64(&mut self, value: u64);

/// Calculate the offset of a slice from another.
/// Calculate the difference in length between two slices.
fn offset_from(&self, other: &Self) -> isize;

/// Iteratively parse and consume digits from bytes.
/// Returns the same bytes with consumed digits being
/// elided.
///
/// Returns the same bytes with consumed digits being elided. Breaks on invalid digits.
fn parse_digits(&self, func: impl FnMut(u8)) -> &Self;
}

Expand All @@ -39,11 +39,11 @@ impl ByteSlice for [u8] {
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
let mut s = self;

while let Some((c, s_next)) = s.split_first() {
while let Some((c, rest)) = s.split_first() {
let c = c.wrapping_sub(b'0');
if c < 10 {
func(c);
s = s_next;
s = rest;
} else {
break;
}
Expand All @@ -53,27 +53,30 @@ impl ByteSlice for [u8] {
}
}

/// Determine if 8 bytes are all decimal digits.
/// Determine if all characters in an 8-byte byte string (represented as a `u64`) are all decimal
/// digits.
///
/// This does not care about the order in which the bytes were loaded.
pub(crate) fn is_8digits(v: u64) -> bool {
let a = v.wrapping_add(0x4646_4646_4646_4646);
let b = v.wrapping_sub(0x3030_3030_3030_3030);
(a | b) & 0x8080_8080_8080_8080 == 0
}

/// A custom 64-bit floating point type, representing `f * 2^e`.
/// e is biased, so it be directly shifted into the exponent bits.
/// A custom 64-bit floating point type, representing `m * 2^p`.
/// p is biased, so it be directly shifted into the exponent bits.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
pub struct BiasedFp {
/// The significant digits.
pub f: u64,
pub m: u64,
/// The biased, binary exponent.
pub e: i32,
pub p_biased: i32,
}

impl BiasedFp {
/// Represent `0 ^ p`
#[inline]
pub const fn zero_pow2(e: i32) -> Self {
Self { f: 0, e }
pub const fn zero_pow2(p_biased: i32) -> Self {
Self { m: 0, p_biased }
}
}
Loading

0 comments on commit 3c361f7

Please sign in to comment.