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

Cleanup option parsing and config.toml.example #82451

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Feb 23, 2021

  • Add an assertion that link-shared = true when thin-lto = true.
    Previously, link-shared would be silently overwritten.

  • Get rid of Option<bool> in bootstrap/config.rs. Set defaults
    immediately instead of delaying until later in bootstrap. This makes
    it easier to find what the default value is.

  • Remove redundant config.x = false when the default was already false

  • Set defaults for bindir in default_opts() instead of parse()

  • Update download-ci-llvm = if-supported option to match bootstrap.py

  • Remove redundant check for link_shared. Previously, it was checked twice.

  • Update various options in config.toml.example to their defaults.
    Previously, some options showed an example value instead of the
    default value.

  • Fix incorrect defaults in config.toml.example

    • use-libcxx defaults to false
    • Add missing check-stage = 0
    • Update several defaults to be conditional (e.g. if incremental { 10 } else { 100 })
  • Remove redundant defaults in prose

  • Use the same comment for the default and target-dependent musl-root

  • Fix typos

  • Link to cc_detect for cc and cxx, since the logic is ... complicated.

  • Update more defaults to better reflect how they actually get set

  • Remove ignored gpg-password-file option

    This stopped being used in
    7704d35,
    but was never removed from config.toml.

  • Remove unused flags from config.toml

    • Disallow infodir and localstatedir in config.toml
    • Allow the flags in ./configure, but give a warning that they will be
      ignored.
    • Fix incorrect comment that datadir will be ignored.

    Example output:

    $ ./configure --set install.infodir=xxx
    configure: processing command line
    configure:
    configure: install.infodir      := xxx
    configure: build.configure-args := ['--set', 'install.infodir=xxx']
    warning: infodir will be ignored
    configure:
    configure: writing `config.toml` in current directory
    configure:
    configure: run `python /home/joshua/rustc3/x.py --help`
    configure:
    
  • Update CHANGELOG

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/bootstrap.20defaults

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself labels Feb 23, 2021
@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 Feb 23, 2021
@jyn514 jyn514 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 23, 2021
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
config.toml.example Outdated Show resolved Hide resolved
src/bootstrap/config.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 changed the title [WIP] Cleanup option parsing and config.toml.example Cleanup option parsing and config.toml.example Feb 24, 2021
@jyn514 jyn514 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 Feb 24, 2021
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 seems good overall, but left some nits.

@@ -171,37 +176,37 @@ changelog-seen = 2
# first compiler.
#
# Defaults to host platform
#build = "x86_64-unknown-linux-gnu"
#build = <host platform>
Copy link
Member

Choose a reason for hiding this comment

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

I think saying host platform is a plausibly a bit confusing here given host key below, though it's always been a bit hard to pin down what build really is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm - would it be helpful to say "native platform" instead? Or maybe just "current platform"?


# Which triples to build libraries (core/alloc/std/test/proc_macro) for. Each of
# these triples will be bootstrapped from the build triple themselves.
#
# Defaults to `host`. If you set this explicitly, you likely want to add all
# host triples to this list as well in order for those host toolchains to be
# able to compile programs for their native target.
#target = ["x86_64-unknown-linux-gnu"]
#target = host (array)
Copy link
Member

Choose a reason for hiding this comment

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

"configured host" or something like this, otherwise it's unclear whether this is defaulting to the host platform (i.e., build = ) or the host array above.

I'm not actually convinced that the diffs to these over stating the linux build triple is actually helpful, it feels like it might just confuse people more. We could instead add a comment that this is just an example configuration, but will differ based on the platform being compiled on.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could instead add a comment that this is just an example configuration, but will differ based on the platform being compiled on.

I like this idea - I'm fine with examples as long as it's clear they're examples and not defaults :) adding that now.

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem done, unless I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

I seem to have lost these commits somewhere; I'm just going to rewrite the changes.


# Instead of download the src/stage0.txt version of rustfmt specified,
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
#rustfmt = "/path/to/bin/rustfmt"
#rustfmt = "<build-dir>/<host platform>/stage0/bin/rustfmt"
Copy link
Member

Choose a reason for hiding this comment

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

I think this change is intending to specify the default, but I think it's not a good idea for us to say what the default is in this case. I really would prefer that people keep the exact location of these files in the "default" out of there configuration, and really even out of their knowledge -- if folks are configuring something else, then the old suggestions here were just as good, but if you're fine with the default then you shouldn't set this at all. We already note the default is specified via src/stage0.txt just above each of these, which seems good enough to me.

@@ -373,7 +371,9 @@ changelog-seen = 2

# Sets the number of codegen units to build the standard library with,
# regardless of what the codegen-unit setting for the rest of the compiler is.
#codegen-units-std = 1
# NOTE: building with anything other than 1 is known to occasionally have bugs.
# See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/bootstrapping.20on.20s390x.2Fmips.20for.20musl/near/227436952 for details.
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer we not link to ephemeral chats like this. If there's some useful conversation there, we can either inline the salient points into this file or otherwise document it (e.g., on rustc-dev-guide) and link there. One other approach would be to file a GitHub issue with some details on the bugs encountered and how to reproduce them and say something like "those bugs are tracked here: #xxx". If it's true that just setting codegen-units-std to non-1 value causes bugs for most folks we should probably prioritize an investigation at least.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I opened #83600 and I can link there in config.toml.

config.toml.example Outdated Show resolved Hide resolved

# Force static or dynamic linkage of the standard library for this target. If
# this target is a host for rustc, this will also affect the linkage of the
# compiler itself. This is useful for building rustc on targets that normally
# only use static libraries. If unset, the target's default linkage is used.
#crt-static = false
#crt-static = <see above> (bool)
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean read the comment on this option? It seems like we should say something like "platform specific" rather than see above, which is pretty confusing to me at least.

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 thing, done.

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem done, unless I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks. Not sure if it just slipped my mind or if I lost it in git somewhere 🤷

@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 Mar 1, 2021
@bors

This comment has been minimized.

@crlf0710 crlf0710 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 Mar 20, 2021
@jyn514 jyn514 removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 28, 2021
@jyn514 jyn514 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 28, 2021
@klensy
Copy link
Contributor

klensy commented Mar 28, 2021

It's hard to understand if some values in comments shows their default values or examples.
For example: codegen-units-std broken by default by setting it to codegen-units (that i assume > 1, by default) or not?

@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 4, 2021
@jyn514 jyn514 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 7, 2021
@Mark-Simulacrum
Copy link
Member

r=me with commits squashed

I think it may be useful to have a broader conversation - somewhere - about our goals for the example file and whether we're meeting them with the current format. I'm worried it's a pretty long file and may not be readily searchable. It may also be fine.

- Add an assertion that `link-shared = true` when `thin-lto = true`.
  Previously, link-shared would be silently overwritten.

- Get rid of `Option<bool>` in bootstrap/config.rs. Set defaults
  immediately instead of delaying until later in bootstrap. This makes
  it easier to find what the default value is.

- Remove redundant `config.x = false` when the default was already false
- Set defaults for `bindir` in `default_opts()` instead of `parse()`
- Update `download-ci-llvm = if-supported` option to match bootstrap.py
- Remove redundant check for link_shared. Previously, it was checked twice.

- Update various options in config.toml.example to their defaults.
  Previously, some options showed an example value instead of the
  default value.

- Fix incorrect defaults in config.toml.example
  + `use-libcxx` defaults to false
  + Add missing `check-stage = 0`
  + Update several defaults to be conditional (e.g. `if incremental { 10 } else { 100 }`)

- Remove redundant defaults in prose
- Use the same comment for the default and target-dependent `musl-root`
- Fix typos
- Link to `cc_detect` for `cc` and `cxx`, since the logic is ... complicated.
- Update more defaults to better reflect how they actually get set
- Remove ignored `gpg-password-file` option

  This stopped being used in
  rust-lang@7704d35,
  but was never removed from config.toml.

- Remove unused flags from `config.toml`
    + Disallow `infodir` and `localstatedir` in `config.toml`
    + Allow the flags in `./configure`, but give a warning that they will be
      ignored.
    + Fix incorrect comment that `datadir` will be ignored.

    Example output:

    ```
    $ ./configure --set install.infodir=xxx
    configure: processing command line
    configure:
    configure: install.infodir      := xxx
    configure: build.configure-args := ['--set', 'install.infodir=xxx']
    warning: infodir will be ignored
    configure:
    configure: writing `config.toml` in current directory
    configure:
    configure: run `python /home/joshua/rustc3/x.py --help`
    configure:
    ```

- Update CHANGELOG
- Add "as an example" where appropriate
- Link to an issue instead of to ephemeral chats
@jyn514
Copy link
Member Author

jyn514 commented Apr 7, 2021

@bors r=Mark-Simulacrum

I think it may be useful to have a broader conversation - somewhere - about our goals for the example file and whether we're meeting them with the current format. I'm worried it's a pretty long file and may not be readily searchable. It may also be fine.

Yeah, I also have some concerns about that ... I've started recommending that people not copy the whole example file because it makes it easier to find which settings you've changed. Maybe we could sort this file somehow to put the most common options first? Or have an easy way to only show the options without the comments - that would trim it down a lot.

@bors
Copy link
Contributor

bors commented Apr 7, 2021

📌 Commit 28e83a4 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 Apr 7, 2021
@jyn514
Copy link
Member Author

jyn514 commented Apr 7, 2021

Or have an easy way to only show the options without the comments - that would trim it down a lot.

grep -v '^# ' config.toml.example | sed '/^$/d' | grep -v '^#$' works.

#codegen-units-std = 1
# NOTE: building with anything other than 1 is known to occasionally have bugs.
# See https://github.com/rust-lang/rust/issues/83600.
#codegen-units-std = codegen-units
Copy link
Contributor

Choose a reason for hiding this comment

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

Here codegen-units-std = codegen-units use codegen-units as default value, that defined as #codegen-units = if incremental { 256 } else { 16 }, so it will be not 1 and have some bugs by default(by comment)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's correct. It's unclear to me how common the bug is or why it's related to codegen units.

@bors
Copy link
Contributor

bors commented Apr 7, 2021

⌛ Testing commit 28e83a4 with merge 361bfce...

@bors
Copy link
Contributor

bors commented Apr 7, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 361bfce to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 7, 2021
@bors bors merged commit 361bfce into rust-lang:master Apr 7, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 7, 2021
@jyn514 jyn514 deleted the defaults branch April 7, 2021 23:24
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 C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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.

None yet

9 participants