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

Use TargetTriple::from_path in rustdoc #85361

Merged
merged 3 commits into from
May 25, 2021

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented May 16, 2021

This fixes the problem reported in Rust-for-Linux/linux#272 where rustdoc requires the absolute path of a target spec json instead of accepting a relative path like rustc.

@bjorn3 bjorn3 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 16, 2021
@rust-highfive
Copy link
Collaborator

r? @jyn514

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 16, 2021
@bjorn3
Copy link
Member Author

bjorn3 commented May 16, 2021

  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=2 origin +d20bfe8ac965fce0c261b2fb0771fbf29324d906:refs/remotes/pull/85361/merge
  remote: Internal Server Error.
  remote: 
  Error: fatal: unable to access 'https://github.com/rust-lang/rust/': The requested URL returned error: 500
  The process '/usr/bin/git' failed with exit code 128

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

Can you add a test for the new behavior (maybe a run-make test)?

Where is this logic for rustc, is it possible to reuse it?

@bjorn3
Copy link
Member Author

bjorn3 commented May 16, 2021

The logic for rustc is at

fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType) -> TargetTriple {
match matches.opt_str("target") {
Some(target) if target.ends_with(".json") => {
let path = Path::new(&target);
TargetTriple::from_path(&path).unwrap_or_else(|_| {
early_error(error_format, &format!("target file {:?} does not exist", path))
})
}
Some(target) => TargetTriple::TargetTriple(target),
_ => TargetTriple::from_triple(host_triple()),
}
}

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

Great. Can you make that function public and use it in rustdoc instead of duplicating it?

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

@bjorn3 you made the function public, but didn't use it in rustdoc. Also it would be nice to have the test.

@jyn514 jyn514 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 May 16, 2021
@bjorn3 bjorn3 force-pushed the rustdoc_target_json_path_canonicalize branch from c707150 to 458a85c Compare May 16, 2021 16:04
@bjorn3
Copy link
Member Author

bjorn3 commented May 16, 2021

I did git add compiler, which doesn't include src/librustdoc. How should I test it? Should I compile the real libcore or use a dummy #![no_core] lib as dependency?

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

The error in Rust-for-Linux/linux#258 (comment) confuses me (that is the error this fixes, right?) but if you can write dummy no_core test that fails before and passes after, that sounds great :)

@bjorn3
Copy link
Member Author

bjorn3 commented May 16, 2021

that is the error this fixes, right?

Yes

The error in Rust-for-Linux/linux#258 (comment) confuses me

The problem is that when using rustc the full canonicalized path of the target spec json would be used by rustc and thus end up in the metadata of libcore and other dependencies, but when trying to use rustdoc, only the literal value of --target is used, which results in rustc rejecting the metadata due to a different target value.

but if you can write dummy no_core test that fails before and passes after, that sounds great :)

👍

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

r=me if you confirmed the test fails before this PR (I can't check right now).

@bors delegate=bjorn3

@@ -0,0 +1,9 @@
-include ../tools.mk
Copy link
Member

Choose a reason for hiding this comment

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

nit: can you use include instead so it gives an error if the file is missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I just copied another rustdoc test.

@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

@bors delegate=bjorn3

@bors
Copy link
Contributor

bors commented May 16, 2021

✌️ @bjorn3 can now approve this pull request

@bjorn3 bjorn3 force-pushed the rustdoc_target_json_path_canonicalize branch from 60579be to 0c99e00 Compare May 16, 2021 16:47
@bjorn3
Copy link
Member Author

bjorn3 commented May 16, 2021

I manually ran the commands in the test. It failed with a nightly rustc/rustdoc.

@bors r=jyn514

@bors
Copy link
Contributor

bors commented May 16, 2021

📌 Commit 0c99e003cf06ed87998b4a0a05d9a331b1709701 has been approved by jyn514

@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 May 16, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented May 16, 2021

@bors r- (until CI is passing)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 16, 2021
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the rustdoc_target_json_path_canonicalize branch from 128f33b to b6d88d3 Compare May 17, 2021 08:43
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the rustdoc_target_json_path_canonicalize branch from b6d88d3 to f4a9ed9 Compare May 24, 2021 17:02
@bjorn3 bjorn3 force-pushed the rustdoc_target_json_path_canonicalize branch from f4a9ed9 to 6afc1f4 Compare May 24, 2021 17:54
@bjorn3
Copy link
Member Author

bjorn3 commented May 24, 2021

Fixed the test.

@bors r=jyn514

@bors
Copy link
Contributor

bors commented May 24, 2021

📌 Commit 6afc1f4 has been approved by jyn514

@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 May 24, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 25, 2021
…onicalize, r=jyn514

Use TargetTriple::from_path in rustdoc

This fixes the problem reported in Rust-for-Linux/linux#272 where rustdoc requires the absolute path of a target spec json instead of accepting a relative path like rustc.
This was referenced May 25, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request May 25, 2021
…laumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#85361 (Use TargetTriple::from_path in rustdoc)
 - rust-lang#85605 (Replace Local::new(1) with CAPTURE_STRUCT_LOCAL)
 - rust-lang#85631 (Move keyword primitive css dom)
 - rust-lang#85644 (Better English for documenting when to use unimplemented!())
 - rust-lang#85650 (Add some backticks to the `rustc_middle::ty::adjustment::Adjustment` docs)
 - rust-lang#85657 (Remove doubled braces in non_exhaustive structs’ documentation text.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6b0b81b into rust-lang:master May 25, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 25, 2021
@bjorn3 bjorn3 deleted the rustdoc_target_json_path_canonicalize branch May 25, 2021 14:58
ojeda added a commit to ojeda/linux that referenced this pull request Feb 27, 2022
In Rust-for-Linux#272 `realpath`
was added to work around a bug in `rustdoc`, but it is not needed
anymore since rust-lang/rust#85361, i.e.
since Rust 1.54.0.

Signed-off-by: Miguel Ojeda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants