Skip to content

Detect configuration for LLVM during setup - #77756

Merged
bors merged 2 commits into
rust-lang:masterfrom
alarsyo:setup-llvm-detect
Oct 15, 2020
Merged

Detect configuration for LLVM during setup#77756
bors merged 2 commits into
rust-lang:masterfrom
alarsyo:setup-llvm-detect

Conversation

@alarsyo

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-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
Copy Markdown
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

Copy link
Copy Markdown
ContributorAuthor

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

@jyn514jyn514 added A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 10, 2020
Comment threadsrc/bootstrap/setup.rs Outdated
Comment threadsrc/bootstrap/setup.rs Outdated
Comment threadsrc/bootstrap/setup.rs Outdated
@bors

bors commented Oct 12, 2020

Copy link
Copy Markdown
Collaborator

☔ 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

Comment threadsrc/bootstrap/bootstrap.py Outdated
Comment threadsrc/bootstrap/setup.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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?

@alarsyoalarsyoOct 13, 2020

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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 :)

@alarsyoalarsyoOct 13, 2020

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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.

Comment threadsrc/bootstrap/setup.rs Outdated
@Mark-SimulacrumMark-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
alarsyoforce-pushed the setup-llvm-detect branch 2 times, most recently from 7345c61 to c39c869CompareOctober 13, 2020 14:59
Comment threadsrc/bootstrap/bootstrap.py Outdated
Comment on lines 1012 to 1013

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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?)

Comment threadsrc/bootstrap/bootstrap.py
@alarsyo

Copy link
Copy Markdown
ContributorAuthor

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

@rustbotrustbot 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
Copy Markdown
Member

@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

bors commented Oct 14, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit b8ae4c5 has been approved by jyn514

@bors

bors commented Oct 14, 2020

Copy link
Copy Markdown
Collaborator

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

@borsbors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2020
@borsbors 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
Copy Markdown
ContributorAuthor

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

@Mark-Simulacrum

Copy link
Copy Markdown
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

bors commented Oct 15, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit b8ae4c5 with merge 19e1aac...

@bors

bors commented Oct 15, 2020

Copy link
Copy Markdown
Collaborator

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

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Oct 15, 2020
@bors
bors merged commit 19e1aac into rust-lang:masterOct 15, 2020
@rustbotrustbot 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rustmerged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-bootstrapRelevant 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

@alarsyo@rust-highfive@Mark-Simulacrum@bors@jyn514@rustbot