Skip to content

Commit 9c51cf7

Browse files
committed
Auto merge of #110546 - matthiaskrgr:rollup-346kik6, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #110123 ('./configure' now checks if 'config.toml' exists before writing to that destination) - #110429 (Spelling src bootstrap) - #110430 (Spelling src ci) - #110515 (Don't special-case download-rustc in `maybe_install_llvm`) - #110521 (Fix `x test lint-docs linkchecker` when download-rustc is enabled) - #110525 (Fix `tests/run-make-translation` when download-rustc is enabled) - #110531 (small type system cleanup) - #110533 (Missing blanket impl trait not public) - #110540 (Fix wrong comment in rustc_hir/src/hir.rs) - #110541 (Fix various configure bugs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents df0d9b4 + 0820e31 commit 9c51cf7

File tree

26 files changed

+113
-86
lines changed

26 files changed

+113
-86
lines changed

README.md

+25-26
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Read ["Installation"] from [The Book].
2222

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

2628
The `x.py` command can be run directly on most Unix systems in the following
2729
format:
@@ -85,6 +87,8 @@ See [the rustc-dev-guide for more info][sysllvm].
8587

8688
### Building on a Unix-like system
8789

90+
#### Build steps
91+
8892
1. Clone the [source] with `git`:
8993

9094
```sh
@@ -96,18 +100,13 @@ See [the rustc-dev-guide for more info][sysllvm].
96100

97101
2. Configure the build settings:
98102

99-
The Rust build system uses a file named `config.toml` in the root of the
100-
source tree to determine various configuration settings for the build.
101-
Set up the defaults intended for distros to get started. You can see a full
102-
list of options in `config.example.toml`.
103-
104103
```sh
105-
printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml
104+
./configure
106105
```
107106

108107
If you plan to use `x.py install` to create an installation, it is
109108
recommended that you set the `prefix` value in the `[install]` section to a
110-
directory.
109+
directory: `./configure --set install.prefix=<path>`
111110

112111
3. Build and install:
113112

@@ -117,12 +116,25 @@ See [the rustc-dev-guide for more info][sysllvm].
117116

118117
When complete, `./x.py install` will place several programs into
119118
`$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
120-
API-documentation tool. If you've set `profile = "user"` or
121-
`build.extended = true`, it will also include [Cargo], Rust's package
122-
manager.
119+
API-documentation tool. By default, it will also include [Cargo], Rust's package manager.
120+
You can disable this behavior by passing `--set build.extended=false` to `./configure`.
123121

124122
[Cargo]: https://github.com/rust-lang/cargo
125123

124+
#### Configure and Make
125+
126+
This project provides a configure script and makefile (the latter of which just invokes `x.py`).
127+
`./configure` is the recommended way to programatically generate a `config.toml`. `make` is not
128+
recommended (we suggest using `x.py` directly), but it is supported and we try not to break it
129+
unnecessarily.
130+
131+
```sh
132+
./configure
133+
make && sudo make install
134+
```
135+
136+
`configure` generates a `config.toml` which can also be used with normal `x.py` invocations.
137+
126138
### Building on Windows
127139

128140
On Windows, we suggest using [winget] to install dependencies by running the
@@ -186,7 +198,7 @@ toolchain.
186198
4. Navigate to Rust's source code (or clone it), then build it:
187199

188200
```sh
189-
./x.py build && ./x.py install
201+
python x.py setup user && python x.py build && python x.py install
190202
```
191203

192204
#### MSVC
@@ -204,6 +216,7 @@ With these dependencies installed, you can build the compiler in a `cmd.exe`
204216
shell with:
205217

206218
```sh
219+
python x.py setup user
207220
python x.py build
208221
```
209222

@@ -232,21 +245,7 @@ Windows build triples are:
232245

233246
The build triple can be specified by either specifying `--build=<triple>` when
234247
invoking `x.py` commands, or by creating a `config.toml` file (as described in
235-
[Installing from Source](#installing-from-source)), and modifying the `build`
236-
option under the `[build]` section.
237-
238-
### Configure and Make
239-
240-
While it's not the recommended build system, this project also provides a
241-
configure script and makefile (the latter of which just invokes `x.py`).
242-
243-
```sh
244-
./configure
245-
make && sudo make install
246-
```
247-
248-
`configure` generates a `config.toml` which can also be used with normal `x.py`
249-
invocations.
248+
[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing `--set build.build=<triple>` to `./configure`.
250249

251250
## Building Documentation
252251

compiler/rustc_hir/src/hir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ pub enum ExprKind<'hir> {
19601960
Lit(&'hir Lit),
19611961
/// A cast (e.g., `foo as f64`).
19621962
Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
1963-
/// A type reference (e.g., `Foo`).
1963+
/// A type ascription (e.g., `x: Foo`). See RFC 3307.
19641964
Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
19651965
/// Wraps the expression in a terminating scope.
19661966
/// This makes it semantically equivalent to `{ let _t = expr; _t }`.

compiler/rustc_middle/src/ty/flags.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl FlagComputation {
178178

179179
&ty::Alias(ty::Projection, data) => {
180180
self.add_flags(TypeFlags::HAS_TY_PROJECTION);
181-
self.add_projection_ty(data);
181+
self.add_alias_ty(data);
182182
}
183183

184184
&ty::Alias(ty::Opaque, ty::AliasTy { substs, .. }) => {
@@ -267,7 +267,7 @@ impl FlagComputation {
267267
projection_ty,
268268
term,
269269
})) => {
270-
self.add_projection_ty(projection_ty);
270+
self.add_alias_ty(projection_ty);
271271
self.add_term(term);
272272
}
273273
ty::PredicateKind::WellFormed(arg) => {
@@ -372,8 +372,8 @@ impl FlagComputation {
372372
}
373373
}
374374

375-
fn add_projection_ty(&mut self, projection_ty: ty::AliasTy<'_>) {
376-
self.add_substs(projection_ty.substs);
375+
fn add_alias_ty(&mut self, alias_ty: ty::AliasTy<'_>) {
376+
self.add_substs(alias_ty.substs);
377377
}
378378

379379
fn add_substs(&mut self, substs: &[GenericArg<'_>]) {

compiler/rustc_trait_selection/src/traits/wf.rs

+11-20
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,20 @@ pub fn predicate_obligations<'tcx>(
170170
ty::PredicateKind::WellFormed(arg) => {
171171
wf.compute(arg);
172172
}
173-
ty::PredicateKind::ObjectSafe(_) => {}
174-
ty::PredicateKind::ClosureKind(..) => {}
175-
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
176-
wf.compute(a.into());
177-
wf.compute(b.into());
178-
}
179-
ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
180-
wf.compute(a.into());
181-
wf.compute(b.into());
182-
}
173+
183174
ty::PredicateKind::ConstEvaluatable(ct) => {
184175
wf.compute(ct.into());
185176
}
186-
ty::PredicateKind::ConstEquate(c1, c2) => {
187-
wf.compute(c1.into());
188-
wf.compute(c2.into());
189-
}
190-
ty::PredicateKind::Ambiguous => {}
191-
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
192-
bug!("TypeWellFormedFromEnv is only used for Chalk")
193-
}
194-
ty::PredicateKind::AliasRelate(..) => {
195-
bug!("We should only wf check where clauses and `AliasRelate` is not a `Clause`")
177+
178+
ty::PredicateKind::ObjectSafe(_)
179+
| ty::PredicateKind::ClosureKind(..)
180+
| ty::PredicateKind::Subtype(..)
181+
| ty::PredicateKind::Coerce(..)
182+
| ty::PredicateKind::ConstEquate(..)
183+
| ty::PredicateKind::Ambiguous
184+
| ty::PredicateKind::AliasRelate(..)
185+
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
186+
bug!("We should only wf check where clauses, unexpected predicate: {predicate:?}")
196187
}
197188
}
198189

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def fix_bin_or_dylib(self, fname):
575575
]
576576
patchelf_args = ["--set-rpath", ":".join(rpath_entries)]
577577
if not fname.endswith(".so"):
578-
# Finally, set the corret .interp for binaries
578+
# Finally, set the correct .interp for binaries
579579
with open("{}/nix-support/dynamic-linker".format(nix_deps_dir)) as dynamic_linker:
580580
patchelf_args += ["--set-interpreter", dynamic_linker.read().rstrip()]
581581

src/bootstrap/bootstrap_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def serialize_and_parse(self, args):
9797
def test_no_args(self):
9898
build = self.serialize_and_parse([])
9999
self.assertEqual(build.get_toml("changelog-seen"), '2')
100+
self.assertEqual(build.get_toml("profile"), 'user')
100101
self.assertIsNone(build.get_toml("llvm.download-ci-llvm"))
101102

102103
def test_set_section(self):
@@ -107,10 +108,9 @@ def test_set_target(self):
107108
build = self.serialize_and_parse(["--set", "target.x86_64-unknown-linux-gnu.cc=gcc"])
108109
self.assertEqual(build.get_toml("cc", section="target.x86_64-unknown-linux-gnu"), 'gcc')
109110

110-
# Uncomment when #108928 is fixed.
111-
# def test_set_top_level(self):
112-
# build = self.serialize_and_parse(["--set", "profile=compiler"])
113-
# self.assertEqual(build.get_toml("profile"), 'compiler')
111+
def test_set_top_level(self):
112+
build = self.serialize_and_parse(["--set", "profile=compiler"])
113+
self.assertEqual(build.get_toml("profile"), 'compiler')
114114

115115
if __name__ == '__main__':
116116
SUITE = unittest.TestSuite()

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ impl<'a> Builder<'a> {
13991399

14001400
// Add extra cfg not defined in/by rustc
14011401
//
1402-
// Note: Altrough it would seems that "-Zunstable-options" to `rustflags` is useless as
1402+
// Note: Although it would seems that "-Zunstable-options" to `rustflags` is useless as
14031403
// cargo would implicitly add it, it was discover that sometimes bootstrap only use
14041404
// `rustflags` without `cargo` making it required.
14051405
rustflags.arg("-Zunstable-options");

src/bootstrap/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub enum GitInfo {
2222
/// If the info should be used (`omit_git_hash` is false), this will be
2323
/// `Some`, otherwise it will be `None`.
2424
Present(Option<Info>),
25-
/// This is not a git repostory, but the info can be fetched from the
25+
/// This is not a git repository, but the info can be fetched from the
2626
/// `git-commit-info` file.
2727
RecordedForTarball(Info),
2828
}

src/bootstrap/configure.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ def parse_example_config(known_args, config):
417417
# Avoid using quotes unless it's necessary.
418418
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target) if "." in target else target)
419419

420+
if 'profile' not in config:
421+
set('profile', 'user', config)
420422
configure_file(sections, top_level_keys, targets, config)
421423
return section_order, sections, targets
422424

@@ -475,7 +477,7 @@ def configure_section(lines, config):
475477
def configure_top_level_key(lines, top_level_key, value):
476478
for i, line in enumerate(lines):
477479
if line.startswith('#' + top_level_key + ' = ') or line.startswith(top_level_key + ' = '):
478-
lines[i] = "{} = {}".format(top_level_key, value)
480+
lines[i] = "{} = {}".format(top_level_key, to_toml(value))
479481
return
480482

481483
raise RuntimeError("failed to find config line for {}".format(top_level_key))
@@ -521,8 +523,14 @@ def write_config_toml(writer, section_order, targets, sections):
521523
else:
522524
writer = write_uncommented(sections[section], writer)
523525

526+
def quit_if_file_exists(file):
527+
if os.path.isfile(file):
528+
err("Existing '" + file + "' detected.")
524529

525530
if __name__ == "__main__":
531+
# If 'config.toml' already exists, exit the script at this point
532+
quit_if_file_exists('config.toml')
533+
526534
p("processing command line")
527535
# Parse all known arguments into a configuration structure that reflects the
528536
# TOML we're going to write out

src/bootstrap/dist.rs

-14
Original file line numberDiff line numberDiff line change
@@ -1965,20 +1965,6 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
19651965
}
19661966
}
19671967

1968-
// FIXME: for reasons I don't understand, the LLVM so in the `rustc` component is different than the one in `rust-dev`.
1969-
// Only the one in `rustc` works with the downloaded compiler.
1970-
if builder.download_rustc() && target == builder.build.build {
1971-
let src_libdir = builder.ci_rustc_dir(target).join("lib");
1972-
for entry in t!(std::fs::read_dir(&src_libdir)) {
1973-
let entry = t!(entry);
1974-
if entry.file_name().to_str().unwrap().starts_with("libLLVM-") {
1975-
install_llvm_file(builder, &entry.path(), dst_libdir);
1976-
return !builder.config.dry_run();
1977-
}
1978-
}
1979-
panic!("libLLVM.so not found in src_libdir {}!", src_libdir.display());
1980-
}
1981-
19821968
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
19831969
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
19841970
// clear why this is the case, though. llvm-config will emit the versioned

src/bootstrap/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ impl Step for Libunwind {
11531153
run.builder.ensure(Libunwind { target: run.target });
11541154
}
11551155

1156-
/// Build linunwind.a
1156+
/// Build libunwind.a
11571157
fn run(self, builder: &Builder<'_>) -> Self::Output {
11581158
builder.update_submodule(&Path::new("src/llvm-project"));
11591159

src/bootstrap/render_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module renders the JSON output of libtest into a human-readable form, trying to be as
22
//! similar to libtest's native output as possible.
33
//!
4-
//! This is needed because we need to use libtest in JSON mode to extract granluar information
4+
//! This is needed because we need to use libtest in JSON mode to extract granular information
55
//! about the executed tests. Doing so suppresses the human-readable output, and (compared to Cargo
66
//! and rustc) libtest doesn't include the rendered human-readable output as a JSON field. We had
77
//! to reimplement all the rendering logic in this module because of that.

src/bootstrap/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn check(build: &mut Build) {
100100
Couldn't find required command: cmake
101101
102102
You should install cmake, or set `download-ci-llvm = true` in the
103-
`[llvm]` section section of `config.toml` to download LLVM rather
103+
`[llvm]` section of `config.toml` to download LLVM rather
104104
than building it.
105105
"
106106
);

src/ci/docker/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ For targets: `armv7-unknown-linux-gnueabihf`
211211
(\*) These options have been selected to match the configuration of the arm
212212
toolchains shipped with Ubuntu 15.10
213213
(+) These options have been selected to match the gcc flags we use to compile C
214-
libraries like jemalloc. See the mk/cfg/arm(v7)-uknown-linux-gnueabi{,hf}.mk
214+
libraries like jemalloc. See the mk/cfg/arm(v7)-unknown-linux-gnueabi{,hf}.mk
215215
file in Rust's source code.
216216
217217
### `aarch64-linux-gnu.config`

src/ci/docker/host-x86_64/disabled/riscv64gc-linux/0001-Remove-stime-function-calls.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Remove stime() function calls
55

66
stime() has been deprecated in glibc 2.31 and replaced with
77
clock_settime(). Let's replace the stime() function calls with
8-
clock_settime() in preperation.
8+
clock_settime() in preparation.
99

1010
function old new delta
1111
rdate_main 197 224 +27

src/ci/docker/host-x86_64/dist-mips-linux/mips-linux-gnu.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ CT_CC_GCC_DEC_FLOAT_AUTO=y
528528
CT_CC_GCC_HAS_ARCH_OPTIONS=y
529529

530530
#
531-
# archictecture-specific options
531+
# architecture-specific options
532532
#
533533
CT_CC_GCC_mips_llsc=m
534534
CT_CC_GCC_mips_synci=m

src/ci/docker/host-x86_64/dist-mips64-linux/mips64-linux-gnu.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ CT_CC_GCC_DEC_FLOAT_AUTO=y
529529
CT_CC_GCC_HAS_ARCH_OPTIONS=y
530530

531531
#
532-
# archictecture-specific options
532+
# architecture-specific options
533533
#
534534
CT_CC_GCC_mips_llsc=m
535535
CT_CC_GCC_mips_synci=m

src/ci/docker/host-x86_64/dist-mips64el-linux/mips64el-linux-gnu.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ CT_CC_GCC_DEC_FLOAT_AUTO=y
529529
CT_CC_GCC_HAS_ARCH_OPTIONS=y
530530

531531
#
532-
# archictecture-specific options
532+
# architecture-specific options
533533
#
534534
CT_CC_GCC_mips_llsc=m
535535
CT_CC_GCC_mips_synci=m

src/ci/docker/host-x86_64/dist-mipsel-linux/mipsel-linux-gnu.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ CT_CC_GCC_DEC_FLOAT_AUTO=y
528528
CT_CC_GCC_HAS_ARCH_OPTIONS=y
529529

530530
#
531-
# archictecture-specific options
531+
# architecture-specific options
532532
#
533533
CT_CC_GCC_mips_llsc=m
534534
CT_CC_GCC_mips_synci=m

src/ci/docker/host-x86_64/mingw-check/validate-toolstate.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# A quick smoke test to make sure publish_tooolstate.py works.
2+
# A quick smoke test to make sure publish_toolstate.py works.
33

44
set -euo pipefail
55
IFS=$'\n\t'

src/ci/docker/scripts/qemu-bare-bones-rcS

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mount -t sysfs none /sys
99
/addentropy < /addentropy
1010
cat /dev/urandom | head -n 2048 | /addentropy
1111

12-
# Set up IP that qemu expects. This confgures eth0 with the public IP that QEMU
12+
# Set up IP that qemu expects. This configures eth0 with the public IP that QEMU
1313
# will communicate to as well as the loopback 127.0.0.1 address.
1414
ifconfig eth0 10.0.2.15
1515
ifconfig lo up

src/librustdoc/clean/blanket_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
2020
trace!("get_blanket_impls({:?})", ty);
2121
let mut impls = Vec::new();
2222
for trait_def_id in cx.tcx.all_traits() {
23-
if !cx.cache.effective_visibilities.is_directly_public(cx.tcx, trait_def_id)
23+
if !cx.cache.effective_visibilities.is_reachable(cx.tcx, trait_def_id)
2424
|| cx.generated_synthetics.get(&(ty.0, trait_def_id)).is_some()
2525
{
2626
continue;

0 commit comments

Comments
 (0)