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

Detect configuration for LLVM during setup #77756

Merged
merged 2 commits into from
Oct 15, 2020

Conversation

alarsyo
Copy link
Contributor

@alarsyo alarsyo commented Oct 9, 2020

This is a first draft to address #77579, setting download-ci-llvm to true on Linux, but I could also implement the if-available setting mentioned in the issue.

On other platforms I was thinking about using the which crate, if adding a dependency on it is considered okay of course, to detect the presence of llvm-config in the path, and use it if found. Still a work in progress of course.

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 Oct 9, 2020
@Mark-Simulacrum
Copy link
Member

I would not want to add a dependency for this sort of thing, it shouldn't be necessary to just scan PATH and append llvm-config to it.

I don't think appending to the file is going to work well, I think the if-available approach is the one we should pursue.

@alarsyo alarsyo force-pushed the setup-llvm-detect branch from 050b60a to 004fd4c Compare October 9, 2020 21:03
@alarsyo
Copy link
Contributor Author

alarsyo commented Oct 9, 2020

Is that better? Hopefully the "if-available" option is now handled everywhere needed, and I just need to write the llvm-config detection logic for other platforms

@alarsyo alarsyo force-pushed the setup-llvm-detect branch from 004fd4c to 8f88847 Compare October 9, 2020 21:18
@jyn514 jyn514 added A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 10, 2020
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Oct 12, 2020

☔ The latest upstream changes (presumably #77867) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

src/bootstrap/bootstrap.py Outdated Show resolved Hide resolved
[llvm]
# Will download LLVM from CI if available on your platform (Linux only for now)
# https://github.com/rust-lang/rust/issues/77084 tracks support for more platforms
download-ci-llvm = "if-available"
Copy link
Member

Choose a reason for hiding this comment

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

Could we just duplicate this across the actual default files? I would prefer to avoid adding even more layers of places where defaults are getting set.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, in my mind setup.rs is for setting defaults that are not the same for everyone, while src/bootstrap/defaults are for things that can reasonably be shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Added to all default configs. I just have a doubt for the config.codegen.toml, maybe people working close to codegen don't want the CI built one by default?

Copy link
Contributor Author

@alarsyo alarsyo Oct 13, 2020

Choose a reason for hiding this comment

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

Ah, it seems moving these lines to the default profiles broke the bootstrap, because bootstrap.py doesn't know about the profile setting (I'm guessing it's only handled in the config.rs file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking further into this, it seems bootstrap only has a basic regex mechanism to lookup toml keys, and returns the first key that matches, which means appending the contents of our default file should work as expected, allowing the main config.toml to override these defaults if needed. Definitely feels like a hack though :D I'll push some code soon

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

@Mark-Simulacrum how hard would it be to move that into rustbuild instead of bootstrap.py? Doesn't need to block this, but I'd like to do as little as possible in python anyway.

Copy link
Member

Choose a reason for hiding this comment

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

That error comes from the Rust portion of rustbuild, I think? It looks like a Rust error...

Presumably LLVM was not downloaded or not unpacked which led to this problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, I'd be interested in tackling this to get more familiar with the bootstrap code, if you decide to move this to rustbuild :)

Copy link
Contributor Author

@alarsyo alarsyo Oct 13, 2020

Choose a reason for hiding this comment

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

Presumably LLVM was not downloaded or not unpacked which led to this problem.

Yes, the rust code doesn't find the executable because it wasn't downloaded by bootstrap.py, because bootstrap.py didn't know about the default file, so the get_toml('download-ci-llvm') returned None

Copy link
Member

Choose a reason for hiding this comment

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

Let's tackle this in a follow-up, it seems reasonable to have bootstrap.py read profiles anyway.

src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum 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 13, 2020
@alarsyo alarsyo force-pushed the setup-llvm-detect branch 2 times, most recently from 7345c61 to c39c869 Compare October 13, 2020 14:59
Comment on lines 1012 to 1013
with open(include_path) as included_toml:
build.config_toml += '\n' + included_toml.read()
Copy link
Member

Choose a reason for hiding this comment

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

I'm 90% sure this will break - this causes invalid syntax if there's already anything in the config.toml. #76628 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would break if parsed by a real TOML parser, but that's not the case, the basic regex parser will just match the first relevant key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(and since the aggregation of the two files is only stored as a string in memory, not written to a toml file somewhere, I don't think it should break anything else?)

@alarsyo
Copy link
Contributor Author

alarsyo commented Oct 14, 2020

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@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 Oct 14, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 14, 2020

@bors r+

In a follow-up I'd like to move handling of LLVM from bootstrap.py to rustbuild, but that doesn't need to block this change.

@bors
Copy link
Contributor

bors commented Oct 14, 2020

📌 Commit b8ae4c5 has been approved by jyn514

@bors
Copy link
Contributor

bors commented Oct 14, 2020

🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2020
@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 14, 2020
@alarsyo
Copy link
Contributor Author

alarsyo commented Oct 14, 2020

@jyn514 should I open an issue about a follow-up change for rustbuild ?

@Mark-Simulacrum
Copy link
Member

It would mean a curl or other "http talker" dep in rustbuild which I'm opposed to at this point I think, but I don't mind an issue.

@bors
Copy link
Contributor

bors commented Oct 15, 2020

⌛ Testing commit b8ae4c5 with merge 19e1aac...

@bors
Copy link
Contributor

bors commented Oct 15, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: jyn514
Pushing 19e1aac to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 15, 2020
@bors bors merged commit 19e1aac into rust-lang:master Oct 15, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 15, 2020
@alarsyo alarsyo deleted the setup-llvm-detect branch October 15, 2020 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself 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