Skip to content

Commit

Permalink
Auto merge of rust-lang#137884 - matthiaskrgr:rollup-d9m5rhf, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes)
 - rust-lang#137081 (change config.toml to bootstrap.toml)
 - rust-lang#137103 ({json|html}docck: catch and error on deprecated syntax)
 - rust-lang#137632 (rustdoc: when merging target features, keep the highest stability)
 - rust-lang#137684 (Add rustdoc support for `--emit=dep-info[=path]`)
 - rust-lang#137794 (make qnx pass a test)
 - rust-lang#137801 (tests: Unignore target modifier tests on all platforms)
 - rust-lang#137826 (test(codegen): add looping_over_ne_bytes test for rust-lang#133528)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 2, 2025
2 parents f4a216d + 8efe509 commit 6786e3c
Show file tree
Hide file tree
Showing 218 changed files with 966 additions and 850 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe what you expected to happen.
Describe what actually happened.
-->

### Bootstrap configuration (config.toml)
### Bootstrap configuration (bootstrap.toml)
```toml
<config>
```
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file should only ignore things that are generated during a `x.py` build,
# generated by common IDEs, and optional files controlled by the user that
# affect the build (such as config.toml).
# affect the build (such as bootstrap.toml).
# In particular, things like `mir_dump` should not be listed here; they are only
# created during manual debugging and many people like to clean up instead of
# having git ignore such leftovers. You can use `.git/info/exclude` to
Expand Down Expand Up @@ -34,6 +34,7 @@ Session.vim
!/tests/run-make/thumb-none-qemu/example/.cargo

## Configuration
/bootstrap.toml
/config.toml
/Makefile
config.mk
Expand Down
3 changes: 2 additions & 1 deletion .ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Make vscode *not* count `config.toml` as ignored, so it is included in search
# Make vscode *not* count `bootstrap.toml` and `config.toml` as ignored, so it is included in search
!/bootstrap.toml
!/config.toml
10 changes: 5 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ If you just want to install Rust, check out the [README.md](README.md) instead.*

The Rust build system uses a Python script called `x.py` to build the compiler,
which manages the bootstrapping process. It lives at the root of the project.
It also uses a file named `config.toml` to determine various configuration
It also uses a file named `bootstrap.toml` to determine various configuration
settings for the build. You can see a full list of options in
`config.example.toml`.
`bootstrap.example.toml`.

The `x.py` command can be run directly on most Unix systems in the following
format:
Expand Down Expand Up @@ -115,15 +115,15 @@ See [the rustc-dev-guide for more info][sysllvm].

This project provides a configure script and makefile (the latter of which just
invokes `x.py`). `./configure` is the recommended way to programmatically
generate a `config.toml`. `make` is not recommended (we suggest using `x.py`
generate a `bootstrap.toml`. `make` is not recommended (we suggest using `x.py`
directly), but it is supported and we try not to break it unnecessarily.

```sh
./configure
make && sudo make install
```

`configure` generates a `config.toml` which can also be used with normal `x.py`
`configure` generates a `bootstrap.toml` which can also be used with normal `x.py`
invocations.

## Building on Windows
Expand Down Expand Up @@ -251,7 +251,7 @@ Windows build triples are:
- `x86_64-pc-windows-msvc`

The build triple can be specified by either specifying `--build=<triple>` when
invoking `x.py` commands, or by creating a `config.toml` file (as described in
invoking `x.py` commands, or by creating a `bootstrap.toml` file (as described in
[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing
`--set build.build=<triple>` to `./configure`.

Expand Down
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ Compatibility Notes
- [Cargo denies `CARGO_HOME` in the `[env]` configuration table. Cargo itself doesn't pick up this value, but recursive calls to cargo would, which was not intended.](https://github.com/rust-lang/cargo/pull/11644/)
- [Debuginfo for build dependencies is now off if not explicitly set. This is expected to improve the overall build time.](https://github.com/rust-lang/cargo/pull/11252/)
- [The Rust distribution no longer always includes rustdoc](https://github.com/rust-lang/rust/pull/106886)
If `tools = [...]` is set in config.toml, we will respect a missing rustdoc in that list. By
If `tools = [...]` is set in bootstrap.toml, we will respect a missing rustdoc in that list. By
default rustdoc remains included. To retain the prior behavior explicitly add `"rustdoc"` to the
list.

Expand Down Expand Up @@ -5268,7 +5268,7 @@ related tools.

- [Building `rustc` from source now uses `ninja` by default over `make`.][74922]
You can continue building with `make` by setting `ninja=false` in
your `config.toml`.
your `bootstrap.toml`.
- [cg_llvm: `fewer_names` in `uncached_llvm_type`][76030]
- [Made `ensure_sufficient_stack()` non-generic][76680]

Expand Down
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path = [
"Cargo.lock",
"Cargo.toml",
"CODE_OF_CONDUCT.md",
"config.example.toml",
"bootstrap.example.toml",
"configure",
"CONTRIBUTING.md",
"COPYRIGHT",
Expand Down
6 changes: 3 additions & 3 deletions config.example.toml → bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# All options are commented out by default in this file, and they're commented
# out with their default values. The build system by default looks for
# `config.toml` in the current directory of a build for build configuration, but
# `bootstrap.toml` in the current directory of a build for build configuration, but
# a custom configuration file can also be specified with `--config` to the build
# system.

Expand All @@ -16,7 +16,7 @@
# Use different pre-set defaults than the global defaults.
#
# See `src/bootstrap/defaults` for more information.
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
#profile = <none>

# Keeps track of major changes made to this configuration.
Expand Down Expand Up @@ -325,7 +325,7 @@
# Enable a build of the extended Rust tool set which is not only the compiler
# but also tools such as Cargo. This will also produce "combined installers"
# which are used to install Rust and Cargo together.
# The `tools` (check `config.example.toml` to see its default value) option specifies
# The `tools` (check `bootstrap.example.toml` to see its default value) option specifies
# which tools should be built if `extended = true`.
#
# This is disabled by default.
Expand Down
56 changes: 44 additions & 12 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::parse::feature_err;
use rustc_span::{Span, Symbol, sym};
use rustc_target::target_features;
use rustc_target::target_features::{self, Stability};

use crate::errors;

Expand Down Expand Up @@ -87,12 +87,17 @@ pub(crate) fn from_target_feature_attr(
// But ensure the ABI does not forbid enabling this.
// Here we do assume that LLVM doesn't add even more implied features
// we don't know about, at least no features that would have ABI effects!
if abi_feature_constraints.incompatible.contains(&name.as_str()) {
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
span: item.span(),
feature: name.as_str(),
reason: "this feature is incompatible with the target ABI",
});
// We skip this logic in rustdoc, where we want to allow all target features of
// all targets, so we can't check their ABI compatibility and anyway we are not
// generating code so "it's fine".
if !tcx.sess.opts.actually_rustdoc {
if abi_feature_constraints.incompatible.contains(&name.as_str()) {
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
span: item.span(),
feature: name.as_str(),
reason: "this feature is incompatible with the target ABI",
});
}
}
target_features.push(TargetFeature { name, implied: name != feature_sym })
}
Expand Down Expand Up @@ -142,11 +147,38 @@ pub(crate) fn provide(providers: &mut Providers) {
rust_target_features: |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc {
// rustdoc needs to be able to document functions that use all the features, so
// whitelist them all
rustc_target::target_features::all_rust_features()
.map(|(a, b)| (a.to_string(), b))
.collect()
// HACK: rustdoc would like to pretend that we have all the target features, so we
// have to merge all the lists into one. To ensure an unstable target never prevents
// a stable one from working, we merge the stability info of all instances of the
// same target feature name, with the "most stable" taking precedence. And then we
// hope that this doesn't cause issues anywhere else in the compiler...
let mut result: UnordMap<String, Stability> = Default::default();
for (name, stability) in rustc_target::target_features::all_rust_features() {
use std::collections::hash_map::Entry;
match result.entry(name.to_owned()) {
Entry::Vacant(vacant_entry) => {
vacant_entry.insert(stability);
}
Entry::Occupied(mut occupied_entry) => {
// Merge the two stabilities, "more stable" taking precedence.
match (occupied_entry.get(), stability) {
(Stability::Stable, _)
| (
Stability::Unstable { .. },
Stability::Unstable { .. } | Stability::Forbidden { .. },
)
| (Stability::Forbidden { .. }, Stability::Forbidden { .. }) => {
// The stability in the entry is at least as good as the new one, just keep it.
}
_ => {
// Overwrite stabilite.
occupied_entry.insert(stability);
}
}
}
}
}
result
} else {
tcx.sess
.target
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ compiler, which will then build the bootstrap binary written in Rust.

Because there are two separate codebases behind `x.py`, they need to
be kept in sync. In particular, both `bootstrap.py` and the bootstrap binary
parse `config.toml` and read the same command line arguments. `bootstrap.py`
parse `bootstrap.toml` and read the same command line arguments. `bootstrap.py`
keeps these in sync by setting various environment variables, and the
programs sometimes have to add arguments that are explicitly ignored, to be
read by the other.
Expand Down
26 changes: 17 additions & 9 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def download_toolchain(self):

def should_fix_bins_and_dylibs(self):
"""Whether or not `fix_bin_or_dylib` needs to be run; can only be True
on NixOS or if config.toml has `build.patch-binaries-for-nix` set.
on NixOS or if bootstrap.toml has `build.patch-binaries-for-nix` set.
"""
if self._should_fix_bins_and_dylibs is not None:
return self._should_fix_bins_and_dylibs
Expand Down Expand Up @@ -775,7 +775,7 @@ def get_answer():
"The IN_NIX_SHELL environment variable is `{}`;".format(
in_nix_shell
),
"you may need to set `patch-binaries-for-nix=true` in config.toml",
"you may need to set `patch-binaries-for-nix=true` in bootstrap.toml",
)

return is_nixos
Expand Down Expand Up @@ -884,7 +884,7 @@ def bin_root(self):
return os.path.join(self.build_dir, self.build, subdir)

def get_toml(self, key, section=None):
"""Returns the value of the given key in config.toml, otherwise returns None
"""Returns the value of the given key in bootstrap.toml, otherwise returns None
>>> rb = RustBuild()
>>> rb.config_toml = 'key1 = "value1"\\nkey2 = "value2"'
Expand Down Expand Up @@ -1250,17 +1250,23 @@ def bootstrap(args):
"unless you put them in place manually."
)

# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`,
# then `config.toml` in the root directory.
# Read from `--config` first, followed by `RUST_BOOTSTRAP_CONFIG`.
# If neither is set, check `./bootstrap.toml`, then `bootstrap.toml` in the root directory.
# If those are unavailable, fall back to `./config.toml`, then `config.toml` for
# backward compatibility.
toml_path = args.config or os.getenv("RUST_BOOTSTRAP_CONFIG")
using_default_path = toml_path is None
if using_default_path:
toml_path = "config.toml"
toml_path = "bootstrap.toml"
if not os.path.exists(toml_path):
toml_path = os.path.join(rust_root, toml_path)
toml_path = os.path.join(rust_root, "bootstrap.toml")
if not os.path.exists(toml_path):
toml_path = "config.toml"
if not os.path.exists(toml_path):
toml_path = os.path.join(rust_root, "config.toml")

# Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
# but not if `config.toml` hasn't been created.
# but not if `bootstrap.toml` hasn't been created.
if not using_default_path or os.path.exists(toml_path):
with open(toml_path) as config:
config_toml = config.read()
Expand All @@ -1278,7 +1284,9 @@ def bootstrap(args):
# profiles to be renamed while maintaining back compatibility
# Keep in sync with `profile_aliases` in config.rs
profile_aliases = {"user": "dist"}
include_file = "config.{}.toml".format(profile_aliases.get(profile) or profile)
include_file = "bootstrap.{}.toml".format(
profile_aliases.get(profile) or profile
)
include_dir = os.path.join(rust_root, "src", "bootstrap", "defaults")
include_path = os.path.join(include_dir, include_file)

Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_known_args(self):


class GenerateAndParseConfig(unittest.TestCase):
"""Test that we can serialize and deserialize a config.toml file"""
"""Test that we can serialize and deserialize a bootstrap.toml file"""

def test_no_args(self):
build = serialize_and_parse([])
Expand Down Expand Up @@ -206,11 +206,11 @@ def build_args(self, configure_args=None, args=None, env=None):
# problem in most cases, but there is a scenario where it would cause
# the test to fail.
#
# When a custom local Cargo is configured in config.toml (with the
# When a custom local Cargo is configured in bootstrap.toml (with the
# build.cargo setting), no Cargo is downloaded to any location known by
# bootstrap, and bootstrap relies on that setting to find it.
#
# In this test though we are not using the config.toml of the caller:
# In this test though we are not using the bootstrap.toml of the caller:
# we are generating a blank one instead. If we don't set build.cargo in
# it, the test will have no way to find Cargo, failing the test.
cargo_bin = os.environ.get("BOOTSTRAP_TEST_CARGO_BIN")
Expand Down
20 changes: 10 additions & 10 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def is_value_list(key):
print("\t\t" + option.desc)
print("")
print("This configure script is a thin configuration shim over the true")
print("configuration system, `config.toml`. You can explore the comments")
print("in `config.example.toml` next to this configure script to see")
print("configuration system, `bootstrap.toml`. You can explore the comments")
print("in `bootstrap.example.toml` next to this configure script to see")
print("more information about what each option is. Additionally you can")
print("pass `--set` as an argument to set arbitrary key/value pairs")
print("in the TOML configuration if desired")
Expand Down Expand Up @@ -562,8 +562,8 @@ def apply_args(known_args, option_checking, config):
raise RuntimeError("unhandled option {}".format(option.name))


# "Parse" the `config.example.toml` file into the various sections, and we'll
# use this as a template of a `config.toml` to write out which preserves
# "Parse" the `bootstrap.example.toml` file into the various sections, and we'll
# use this as a template of a `bootstrap.toml` to write out which preserves
# all the various comments and whatnot.
#
# Note that the `target` section is handled separately as we'll duplicate it
Expand All @@ -576,7 +576,7 @@ def parse_example_config(known_args, config):
targets = {}
top_level_keys = []

with open(rust_dir + "/config.example.toml") as example_config:
with open(rust_dir + "/bootstrap.example.toml") as example_config:
example_lines = example_config.read().split("\n")
for line in example_lines:
if cur_section is None:
Expand Down Expand Up @@ -750,8 +750,8 @@ def quit_if_file_exists(file):


if __name__ == "__main__":
# If 'config.toml' already exists, exit the script at this point
quit_if_file_exists("config.toml")
# If 'bootstrap.toml' already exists, exit the script at this point
quit_if_file_exists("bootstrap.toml")

if "GITHUB_ACTIONS" in os.environ:
print("::group::Configure the build")
Expand All @@ -761,11 +761,11 @@ def quit_if_file_exists(file):
p("")
section_order, sections, targets = parse_args(sys.argv[1:])

# Now that we've built up our `config.toml`, write it all out in the same
# Now that we've built up our `bootstrap.toml`, write it all out in the same
# order that we read it in.
p("")
p("writing `config.toml` in current directory")
with bootstrap.output("config.toml") as f:
p("writing `bootstrap.toml` in current directory")
with bootstrap.output("bootstrap.toml") as f:
write_config_toml(f, section_order, targets, sections)

with bootstrap.output("Makefile") as f:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6786e3c

Please sign in to comment.