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

Fix build failure in case file doesn't exist #63869

Merged
merged 1 commit into from
Sep 3, 2019

Conversation

GuillaumeGomez
Copy link
Member

It fixes the following issue:

$ ./x.py test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1
Updating only changed submodules
Submodules updated in 0.05 seconds
    Finished dev [unoptimized] target(s) in 0.15s
thread 'main' panicked at 'source "/Users/imperio/rust/rust/build/x86_64-apple-darwin/doc/version_info.html" failed to get metadata: No such file or directory (os error 2)', src/build_helper/lib.rs:179:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failed to run: /Users/imperio/rust/rust/build/bootstrap/debug/bootstrap test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1
Build completed unsuccessfully in 0:00:01

If the file doesn't exist, it makes sense anyway to just run the command in order to generate it.

r? @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2019
@GuillaumeGomez
Copy link
Member Author

I removed the useless parens I added.

@Mark-Simulacrum
Copy link
Member

Could we instead make sure the file is created in that same function? The code that creates it should probably have a || !version_info.exists()

@GuillaumeGomez
Copy link
Member Author

Added the check (hope it's what you had in mind).

@@ -375,6 +376,7 @@ impl Step for Standalone {
up_to_date(&footer, &html) &&
up_to_date(&favicon, &html) &&
up_to_date(&full_toc, &html) &&
version_info.exists() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is false, something has gone horribly wrong; we should remove this check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be false during the dry run. I think the correct fix would be to not run up_to_date(&version_info, &html) if builder.config.dry_run just like up_to_date(&rustdoc, &html) below.

@Mark-Simulacrum
Copy link
Member

r=me with last comment fixed and commits squashed into one

@@ -353,7 +353,8 @@ impl Step for Standalone {
let version_input = builder.src.join("src/doc/version_info.html.template");
let version_info = out.join("version_info.html");

if !builder.config.dry_run && !up_to_date(&version_input, &version_info) {
if !builder.config.dry_run &&
(!version_info.exists() || !up_to_date(&version_input, &version_info)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't have any effect as up_to_date already checks if the file exists:

if !dst.exists() {
return false;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the check should be on version_input. Good catch!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what I meant. Checking version_input makes even less sense as that file has to exist because it's part of the source code.

Try changing the line:

up_to_date(&version_info, &html) &&

to

(builder.config.dry_run || up_to_date(&version_info, &html)) &&

I think that will fix this issue.

@GuillaumeGomez GuillaumeGomez force-pushed the fix-build-failure branch 2 times, most recently from c3eee3a to 4b340b9 Compare August 30, 2019 11:08
@@ -353,7 +353,8 @@ impl Step for Standalone {
let version_input = builder.src.join("src/doc/version_info.html.template");
let version_info = out.join("version_info.html");

if !builder.config.dry_run && !up_to_date(&version_input, &version_info) {
if (builder.config.dry_run || up_to_date(&version_input, &version_info)) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is wrong. We shouldn't need to generate this file during dry_run; if there's something that reads from it during dry_run then that should be gated, not the file creation.

@GuillaumeGomez
Copy link
Member Author

I wonder if I shouldn't just go back to my initial fix at this point. 😆

@ollie27
Copy link
Member

ollie27 commented Aug 31, 2019

I think I've caused some confusion. Anyway what I was trying to suggest was to just do:

--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -375,7 +375,7 @@ impl Step for Standalone {
                up_to_date(&footer, &html) &&
                up_to_date(&favicon, &html) &&
                up_to_date(&full_toc, &html) &&
-               up_to_date(&version_info, &html) &&
+               (builder.config.dry_run || up_to_date(&version_info, &html)) &&
                (builder.config.dry_run || up_to_date(&rustdoc, &html)) {
                 continue
             }

That will avoid the panic but I don't know if it's the best fix because I'm not 100% sure what should and shouldn't be run during the dry run.

@Mark-Simulacrum
Copy link
Member

dry run as much as possible shouldn't be creating/reading files -- we can mostly avoid this via helper methods on builder which internally return empty strings and such, but not always, which is why we something see gating on dry_run in various code

@GuillaumeGomez
Copy link
Member Author

Ok updated. Sorry about the confusion.

@Mark-Simulacrum
Copy link
Member

I presume you've tested that this works?

@GuillaumeGomez
Copy link
Member Author

Not yet. Just applied your suggestion. I'll try it once I'm done with dayjob.

@Mark-Simulacrum
Copy link
Member

r=me if it works

@GuillaumeGomez
Copy link
Member Author

I confirm: problem fixed. Thanks a lot @Mark-Simulacrum and @ollie27 !

@bors: r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Sep 2, 2019

📌 Commit a80ab3a has been approved by Mark-Simulacrum

@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 Sep 2, 2019
@@ -375,7 +375,7 @@ impl Step for Standalone {
up_to_date(&footer, &html) &&
up_to_date(&favicon, &html) &&
up_to_date(&full_toc, &html) &&
up_to_date(&version_info, &html) &&
(builder.config.dry_run || up_to_date(&version_info, &html)) &&
(builder.config.dry_run || up_to_date(&rustdoc, &html)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(builder.config.dry_run || up_to_date(&rustdoc, &html)) {
builder.config.dry_run ||
(up_to_date(&version_info, &html) && up_to_date(&rustdoc, &html)) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hurts rather than aids readability in my eyes.

@bors
Copy link
Contributor

bors commented Sep 3, 2019

⌛ Testing commit a80ab3a with merge 815dec9...

bors added a commit that referenced this pull request Sep 3, 2019
…acrum

Fix build failure in case file doesn't exist

It fixes the following issue:

```bash
$ ./x.py test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1
Updating only changed submodules
Submodules updated in 0.05 seconds
    Finished dev [unoptimized] target(s) in 0.15s
thread 'main' panicked at 'source "/Users/imperio/rust/rust/build/x86_64-apple-darwin/doc/version_info.html" failed to get metadata: No such file or directory (os error 2)', src/build_helper/lib.rs:179:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failed to run: /Users/imperio/rust/rust/build/bootstrap/debug/bootstrap test src/tools/linkchecker ./build/x86_64-apple-darwin/doc/ --stage 1
Build completed unsuccessfully in 0:00:01
```

If the file doesn't exist, it makes sense anyway to just run the command in order to generate it.

r? @Mark-Simulacrum
@bors
Copy link
Contributor

bors commented Sep 3, 2019

☀️ Test successful - checks-azure
Approved by: Mark-Simulacrum
Pushing 815dec9 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 3, 2019
@bors bors merged commit a80ab3a into rust-lang:master Sep 3, 2019
@GuillaumeGomez GuillaumeGomez deleted the fix-build-failure branch September 4, 2019 08:27
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants