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 6 pull requests #133415

Merged
merged 12 commits into from
Nov 24, 2024
Merged

Rollup of 6 pull requests #133415

merged 12 commits into from
Nov 24, 2024

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Enselic and others added 12 commits November 21, 2024 19:16
…age, r=jieyouxu

inject_panic_runtime(): Avoid double negation for 'any non rlib'

<details>

<summary>This PR originally did more things .Click to expand to see.</summary>

By not trying to inject a profiler runtime when only building an rlib. This logic already exists for the panic runtime.

This makes

    RUSTFLAGS="-Cinstrument-coverage" cargo build -Zbuild-std=std,profiler_builtins

work. Note that you probably also need
`RUST_COMPILER_RT_FOR_PROFILER=$src/llvm-project/compiler-rt` in your environment.

cc rust-lang#79401

# Demonstration

Before this fix you get these errors:

```console
$ rm -rf target ; RUST_COMPILER_RT_FOR_PROFILER=/home/martin/src/llvm-project/compiler-rt RUSTFLAGS="-Cinstrument-coverage" cargo +nightly build --release -Zbuild-std=std,profiler_builtins
error: `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`
error[E0152]: found duplicate lang item `manually_drop`
    = note: first definition in `core` loaded from /home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d453bab70303062c.rlib
    = note: second definition in the local crate (`core`)
```

With the fix the build succeeds:

```console
$ rm -rf target ; RUST_COMPILER_RT_FOR_PROFILER=/home/martin/src/llvm-project/compiler-rt RUSTFLAGS="-Cinstrument-coverage" cargo +stage1 build --release -Zbuild-std=std,profiler_builtins
    Finished `release` profile [optimized] target(s) in 45.57s
```

And we can check code coverage. My example program looks like this:

```rs
fn main() {
    if std::env::args_os().nth(1) == Some("write-file".into()) {
        std::fs::write("hello.txt", "Hello, world!").unwrap();
    } else {
        println!("Hello, world!");
    }
}
```

when the program prints to stdout:

```
$ LLVM_PROFILE_FILE=stdout.profraw ./target/release/hello-world
Hello, world!
```

we can see that `fs::write()` is not being used (note the `0`'s):

```console
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse stdout.profraw -o stdout.profdata
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show target/release/hello-world --sources /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std/src/fs.rs --instr-profile stdout.profdata --color | grep -A 3 'pub fn write(&mut self, write: b
ool) -> &mut Self {'
 1357|      0|    pub fn write(&mut self, write: bool) -> &mut Self {
 1358|      0|        self.0.write(write);
 1359|      0|        self
 1360|      0|    }
```

but when we print to a file:

```console
$ LLVM_PROFILE_FILE=file.profraw ./target/release/hello-world write-file
```

the code coverage shows `fs::write()` as being used (note the `1`'s):

```console
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse file.profraw -o file.profdata
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show target/release/hello-world --sources /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std/src/fs.rs --instr-profile file.profdata --color | grep -A 3 'pub fn write(&mut self, write: bool) -> &mut Self {'
 1357|      1|    pub fn write(&mut self, write: bool) -> &mut Self {
 1358|      1|        self.0.write(write);
 1359|      1|        self
 1360|      1|    }
```
</summary>
…g-neg, r=workingjubilee

Add code example for `wrapping_neg` method for signed integers

With this example, we make it obvious that `wrapping_neg` works both ways (neg to pos and pos to neg).

r? `@workingjubilee`
…r=compiler-errors

remove is_trivially_const_drop

I'm not sure this still brings any perf benefits, so let's benchmark this.

r? `@compiler-errors`
…thods, r=RalfJung

Stabilize `const_float_methods`

Tracking issue: rust-lang#130843
Relnotes: rust-lang#133383

Stabilized const API:

```rust
// in `core`
impl f32/f64 {
    pub const fn recip(self) -> Self;
    pub const fn to_degrees(self) -> Self;
    pub const fn to_radians(self) -> Self;
    pub const fn max(self, other: Self) -> Self;
    pub const fn min(self, other: Self) -> Self;
    pub const fn clamp(self, min: Self, max: Self) -> Self;
    pub const fn abs(self) -> Self;
    pub const fn signum(self) -> Self;
    pub const fn copysign(self, sign: Self) -> Self;
}
```

Closes rust-lang#130843

r? libs-api

cc `@RalfJung` -- I think the way const-stability attributes work have change a bit since the last time a wrote a const-stabilization PR, please make sure I got them right.
rustdoc: do not call to_string, it's already impl Display

`anchor` returns impl Display, so no need to call to_string().
tidy: Distinguish between two different meanings of "style file"

This file contains code that uses “style file” to mean “CSS file”, and other code that uses “style file” to mean “this file, which implements the style checker”.

That's very confusing, so it's easier to just say *CSS file* or *this file* as appropriate.

No functional change.
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Nov 24, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=6

@bors
Copy link
Contributor

bors commented Nov 24, 2024

📌 Commit 3ccacef has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 24, 2024
@bors
Copy link
Contributor

bors commented Nov 24, 2024

⌛ Testing commit 3ccacef with merge f5d1857...

@bors
Copy link
Contributor

bors commented Nov 24, 2024

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing f5d1857 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 24, 2024
@bors bors merged commit f5d1857 into rust-lang:master Nov 24, 2024
7 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Nov 24, 2024
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#133300 inject_panic_runtime(): Avoid double negation for 'any non … 5ddd51dffa4cec7da1f6a423a25b076af64c5d7d (link)
#133301 Add code example for wrapping_neg method for signed integ… 2e8e055bacaa678551191b636a5ecae9478acbe6 (link)
#133371 remove is_trivially_const_drop 05fb9f9325d69501db9a743605420a32204e72fb (link)
#133389 Stabilize const_float_methods 3efffed761e5bb022e83f8ae0aede4f9395421c5 (link)
#133398 rustdoc: do not call to_string, it's already impl Display 10986b9d6b8278e5cc6f43db73e7f637bdd339c1 (link)
#133405 tidy: Distinguish between two different meanings of "style … 98a568590ef8b236f0b301a58d821a782e93d458 (link)

previous master: ab3cf268b5

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f5d1857): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-1.3%, -0.2%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.1%, secondary -2.6%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.8%, -1.4%] 2
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 2
All ❌✅ (primary) -2.1% [-2.8%, -1.4%] 2

Cycles

Results (secondary 2.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 798.172s -> 797.067s (-0.14%)
Artifact size: 336.30 MiB -> 336.23 MiB (-0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants