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

Allow getting no_std from the config file #69381

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

Ericson2314
Copy link
Contributor

Currently, it is only set correctly in the sanity checking implicit
default fallback code. Having a config file at all will for force
no_std = false.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(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 Feb 22, 2020
Currently, it is only set correctly in the sanity checking implicit
default fallback code. Having a config file at all will for force
`no_std = false`.
@@ -615,6 +616,8 @@ impl Config {
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
target.no_std =
cfg.no_std.unwrap_or(triple.contains("-none-") || triple.contains("nvptx"));
Copy link
Member

Choose a reason for hiding this comment

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

Hm, is -none- perhaps a bit too broad? I guess we presumably don't ship any platforms with that triple today that do have std compiled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic is taken from if target.contains("-none-") || target.contains("nvptx") {. Some later refactor should just ensure there are Targets for all platforms specified by name, rather than config, so we can deduplicate this.

@@ -194,9 +194,7 @@ pub fn check(build: &mut Build) {

if target.contains("-none-") || target.contains("nvptx") {
if build.no_std(*target).is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

This function looks potentially relevant; is there a reason it's not receiving updates or so?

Copy link
Contributor Author

@Ericson2314 Ericson2314 Feb 23, 2020

Choose a reason for hiding this comment

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

Ah, I should replace the calls to Default::default with a new method that defaults based on the triple. Then this will work as I intended: the defaulting logic happens in one place. and we simply ensure that the target exists here so that the triple-specific defaults rather than triple-agnostic defaults are used.

@Mark-Simulacrum
Copy link
Member

Okay, I think the new logic is better, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 25, 2020

📌 Commit 03ca0e2 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 Feb 25, 2020
@Ericson2314
Copy link
Contributor Author

Wait I should have called out the issue in #69381 (comment) more strongly. This as-is will break just doing --target <something>-<something>-none-<something> which does work today. I should fix that.

@Ericson2314
Copy link
Contributor Author

@bors r-

@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 Feb 25, 2020
@Ericson2314
Copy link
Contributor Author

oh cool, that does work for me as author.

Background: targets can be specied with or without config files;
unneccessarily differences in the logic between those cases has caused
a) the bug I tried to fix in the previous commit, b) the bug I
introduced in the previous commit.

The solution is to make the code paths the same as much as possible.

1. Targets are now not created from the `default` method. (I would both
remove the impl if this was a public library, but just wrap it for
convience becaues it's not.) Instead, there is a `from_triple` method
which does the defaulting.

2. Besides the sanity checking, use the new method in the code reading
config files. Now `no_std` is overriden iff set explicitly just like the
other fields which are optional in the TOML AST type.

3. In sanity checking, just populate the map for all targets no matter
what. That way do don't duplicate logic trying to be clever and remember
which targets have "non standard" overrides. Sanity checking is back to
just sanity checking, and out of the game of trying to default too.
@Ericson2314
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented Feb 25, 2020

@Ericson2314: 🔑 Insufficient privileges: Not in reviewers

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 25, 2020

📌 Commit 4f15867 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 25, 2020
@nikomatsakis
Copy link
Contributor

r? @Mark-Simulacrum

bors added a commit that referenced this pull request Feb 26, 2020
Rollup of 5 pull requests

Successful merges:

 - #68712 (Add methods to 'leak' RefCell borrows as references with the lifetime of the original reference)
 - #69209 (Miscellaneous cleanup to formatting)
 - #69381 (Allow getting `no_std` from the config file)
 - #69434 (rustc_metadata: Use binary search from standard library)
 - #69447 (Minor refactoring of statement parsing)

Failed merges:

r? @ghost
@bors bors merged commit d799f2d into rust-lang:master Feb 26, 2020
@Ericson2314 Ericson2314 deleted the no-std-from-config branch February 26, 2020 20:02
kevincox added a commit to NixOS/nixpkgs that referenced this pull request Mar 18, 2020
Note: The removed patch has been merged in rust-lang/rust#69381
@kevincox kevincox mentioned this pull request Mar 18, 2020
10 tasks
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants