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

Pass flags to rustdoc shim without env. vars #116449

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Oct 5, 2023

Discussed here: #116448 (comment). Since it was not really documented why these flags were passed through the shim, I guess that the only way to find out if it's really needed... is to remove it :)

r? @petrochenkov

@rustbot rustbot added 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) labels Oct 5, 2023
@rust-log-analyzer

This comment has been minimized.

@Kobzol Kobzol changed the title Pass host flags to rustc shim using prefixed env. vars Pass flags to rustdoc shim without env. vars Oct 5, 2023
@petrochenkov
Copy link
Contributor

I recalled what the issue with doctests was - bootstrap passes options to rustdoc only when it calls rustdoc directly, not through cargo.
The options should also be passed when rustdoc is run through cargo (doctests are tested that way).

@petrochenkov
Copy link
Contributor

This really needs to be tested separately, with full x.py test --stage 2 #116448 (comment).
It's also quite possible that it is broken on master.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2023
@Kobzol
Copy link
Contributor Author

Kobzol commented Oct 9, 2023

I recalled what the issue with doctests was - bootstrap passes options to rustdoc only when it calls rustdoc directly, not through cargo. The options should also be passed when rustdoc is run through cargo (doctests are tested that way).

Yes, this accurately describes the state on master.

Do you have an example of a x.py test command or a subdirectory of tests where doc tests are executed through cargo? I tried using x.py test --doc, but couldn't really find a place where it would be applied. It seems to me that this only happens when we test tools and submodules (?).

@petrochenkov
Copy link
Contributor

cargo test on standard library crates or rustc crates should run rustdoc with doctest building & running?
I don't know how to run it in a more fine-grained way, I just remember that it was included into full x.py test (at least back in 2017 :D).

@Kobzol
Copy link
Contributor Author

Kobzol commented Oct 10, 2023

I looked around and there are indeed a few places where rustdoc is being executed without the linker being set (CargoTest, Bootstrap at least). But this is a bigger issue I think - there are some places in bootstrap where we execute cargo that doesn't go through the main Cargo builder function. This means that there might be more places where the linker isn't set.

If we set use-lld or linker, should it mean that absolutely all relevant commands executed by bootstrap should change the linker/flavor? If yes, then this might need some more restructuring, rather than just adding it arbitrarily to a few places where rustdoc is invoked by cargo.

@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 11, 2023

If we set use-lld or linker, should it mean that absolutely all relevant commands executed by bootstrap should change the linker/flavor?

Yes, that was the case when I originally implemented linker and full use-lld support (EDIT: at least for all commands executed during full testing x.py test --stage 2).
If they are not used in some cases it's a later regression.

@Kobzol
Copy link
Contributor Author

Kobzol commented Oct 11, 2023

Okay so I investigated a bit and the only place where rustdoc is invoked manually (outside of Builder::rustdoc_cmd) is here:

let rustdoc = builder.bootstrap_out.join("rustdoc");
. There's an issue that here we need to prepend the rustdoc-theme command before actually passing the rustdoc command, but I don't think that Command allows prepending arguments, so that we could call rustdoc_cmd and then prepend rustdoc-theme.

@Kobzol Kobzol force-pushed the bootstrap-rustdoc-shim branch from acd1869 to e42eeea Compare October 11, 2023 19:26
@Kobzol
Copy link
Contributor Author

Kobzol commented Oct 11, 2023

I have added two functions to add the LLD flags to both normal rustdoc and cargo rustdoc invocations. It's far from pretty..

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@Kobzol Kobzol force-pushed the bootstrap-rustdoc-shim branch from e42eeea to fa86c78 Compare November 12, 2023 10:33
@Kobzol
Copy link
Contributor Author

Kobzol commented Nov 12, 2023

Rebased and tested full x.py test --stage 2 locally.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 12, 2023
@rust-log-analyzer

This comment has been minimized.

src/bootstrap/src/utils/helpers.rs Show resolved Hide resolved
src/bootstrap/src/utils/helpers.rs Outdated Show resolved Hide resolved
src/bootstrap/src/utils/helpers.rs Outdated Show resolved Hide resolved
src/bootstrap/src/utils/helpers.rs Outdated Show resolved Hide resolved
src/bootstrap/src/core/builder.rs Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

I'm also not sure whether the CI failure in #116449 (comment) is spurious or not.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 17, 2023
@Kobzol
Copy link
Contributor Author

Kobzol commented Nov 17, 2023

I'm also unsure about the CI failure, it happened repeatedly, but I can't reproduce it locally. Let's see what happens now.

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Contributor Author

Kobzol commented Nov 18, 2023

There was a problem with empty RUSTDOCFLAGS. If I passed the env. var. with an empty value, one rustdoc-gui test failed. So I added a check to skip setting the environment variable if it's empty.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 18, 2023
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 21, 2023

📌 Commit 4ba9586 has been approved by petrochenkov

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 21, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

⌛ Testing commit 4ba9586 with merge 98af42c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 21, 2023
…rochenkov

Pass flags to `rustdoc` shim without env. vars

Discussed here: rust-lang#116448 (comment). Since it was not really documented why these flags were passed through the shim, I guess that the only way to find out if it's really needed... is to remove it :)

r? `@petrochenkov`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 21, 2023

💔 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 Nov 21, 2023
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2023
@Kobzol Kobzol force-pushed the bootstrap-rustdoc-shim branch from 4ba9586 to 2e7d684 Compare November 23, 2023 09:37
@Kobzol
Copy link
Contributor Author

Kobzol commented Nov 23, 2023

A redundant use statement was in windows cfg-gated code.

@bors r=petrochenkov

@bors
Copy link
Contributor

bors commented Nov 23, 2023

📌 Commit 2e7d684 has been approved by petrochenkov

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 23, 2023
@bors
Copy link
Contributor

bors commented Nov 23, 2023

⌛ Testing commit 2e7d684 with merge e7b2285...

@bors
Copy link
Contributor

bors commented Nov 23, 2023

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing e7b2285 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 23, 2023
@bors bors merged commit e7b2285 into rust-lang:master Nov 23, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 23, 2023
@Kobzol Kobzol deleted the bootstrap-rustdoc-shim branch November 23, 2023 12:58
@bors bors mentioned this pull request Nov 23, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e7b2285): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results

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)
- - 0
Improvements ✅
(secondary)
-1.8% [-1.8%, -1.8%] 1
All ❌✅ (primary) - - 0

Cycles

Results

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.3% [2.3%, 2.3%] 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: 677.592s -> 676.441s (-0.17%)
Artifact size: 313.72 MiB -> 313.75 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants