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

bootstrap: make cmake executable configurable with config.toml #85728

Closed
wants to merge 1 commit into from

Conversation

nodakai
Copy link
Contributor

@nodakai nodakai commented May 26, 2021

This is a spiritual successor to #71262

Fixes #71227

TODO

  • Add a template section to config.toml.example
  • Official CI runs the build with a weird setup; it is trivial to add if-else just to avoid crashing under the CI but its implications should be reviewed
  • With this change, CMAKE env var to control cmake crate will no longer be a pass-through field; bootstrap will (almost) always overwrite it. Its implications should be reviewed

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

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented May 26, 2021

Why is this useful, compared to only searching for cmake3 -> cmake?

@Mark-Simulacrum
Copy link
Member

Additionally, can you say what uses the CMAKE env var? Marking as waiting-on-author for now.

@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 May 29, 2021
@nodakai
Copy link
Contributor Author

nodakai commented May 30, 2021

Updated the PR description

@jyn514 "the same reason why config.toml supports specifying command names for python, nodejs, npm, and gdb"

To be more specific, I'm aware of

  1. people who have CMake 2.x as cmake and a sufficiently new CMake 3.x as cmake3 and want to invoke the latter, and
  2. people who have a very old CMake 3.x from Yum as cmake3 and the latest CMake 3.x from https://cmake.org/download/ as cmake and want to invoke the latter

@Mark-Simulacrum https://docs.rs/cmake/0.1.45/src/cmake/lib.rs.html#456

@bors
Copy link
Contributor

bors commented Jul 23, 2021

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

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

This looks like a good start. As you noted, we'll need to fix CI; unfortunately those logs have expired now so I'm not sure what the failure looked like exactly.

src/bootstrap/lib.rs Outdated Show resolved Hide resolved
src/bootstrap/config.rs Show resolved Hide resolved
@Mark-Simulacrum
Copy link
Member

(Once you're ready for a review, you can use @rustbot ready to switch the status such that I'll take a look).

@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Sep 15, 2021
@Dylan-DPC
Copy link
Member

@nodakai any updates on this?

@nodakai nodakai force-pushed the bootstrap-cmake-cmd-name branch from d26bc33 to be5b9be Compare April 18, 2022 16:04
@rust-log-analyzer

This comment has been minimized.

@nodakai nodakai force-pushed the bootstrap-cmake-cmd-name branch from be5b9be to 48c691f Compare April 18, 2022 16:34
@rust-log-analyzer

This comment has been minimized.

@nodakai nodakai force-pushed the bootstrap-cmake-cmd-name branch from 48c691f to 655535b Compare April 18, 2022 17:05
@nodakai nodakai marked this pull request as ready for review April 19, 2022 02:59
@nodakai nodakai changed the title WIP: bootstrap: cmake cmd configurable with config.toml bootstrap: make cmake executable configurable with config.toml Apr 19, 2022
@nodakai
Copy link
Contributor Author

nodakai commented Apr 19, 2022

@rustbot ready

@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 Apr 19, 2022
Signed-off-by: NODA Kai <nodakai@gmail.com>
@nodakai nodakai force-pushed the bootstrap-cmake-cmd-name branch from 655535b to 680f4b6 Compare April 19, 2022 15:41
}
} else {
None
};
Copy link
Member

Choose a reason for hiding this comment

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

Most of this logic probably belongs in config.rs, not here. We should always have build.config.cmake as the source of truth for the cmake path, and support setting it only via config.toml. (If it is set in the environment and not equal to the config.toml value, it should be a panic! at config parse time).

Here, we should just have the if need_cmake { cmd_finder.must_have(&build.config.cmake); }, with that defaulting to just "cmake" if nothing is set in the config.toml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a couple of comments, let me start with minor ones (since major ones are going to take more time to write)

  1. (If it is set in the environment and not equal to the config.toml value, it should be a panic! at config parse time)

    Last time, you wrote
    bootstrap: make cmake executable configurable with config.toml #85728 (comment)

    If it is set and different, I think we should probably prefer config.toml still but issue a warning (just eprintln! is fine).

    Warn or panic? Let me know of your decision.

  2. We should always have build.config.cmake as the source of truth for the cmake path, and support setting it only via config.toml.

    Are you suggesting to set CMAKE env var unconditionally based on what's in config.toml (or its default value defined in config.rs > define_config!)? Is that your opinion? You don't mind breaking a hypothetical existing build env which relies on a custom CMAKE env var (which is passed through to cmake crate as of today)? Let's say someone has CMAKE=mycmake as of today, expecting it to be passed through to cmake crate, and your suggestion is that they should set cmake = "mycmake" instead, and if they don't, their build should fail with a panic saying sth like "cmake from config.toml wants to use cmake but you have a contradictory env var CMAKE=mycmake`"?

    Caveat: from what I see, cmake crate accepts a very wide variety of env vars,
    https://docs.rs/cmake/0.1.48/src/cmake/lib.rs.html#857-861
    like CMAKE_x86_64-unknown-linux-gnu, and I don't think it's realistic for bootstrap to cover all of them.

I'll find time to add more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Warn or panic? Let me know of your decision.

I think panic! is probably best.

[...] cmake env

Looking into our use of cmake a little more, it looks like we only ever actually invoke it through the cmake crate, so if users are supplying configuration to us via env variables, the cmake crate would already be picking that up appropriately. In sanity checking, we do use "cmake" without doing the same env-variable lookup that the cmake crate does. (Target-specific cmake binaries do not feel particularly likely to be actually necessary, as it's really a host tool).

I'm not too worried about env-variables overriding bootstrap's configuration in the cmake crate - that seems unlikely to be an issue in practice, given how bootstrap itself isn't using cmake directly (except for sanity checks). Given that CMAKE isn't a "standard" env variable (or at least I've seen no evidence of that), I'm not really worried about supporting setting it as an alternative to editing config.toml, either.

So I think the value of config.cmake probably comes down to:

  • config.toml, if set
  • cmake, if not

After we load that, we want to put it in our own environment (set_var("CMAKE")) so that the cmake crate picks it up, at least as things stand today. Just before doing that I think it makes sense to check that it's not set to a different value (mostly just as a sanity check, but it doesn't make sense for this to be in sanity.rs).

Pretty much all of that logic should go into config.rs.

@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 Apr 24, 2022
@bors
Copy link
Contributor

bors commented May 8, 2022

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

@apiraino apiraino added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label May 23, 2022
@JohnCSimon
Copy link
Member

ping from triage:
@nodakai can you please address the merge conflicts?

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@nodakai
Copy link
Contributor Author

nodakai commented Jun 21, 2022

😵‍💫

@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 24, 2022
@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to open a new PR when you have the time for it. Thanks for contributing

@Dylan-DPC Dylan-DPC closed this Aug 1, 2022
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error bootstrapping on CentOS
10 participants