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 8 pull requests #102930

Closed
wants to merge 30 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

joboet and others added 30 commits October 6, 2022 22:46
rustc's startup has several layers, including:
- `interface::run_compiler` passes a closure, `f`, to
  `run_in_thread_pool_with_globals`, which creates a thread pool, sets
  up session globals, and passes `f` to `create_compiler_and_run`.
- `create_compiler_and_run` creates a `Session`, a `Compiler`, sets the
  source map, and calls `f`.

rustdoc is a bit different.
- `main_args` calls `main_options` via
  `run_in_thread_pool_with_globals`, which (again) creates a thread pool
  (hardcoded to a single thread!) and sets up session globals.
- `main_options` has four different paths.
  - The second one calls `interface::run_compiler`, which redoes the
    `run_in_thread_pool_with_globals`! This is bad.
  - The fourth one calls `interface::create_compiler_and_run`, which is
    reasonable.
  - The first and third ones don't do anything of note involving the
    above functions, except for some symbol interning which requires
    session globals.

In other words, rustdoc calls into `rustc_interface` at three different
levels. It's a bit confused, and feels like code where functionality has
been added by different people at different times without fully
understanding how the globally accessible stuff is set up.

This commit tidies things up. It removes the
`run_in_thread_pool_with_globals` call in `main_args`, and adjust the
four paths in `main_options` as follows.
- `markdown::test` calls `test::test_main`, which provides its own
  parallelism and so doesn't need a thread pool. It had one small use of
  symbol interning, which required session globals, but the commit
  removes this.
- `doctest::run` already calls `interface::run_compiler`, so it doesn't
  need further adjustment.
- `markdown::render` is simple but needs session globals for interning
  (which can't easily be removed), so it's now wrapped in
  `create_session_globals_then`.
- The fourth path now uses `interface::run_compiler`, which is
  equivalent to the old `run_in_thread_pool_with_globals` +
  `create_compiler_and_run` pairing.
There is no longer any need for them to be separate.
It has a single call site, and removing it slightly improves the
confusing tangle of nested closures present at startup.
This avoids the need for a degenerate `Lrc::get_mut` call.
the kernel currently enforce that a stack is immutable. calling mmap(2) or 
mprotect(2) to change it will result in EPERM, which generate a panic!().

so just do like for Linux, and trust the kernel to do the right thing.
rust-lang#100892 implemented AsFd for the
sys versions, rather than for the public types. Change the
implementations to apply to the public types.
Since 98f05a0 removed separate colors
from the currently-selected item, there's no need to have item classes on
sidebar links.
Since 98f05a0 and
b5963f0 removed color classes from sidebar
items, there's no need for the selectors to be so specific any more.

This commit does have to change `h1.fqn a` to just be `h1 a`, so that the
header link color selector is less specific than the typed link at the end.
Since rust-lang#89506 made docblocks start at `h2`, the main page link header should
be the only h1 in the page now.
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Optimize TLS on Windows

This implements the suggestion in the current TLS code to embed the linked list of destructors in the `StaticKey` structure to save allocations. Additionally, locking is avoided when no destructor needs to be run. By using one Windows-provided `Once` per key instead of a global lock, locking is more finely-grained (this unblocks rust-lang#100579).
Prevent foreign Rust exceptions from being caught

Fix rust-lang#102715

Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
Clean up rustdoc startup

Startup is pretty hairy, in both rustdoc and rustc. The first commit here improves the rustdoc situation quite a bit. The remaining commits are smaller but also help.

Best reviewed one commit at a time.

r? ``@jyn514``
Use semaphores for thread parking on Apple platforms

Currently we use a mutex-condvar pair for thread parking on Apple systems. Unfortunately, `pthread_cond_timedwait` uses the real-time clock for measuring time, which causes problems when the system time changes. The parking implementation in this PR uses a semaphore instead, which measures monotonic time by default, avoiding these issues. As a further benefit, this has the potential to improve performance a bit, since `unpark` does not need to wait for a lock to be released.

Since the Mach semaphores are poorly documented (I could not find availability or stability guarantees for instance), this uses a [dispatch semaphore](https://developer.apple.com/documentation/dispatch/dispatch_semaphore?language=objc) instead. While it adds a layer of indirection (it uses Mach semaphores internally), the overhead is probably negligible.

Tested on macOS 12.5.

r? ```@thomcc```
…-for-io-types, r=m-ou-se

impl AsFd and AsRawFd for io::{Stdin, Stdout, Stderr}, not the sys versions

rust-lang#100892 implemented AsFd for the
sys versions, rather than for the public types. Change the
implementations to apply to the public types.
…m-ou-se

openbsd: don't reallocate a guard page on the stack.

the kernel currently enforce that a stack is immutable. calling mmap(2) or  mprotect(2) to change it will result in EPERM, which generate a panic!().

so just do like for Linux, and trust the kernel to do the right thing.
…ity, r=cjgillot

Check representability in adt_sized_constraint

Now that representability is a query, we can use it to preemptively avoid a cycle in `adt_sized_constraint`.

I moved the representability check into `check_mod_type_wf` to avoid a scenario where rustc quits before checking all the types for representability. This also removes the check from rustdoc, which is alright AFAIK.

r? `@cjgillot`
…lass, r=GuillaumeGomez

rustdoc: remove unused classes from sidebar links

Since rust-lang@98f05a0 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links.

Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-link-class/std/vec/struct.Vec.html

While cleaning up the CSS to remove unneeded `.content` selectors, this PR changes the `h1.fqn a` CSS selector to just be `h1 a`, so that the header link color selector is less specific than the typed link at the end. Since rust-lang#89506 made docblocks start at `h2`, the main page link header should be the only h1 in the page now.
@rustbot rustbot added 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 Oct 11, 2022
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Oct 11, 2022

📌 Commit 01f0c88 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 11, 2022
@bors
Copy link
Contributor

bors commented Oct 12, 2022

⌛ Testing commit 01f0c88 with merge 8bf0f4eed22b19551825a4bc6f835f2a7f572441...

@rust-log-analyzer
Copy link
Collaborator

The job wasm32 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] src/test/ui/mir/mir_let_chains_drop_order.rs stdout ----

error: test run failed!
status: exit status: 1
command: "/emsdk-portable/node/latest/bin/node" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_let_chains_drop_order/a.js"
stdout: none
--- stderr -------------------------------
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
    at dynCall_vi (<anonymous>:wasm-function[382]:0x135bf)
    at invoke_vi (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_let_chains_drop_order/a.js:4651:5)
    at <anonymous>:wasm-function[63]:0x1d1e
    at dynCall_v (<anonymous>:wasm-function[43]:0x96f)
    at <anonymous>:wasm-function[44]:0x97a
    at dynCall_ii (<anonymous>:wasm-function[386]:0x135f3)
    at Module.dynCall_ii (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_let_chains_drop_order/a.js:4609:76)
    at invoke_ii (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_let_chains_drop_order/a.js:4739:12)
    at <anonymous>:wasm-function[157]:0x5d74
    at main (<anonymous>:wasm-function[65]:0x23b5)


---- [ui] src/test/ui/rfcs/rfc1857-drop-order.rs stdout ----


error: test run failed!
status: exit status: 1
command: "/emsdk-portable/node/latest/bin/node" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfcs/rfc1857-drop-order/a.js"
stdout: none
--- stderr -------------------------------
thread 'main' panicked at 'this panic is caught :D', /checkout/src/test/ui/rfcs/rfc1857-drop-order.rs:61:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
    at dynCall_vi (<anonymous>:wasm-function[385]:0x16eea)
    at invoke_vi (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfcs/rfc1857-drop-order/a.js:4651:5)
    at <anonymous>:wasm-function[67]:0x1a0d
    at dynCall_v (<anonymous>:wasm-function[43]:0x998)
    at <anonymous>:wasm-function[44]:0x9a3
    at dynCall_ii (<anonymous>:wasm-function[389]:0x16f20)
    at Module.dynCall_ii (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfcs/rfc1857-drop-order/a.js:4609:76)
    at invoke_ii (/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfcs/rfc1857-drop-order/a.js:4728:12)
    at <anonymous>:wasm-function[159]:0x9682
    at main (<anonymous>:wasm-function[68]:0x5cd1)



failures:

@bors
Copy link
Contributor

bors commented Oct 12, 2022

💔 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 Oct 12, 2022
@matthiaskrgr matthiaskrgr deleted the rollup-xi5c9lw branch December 22, 2022 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-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.