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 7 pull requests #127639

Closed
wants to merge 21 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

zachs18 and others added 21 commits May 10, 2024 13:44
we now distinguish between pidfd_spawn support, pidfd-via-fork/exec and not-supported
previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook would be interleaved with the backtrace. now, we hold the lock for the full duration of the hook, and the output is ordered.
binutils 2.40 is required by LLVM 19, as older versions do not
know about the zmmull extension.

I've had to backport some patches to glibc and gcc as well,
as they don't build with binutils 2.40. Alternatively, we could
also switch to glibc 2.35 and gcc 12 (I think). I figured we'd
want to avoid the glibc version change, but if that's fine for
riscv I can go with that instead.
A `rustc_const_stable` attribute by itself has nonintuitive purpose when
placed in a public module.

Separately, it would probably be okay to rename `const_strlen` to just
`strlen` to make it more clear this is our general-purpose
implementation of strlen now, not something specifically for const
(avoiding confusion like in PR 127444).
Generalize `fn allocator` for Rc/Arc.

Split out from rust-lang#119761

- For `Rc`/`Arc`, the existing associated `fn`s are changed to allow unsized pointees.
 - For `Weak`s, new methods are added.

`@rustbot` label +A-allocators
Add AMX target-features and `x86_amx_intrinsics` feature flag

This is an effort towards rust-lang#126622. This adds support for all 5 target-features for `AMX`, and introduces the feature flag `x86_amx_intrinsics`, which would gate these target-features and the yet-to-be-implemented amx intrinsics in stdarch.
Use pidfd_spawn for faster process spawning when a PidFd is requested

glibc 2.39 added `pidfd_spawnp` and `pidfd_getpid` which makes it possible to get pidfds while staying on the CLONE_VFORK path.

verified that vfork gets used with strace:

```
$  strace -ff -e pidfd_open,clone3,openat,execve,waitid,close ./x test std --no-doc -- pidfd
[...]
[pid 2820532] clone3({flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|CLONE_CLEAR_SIGHAND, pidfd=0x7b7f885fec6c, exit_signal=SIGCHLD, stack=0x7b7f88aff000, stack_size=0x9000}strace: Process 2820533 attached
 <unfinished ...>
[pid 2820533] execve("/home/the8472/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/home/the8472/.cargo/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/usr/local/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory)
[pid 2820533] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */ <unfinished ...>
[pid 2820532] <... clone3 resumed> => {pidfd=[3]}, 88) = 2820533
[pid 2820533] <... execve resumed>)     = 0
[pid 2820532] openat(AT_FDCWD, "/proc/self/fdinfo/3", O_RDONLY|O_CLOEXEC) = 4
[pid 2820532] close(4)                  = 0
```

Tracking issue: rust-lang#82971
…workingjubilee

fix interleaved output in the default panic hook when multiple threads panic simultaneously

previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook from one thread would be interleaved with the backtrace from another. now, we hold the lock for the full duration of the hook, and the output is ordered.

---

i noticed some odd things while working on this you may or may not already be aware of.

- libbacktrace is included as a submodule instead of a normal rustc crate, and as a result uses `cfg(backtrace_in_std)` instead of a more normal `cfg(feature = "rustc-dep-of-std")`. probably this is left over from before rust used a cargo-based build system?
- the default panic handler uses `trace_unsynchronized`, etc, in `sys::backtrace::print`. as a result, the lock only applies to concurrent *panic handlers*, not concurrent *threads*.  in other words, if another, non-panicking, thread tried to print a backtrace at the same time as the panic handler, we may have UB, especially on windows.
    - we have the option of changing backtrace to enable locking when `backtrace_in_std` is set so we can reuse their lock instead of trying to add our own.
Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes)

Completed the pair of FCPs rust-lang#113219 (comment) + rust-lang#114441 (comment).

`CStr::from_ptr` is covered by just the first FCP on its own. `CStr::count_bytes` requires the approval of both FCPs. The second paragraph of the first link and the last paragraph of the second link explain the relationship between the two FCPs. As both have been approved, we can proceed with stabilizing `const` on both of these already-stable functions.
Update dist-riscv64-linux to binutils 2.40

binutils 2.40 is required by LLVM 19, as older versions do not know about the zmmul extension.

I've had to backport some patches to glibc and gcc as well, as they don't build with binutils 2.40. Alternatively, we could also switch to glibc 2.35 and gcc 10 (I think). I figured we'd want to avoid the glibc version change, but if that's fine for riscv I can go with that instead.

r? `@cuviper`

try-job: dist-riscv64-linux
…rustdoc, r=fmease

Implement `precise_capturing` support for rustdoc

Implements rustdoc (+json) support for local (i.e. non-cross-crate-inlined) RPITs with `use<...>` precise capturing syntax.

Tests kinda suck. They're really hard to write 😰

r? `@fmease` or re-roll if you're too busy!
also cc `@aDotInTheVoid` for the json side

Tracking:
* rust-lang#127228 (comment) (not fully fixed for cross-crate-inlined opaques)
* rust-lang#123432
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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. labels Jul 12, 2024
@rustbot rustbot added the rollup A PR which is a rollup label Jul 12, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=7

@bors
Copy link
Contributor

bors commented Jul 12, 2024

📌 Commit 14e17b8 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 Jul 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 12, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#124980 (Generalize `fn allocator` for Rc/Arc.)
 - rust-lang#126639 (Add AMX target-features and `x86_amx_intrinsics` feature flag)
 - rust-lang#126827 (Use pidfd_spawn for faster process spawning when a PidFd is requested)
 - rust-lang#127397 (fix interleaved output in the default panic hook when multiple threads panic simultaneously)
 - rust-lang#127433 (Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes))
 - rust-lang#127613 (Update dist-riscv64-linux to binutils 2.40)
 - rust-lang#127632 (Implement `precise_capturing` support for rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Jul 12, 2024

⌛ Testing commit 14e17b8 with merge 5088fe3...

@rust-log-analyzer
Copy link
Collaborator

The job test-various failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/backtrace/synchronized-panic-handler.rs stdout ----
diff of run.stderr:

- thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:9:5:
- oops oh no woe is me
- thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:9:5:
- thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:9:5:
- oops oh no woe is me

The actual run.stderr differed from the expected run.stderr.
Actual run.stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace/synchronized-panic-handler/synchronized-panic-handler.run.stderr


error: 1 errors occurred comparing run output.
status: exit status: 134
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace/synchronized-panic-handler" && RUST_BACKTRACE="0" RUST_TEST_THREADS="4" "/wasmtime-v19.0.0-x86_64-linux/wasmtime" "run" "-C" "cache=n" "--dir" "." "--env" "RUSTC_BOOTSTRAP" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace/synchronized-panic-handler/a.wasm"
--- stderr -------------------------------
thread 'main' panicked at /rustc/FAKE_PREFIX/library/std/src/thread/mod.rs:698:29:
thread 'main' panicked at /rustc/FAKE_PREFIX/library/std/src/thread/mod.rs:698:29:
failed to spawn thread: Error { kind: Unsupported, message: "operation not supported on this platform" }
Error: failed to run main module `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/backtrace/synchronized-panic-handler/a.wasm`

Caused by:
    0: failed to invoke command default
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x45e4 - a.wasm!__rust_start_panic
           1: 0x44ca - a.wasm!rust_panic
           2: 0x4406 - a.wasm!std::panicking::rust_panic_with_hook::h400061369894ed48
           3: 0x36ba - a.wasm!std::panicking::begin_panic_handler::{{closure}}::h24a05a60cca8ed4d
           4: 0x362b - a.wasm!std::sys::backtrace::__rust_end_short_backtrace::h0f81b346bc1f4de3
           5: 0x3d56 - a.wasm!rust_begin_unwind
           6: 0x8b13 - a.wasm!core::panicking::panic_fmt::hf2ed1b9068633dfa
           7: 0xa23f - a.wasm!core::result::unwrap_failed::h51d6ce8170f816c6
           8:  0x3cf - a.wasm!std::thread::spawn::h86308dbefcfe23a4
           9:  0xcc1 - a.wasm!synchronized_panic_handler::main::h759d94c8d4c5af1b
          10:  0x2ff - a.wasm!std::sys::backtrace::__rust_begin_short_backtrace::h90f98c5fee75354c
          11:  0x2f2 - a.wasm!std::rt::lang_start::{{closure}}::h526e27c9c8d8f751
          12: 0x23ab - a.wasm!std::rt::lang_start_internal::h4871dda8cfe28ab8
          13:  0xcfa - a.wasm!__main_void
          14:  0x2ca - a.wasm!_start
    2: wasm trap: wasm `unreachable` instruction executed



failures:

@bors
Copy link
Contributor

bors commented Jul 12, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 12, 2024
@matthiaskrgr matthiaskrgr deleted the rollup-pfmhack branch September 1, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc O-unix Operating system: Unix-like rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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.