New upstream version 1.38.0+dfsg1

This commit is contained in:
Ximin Luo 2019-11-25 21:38:20 +00:00
parent dc9dc13558
commit 416331ca66
8070 changed files with 166464 additions and 92208 deletions

View File

@ -179,7 +179,6 @@ Speaking of tests, Rust has a comprehensive test suite. More information about
it can be found [here][rctd].
### External Dependencies
[external-dependencies]: #external-dependencies
Currently building Rust will also build the following external projects:
@ -209,7 +208,6 @@ Breakage is not allowed in the beta and stable channels, and must be addressed
before the PR is merged.
#### Breaking Tools Built With The Compiler
[breaking-tools-built-with-the-compiler]: #breaking-tools-built-with-the-compiler
Rust's build system builds a number of tools that make use of the
internals of the compiler. This includes
@ -242,7 +240,7 @@ Here are those same steps in detail:
`config.toml.example` in the root directory of the Rust repository.
Set `submodules = false` in the `[build]` section. This will prevent `x.py`
from resetting to the original branch after you make your changes. If you
need to [update any submodules to their latest versions][updating-submodules],
need to [update any submodules to their latest versions](#updating-submodules),
see the section of this file about that for more information.
2. (optional) Run `./x.py test src/tools/rustfmt` (substituting the submodule
that broke for `rustfmt`). Fix any errors in the submodule (and possibly others).
@ -256,7 +254,6 @@ Here are those same steps in detail:
8. (optional) Send a PR to rust-lang/rust updating the submodule.
#### Updating submodules
[updating-submodules]: #updating-submodules
These instructions are specific to updating `rustfmt`, however they may apply
to the other submodules as well. Please help by improving these instructions
@ -310,7 +307,6 @@ This should change the version listed in `Cargo.lock` to the new version you upd
the submodule to. Running `./x.py build` should work now.
## Writing Documentation
[writing-documentation]: #writing-documentation
Documentation improvements are very welcome. The source of `doc.rust-lang.org`
is located in `src/doc` in the tree, and standard API documentation is generated
@ -337,7 +333,6 @@ tracker in that repo is also a great way to find things that need doing. There
are issues for beginners and advanced compiler devs alike!
## Issue Triage
[issue-triage]: #issue-triage
Sometimes, an issue will stay open, even though the bug has been fixed. And
sometimes, the original bug may go stale because something has changed in the
@ -405,7 +400,6 @@ If you're looking for somewhere to start, check out the [E-easy][eeasy] tag.
[rfcbot]: https://github.com/anp/rfcbot-rs/
## Out-of-tree Contributions
[out-of-tree-contributions]: #out-of-tree-contributions
There are a number of other ways to contribute to Rust that don't deal with
this repository.
@ -425,7 +419,6 @@ valuable!
[community-library]: https://github.com/rust-lang/rfcs/labels/A-community-library
## Helpful Links and Information
[helpful-info]: #helpful-info
For people new to Rust, and just starting to contribute, or even for
more seasoned developers, some useful places to look for information

1442
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ standard library, and documentation.
[Rust]: https://www.rust-lang.org
## Quick Start
[quick-start]: #quick-start
Read ["Installation"] from [The Book].
@ -14,11 +13,15 @@ Read ["Installation"] from [The Book].
[The Book]: https://doc.rust-lang.org/book/index.html
## Installing from Source
[building-from-source]: #building-from-source
_Note: If you wish to contribute to the compiler, you should read
[this chapter](https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html)
of the rustc-guide instead._
_Note: If you wish to contribute to the compiler, you should read [this
chapter][rustcguidebuild] of the rustc-guide instead of this section._
The Rust build system has a Python script called `x.py` to bootstrap building
the compiler. More information about it may be found by running `./x.py --help`
or reading the [rustc guide][rustcguidebuild].
[rustcguidebuild]: https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html
### Building on *nix
1. Make sure you have installed the dependencies:
@ -39,43 +42,36 @@ of the rustc-guide instead._
[source]: https://github.com/rust-lang/rust
3. Build and install:
3. Configure the build settings:
The Rust build system uses a file named `config.toml` in the root of the
source tree to determine various configuration settings for the build.
Copy the default `config.toml.example` to `config.toml` to get started.
```sh
$ ./x.py build && sudo ./x.py install
$ cp config.toml.example config.toml
```
If after running `sudo ./x.py install` you see an error message like
It is recommended that if you plan to use the Rust build system to create
an installation (using `./x.py install`) that you set the `prefix` value
in the `[install]` section to a directory that you have write permissions.
```
error: failed to load source for a dependency on 'cc'
4. Build and install:
```sh
$ ./x.py build && ./x.py install
```
then run these two commands and then try `sudo ./x.py install` again:
```
$ cargo install cargo-vendor
```
```
$ cargo vendor
```
> ***Note:*** Install locations can be adjusted by copying the config file
> from `./config.toml.example` to `./config.toml`, and
> adjusting the `prefix` option under `[install]`. Various other options, such
> as enabling debug information, are also supported, and are documented in
> the config file.
When complete, `sudo ./x.py install` will place several programs into
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
When complete, `./x.py install` will place several programs into
`$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
API-documentation tool. This install does not include [Cargo],
Rust's package manager, which you may also want to build.
Rust's package manager. To build and install Cargo, you may
run `./x.py install cargo` or set the `build.extended` key in
`config.toml` to `true` to build and install all tools.
[Cargo]: https://github.com/rust-lang/cargo
### Building on Windows
[building-on-windows]: #building-on-windows
There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust
@ -85,7 +81,6 @@ for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
build.
#### MinGW
[windows-mingw]: #windows-mingw
[MSYS2][msys2] can be used to easily build Rust on Windows:
@ -126,7 +121,6 @@ build.
```
#### MSVC
[windows-msvc]: #windows-msvc
MSVC builds of Rust additionally require an installation of Visual Studio 2017
(or later) so `rustc` can use its linker. The simplest way is to get the
@ -155,7 +149,6 @@ by manually calling the appropriate vcvars file before running the bootstrap.
```
#### Specifying an ABI
[specifying-an-abi]: #specifying-an-abi
Each specific ABI can also be used from either environment (for example, using
the GNU ABI in PowerShell) by using an explicit build triple. The available
@ -169,11 +162,10 @@ Windows build triples are:
The build triple can be specified by either specifying `--build=<triple>` when
invoking `x.py` commands, or by copying the `config.toml` file (as described
in Building From Source), and modifying the `build` option under the `[build]`
section.
in [Installing From Source](#installing-from-source)), and modifying the
`build` option under the `[build]` section.
### Configure and Make
[configure-and-make]: #configure-and-make
While it's not the recommended build system, this project also provides a
configure script and makefile (the latter of which just invokes `x.py`).
@ -188,7 +180,6 @@ When using the configure script, the generated `config.mk` file may override the
`config.mk` file.
## Building Documentation
[building-documentation]: #building-documentation
If youd like to build the documentation, its almost the same:
@ -201,7 +192,6 @@ the ABI used. I.e., if the ABI was `x86_64-pc-windows-msvc`, the directory will
`build\x86_64-pc-windows-msvc\doc`.
## Notes
[notes]: #notes
Since the Rust compiler is written in Rust, it must be built by a
precompiled "snapshot" version of itself (made in an earlier stage of
@ -210,11 +200,11 @@ fetch snapshots, and an OS that can execute the available snapshot binaries.
Snapshot binaries are currently built and tested on several platforms:
| Platform / Architecture | x86 | x86_64 |
|--------------------------|-----|--------|
| Windows (7, 8, 10, ...) | ✓ | ✓ |
| Linux (2.6.18 or later) | ✓ | ✓ |
| OSX (10.7 Lion or later) | ✓ | ✓ |
| Platform / Architecture | x86 | x86_64 |
|----------------------------|-----|--------|
| Windows (7, 8, 10, ...) | ✓ | ✓ |
| Linux (2.6.18 or later) | ✓ | ✓ |
| macOS (10.7 Lion or later) | ✓ | ✓ |
You may find that other platforms work, but these are our officially
supported build environments that are most likely to work.
@ -224,7 +214,6 @@ There is more advice about hacking on Rust in [CONTRIBUTING.md].
[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
## Getting Help
[getting-help]: #getting-help
The Rust community congregates in a few places:
@ -237,7 +226,6 @@ The Rust community congregates in a few places:
[users.rust-lang.org]: https://users.rust-lang.org/
## Contributing
[contributing]: #contributing
To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
@ -258,7 +246,6 @@ Also, you may find the [rustdocs for the compiler itself][rustdocs] useful.
[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
## License
[license]: #license
Rust is primarily distributed under the terms of both the MIT license
and the Apache License (Version 2.0), with portions covered by various
@ -268,7 +255,6 @@ See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
[COPYRIGHT](COPYRIGHT) for details.
## Trademark
[trademark]: #trademark
The Rust programming language is an open source, community project governed
by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”),

View File

@ -1,3 +1,117 @@
Version 1.38.0 (2019-09-26)
==========================
Language
--------
- [The `#[global_allocator]` attribute can now be used in submodules.][62735]
- [The `#[deprecated]` attribute can now be used on macros.][62042]
Compiler
--------
- [Added pipelined compilation support to `rustc`.][62766] This will
improve compilation times in some cases. For further information please refer
to the [_"Evaluating pipelined rustc compilation"_][pipeline-internals] thread.
- [Added tier 3\* support for the `aarch64-uwp-windows-msvc`, `i686-uwp-windows-gnu`,
`i686-uwp-windows-msvc`, `x86_64-uwp-windows-gnu`, and
`x86_64-uwp-windows-msvc` targets.][60260]
- [Added tier 3 support for the `armv7-unknown-linux-gnueabi` and
`armv7-unknown-linux-musleabi` targets.][63107]
- [Added tier 3 support for the `hexagon-unknown-linux-musl` target.][62814]
- [Added tier 3 support for the `riscv32i-unknown-none-elf` target.][62784]
\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
Libraries
---------
- [`ascii::EscapeDefault` now implements `Clone` and `Display`.][63421]
- [Derive macros for prelude traits (e.g. `Clone`, `Debug`, `Hash`) are now
available at the same path as the trait.][63056] (e.g. The `Clone` derive macro
is available at `std::clone::Clone`). This also makes all built-in macros
available in `std`/`core` root. e.g. `std::include_bytes!`.
- [`str::Chars` now implements `Debug`.][63000]
- [`slice::{concat, connect, join}` now accepts `&[T]` in addition to `&T`.][62528]
- [`*const T` and `*mut T` now implement `marker::Unpin`.][62583]
- [`Arc<[T]>` and `Rc<[T]>` now implement `FromIterator<T>`.][61953]
- [Added euclidean remainder and division operations (`div_euclid`,
`rem_euclid`) to all numeric primitives.][61884] Additionally `checked`,
`overflowing`, and `wrapping` versions are available for all
integer primitives.
- [`thread::AccessError` now implements `Clone`, `Copy`, `Eq`, `Error`, and
`PartialEq`.][61491]
- [`iter::{StepBy, Peekable, Take}` now implement `DoubleEndedIterator`.][61457]
Stabilized APIs
---------------
- [`<*const T>::cast`]
- [`<*mut T>::cast`]
- [`Duration::as_secs_f32`]
- [`Duration::as_secs_f64`]
- [`Duration::div_duration_f32`]
- [`Duration::div_duration_f64`]
- [`Duration::div_f32`]
- [`Duration::div_f64`]
- [`Duration::from_secs_f32`]
- [`Duration::from_secs_f64`]
- [`Duration::mul_f32`]
- [`Duration::mul_f64`]
- [`any::type_name`]
Cargo
-----
- [Added pipelined compilation support to `cargo`.][cargo/7143]
- [You can now pass the `--features` option multiple times to enable
multiple features.][cargo/7084]
Misc
----
- [`rustc` will now warn about some incorrect uses of
`mem::{uninitialized, zeroed}` that are known to cause undefined behaviour.][63346]
Compatibility Notes
-------------------
- Unfortunately the [`x86_64-unknown-uefi` platform can not be built][62785]
with rustc 1.39.0.
- The [`armv7-unknown-linux-gnueabihf` platform is also known to have
issues][62896] for certain crates such as libc.
[60260]: https://github.com/rust-lang/rust/pull/60260/
[61457]: https://github.com/rust-lang/rust/pull/61457/
[61491]: https://github.com/rust-lang/rust/pull/61491/
[61884]: https://github.com/rust-lang/rust/pull/61884/
[61953]: https://github.com/rust-lang/rust/pull/61953/
[62042]: https://github.com/rust-lang/rust/pull/62042/
[62528]: https://github.com/rust-lang/rust/pull/62528/
[62583]: https://github.com/rust-lang/rust/pull/62583/
[62735]: https://github.com/rust-lang/rust/pull/62735/
[62766]: https://github.com/rust-lang/rust/pull/62766/
[62784]: https://github.com/rust-lang/rust/pull/62784/
[62785]: https://github.com/rust-lang/rust/issues/62785/
[62814]: https://github.com/rust-lang/rust/pull/62814/
[62896]: https://github.com/rust-lang/rust/issues/62896/
[63000]: https://github.com/rust-lang/rust/pull/63000/
[63056]: https://github.com/rust-lang/rust/pull/63056/
[63107]: https://github.com/rust-lang/rust/pull/63107/
[63346]: https://github.com/rust-lang/rust/pull/63346/
[63421]: https://github.com/rust-lang/rust/pull/63421/
[cargo/7084]: https://github.com/rust-lang/cargo/pull/7084/
[cargo/7143]: https://github.com/rust-lang/cargo/pull/7143/
[`<*const T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`<*mut T>::cast`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.cast
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.div_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f32
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_secs_f64
[`Duration::mul_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f32
[`Duration::mul_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f64
[`any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
[forge-platform-support]: https://forge.rust-lang.org/platform-support.html
[pipeline-internals]: https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199
Version 1.37.0 (2019-08-15)
==========================
@ -22,7 +136,7 @@ Language
- [You can now use `_` as an identifier for consts.][61347] e.g. You can write
`const _: u32 = 5;`.
- [You can now use `#[repr(align(X)]` on enums.][61229]
- [The `?`/_"Kleene"_ macro operator is now available in the
- [The `?` Kleene macro operator is now available in the
2015 edition.][60932]
Compiler
@ -179,10 +293,8 @@ Misc
Compatibility Notes
-------------------
- [`std::arch::x86::_rdtsc` returns `u64` instead of `i64`][stdsimd/559]
- [`std::arch::x86_64::_mm_shuffle_ps` takes an `i32` instead of `u32` for `mask`][stdsimd/522]
- With the stabilisation of `mem::MaybeUninit`, `mem::uninitialized` use is no
longer recommended, and will be deprecated in 1.38.0.
longer recommended, and will be deprecated in 1.39.0.
[60318]: https://github.com/rust-lang/rust/pull/60318/
[60364]: https://github.com/rust-lang/rust/pull/60364/
@ -217,8 +329,7 @@ Compatibility Notes
[`task::Poll`]: https://doc.rust-lang.org/beta/std/task/enum.Poll.html
[clippy-1-36-0]: https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-136
[cargo-1-36-0]: https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-136-2019-07-04
[stdsimd/522]: https://github.com/rust-lang-nursery/stdsimd/issues/522
[stdsimd/559]: https://github.com/rust-lang-nursery/stdsimd/issues/559
Version 1.35.0 (2019-05-23)
==========================
@ -542,7 +653,7 @@ Compiler
--------
- [You can now set a linker flavor for `rustc` with the `-Clinker-flavor`
command line argument.][56351]
- [The mininum required LLVM version has been bumped to 6.0.][56642]
- [The minimum required LLVM version has been bumped to 6.0.][56642]
- [Added support for the PowerPC64 architecture on FreeBSD.][57615]
- [The `x86_64-fortanix-unknown-sgx` target support has been upgraded to
tier 2 support.][57130] Visit the [platform support][platform-support] page for
@ -973,7 +1084,7 @@ Compiler
Libraries
---------
- [You can now convert `num::NonZero*` types to their raw equivalvents using the
- [You can now convert `num::NonZero*` types to their raw equivalents using the
`From` trait.][54240] E.g. `u8` now implements `From<NonZeroU8>`.
- [You can now convert a `&Option<T>` into `Option<&T>` and `&mut Option<T>`
into `Option<&mut T>` using the `From` trait.][53218]
@ -1166,7 +1277,7 @@ Security Notes
caused by an integer overflow. This has been fixed by deterministically
panicking when an overflow happens.
Thank you to Scott McMurray for responsibily disclosing this vulnerability to
Thank you to Scott McMurray for responsibly disclosing this vulnerability to
us.
@ -1438,7 +1549,7 @@ Security Notes
given machine. This release fixes that vulnerability; you can read
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].
Thank you to Red Hat for responsibily disclosing this vulnerability to us.
Thank you to Red Hat for responsibly disclosing this vulnerability to us.
Compatibility Notes
-------------------

View File

@ -57,14 +57,13 @@
# support. You'll need to write a target specification at least, and most
# likely, teach rustc about the C ABI of the target. Get in touch with the
# Rust team and file an issue if you need assistance in porting!
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon"
#targets = "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86"
# LLVM experimental targets to build support for. These targets are specified in
# the same format as above, but since these targets are experimental, they are
# not built by default and the experimental Rust compilation targets that depend
# on them will not work unless the user opts in to building them. By default the
# `WebAssembly` and `RISCV` targets are enabled when compiling LLVM from scratch.
#experimental-targets = "WebAssembly;RISCV"
# on them will not work unless the user opts in to building them.
#experimental-targets = ""
# Cap the number of parallel linker invocations when compiling LLVM.
# This can be useful when building LLVM with debug info, which significantly
@ -369,10 +368,6 @@
# When creating source tarballs whether or not to create a source tarball.
#dist-src = false
# Whether to also run the Miri tests suite when running tests.
# As a side-effect also generates MIR for all libraries.
#test-miri = false
# After building or testing extended tools (e.g. clippy and rustfmt), append the
# result (broken, compiling, testing) into this JSON file.
#save-toolstates = "/path/to/toolstates.json"

View File

@ -1 +1 @@
eae3437dfe991621e8afdc82734f4a172d7ddf9b
625451e376bb2e5283fc4741caa0a3e8a2ca4d54

View File

@ -5,10 +5,7 @@ This directory contains the source code of the rust project, including:
For more information on how various parts of the compiler work, see the [rustc guide].
There is also useful content in the following READMEs, which are gradually being moved over to the guide:
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query
- https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/higher_ranked
- https://github.com/rust-lang/rust/tree/master/src/librustc/infer/lexical_region_resolve
There is also useful content in this README:
https://github.com/rust-lang/rust/tree/master/src/librustc/infer/lexical_region_resolve.
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html

View File

@ -55,11 +55,11 @@ The script accepts commands, flags, and arguments to determine what to do:
# run all unit tests
./x.py test
# execute the run-pass test suite
./x.py test src/test/run-pass
# execute the UI test suite
./x.py test src/test/ui
# execute only some tests in the run-pass test suite
./x.py test src/test/run-pass --test-args substring-of-test-name
# execute only some tests in the UI test suite
./x.py test src/test/ui --test-args substring-of-test-name
# execute tests in the standard library in stage0
./x.py test --stage 0 src/libstd
@ -215,7 +215,7 @@ build/
# Output for all compiletest-based test suites
test/
run-pass/
ui/
compile-fail/
debuginfo/
...

View File

@ -5,7 +5,8 @@
//! parent directory, and otherwise documentation can be found throughout the `build`
//! directory in each respective module.
#![deny(warnings)]
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
use std::env;

View File

@ -15,7 +15,8 @@
//! switching compilers for the bootstrap and for build scripts will probably
//! never get replaced.
#![deny(warnings)]
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
use std::env;
use std::ffi::OsString;
@ -91,17 +92,16 @@ fn main() {
cmd.args(&args)
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
let mut maybe_crate = None;
// Get the name of the crate we're compiling, if any.
let maybe_crate_name = args.windows(2)
.find(|a| &*a[0] == "--crate-name")
.map(|crate_name| &*crate_name[1]);
let crate_name = args.windows(2)
.find(|args| args[0] == "--crate-name")
.and_then(|args| args[1].to_str());
if let Some(current_crate) = maybe_crate_name {
if let Some(crate_name) = crate_name {
if let Some(target) = env::var_os("RUSTC_TIME") {
if target == "all" ||
target.into_string().unwrap().split(",").any(|c| c.trim() == current_crate)
target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
{
cmd.arg("-Ztime");
}
@ -125,10 +125,29 @@ fn main() {
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
}
if env::var_os("RUSTC_DENY_WARNINGS").is_some() &&
env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
// When extending this list, search for `NO-RUSTC-WRAPPER` and add the new lints
// there as well, some code doesn't go through this `rustc` wrapper.
cmd.arg("-Dwarnings");
cmd.arg("-Drust_2018_idioms");
cmd.arg("-Dunused_lifetimes");
// cfg(not(bootstrap)): Remove this during the next stage 0 compiler update.
// `-Drustc::internal` is a new feature and `rustc_version` mis-reports the `stage`.
let cfg_not_bootstrap = stage != "0" && crate_name != Some("rustc_version");
if cfg_not_bootstrap && use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Drustc::internal");
}
}
if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
// actually downloaded, so we just always pass the `--sysroot` option.
cmd.arg("--sysroot").arg(&sysroot);
// actually downloaded, so we just always pass the `--sysroot` option,
// unless one is already set.
if !args.iter().any(|arg| arg == "--sysroot") {
cmd.arg("--sysroot").arg(&sysroot);
}
cmd.arg("-Zexternal-macro-backtrace");
@ -167,9 +186,6 @@ fn main() {
cmd.arg(format!("-Clinker={}", target_linker));
}
let crate_name = maybe_crate_name.unwrap();
maybe_crate = Some(crate_name);
// If we're compiling specifically the `panic_abort` crate then we pass
// the `-C panic=abort` option. Note that we do not do this for any
// other crate intentionally as this is the only crate for now that we
@ -182,8 +198,8 @@ fn main() {
// `compiler_builtins` are unconditionally compiled with panic=abort to
// workaround undefined references to `rust_eh_unwind_resume` generated
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
if crate_name == "panic_abort" ||
crate_name == "compiler_builtins" && stage != "0" {
if crate_name == Some("panic_abort") ||
crate_name == Some("compiler_builtins") && stage != "0" {
cmd.arg("-C").arg("panic=abort");
}
@ -196,7 +212,7 @@ fn main() {
// The compiler builtins are pretty sensitive to symbols referenced in
// libcore and such, so we never compile them with debug assertions.
if crate_name == "compiler_builtins" {
if crate_name == Some("compiler_builtins") {
cmd.arg("-C").arg("debug-assertions=no");
} else {
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
@ -272,20 +288,6 @@ fn main() {
}
}
// When running miri tests, we need to generate MIR for all libraries
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
// The flags here should be kept in sync with `add_miri_default_args`
// in miri's `src/lib.rs`.
cmd.arg("-Zalways-encode-mir");
cmd.arg("--cfg=miri");
// These options are preferred by miri, to be able to perform better validation,
// but the bootstrap compiler might not understand them.
if stage != "0" {
cmd.arg("-Zmir-emit-retag");
cmd.arg("-Zmir-opt-level=0");
}
}
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
cmd.arg("--remap-path-prefix").arg(&map);
}
@ -305,9 +307,6 @@ fn main() {
}
}
// This is required for internal lints.
cmd.arg("-Zunstable-options");
// Force all crates compiled by this compiler to (a) be unstable and (b)
// allow the `rustc_private` feature to link to other unstable crates
// also in the sysroot. We also do this for host crates, since those
@ -320,13 +319,6 @@ fn main() {
cmd.arg("--cfg").arg("parallel_compiler");
}
if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
{
cmd.arg("-Dwarnings");
cmd.arg("-Dbare_trait_objects");
cmd.arg("-Drust_2018_idioms");
}
if verbose > 1 {
eprintln!(
"rustc command: {:?}={:?} {:?}",
@ -349,7 +341,7 @@ fn main() {
}
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
if let Some(krate) = maybe_crate {
if let Some(crate_name) = crate_name {
let start = Instant::now();
let status = cmd
.status()
@ -358,7 +350,7 @@ fn main() {
let is_test = args.iter().any(|a| a == "--test");
eprintln!("[RUSTC-TIMING] {} test:{} {}.{:03}",
krate.to_string_lossy(),
crate_name,
is_test,
dur.as_secs(),
dur.subsec_nanos() / 1_000_000);
@ -377,6 +369,14 @@ fn main() {
std::process::exit(code);
}
// Rustc crates for which internal lints are in effect.
fn use_internal_lints(crate_name: Option<&str>) -> bool {
crate_name.map_or(false, |crate_name| {
crate_name.starts_with("rustc") || crate_name.starts_with("syntax") ||
["arena", "fmt_macros"].contains(&crate_name)
})
}
#[cfg(unix)]
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
use std::os::unix::process::CommandExt;

View File

@ -2,7 +2,8 @@
//!
//! See comments in `src/bootstrap/rustc.rs` for more information.
#![deny(warnings)]
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
use std::env;
use std::process::Command;

View File

@ -735,6 +735,47 @@ class RustBuild(object):
"""Set download URL for development environment"""
self._download_url = 'https://dev-static.rust-lang.org'
def check_vendored_status(self):
"""Check that vendoring is configured properly"""
vendor_dir = os.path.join(self.rust_root, 'vendor')
if 'SUDO_USER' in os.environ and not self.use_vendored_sources:
if os.environ.get('USER') != os.environ['SUDO_USER']:
self.use_vendored_sources = True
print('info: looks like you are running this command under `sudo`')
print(' and so in order to preserve your $HOME this will now')
print(' use vendored sources by default.')
if not os.path.exists(vendor_dir):
print('error: vendoring required, but vendor directory does not exist.')
print(' Run `cargo vendor` without sudo to initialize the '
'vendor directory.')
raise Exception("{} not found".format(vendor_dir))
if self.use_vendored_sources:
if not os.path.exists('.cargo'):
os.makedirs('.cargo')
with output('.cargo/config') as cargo_config:
cargo_config.write(
"[source.crates-io]\n"
"replace-with = 'vendored-sources'\n"
"registry = 'https://example.com'\n"
"\n"
"[source.vendored-sources]\n"
"directory = '{}/vendor'\n"
.format(self.rust_root))
else:
if os.path.exists('.cargo'):
shutil.rmtree('.cargo')
def ensure_vendored(self):
"""Ensure that the vendored sources are available if needed"""
vendor_dir = os.path.join(self.rust_root, 'vendor')
# Note that this does not handle updating the vendored dependencies if
# the rust git repository is updated. Normal development usually does
# not use vendoring, so hopefully this isn't too much of a problem.
if self.use_vendored_sources and not os.path.exists(vendor_dir):
run([self.cargo(), "vendor"],
verbose=self.verbose, cwd=self.rust_root)
def bootstrap(help_triggered):
"""Configure, fetch, build and run the initial bootstrap"""
@ -776,30 +817,7 @@ def bootstrap(help_triggered):
build.use_locked_deps = '\nlocked-deps = true' in build.config_toml
if 'SUDO_USER' in os.environ and not build.use_vendored_sources:
if os.environ.get('USER') != os.environ['SUDO_USER']:
build.use_vendored_sources = True
print('info: looks like you are running this command under `sudo`')
print(' and so in order to preserve your $HOME this will now')
print(' use vendored sources by default. Note that if this')
print(' does not work you should run a normal build first')
print(' before running a command like `sudo ./x.py install`')
if build.use_vendored_sources:
if not os.path.exists('.cargo'):
os.makedirs('.cargo')
with output('.cargo/config') as cargo_config:
cargo_config.write("""
[source.crates-io]
replace-with = 'vendored-sources'
registry = 'https://example.com'
[source.vendored-sources]
directory = '{}/vendor'
""".format(build.rust_root))
else:
if os.path.exists('.cargo'):
shutil.rmtree('.cargo')
build.check_vendored_status()
data = stage0_data(build.rust_root)
build.date = data['date']
@ -815,6 +833,7 @@ def bootstrap(help_triggered):
build.build = args.build or build.build_triple()
build.download_stage0()
sys.stdout.flush()
build.ensure_vendored()
build.build_bootstrap()
sys.stdout.flush()

View File

@ -371,7 +371,6 @@ impl<'a> Builder<'a> {
Kind::Test => describe!(
test::Tidy,
test::Ui,
test::RunPass,
test::CompileFail,
test::RunFail,
test::RunPassValgrind,
@ -382,10 +381,8 @@ impl<'a> Builder<'a> {
test::Incremental,
test::Debuginfo,
test::UiFullDeps,
test::RunPassFullDeps,
test::Rustdoc,
test::Pretty,
test::RunPassPretty,
test::RunFailPretty,
test::RunPassValgrindPretty,
test::Crate,
@ -405,6 +402,7 @@ impl<'a> Builder<'a> {
test::TheBook,
test::UnstableBook,
test::RustcBook,
test::RustcGuide,
test::EmbeddedBook,
test::EditionGuide,
test::Rustfmt,
@ -545,15 +543,6 @@ impl<'a> Builder<'a> {
parent: Cell::new(None),
};
if kind == Kind::Dist {
assert!(
!builder.config.test_miri,
"Do not distribute with miri enabled.\n\
The distributed libraries would include all MIR (increasing binary size).
The distributed MIR would include validation statements."
);
}
builder
}
@ -983,7 +972,6 @@ impl<'a> Builder<'a> {
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
},
)
.env("TEST_MIRI", self.config.test_miri.to_string())
.env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir());
if let Some(host_linker) = self.linker(compiler.host) {

View File

@ -629,7 +629,6 @@ fn test_with_no_doc_stage0() {
fn test_exclude() {
let mut config = configure(&[], &[]);
config.exclude = vec![
"src/test/run-pass".into(),
"src/tools/tidy".into(),
];
config.cmd = Subcommand::Test {
@ -648,11 +647,9 @@ fn test_exclude() {
let builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
// Ensure we have really excluded run-pass & tidy
assert!(!builder.cache.contains::<test::RunPass>());
// Ensure we have really excluded tidy
assert!(!builder.cache.contains::<test::Tidy>());
// Ensure other tests are not affected.
assert!(builder.cache.contains::<test::RunPassFullDeps>());
assert!(builder.cache.contains::<test::RustdocUi>());
}

View File

@ -266,8 +266,10 @@ impl Cache {
.expect("invalid type mapped");
stepcache.get(step).cloned()
}
}
#[cfg(test)]
#[cfg(test)]
impl Cache {
pub fn all<S: Ord + Copy + Step>(&mut self) -> Vec<(S, S::Output)> {
let cache = self.0.get_mut();
let type_id = TypeId::of::<S>();
@ -279,7 +281,6 @@ impl Cache {
v
}
#[cfg(test)]
pub fn contains<S: Step>(&self) -> bool {
self.0.borrow().contains_key(&TypeId::of::<S>())
}

View File

@ -45,6 +45,8 @@ fn cc2ar(cc: &Path, target: &str) -> Option<PathBuf> {
Some(PathBuf::from("ar"))
} else if target.contains("openbsd") {
Some(PathBuf::from("ar"))
} else if target.contains("vxworks") {
Some(PathBuf::from("vx-ar"))
} else {
let parent = cc.parent().unwrap();
let file = cc.file_name().unwrap().to_str().unwrap();

View File

@ -13,7 +13,7 @@ use build_helper::output;
use crate::Build;
// The version number
pub const CFG_RELEASE_NUM: &str = "1.37.0";
pub const CFG_RELEASE_NUM: &str = "1.38.0";
pub struct GitInfo {
inner: Option<Info>,

View File

@ -50,7 +50,6 @@ impl Step for Std {
let mut cargo = builder.cargo(compiler, Mode::Std, target, cargo_subcommand(builder.kind));
std_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target));
run_cargo(builder,
&mut cargo,
@ -99,7 +98,6 @@ impl Step for Rustc {
cargo_subcommand(builder.kind));
rustc_cargo(builder, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target));
run_cargo(builder,
&mut cargo,
@ -153,7 +151,6 @@ impl Step for CodegenBackend {
// We won't build LLVM if it's not available, as it shouldn't affect `check`.
let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
run_cargo(builder,
&mut cargo,
args(builder.kind),
@ -190,7 +187,6 @@ impl Step for Test {
let mut cargo = builder.cargo(compiler, Mode::Test, target, cargo_subcommand(builder.kind));
test_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
builder.info(&format!("Checking test artifacts ({} -> {})", &compiler.host, target));
run_cargo(builder,
&mut cargo,
@ -239,7 +235,6 @@ impl Step for Rustdoc {
SourceType::InTree,
&[]);
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
run_cargo(builder,
&mut cargo,

View File

@ -95,7 +95,6 @@ impl Step for Std {
let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
std_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
builder.info(&format!("Building stage{} std artifacts ({} -> {})", compiler.stage,
&compiler.host, target));
run_cargo(builder,
@ -326,7 +325,7 @@ impl Step for StartupObjects {
fn run(self, builder: &Builder<'_>) {
let for_compiler = self.compiler;
let target = self.target;
if !target.contains("pc-windows-gnu") {
if !target.contains("windows-gnu") {
return
}
@ -422,7 +421,6 @@ impl Step for Test {
let mut cargo = builder.cargo(compiler, Mode::Test, target, "build");
test_cargo(builder, &compiler, target, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
builder.info(&format!("Building stage{} test artifacts ({} -> {})", compiler.stage,
&compiler.host, target));
run_cargo(builder,
@ -555,7 +553,6 @@ impl Step for Rustc {
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "build");
rustc_cargo(builder, &mut cargo);
let _folder = builder.fold_output(|| format!("stage{}-rustc", compiler.stage));
builder.info(&format!("Building stage{} compiler artifacts ({} -> {})",
compiler.stage, &compiler.host, target));
run_cargo(builder,
@ -710,7 +707,6 @@ impl Step for CodegenBackend {
let tmp_stamp = out_dir.join(".tmp.stamp");
let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
let files = run_cargo(builder,
cargo.arg("--features").arg(features),
vec![],
@ -1130,6 +1126,7 @@ pub fn run_cargo(builder: &Builder<'_>,
// Skip files like executables
if !filename.ends_with(".rlib") &&
!filename.ends_with(".lib") &&
!filename.ends_with(".a") &&
!is_dylib(&filename) &&
!(is_check && filename.ends_with(".rmeta")) {
continue;

View File

@ -75,7 +75,7 @@ pub struct Config {
pub llvm_link_shared: bool,
pub llvm_clang_cl: Option<String>,
pub llvm_targets: Option<String>,
pub llvm_experimental_targets: String,
pub llvm_experimental_targets: Option<String>,
pub llvm_link_jobs: Option<u32>,
pub llvm_version_suffix: Option<String>,
pub llvm_use_linker: Option<String>,
@ -128,7 +128,6 @@ pub struct Config {
pub low_priority: bool,
pub channel: String,
pub verbose_tests: bool,
pub test_miri: bool,
pub save_toolstates: Option<PathBuf>,
pub print_step_timings: bool,
pub missing_tools: bool,
@ -315,7 +314,6 @@ struct Rust {
debug: Option<bool>,
dist_src: Option<bool>,
verbose_tests: Option<bool>,
test_miri: Option<bool>,
incremental: Option<bool>,
save_toolstates: Option<String>,
codegen_backends: Option<Vec<String>>,
@ -375,7 +373,6 @@ impl Config {
config.codegen_tests = true;
config.ignore_git = false;
config.rust_dist_src = true;
config.test_miri = false;
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
config.rust_codegen_backends_dir = "codegen-backends".to_owned();
config.deny_warnings = true;
@ -405,7 +402,7 @@ impl Config {
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.keep_stage = flags.keep_stage;
if let Some(value) = flags.warnings {
if let Some(value) = flags.deny_warnings {
config.deny_warnings = value;
}
@ -524,8 +521,7 @@ impl Config {
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
set(&mut config.llvm_link_shared, llvm.link_shared);
config.llvm_targets = llvm.targets.clone();
config.llvm_experimental_targets = llvm.experimental_targets.clone()
.unwrap_or_else(|| "WebAssembly;RISCV".to_string());
config.llvm_experimental_targets = llvm.experimental_targets.clone();
config.llvm_link_jobs = llvm.link_jobs;
config.llvm_version_suffix = llvm.version_suffix.clone();
config.llvm_clang_cl = llvm.clang_cl.clone();
@ -558,7 +554,6 @@ impl Config {
set(&mut config.channel, rust.channel.clone());
set(&mut config.rust_dist_src, rust.dist_src);
set(&mut config.verbose_tests, rust.verbose_tests);
set(&mut config.test_miri, rust.test_miri);
// in the case "false" is set explicitly, do not overwrite the command line args
if let Some(true) = rust.incremental {
config.incremental = true;
@ -571,7 +566,7 @@ impl Config {
config.rustc_default_linker = rust.default_linker.clone();
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);

View File

@ -36,7 +36,6 @@ o("docs", "build.docs", "build standard library documentation")
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
o("optimize-tests", "rust.optimize-tests", "build tests with optimizations")
o("parallel-compiler", "rust.parallel-compiler", "build a multi-threaded rustc")
o("test-miri", "rust.test-miri", "run miri's test suite")
o("verbose-tests", "rust.verbose-tests", "enable verbose output when running tests")
o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds")
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds")
@ -125,7 +124,9 @@ v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root",
"arm-unknown-linux-musleabihf install directory")
v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root",
"armv5te-unknown-linux-musleabi install directory")
v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
v("musl-root-armv7", "target.armv7-unknown-linux-musleabi.musl-root",
"armv7-unknown-linux-musleabi install directory")
v("musl-root-armv7hf", "target.armv7-unknown-linux-musleabihf.musl-root",
"armv7-unknown-linux-musleabihf install directory")
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
"aarch64-unknown-linux-musl install directory")

View File

@ -808,6 +808,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
"llvm-project/lld", "llvm-project\\lld",
"llvm-project/lldb", "llvm-project\\lldb",
"llvm-project/llvm", "llvm-project\\llvm",
"llvm-project/compiler-rt", "llvm-project\\compiler-rt",
];
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))
@ -903,7 +904,7 @@ impl Step for Src {
"src/libtest",
"src/libterm",
"src/libprofiler_builtins",
"src/stdsimd",
"src/stdarch",
"src/libproc_macro",
"src/tools/rustc-std-workspace-core",
"src/tools/rustc-std-workspace-alloc",
@ -935,8 +936,6 @@ impl Step for Src {
}
}
const CARGO_VENDOR_VERSION: &str = "0.1.22";
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct PlainSourceTarball;
@ -998,26 +997,6 @@ impl Step for PlainSourceTarball {
// If we're building from git sources, we need to vendor a complete distribution.
if builder.rust_info.is_git() {
// Get cargo-vendor installed, if it isn't already.
let mut has_cargo_vendor = false;
let mut cmd = Command::new(&builder.initial_cargo);
for line in output(cmd.arg("install").arg("--list")).lines() {
has_cargo_vendor |= line.starts_with("cargo-vendor ");
}
if !has_cargo_vendor {
let mut cmd = builder.cargo(
builder.compiler(0, builder.config.build),
Mode::ToolBootstrap,
builder.config.build,
"install"
);
cmd.arg("--force")
.arg("--debug")
.arg("--vers").arg(CARGO_VENDOR_VERSION)
.arg("cargo-vendor");
builder.run(&mut cmd);
}
// Vendor all Cargo dependencies
let mut cmd = Command::new(&builder.initial_cargo);
cmd.arg("vendor")

View File

@ -23,7 +23,7 @@ use crate::cache::{INTERNER, Interned};
use crate::config::Config;
macro_rules! book {
($($name:ident, $path:expr, $book_name:expr, $book_ver:expr;)+) => {
($($name:ident, $path:expr, $book_name:expr;)+) => {
$(
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $name {
@ -49,7 +49,6 @@ macro_rules! book {
builder.ensure(RustbookSrc {
target: self.target,
name: INTERNER.intern_str($book_name),
version: $book_ver,
src: doc_src(builder),
})
}
@ -61,21 +60,15 @@ macro_rules! book {
// NOTE: When adding a book here, make sure to ALSO build the book by
// adding a build step in `src/bootstrap/builder.rs`!
book!(
EditionGuide, "src/doc/edition-guide", "edition-guide", RustbookVersion::Latest;
EmbeddedBook, "src/doc/embedded-book", "embedded-book", RustbookVersion::Latest;
Nomicon, "src/doc/nomicon", "nomicon", RustbookVersion::Latest;
Reference, "src/doc/reference", "reference", RustbookVersion::MdBook1;
RustByExample, "src/doc/rust-by-example", "rust-by-example", RustbookVersion::Latest;
RustcBook, "src/doc/rustc", "rustc", RustbookVersion::MdBook1;
RustdocBook, "src/doc/rustdoc", "rustdoc", RustbookVersion::Latest;
EditionGuide, "src/doc/edition-guide", "edition-guide";
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
Nomicon, "src/doc/nomicon", "nomicon";
Reference, "src/doc/reference", "reference";
RustByExample, "src/doc/rust-by-example", "rust-by-example";
RustcBook, "src/doc/rustc", "rustc";
RustdocBook, "src/doc/rustdoc", "rustdoc";
);
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
enum RustbookVersion {
MdBook1,
Latest,
}
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
INTERNER.intern_path(builder.src.join("src/doc"))
}
@ -108,7 +101,6 @@ impl Step for UnstableBook {
target: self.target,
name: INTERNER.intern_str("unstable-book"),
src: builder.md_doc_out(self.target),
version: RustbookVersion::Latest,
})
}
}
@ -162,7 +154,6 @@ struct RustbookSrc {
target: Interned<String>,
name: Interned<String>,
src: Interned<PathBuf>,
version: RustbookVersion,
}
impl Step for RustbookSrc {
@ -194,18 +185,11 @@ impl Step for RustbookSrc {
builder.info(&format!("Rustbook ({}) - {}", target, name));
let _ = fs::remove_dir_all(&out);
let vers = match self.version {
RustbookVersion::MdBook1 => "1",
RustbookVersion::Latest => "3",
};
builder.run(rustbook_cmd
.arg("build")
.arg(&src)
.arg("-d")
.arg(out)
.arg("-m")
.arg(vers));
.arg(out));
}
}
@ -251,7 +235,6 @@ impl Step for TheBook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(name.to_string()),
version: RustbookVersion::Latest,
src: doc_src(builder),
});
@ -261,7 +244,6 @@ impl Step for TheBook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::Latest,
src: doc_src(builder),
});
@ -269,7 +251,6 @@ impl Step for TheBook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::Latest,
src: doc_src(builder),
});
@ -277,7 +258,6 @@ impl Step for TheBook {
builder.ensure(RustbookSrc {
target,
name: INTERNER.intern_string(source_name),
version: RustbookVersion::Latest,
src: doc_src(builder),
});

View File

@ -33,8 +33,11 @@ pub struct Flags {
pub rustc_error_format: Option<String>,
pub dry_run: bool,
// true => deny
pub warnings: Option<bool>,
// This overrides the deny-warnings configuation option,
// which passes -Dwarnings to the compiler invocations.
//
// true => deny, false => allow
pub deny_warnings: Option<bool>,
}
pub enum Subcommand {
@ -327,7 +330,7 @@ Arguments:
This subcommand accepts a number of paths to directories to tests that
should be compiled and run. For example:
./x.py test src/test/run-pass
./x.py test src/test/ui
./x.py test src/libstd --test-args hash_map
./x.py test src/libstd --stage 0 --no-doc
./x.py test src/test/ui --bless
@ -468,7 +471,7 @@ Arguments:
.into_iter()
.map(|p| p.into())
.collect::<Vec<_>>(),
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
deny_warnings: parse_deny_warnings(&matches),
}
}
}
@ -549,3 +552,18 @@ fn split(s: &[String]) -> Vec<String> {
.map(|s| s.to_string())
.collect()
}
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
Some("deny") => Some(true),
Some("allow") => Some(false),
Some(value) => {
eprintln!(
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
value,
);
process::exit(1);
},
None => None,
}
}

View File

@ -103,8 +103,9 @@
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.
#![deny(rust_2018_idioms)]
#![deny(warnings)]
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
@ -124,11 +125,11 @@ use std::os::unix::fs::symlink as symlink_file;
use std::os::windows::fs::symlink_file;
use build_helper::{
mtime, output, run_silent, run_suppressed, t, try_run_silent, try_run_suppressed,
mtime, output, run, run_suppressed, t, try_run, try_run_suppressed,
};
use filetime::FileTime;
use crate::util::{exe, libdir, OutputFolder, CiEnv};
use crate::util::{exe, libdir, CiEnv};
mod cc_detect;
mod channel;
@ -539,9 +540,7 @@ impl Build {
Mode::Rustc => "-rustc",
Mode::Codegen => "-codegen",
Mode::ToolBootstrap => "-bootstrap-tools",
Mode::ToolStd => "-tools",
Mode::ToolTest => "-tools",
Mode::ToolRustc => "-tools",
Mode::ToolStd | Mode::ToolTest | Mode::ToolRustc => "-tools",
};
self.out.join(&*compiler.host)
.join(format!("stage{}{}", compiler.stage, suffix))
@ -681,7 +680,7 @@ impl Build {
fn run(&self, cmd: &mut Command) {
if self.config.dry_run { return; }
self.verbose(&format!("running: {:?}", cmd));
run_silent(cmd)
run(cmd)
}
/// Runs a command, printing out nice contextual information if it fails.
@ -697,7 +696,7 @@ impl Build {
fn try_run(&self, cmd: &mut Command) -> bool {
if self.config.dry_run { return true; }
self.verbose(&format!("running: {:?}", cmd));
try_run_silent(cmd)
try_run(cmd)
}
/// Runs a command, printing out nice contextual information if it fails.
@ -1092,19 +1091,6 @@ impl Build {
}
}
/// Fold the output of the commands after this method into a group. The fold
/// ends when the returned object is dropped. Folding can only be used in
/// the Travis CI environment.
pub fn fold_output<D, F>(&self, name: F) -> Option<OutputFolder>
where D: Into<String>, F: FnOnce() -> D
{
if !self.config.dry_run && self.ci_env == CiEnv::Travis {
Some(OutputFolder::new(name().into()))
} else {
None
}
}
/// Updates the actual toolstate of a tool.
///
/// The toolstates are saved to the file specified by the key
@ -1325,7 +1311,7 @@ fn chmod(path: &Path, perms: u32) {
fn chmod(_path: &Path, _perms: u32) {}
impl<'a> Compiler {
impl Compiler {
pub fn with_stage(mut self, stage: u32) -> Compiler {
self.stage = stage;
self

View File

@ -48,10 +48,8 @@ check:
$(Q)$(BOOTSTRAP) test $(BOOTSTRAP_ARGS)
check-aux:
$(Q)$(BOOTSTRAP) test \
src/test/run-pass/pretty \
src/test/run-fail/pretty \
src/test/run-pass-valgrind/pretty \
src/test/run-pass-fulldeps/pretty \
$(AUX_ARGS) \
$(BOOTSTRAP_ARGS)
check-bootstrap:
@ -75,9 +73,7 @@ check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu:
TESTS_IN_2 := \
src/test/ui \
src/test/run-pass \
src/test/compile-fail \
src/test/run-pass-fulldeps \
src/tools/linkchecker
ci-subset-1:

View File

@ -104,7 +104,6 @@ impl Step for Llvm {
}
}
let _folder = builder.fold_output(|| "llvm");
let descriptor = if emscripten { "Emscripten " } else { "" };
builder.info(&format!("Building {}LLVM for {}", descriptor, target));
let _time = util::timeit(&builder);
@ -126,14 +125,18 @@ impl Step for Llvm {
} else {
match builder.config.llvm_targets {
Some(ref s) => s,
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon",
None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\
Sparc;SystemZ;WebAssembly;X86",
}
};
let llvm_exp_targets = if self.emscripten {
""
} else {
&builder.config.llvm_experimental_targets[..]
match builder.config.llvm_experimental_targets {
Some(ref s) => s,
None => "",
}
};
let assertions = if builder.config.llvm_assertions {"ON"} else {"OFF"};
@ -151,6 +154,7 @@ impl Step for Llvm {
.define("WITH_POLLY", "OFF")
.define("LLVM_ENABLE_TERMINFO", "OFF")
.define("LLVM_ENABLE_LIBEDIT", "OFF")
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
@ -493,7 +497,6 @@ impl Step for Lld {
return out_dir
}
let _folder = builder.fold_output(|| "lld");
builder.info(&format!("Building LLD for {}", target));
let _time = util::timeit(&builder);
t!(fs::create_dir_all(&out_dir));
@ -548,7 +551,7 @@ impl Step for TestHelpers {
}
/// Compiles the `rust_test_helpers.c` library which we used in various
/// `run-pass` test suites for ABI testing.
/// `run-pass` tests for ABI testing.
fn run(self, builder: &Builder<'_>) {
if builder.config.dry_run {
return;
@ -560,7 +563,6 @@ impl Step for TestHelpers {
return
}
let _folder = builder.fold_output(|| "build_test_helpers");
builder.info("Building test helpers");
t!(fs::create_dir_all(&dst));
let mut cfg = cc::Build::new();

View File

@ -78,8 +78,11 @@ pub fn check(build: &mut Build) {
// We need cmake, but only if we're actually building LLVM or sanitizers.
let building_llvm = build.hosts.iter()
.filter_map(|host| build.config.target_config.get(host))
.any(|config| config.llvm_config.is_none());
.map(|host| build.config.target_config
.get(host)
.map(|config| config.llvm_config.is_none())
.unwrap_or(true))
.any(|build_llvm_ourselves| build_llvm_ourselves);
if building_llvm || build.config.sanitizers {
cmd_finder.must_have("cmake");
}
@ -106,6 +109,14 @@ pub fn check(build: &mut Build) {
build.config.ninja = true;
}
}
if build.config.lldb_enabled {
cmd_finder.must_have("swig");
let out = output(Command::new("swig").arg("-version"));
if !out.contains("SWIG Version 3") && !out.contains("SWIG Version 4") {
panic!("Ensure that Swig 3.x.x or 4.x.x is installed.");
}
}
}
build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))

View File

@ -229,6 +229,9 @@ impl Step for Cargo {
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
// Disable a test that has issues with mingw.
cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1");
// Forcibly disable tests using nightly features since any changes to
// those features won't be able to land.
cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
try_run(
builder,
@ -360,11 +363,9 @@ pub struct Miri {
impl Step for Miri {
type Output = ();
const ONLY_HOSTS: bool = true;
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let test_miri = run.builder.config.test_miri;
run.path("src/tools/miri").default_condition(test_miri)
run.path("src/tools/miri")
}
fn make_run(run: RunConfig<'_>) {
@ -386,26 +387,92 @@ impl Step for Miri {
extra_features: Vec::new(),
});
if let Some(miri) = miri {
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::ToolRustc,
host,
"test",
"src/tools/miri",
SourceType::Submodule,
&[]);
// # Run `cargo miri setup`.
// As a side-effect, this will install xargo.
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolRustc,
host,
"run",
"src/tools/miri",
SourceType::Submodule,
&[],
);
cargo
.arg("--bin")
.arg("cargo-miri")
.arg("--")
.arg("miri")
.arg("setup");
// Tell `cargo miri` not to worry about the sysroot mismatch (we built with
// stage1 but run with stage2).
cargo.env("MIRI_SKIP_SYSROOT_CHECK", "1");
// Tell `cargo miri setup` where to find the sources.
cargo.env("XARGO_RUST_SRC", builder.src.join("src"));
// Debug things.
cargo.env("RUST_BACKTRACE", "1");
// Configure `cargo install` path, and let cargo-miri know that that's where
// xargo ends up.
cargo.env("CARGO_INSTALL_ROOT", &builder.out); // cargo adds a `bin/`
cargo.env("XARGO", builder.out.join("bin").join("xargo"));
if !try_run(builder, &mut cargo) {
return;
}
// # Determine where Miri put its sysroot.
// To this end, we run `cargo miri setup --env` and capture the output.
// (We do this separately from the above so that when the setup actually
// happens we get some output.)
// We re-use the `cargo` from above.
cargo.arg("--env");
// FIXME: Is there a way in which we can re-use the usual `run` helpers?
let miri_sysroot = if builder.config.dry_run {
String::new()
} else {
builder.verbose(&format!("running: {:?}", cargo));
let out = cargo.output()
.expect("We already ran `cargo miri setup` before and that worked");
assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
// Output is "MIRI_SYSROOT=<str>\n".
let stdout = String::from_utf8(out.stdout)
.expect("`cargo miri setup` stdout is not valid UTF-8");
let stdout = stdout.trim();
builder.verbose(&format!("`cargo miri setup --env` returned: {:?}", stdout));
let sysroot = stdout.splitn(2, '=')
.nth(1).expect("`cargo miri setup` stdout did not contain '='");
sysroot.to_owned()
};
// # Run `cargo test`.
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolRustc,
host,
"test",
"src/tools/miri",
SourceType::Submodule,
&[],
);
// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
cargo.env("MIRI_SYSROOT", miri_sysroot);
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
cargo.env("MIRI_PATH", miri);
builder.add_rustc_lib_path(compiler, &mut cargo);
if try_run(builder, &mut cargo) {
builder.save_toolstate("miri", ToolState::TestPass);
if !try_run(builder, &mut cargo) {
return;
}
// # Done!
builder.save_toolstate("miri", ToolState::TestPass);
} else {
eprintln!("failed to test miri: could not build");
}
@ -713,7 +780,6 @@ impl Step for Tidy {
cmd.arg("--verbose");
}
let _folder = builder.fold_output(|| "tidy");
builder.info("tidy check");
try_run(builder, &mut cmd);
}
@ -821,13 +887,6 @@ default_test_with_compare_mode!(Ui {
compare_mode: "nll"
});
default_test_with_compare_mode!(RunPass {
path: "src/test/run-pass",
mode: "run-pass",
suite: "run-pass",
compare_mode: "nll"
});
default_test!(CompileFail {
path: "src/test/compile-fail",
mode: "compile-fail",
@ -882,12 +941,6 @@ host_test!(UiFullDeps {
suite: "ui-fulldeps"
});
host_test!(RunPassFullDeps {
path: "src/test/run-pass-fulldeps",
mode: "run-pass",
suite: "run-pass-fulldeps"
});
host_test!(Rustdoc {
path: "src/test/rustdoc",
mode: "rustdoc",
@ -899,13 +952,6 @@ host_test!(Pretty {
mode: "pretty",
suite: "pretty"
});
test!(RunPassPretty {
path: "src/test/run-pass/pretty",
mode: "pretty",
suite: "run-pass",
default: false,
host: true
});
test!(RunFailPretty {
path: "src/test/run-fail/pretty",
mode: "pretty",
@ -1310,7 +1356,6 @@ impl Step for Compiletest {
builder.ci_env.force_coloring_in_ci(&mut cmd);
let _folder = builder.fold_output(|| format!("test_{}", suite));
builder.info(&format!(
"Check compiletest suite={} mode={} ({} -> {})",
suite, mode, &compiler.host, target
@ -1320,7 +1365,6 @@ impl Step for Compiletest {
if let Some(compare_mode) = compare_mode {
cmd.arg("--compare-mode").arg(compare_mode);
let _folder = builder.fold_output(|| format!("test_{}_{}", suite, compare_mode));
builder.info(&format!(
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
suite, mode, compare_mode, &compiler.host, target
@ -1364,7 +1408,6 @@ impl Step for DocTest {
// tests for all files that end in `*.md`
let mut stack = vec![builder.src.join(self.path)];
let _time = util::timeit(&builder);
let _folder = builder.fold_output(|| format!("test_{}", self.name));
let mut files = Vec::new();
while let Some(p) = stack.pop() {
@ -1495,10 +1538,9 @@ impl Step for ErrorIndex {
.env("CFG_BUILD", &builder.config.build)
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
let _folder = builder.fold_output(|| "test_error_index");
builder.info(&format!("Testing error-index stage{}", compiler.stage));
let _time = util::timeit(&builder);
builder.run(&mut tool);
builder.run_quiet(&mut tool);
markdown_test(builder, compiler, &output);
}
}
@ -1530,6 +1572,34 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct RustcGuide;
impl Step for RustcGuide {
type Output = ();
const DEFAULT: bool = false;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/doc/rustc-guide")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustcGuide);
}
fn run(self, builder: &Builder<'_>) {
let src = builder.src.join("src/doc/rustc-guide");
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
ToolState::TestPass
} else {
ToolState::TestFail
};
builder.save_toolstate("rustc-guide", toolstate);
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct CrateLibrustc {
compiler: Compiler,
@ -1794,14 +1864,6 @@ impl Step for Crate {
);
}
let _folder = builder.fold_output(|| {
format!(
"{}_stage{}-{}",
test_kind.subcommand(),
compiler.stage,
krate
)
});
builder.info(&format!(
"{} {} stage{} ({} -> {})",
test_kind, krate, compiler.stage, &compiler.host, target
@ -1869,8 +1931,6 @@ impl Step for CrateRustdoc {
cargo.arg("--quiet");
}
let _folder = builder
.fold_output(|| format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage));
builder.info(&format!(
"{} rustdoc stage{} ({} -> {})",
test_kind, compiler.stage, &compiler.host, target

View File

@ -9,7 +9,7 @@ use build_helper::t;
use crate::Mode;
use crate::Compiler;
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
use crate::util::{exe, add_lib_path};
use crate::util::{exe, add_lib_path, CiEnv};
use crate::compile;
use crate::channel::GitInfo;
use crate::channel;
@ -74,7 +74,6 @@ impl Step for ToolBuild {
&self.extra_features,
);
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
let mut duplicates = Vec::new();
let is_expected = compile::stream_cargo(builder, &mut cargo, vec![], &mut |msg| {
@ -109,36 +108,63 @@ impl Step for ToolBuild {
continue
}
// Don't worry about libs that turn out to be host dependencies
// or build scripts, we only care about target dependencies that
// are in `deps`.
if let Some(maybe_target) = val.1
.parent() // chop off file name
.and_then(|p| p.parent()) // chop off `deps`
.and_then(|p| p.parent()) // chop off `release`
.and_then(|p| p.file_name())
.and_then(|p| p.to_str())
{
if maybe_target != &*target {
continue
// Don't worry about compiles that turn out to be host
// dependencies or build scripts. To skip these we look for
// anything that goes in `.../release/deps` but *doesn't* go in
// `$target/release/deps`. This ensure that outputs in
// `$target/release` are still considered candidates for
// deduplication.
if let Some(parent) = val.1.parent() {
if parent.ends_with("release/deps") {
let maybe_target = parent
.parent()
.and_then(|p| p.parent())
.and_then(|p| p.file_name())
.and_then(|p| p.to_str())
.unwrap();
if maybe_target != &*target {
continue;
}
}
}
// Record that we've built an artifact for `id`, and if one was
// already listed then we need to see if we reused the same
// artifact or produced a duplicate.
let mut artifacts = builder.tool_artifacts.borrow_mut();
let prev_artifacts = artifacts
.entry(target)
.or_default();
if let Some(prev) = prev_artifacts.get(&*id) {
if prev.1 != val.1 {
duplicates.push((
id.to_string(),
val,
prev.clone(),
));
let prev = match prev_artifacts.get(&*id) {
Some(prev) => prev,
None => {
prev_artifacts.insert(id.to_string(), val);
continue;
}
return
};
if prev.1 == val.1 {
return; // same path, same artifact
}
prev_artifacts.insert(id.to_string(), val);
// If the paths are different and one of them *isn't* inside of
// `release/deps`, then it means it's probably in
// `$target/release`, or it's some final artifact like
// `libcargo.rlib`. In these situations Cargo probably just
// copied it up from `$target/release/deps/libcargo-xxxx.rlib`,
// so if the features are equal we can just skip it.
let prev_no_hash = prev.1.parent().unwrap().ends_with("release/deps");
let val_no_hash = val.1.parent().unwrap().ends_with("release/deps");
if prev.2 == val.2 || !prev_no_hash || !val_no_hash {
return;
}
// ... and otherwise this looks like we duplicated some sort of
// compilation, so record it to generate an error later.
duplicates.push((
id.to_string(),
val,
prev.clone(),
));
}
});
@ -253,11 +279,26 @@ pub fn prepare_tool_cargo(
cargo
}
fn rustbook_features() -> Vec<String> {
let mut features = Vec::new();
// Due to CI budged and risk of spurious failures we want to limit jobs running this check.
// At same time local builds should run it regardless of the platform.
// `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
// explicitly enable it on single job
if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
features.push("linkcheck".to_string());
}
features
}
macro_rules! bootstrap_tool {
($(
$name:ident, $path:expr, $tool_name:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
$(,features = $features:expr)*
;
)+) => {
#[derive(Copy, PartialEq, Eq, Clone)]
@ -324,7 +365,12 @@ macro_rules! bootstrap_tool {
} else {
SourceType::InTree
},
extra_features: Vec::new(),
extra_features: {
// FIXME(#60643): avoid this lint by using `_`
let mut _tmp = Vec::new();
$(_tmp.extend($features);)*
_tmp
},
}).expect("expected to build -- essential tool")
}
}
@ -333,7 +379,7 @@ macro_rules! bootstrap_tool {
}
bootstrap_tool!(
Rustbook, "src/tools/rustbook", "rustbook";
Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
Tidy, "src/tools/tidy", "tidy";
Linkchecker, "src/tools/linkchecker", "linkchecker";
@ -482,7 +528,6 @@ impl Step for Rustdoc {
&[],
);
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage));
builder.info(&format!("Building rustdoc for stage{} ({})",
target_compiler.stage, target_compiler.host));
builder.run(&mut cargo);

View File

@ -6,10 +6,10 @@
use std::env;
use std::str;
use std::fs;
use std::io::{self, Write};
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::{SystemTime, Instant};
use std::time::Instant;
use build_helper::t;
@ -254,78 +254,12 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
}
}
/// An RAII structure that indicates all output until this instance is dropped
/// is part of the same group.
///
/// On Travis CI, these output will be folded by default, together with the
/// elapsed time in this block. This reduces noise from unnecessary logs,
/// allowing developers to quickly identify the error.
///
/// Travis CI supports folding by printing `travis_fold:start:<name>` and
/// `travis_fold:end:<name>` around the block. Time elapsed is recognized
/// similarly with `travis_time:[start|end]:<name>`. These are undocumented, but
/// can easily be deduced from source code of the [Travis build commands].
///
/// [Travis build commands]:
/// https://github.com/travis-ci/travis-build/blob/f603c0089/lib/travis/build/templates/header.sh
pub struct OutputFolder {
name: String,
start_time: SystemTime, // we need SystemTime to get the UNIX timestamp.
}
impl OutputFolder {
/// Creates a new output folder with the given group name.
pub fn new(name: String) -> OutputFolder {
// "\r" moves the cursor to the beginning of the line, and "\x1b[0K" is
// the ANSI escape code to clear from the cursor to end of line.
// Travis seems to have trouble when _not_ using "\r\x1b[0K", that will
// randomly put lines to the top of the webpage.
print!("travis_fold:start:{0}\r\x1b[0Ktravis_time:start:{0}\r\x1b[0K", name);
OutputFolder {
name,
start_time: SystemTime::now(),
}
}
}
impl Drop for OutputFolder {
fn drop(&mut self) {
use std::time::*;
use std::u64;
fn to_nanos(duration: Result<Duration, SystemTimeError>) -> u64 {
match duration {
Ok(d) => d.as_secs() * 1_000_000_000 + d.subsec_nanos() as u64,
Err(_) => u64::MAX,
}
}
let end_time = SystemTime::now();
let duration = end_time.duration_since(self.start_time);
let start = self.start_time.duration_since(UNIX_EPOCH);
let finish = end_time.duration_since(UNIX_EPOCH);
println!(
"travis_fold:end:{0}\r\x1b[0K\n\
travis_time:end:{0}:start={1},finish={2},duration={3}\r\x1b[0K",
self.name,
to_nanos(start),
to_nanos(finish),
to_nanos(duration)
);
io::stdout().flush().unwrap();
}
}
/// The CI environment rustbuild is running in. This mainly affects how the logs
/// are printed.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum CiEnv {
/// Not a CI environment.
None,
/// The Travis CI environment, for Linux (including Docker) and macOS builds.
Travis,
/// The AppVeyor environment, for Windows builds.
AppVeyor,
/// The Azure Pipelines environment, for Linux (including Docker), Windows, and macOS builds.
AzurePipelines,
}
@ -333,11 +267,7 @@ pub enum CiEnv {
impl CiEnv {
/// Obtains the current CI environment.
pub fn current() -> CiEnv {
if env::var("TRAVIS").ok().map_or(false, |e| &*e == "true") {
CiEnv::Travis
} else if env::var("APPVEYOR").ok().map_or(false, |e| &*e == "True") {
CiEnv::AppVeyor
} else if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") {
if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") {
CiEnv::AzurePipelines
} else {
CiEnv::None

View File

@ -1,4 +1,5 @@
#![deny(rust_2018_idioms)]
// NO-RUSTC-WRAPPER
#![deny(warnings, rust_2018_idioms, unused_lifetimes)]
use std::fs::File;
use std::path::{Path, PathBuf};
@ -44,18 +45,19 @@ pub fn restore_library_path() {
}
}
pub fn run(cmd: &mut Command) {
/// Run the command, printing what we are running.
pub fn run_verbose(cmd: &mut Command) {
println!("running: {:?}", cmd);
run_silent(cmd);
run(cmd);
}
pub fn run_silent(cmd: &mut Command) {
if !try_run_silent(cmd) {
pub fn run(cmd: &mut Command) {
if !try_run(cmd) {
std::process::exit(1);
}
}
pub fn try_run_silent(cmd: &mut Command) -> bool {
pub fn try_run(cmd: &mut Command) -> bool {
let status = match cmd.status() {
Ok(status) => status,
Err(e) => fail(&format!(

View File

@ -1,13 +0,0 @@
awscli==1.16.201
botocore==1.12.191
colorama==0.3.9
docutils==0.14
jmespath==0.9.4
pyasn1==0.4.5
python-dateutil==2.8.0
PyYAML==5.1
rsa==3.4.2
s3transfer==0.2.1
six==1.12.0
urllib3==1.25.3
futures==3.3.0; python_version < '3.0'

View File

@ -7,7 +7,7 @@ trigger:
- auto
variables:
- group: real-prod-credentials
- group: prod-credentials
jobs:
- job: Linux
@ -174,7 +174,7 @@ jobs:
dist-x86_64-apple:
SCRIPT: ./x.py dist
RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc
RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
DEPLOY: 1
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
MACOSX_DEPLOYMENT_TARGET: 10.7
@ -184,7 +184,7 @@ jobs:
dist-x86_64-apple-alt:
SCRIPT: ./x.py dist
RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --enable-lldb --set rust.jemalloc
RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
DEPLOY_ALT: 1
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
MACOSX_DEPLOYMENT_TARGET: 10.7
@ -202,7 +202,7 @@ jobs:
dist-i686-apple:
SCRIPT: ./x.py dist
RUST_CONFIGURE_ARGS: --build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb --set rust.jemalloc
RUST_CONFIGURE_ARGS: --build=i686-apple-darwin --enable-full-tools --enable-profiler --set rust.jemalloc
DEPLOY: 1
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
MACOSX_DEPLOYMENT_TARGET: 10.7
@ -254,7 +254,7 @@ jobs:
x86_64-msvc-tools:
MSYS_BITS: 64
SCRIPT: src/ci/docker/x86_64-gnu-tools/checktools.sh x.py /tmp/toolstates.json windows
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --save-toolstates=/tmp/toolstates.json --enable-test-miri
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --save-toolstates=/tmp/toolstates.json
# 32/64-bit MinGW builds.
#
@ -273,7 +273,7 @@ jobs:
MSYS_BITS: 32
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu
SCRIPT: make ci-subset-1
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z
MINGW_DIR: mingw32
# FIXME(#59637)
@ -283,14 +283,14 @@ jobs:
MSYS_BITS: 32
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu
SCRIPT: make ci-subset-2
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z
MINGW_DIR: mingw32
x86_64-mingw-1:
MSYS_BITS: 64
SCRIPT: make ci-subset-1
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z
MINGW_DIR: mingw64
# FIXME(#59637)
@ -300,7 +300,7 @@ jobs:
MSYS_BITS: 64
SCRIPT: make ci-subset-2
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z
MINGW_DIR: mingw64
@ -327,7 +327,7 @@ jobs:
MSYS_BITS: 32
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools --enable-profiler
SCRIPT: python x.py dist
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z
MINGW_DIR: mingw32
DIST_REQUIRE_ALL_TOOLS: 1
@ -336,7 +336,7 @@ jobs:
MSYS_BITS: 64
SCRIPT: python x.py dist
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler
MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z
MINGW_DIR: mingw64
DIST_REQUIRE_ALL_TOOLS: 1

View File

@ -7,7 +7,7 @@ trigger:
- master
variables:
- group: real-prod-credentials
- group: prod-credentials
pool:
vmImage: ubuntu-16.04

View File

@ -6,6 +6,9 @@ trigger: none
pr:
- master
variables:
- group: public-credentials
jobs:
- job: Linux
timeoutInMinutes: 600
@ -20,14 +23,13 @@ jobs:
mingw-check:
IMAGE: mingw-check
# TODO: enable this job if the commit message matches this regex, need tools
# figure out how to get the current commit message on azure and stick it in a
# condition somewhere
# if: commit_message =~ /(?i:^update.*\b(rls|rustfmt|clippy|miri|cargo)\b)/
# - job: Linux-x86_64-gnu-tools
# pool:
# vmImage: ubuntu-16.04
# steps:
# - template: steps/run.yml
# variables:
# IMAGE: x86_64-gnu-tools
- job: LinuxTools
timeoutInMinutes: 600
pool:
vmImage: ubuntu-16.04
steps:
- template: steps/run.yml
parameters:
only_on_updated_submodules: 'yes'
variables:
IMAGE: x86_64-gnu-tools

View File

@ -26,12 +26,18 @@ steps:
#
# Original downloaded here came from
# http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe
- script: |
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %TEMP%\LLVM-7.0.0-win64.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-7.0.0-win64.exe"
set CLANG_DIR=%CD%\citools\clang-rust
%TEMP%\LLVM-7.0.0-win64.exe /S /NCRC /D=%CLANG_DIR%
set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --set llvm.clang-cl=%CLANG_DIR%\bin\clang-cl.exe
echo ##vso[task.setvariable variable=RUST_CONFIGURE_ARGS]%RUST_CONFIGURE_ARGS%
# That installer was run through `wine` on Linux and then the resulting
# installation directory (found in `$HOME/.wine/drive_c/Program Files/LLVM`) was
# packaged up into a tarball. We've had issues otherwise that the installer will
# randomly hang, provide not a lot of useful information, pollute global state,
# etc. In general the tarball is just more confined and easier to deal with when
# working with various CI environments.
- bash: |
set -e
mkdir -p citools
cd citools
curl -f https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/LLVM-7.0.0-win64.tar.gz | tar xzf -
echo "##vso[task.setvariable variable=RUST_CONFIGURE_ARGS]$RUST_CONFIGURE_ARGS --set llvm.clang-cl=`pwd`/clang-rust/bin/clang-cl.exe"
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['MINGW_URL'],''))
displayName: Install clang (Windows)

View File

@ -2,14 +2,14 @@ steps:
- bash: |
set -e
curl -fo /usr/local/bin/sccache https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin
curl -fo /usr/local/bin/sccache https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-02-sccache-x86_64-apple-darwin
chmod +x /usr/local/bin/sccache
displayName: Install sccache (OSX)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
- script: |
md sccache
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc"
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-26-sccache-x86_64-pc-windows-msvc"
echo ##vso[task.prependpath]%CD%\sccache
displayName: Install sccache (Windows)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

View File

@ -1,4 +1,29 @@
steps:
# We use the WIX toolset to create combined installers for Windows, and these
# binaries are downloaded from
# https://github.com/wixtoolset/wix3 originally
- bash: |
set -e
curl -O https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/wix311-binaries.zip
echo "##vso[task.setvariable variable=WIX]`pwd`/wix"
mkdir -p wix/bin
cd wix/bin
7z x ../../wix311-binaries.zip
displayName: Install wix
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# We use InnoSetup and its `iscc` program to also create combined installers.
# Honestly at this point WIX above and `iscc` are just holdovers from
# oh-so-long-ago and are required for creating installers on Windows. I think
# one is MSI installers and one is EXE, but they're not used so frequently at
# this point anyway so perhaps it's a wash!
- script: |
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf is-install.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-08-22-is.exe"
is-install.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
echo ##vso[task.prependpath]C:\Program Files (x86)\Inno Setup 5
displayName: Install InnoSetup
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
# We've had issues with the default drive in use running out of space during a
# build, and it looks like the `C:` drive has more space than the default `D:`
# drive. We should probably confirm this with the azure pipelines team at some
@ -84,7 +109,7 @@ steps:
# Note that this is originally from the github releases patch of Ninja
- script: |
md ninja
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-03-15-ninja-win.zip https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-03-15-ninja-win.zip"
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-03-15-ninja-win.zip https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-03-15-ninja-win.zip"
7z x -oninja 2017-03-15-ninja-win.zip
del 2017-03-15-ninja-win.zip
set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja

View File

@ -6,6 +6,11 @@
#
# Check travis config for `gdb --batch` command to print all crash logs
parameters:
# When this parameter is set to anything other than an empty string the tests
# will only be executed when the commit updates submodules
only_on_updated_submodules: ''
steps:
# Disable automatic line ending conversion, which is enabled by default on
@ -21,6 +26,22 @@ steps:
- checkout: self
fetchDepth: 2
# Set the SKIP_JOB environment variable if this job is supposed to only run
# when submodules are updated and they were not. The following time consuming
# tasks will be skipped when the environment variable is present.
- ${{ if parameters.only_on_updated_submodules }}:
- bash: |
set -e
# Submodules pseudo-files inside git have the 160000 permissions, so when
# those files are present in the diff a submodule was updated.
if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then
echo "Executing the job since submodules are updated"
else
echo "Not executing this job since no submodules were updated"
echo "##vso[task.setvariable variable=SKIP_JOB;]1"
fi
displayName: Decide whether to run this job
# Spawn a background process to collect CPU usage statistics which we'll upload
# at the end of the build. See the comments in the script here for more
# information.
@ -30,10 +51,6 @@ steps:
- bash: printenv | sort
displayName: Show environment variables
# Log the date, even on failure. Attempting to debug SSL certificate errors.
- bash: date
displayName: Print out date (before build)
- bash: |
set -e
df -h
@ -45,17 +62,6 @@ steps:
- template: install-sccache.yml
- template: install-clang.yml
# Install some dependencies needed to build LLDB/Clang, currently only needed
# during the `dist` target
- bash: |
set -e
brew update
brew install xz
brew install swig@3
brew link --force swig@3
displayName: Install build dependencies (OSX)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'), eq(variables['SCRIPT'],'./x.py dist'))
# Switch to XCode 9.3 on OSX since it seems to be the last version that supports
# i686-apple-darwin. We'll eventually want to upgrade this and it will probably
# force us to drop i686-apple-darwin, but let's keep the wheels turning for now.
@ -75,7 +81,7 @@ steps:
echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
displayName: Enable IPv6
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
# Disable automatic line ending conversion (again). On Windows, when we're
# installing dependencies, something switches the git configuration directory or
@ -91,12 +97,12 @@ steps:
set -e
mkdir -p $HOME/rustsrc
$BUILD_SOURCESDIRECTORY/src/ci/init_repo.sh . $HOME/rustsrc
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Windows_NT'))
displayName: Check out submodules (Unix)
- script: |
if not exist D:\cache\rustsrc\NUL mkdir D:\cache\rustsrc
sh src/ci/init_repo.sh . /d/cache/rustsrc
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc
sh src/ci/init_repo.sh . /c/cache/rustsrc
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Windows_NT'))
displayName: Check out submodules (Windows)
# See also the disable for autocrlf above, this just checks that it worked
@ -121,21 +127,17 @@ steps:
# Ensure the `aws` CLI is installed so we can deploy later on, cache docker
# images, etc.
- bash: |
set -e
source src/ci/shared.sh
sudo apt-get install -y python3-setuptools
retry pip3 install -r src/ci/awscli-requirements.txt --upgrade --user
echo "##vso[task.prependpath]$HOME/.local/bin"
displayName: Install awscli (Linux)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
- script: pip install -r src/ci/awscli-requirements.txt
displayName: Install awscli (non-Linux)
condition: and(succeeded(), ne(variables['Agent.OS'], 'Linux'))
- bash: src/ci/install-awscli.sh
env:
AGENT_OS: $(Agent.OS)
condition: and(succeeded(), not(variables.SKIP_JOB))
displayName: Install awscli
# Configure our CI_JOB_NAME variable which log analyzers can use for the main
# step to see what's going on.
- bash: echo "##vso[task.setvariable variable=CI_JOB_NAME]$SYSTEM_JOBNAME"
- bash: |
builder=$(echo $AGENT_JOBNAME | cut -d ' ' -f 2)
echo "##vso[task.setvariable variable=CI_JOB_NAME]$builder"
displayName: Configure Job Name
# As a quick smoke check on the otherwise very fast mingw-check linux builder
@ -147,7 +149,7 @@ steps:
python2.7 "$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "" ""
cd ..
rm -rf rust-toolstate
condition: and(succeeded(), eq(variables['IMAGE'], 'mingw-check'))
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['IMAGE'], 'mingw-check'))
displayName: Verify the publish_toolstate script works
- bash: |
@ -166,8 +168,10 @@ steps:
env:
CI: true
SRC: .
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
AWS_ACCESS_KEY_ID: $(SCCACHE_AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(SCCACHE_AWS_SECRET_ACCESS_KEY)
TOOLSTATE_REPO_ACCESS_TOKEN: $(TOOLSTATE_REPO_ACCESS_TOKEN)
condition: and(succeeded(), not(variables.SKIP_JOB))
displayName: Run build
# If we're a deploy builder, use the `aws` command to publish everything to our
@ -189,8 +193,9 @@ steps:
fi
retry aws s3 cp --no-progress --recursive --acl public-read ./$upload_dir s3://$DEPLOY_BUCKET/$deploy_dir/$BUILD_SOURCEVERSION
env:
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
condition: and(succeeded(), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
AWS_ACCESS_KEY_ID: $(UPLOAD_AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(UPLOAD_AWS_SECRET_ACCESS_KEY)
condition: and(succeeded(), not(variables.SKIP_JOB), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
displayName: Upload artifacts
# Upload CPU usage statistics that we've been gathering this whole time. Always
@ -198,12 +203,8 @@ steps:
# errors here ever fail the build since this is just informational.
- bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv
env:
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
condition: variables['AWS_SECRET_ACCESS_KEY']
AWS_ACCESS_KEY_ID: $(UPLOAD_AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(UPLOAD_AWS_SECRET_ACCESS_KEY)
condition: variables['UPLOAD_AWS_SECRET_ACCESS_KEY']
continueOnError: true
displayName: Upload CPU usage statistics
# Log the date, even on failure. Attempting to debug SSL certificate errors.
- bash: date
continueOnError: true
displayName: Print out date (after build)

View File

@ -3,7 +3,7 @@ trigger:
- try
variables:
- group: real-prod-credentials
- group: prod-credentials
jobs:
- job: Linux
@ -36,7 +36,7 @@ jobs:
# matrix:
# dist-x86_64-apple:
# SCRIPT: ./x.py dist
# RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc
# RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
# DEPLOY: 1
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
# MACOSX_DEPLOYMENT_TARGET: 10.7
@ -46,7 +46,7 @@ jobs:
#
# dist-x86_64-apple-alt:
# SCRIPT: ./x.py dist
# RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --enable-lldb --set rust.jemalloc
# RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
# DEPLOY_ALT: 1
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
# MACOSX_DEPLOYMENT_TARGET: 10.7

View File

@ -20,7 +20,7 @@ Images will output artifacts in an `obj` dir at the root of a repository.
- Each directory, excluding `scripts` and `disabled`, corresponds to a docker image
- `scripts` contains files shared by docker images
- `disabled` contains images that are not built on travis
- `disabled` contains images that are not built on CI
## Docker Toolbox on Windows

View File

@ -72,7 +72,7 @@ RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static
# TODO: What is this?!
# Source of the file: https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/vexpress-v2p-ca15-tc1.dtb
RUN curl -O https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/vexpress-v2p-ca15-tc1.dtb
RUN curl -O https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/vexpress-v2p-ca15-tc1.dtb
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

View File

@ -32,7 +32,7 @@ ENV TARGETS=asmjs-unknown-emscripten
ENV RUST_CONFIGURE_ARGS --enable-emscripten --disable-optimize-tests
ENV SCRIPT python2.7 ../x.py test --target $TARGETS \
src/test/run-pass \
src/test/ui \
src/test/run-fail \
src/libstd \
src/liballoc \

View File

@ -36,7 +36,3 @@ ENV HOSTS=powerpc-unknown-linux-gnu
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
# FIXME(#36150) this will fail the bootstrap. Probably means something bad is
# happening!
ENV NO_LLVM_ASSERTIONS 1

View File

@ -64,7 +64,7 @@ RUN env \
env \
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \
CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \
bash musl.sh armv7 && \
bash musl.sh armv7hf && \
env \
CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
@ -104,7 +104,9 @@ ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
ENV TARGETS=$TARGETS,x86_64-unknown-redox
# FIXME: temporarily disable the redox builder,
# see: https://github.com/rust-lang/rust/issues/63160
# ENV TARGETS=$TARGETS,x86_64-unknown-redox
ENV TARGETS=$TARGETS,thumbv6m-none-eabi
ENV TARGETS=$TARGETS,thumbv7m-none-eabi
ENV TARGETS=$TARGETS,thumbv7em-none-eabi
@ -112,6 +114,7 @@ ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
ENV TARGETS=$TARGETS,thumbv8m.base-none-eabi
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabi
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabihf
ENV TARGETS=$TARGETS,riscv32i-unknown-none-elf
ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
ENV TARGETS=$TARGETS,riscv64imac-unknown-none-elf
@ -134,7 +137,7 @@ ENV RUST_CONFIGURE_ARGS \
--musl-root-armv5te=/musl-armv5te \
--musl-root-arm=/musl-arm \
--musl-root-armhf=/musl-armhf \
--musl-root-armv7=/musl-armv7 \
--musl-root-armv7hf=/musl-armv7hf \
--musl-root-aarch64=/musl-aarch64 \
--musl-root-mips=/musl-mips \
--musl-root-mipsel=/musl-mipsel \

View File

@ -5,7 +5,7 @@ mkdir /usr/local/mips-linux-musl
# originally from
# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/
# OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2
URL="https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror"
URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc"
FILE="OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2"
curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mips-linux-musl --strip-components=2

View File

@ -5,7 +5,7 @@ mkdir /usr/local/mipsel-linux-musl
# Note that this originally came from:
# https://downloads.openwrt.org/snapshots/trunk/malta/generic/
# OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
URL="https://rust-lang-ci2.s3.amazonaws.com/libc"
URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc"
FILE="OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2"
curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2

View File

@ -8,7 +8,8 @@ RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list
RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no-install-recommends \
build-essential \
gcc-multilib \
# gcc-multilib can not be installed together with gcc-arm-linux-gnueabi
gcc-7-multilib \
libedit-dev \
libgmp-dev \
libisl-dev \
@ -21,11 +22,20 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no
unzip \
# Needed for apt-key to work:
dirmngr \
gpg-agent
gpg-agent \
g++-7-arm-linux-gnueabi
RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main'
WORKDIR /build
COPY scripts/musl.sh /build
RUN env \
CC=arm-linux-gnueabi-gcc-7 CFLAGS="-march=armv7-a" \
CXX=arm-linux-gnueabi-g++-7 CXXFLAGS="-march=armv7-a" \
bash musl.sh armv7 && \
rm -rf /build/*
WORKDIR /tmp
COPY dist-various-2/shared.sh /tmp/
COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/
@ -58,7 +68,11 @@ ENV \
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \
CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \
CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-7 \
CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-7 \
CC=gcc-7 \
CXX=g++-7
ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar
ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
@ -81,9 +95,19 @@ ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi
ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
ENV TARGETS=$TARGETS,armv7-unknown-linux-gnueabi
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi
ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/"
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
# we need asm in the search path for gcc-7 (for gnux32) but not in the search path of the
# cross compilers.
# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there
RUN ln -s /usr/include/asm-generic /usr/local/include/asm
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-wasi.wasi-root=/wasm32-wasi
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
--musl-root-armv7=/musl-armv7
ENV SCRIPT python2.7 ../x.py dist --target $TARGETS

View File

@ -5,7 +5,7 @@
set -ex
# Originally from https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
curl https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \
curl https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \
tar xJf -
export PATH=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH

View File

@ -4,7 +4,7 @@ set -ex
source shared.sh
VERSION=1.0.2k
URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/openssl-$VERSION.tar.gz
URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/openssl-$VERSION.tar.gz
curl $URL | tar xzf -

View File

@ -25,7 +25,7 @@ cd netbsd
mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot
URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror
URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc
# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz
curl $URL/2018-03-01-netbsd-src.tgz | tar xzf -

View File

@ -17,9 +17,6 @@ dist=$objdir/build/dist
source "$ci_dir/shared.sh"
travis_fold start build_docker
travis_time_start
if [ -f "$docker_dir/$image/Dockerfile" ]; then
if [ "$CI" != "" ]; then
hash_key=/tmp/.docker-hash-key.txt
@ -94,7 +91,6 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
echo Cannot run disabled images on CI!
exit 1
fi
# retry messes with the pipe from tar to docker. Not needed on non-travis
# Transform changes the context of disabled Dockerfiles to match the enabled ones
tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
build \
@ -107,9 +103,6 @@ else
exit 1
fi
travis_fold end build_docker
travis_time_finish
mkdir -p $HOME/.cargo
mkdir -p $objdir/tmp
mkdir -p $objdir/cores
@ -132,28 +125,61 @@ fi
# goes ahead and sets it for all builders.
args="$args --privileged"
exec docker \
# Things get a little weird if this script is already running in a docker
# container. If we're already in a docker container then we assume it's set up
# to do docker-in-docker where we have access to a working `docker` command.
#
# If this is the case (we check via the presence of `/.dockerenv`)
# then we can't actually use the `--volume` argument. Typically we use
# `--volume` to efficiently share the build and source directory between this
# script and the container we're about to spawn. If we're inside docker already
# though the `--volume` argument maps the *host's* folder to the container we're
# about to spawn, when in fact we want the folder in this container itself. To
# work around this we use a recipe cribbed from
# https://circleci.com/docs/2.0/building-docker-images/#mounting-folders to
# create a temporary container with a volume. We then copy the entire source
# directory into this container, and then use that copy in the container we're
# about to spawn. Finally after the build finishes we re-extract the object
# directory.
#
# Note that none of this is necessary if we're *not* in a docker-in-docker
# scenario. If this script is run on a bare metal host then we share a bunch of
# data directories to share as much data as possible. Note that we also use
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
# read/written as the same user as the bare-metal user.
if [ -f /.dockerenv ]; then
docker create -v /checkout --name checkout alpine:3.4 /bin/true
docker cp . checkout:/checkout
args="$args --volumes-from checkout"
else
args="$args --volume $root_dir:/checkout:ro"
args="$args --volume $objdir:/checkout/obj"
args="$args --volume $HOME/.cargo:/cargo"
args="$args --volume $HOME/rustsrc:$HOME/rustsrc"
args="$args --env LOCAL_USER_ID=`id -u`"
fi
docker \
run \
--volume "$root_dir:/checkout:ro" \
--volume "$objdir:/checkout/obj" \
--workdir /checkout/obj \
--env SRC=/checkout \
$args \
--env CARGO_HOME=/cargo \
--env DEPLOY \
--env DEPLOY_ALT \
--env LOCAL_USER_ID=`id -u` \
--env CI \
--env TRAVIS \
--env TRAVIS_BRANCH \
--env TF_BUILD \
--env BUILD_SOURCEBRANCHNAME \
--env TOOLSTATE_REPO_ACCESS_TOKEN \
--env TOOLSTATE_REPO \
--env TOOLSTATE_PUBLISH \
--env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
--volume "$HOME/.cargo:/cargo" \
--volume "$HOME/rustsrc:$HOME/rustsrc" \
--init \
--rm \
rust-ci \
/checkout/src/ci/run.sh
if [ -f /.dockerenv ]; then
rm -rf $objdir
docker cp checkout:/checkout/obj $objdir
fi

View File

@ -23,8 +23,9 @@ REPOSITORIES = [
HOST_OS = "linux"
# Mirroring options
MIRROR_BUCKET = "rust-lang-ci2"
MIRROR_BASE_DIR = "rust-ci-mirror/android/"
MIRROR_BUCKET = "rust-lang-ci-mirrors"
MIRROR_BUCKET_REGION = "us-west-1"
MIRROR_BASE_DIR = "rustc/android/"
import argparse
import hashlib
@ -144,7 +145,8 @@ def cli_install(args):
lockfile = Lockfile(args.lockfile)
for package in lockfile.packages.values():
# Download the file from the mirror into a temp file
url = "https://" + MIRROR_BUCKET + ".s3.amazonaws.com/" + MIRROR_BASE_DIR
url = "https://" + MIRROR_BUCKET + ".s3-" + MIRROR_BUCKET_REGION + \
".amazonaws.com/" + MIRROR_BASE_DIR
downloaded = package.download(url)
# Extract the file in a temporary directory
extract_dir = tempfile.mkdtemp()

View File

@ -59,7 +59,7 @@ done
# Originally downloaded from:
# https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz
URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz
URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz
curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}"
# Fix up absolute symlinks from the system image. This can be removed

View File

@ -1,6 +1,6 @@
set -ex
curl -fo /usr/local/bin/sccache \
https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-unknown-linux-musl
https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-02-sccache-x86_64-unknown-linux-musl
chmod +x /usr/local/bin/sccache

View File

@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
wget \
patch
@ -41,7 +43,6 @@ ENV WASM_TARGETS=wasm32-unknown-unknown
ENV WASM_SCRIPT python2.7 /checkout/x.py test --target $WASM_TARGETS \
src/test/run-make \
src/test/ui \
src/test/run-pass \
src/test/compile-fail \
src/test/mir-opt \
src/test/codegen-units \

View File

@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
lld \
clang
@ -31,7 +33,6 @@ ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--enable-debug \
--enable-lld \
--enable-lldb \
--enable-optimize \
--set llvm.use-linker=lld \
--set target.x86_64-unknown-linux-gnu.linker=clang \

View File

@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils
COPY scripts/sccache.sh /scripts/

View File

@ -13,6 +13,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
llvm-6.0-tools \
libedit-dev \
libssl-dev \
pkg-config \
zlib1g-dev \
xz-utils

View File

@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils
COPY scripts/sccache.sh /scripts/

View File

@ -21,8 +21,10 @@ COPY x86_64-gnu-tools/checkregression.py /tmp/
COPY x86_64-gnu-tools/checktools.sh /tmp/
COPY x86_64-gnu-tools/repo.sh /tmp/
# Run rustbook with `linkcheck` feature enabled
ENV CHECK_LINKS 1
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--enable-test-miri \
--save-toolstates=/tmp/toolstates.json
ENV SCRIPT /tmp/checktools.sh ../x.py /tmp/toolstates.json linux

View File

@ -1,9 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## This script has two purposes: detect any tool that *regressed*, which is used
## during the week before the beta branches to reject PRs; and detect any tool
## that *changed* to see if we need to update the toolstate repo.
import sys
import json
# Regressions for these tools during the beta cutoff week do not cause failure.
# See `status_check` in `checktools.sh` for tools that have to pass on the
# beta/stable branches.
REGRESSION_OK = ["rustc-guide", "miri", "embedded-book"]
if __name__ == '__main__':
os_name = sys.argv[1]
toolstate_file = sys.argv[2]
@ -32,7 +41,8 @@ if __name__ == '__main__':
'The state of "{}" has {} from "{}" to "{}"'
.format(tool, verb, state, new_state)
)
regressed = True
if not (verb == 'regressed' and tool in REGRESSION_OK):
regressed = True
if regressed:
sys.exit(1)

View File

@ -25,6 +25,7 @@ python2.7 "$X_PY" test --no-fail-fast \
src/doc/rust-by-example \
src/doc/embedded-book \
src/doc/edition-guide \
src/doc/rustc-guide \
src/tools/clippy \
src/tools/rls \
src/tools/rustfmt \
@ -41,7 +42,7 @@ check_tool_failed() {
}
# This function checks that if a tool's submodule changed, the tool's state must improve
verify_status() {
verify_submodule_changed() {
echo "Verifying status of $1..."
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then
echo "This PR updated '$2', verifying if status is 'test-pass'..."
@ -66,7 +67,7 @@ verify_status() {
check_dispatch() {
if [ "$1" = submodule_changed ]; then
# ignore $2 (branch id)
verify_status $3 $4
verify_submodule_changed $3 $4
elif [ "$2" = beta ]; then
echo "Requiring test passing for $3..."
if check_tool_failed "$3"; then
@ -75,7 +76,12 @@ check_dispatch() {
fi
}
# list all tools here
# List all tools here.
# This function gets called with "submodule_changed" for each PR that changed a submodule,
# and with "beta_required" for each PR that lands on beta/stable.
# The purpose of this function is to *reject* PRs if a tool is not "test-pass" and
# (a) the tool's submodule has been updated, or (b) we landed on beta/stable and the
# tool has to "test-pass" on that branch.
status_check() {
check_dispatch $1 beta book src/doc/book
check_dispatch $1 beta nomicon src/doc/nomicon
@ -85,9 +91,13 @@ status_check() {
check_dispatch $1 beta rls src/tools/rls
check_dispatch $1 beta rustfmt src/tools/rustfmt
check_dispatch $1 beta clippy-driver src/tools/clippy
# these tools are not required for beta to successfully branch
# These tools are not required on the beta/stable branches, but they *do* cause
# PRs to fail if a submodule update does not fix them.
# They will still cause failure during the beta cutoff week, unless `checkregression.py`
# exempts them from that.
check_dispatch $1 nightly miri src/tools/miri
check_dispatch $1 nightly embedded-book src/doc/embedded-book
check_dispatch $1 nightly rustc-guide src/doc/rustc-guide
}
# If this PR is intended to update one of these tools, do not let the build pass
@ -96,12 +106,14 @@ status_check() {
status_check "submodule_changed"
CHECK_NOT="$(readlink -f "$(dirname $0)/checkregression.py")"
# This callback is called by `commit_toolstate_change`, see `repo.sh`.
change_toolstate() {
# only update the history
if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
echo 'Toolstate is not changed. Not updating.'
else
if [ $SIX_WEEK_CYCLE -ge 35 ]; then
# Reject any regressions during the week before beta cutoff.
python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
fi
sed -i "1 a\\
@ -111,7 +123,7 @@ $COMMIT\t$(cat "$TOOLSTATE_FILE")
}
if [ "$RUST_RELEASE_CHANNEL" = nightly ]; then
if [ -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
if [ -n "${TOOLSTATE_PUBLISH+is_set}" ]; then
. "$(dirname $0)/repo.sh"
MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
echo "($OS CI update)" > "$MESSAGE_FILE"

View File

@ -5,8 +5,8 @@
#
# The function relies on a GitHub bot user, which should have a Personal access
# token defined in the environment variable $TOOLSTATE_REPO_ACCESS_TOKEN. If for
# some reason you need to change the token, please update `.travis.yml` and
# `appveyor.yml`:
# some reason you need to change the token, please update the Azure Pipelines
# variable group.
#
# 1. Generate a new Personal access token:
#
@ -18,28 +18,9 @@
# Save it somewhere secure, as the token would be gone once you leave
# the page.
#
# 2. Encrypt the token for Travis CI
# 2. Update the variable group in Azure Pipelines
#
# * Install the `travis` tool locally (`gem install travis`).
# * Encrypt the token:
# ```
# travis -r rust-lang/rust encrypt \
# TOOLSTATE_REPO_ACCESS_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# ```
# * Copy output to replace the existing one in `.travis.yml`.
# * Details of this step can be found in
# <https://docs.travis-ci.com/user/encryption-keys/>
#
# 3. Encrypt the token for AppVeyor
#
# * Login to AppVeyor using your main account, and login as the rust-lang
# organization.
# * Open the ["Encrypt data" tool](https://ci.appveyor.com/tools/encrypt)
# * Paste the 40-digit token into the "Value to encrypt" box, then click
# "Encrypt"
# * Copy the output to replace the existing one in `appveyor.yml`.
# * Details of this step can be found in
# <https://www.appveyor.com/docs/how-to/git-push/>
# * Ping a member of the infrastructure team to do this.
#
# 4. Replace the email address below if the bot account identity is changed
#
@ -62,6 +43,13 @@ commit_toolstate_change() {
MESSAGE_FILE="$1"
shift
for RETRY_COUNT in 1 2 3 4 5; do
# Call the callback.
# - If we are in the `auto` branch (pre-landing), this is called from `checktools.sh` and
# the callback is `change_toolstate` in that file. The purpose of this is to publish the
# test results (the new commit-to-toolstate mapping) in the toolstate repo.
# - If we are in the `master` branch (post-landing), this is called by the CI pipeline
# and the callback is `src/tools/publish_toolstate.py`. The purpose is to publish
# the new "current" toolstate in the toolstate repo.
"$@"
# `git commit` failing means nothing to commit.
FAILURE=0

View File

@ -11,6 +11,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils
COPY scripts/sccache.sh /scripts/

View File

@ -11,9 +11,6 @@ set -o nounset
ci_dir=$(cd $(dirname $0) && pwd)
. "$ci_dir/shared.sh"
travis_fold start init_repo
travis_time_start
REPO_DIR="$1"
CACHE_DIR="$2"
@ -73,5 +70,3 @@ retry sh -c "git submodule deinit -f $use_git && \
git submodule sync && \
git submodule update -j 16 --init --recursive $use_git"
wait
travis_fold end init_repo
travis_time_finish

35
src/ci/install-awscli.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# This script downloads and installs awscli from the packages mirrored in our
# own S3 bucket. This follows the recommendations at:
#
# https://packaging.python.org/guides/index-mirrors-and-caches/#caching-with-pip
#
# To create a new mirrored copy you can run the command:
#
# pip wheel awscli
#
# Before compressing please make sure all the wheels end with `-none-any.whl`.
# If that's not the case you'll need to remove the non-cross-platform ones and
# replace them with the .tar.gz downloaded from https://pypi.org. Also make
# sure it's possible to call this script with both Python 2 and Python 3.
set -euo pipefail
IFS=$'\n\t'
MIRROR="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2019-07-27-awscli.tar"
DEPS_DIR="/tmp/awscli-deps"
pip="pip"
pipflags=""
if [[ "${AGENT_OS}" == "Linux" ]]; then
pip="pip3"
pipflags="--user"
sudo apt-get install -y python3-setuptools
echo "##vso[task.prependpath]$HOME/.local/bin"
fi
mkdir -p "${DEPS_DIR}"
curl "${MIRROR}" | tar xf - -C "${DEPS_DIR}"
"${pip}" install ${pipflags} --no-index "--find-links=${DEPS_DIR}" awscli
rm -rf "${DEPS_DIR}"

View File

@ -25,7 +25,7 @@ source "$ci_dir/shared.sh"
branch_name=$(getCIBranch)
if [ ! isCI ] || [ "$branch_name" = "auto" ]; then
if [ ! isCI ] || [ "$branch_name" = "auto" ] || [ "$branch_name" = "try" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests"
fi
@ -91,27 +91,14 @@ if [ "$RUN_CHECK_WITH_PARALLEL_QUERIES" != "" ]; then
rm -rf build
fi
travis_fold start configure
travis_time_start
$SRC/configure $RUST_CONFIGURE_ARGS
travis_fold end configure
travis_time_finish
travis_fold start make-prepare
travis_time_start
retry make prepare
travis_fold end make-prepare
travis_time_finish
travis_fold start check-bootstrap
travis_time_start
make check-bootstrap
travis_fold end check-bootstrap
travis_time_finish
# Display the CPU and memory information. This helps us know why the CI timing
# is fluctuating.
travis_fold start log-system-info
if isOSX; then
system_profiler SPHardwareDataType || true
sysctl hw || true
@ -121,19 +108,14 @@ else
cat /proc/meminfo || true
ncpus=$(grep processor /proc/cpuinfo | wc -l)
fi
travis_fold end log-system-info
if [ ! -z "$SCRIPT" ]; then
sh -x -c "$SCRIPT"
else
do_make() {
travis_fold start "make-$1"
travis_time_start
echo "make -j $ncpus $1"
make -j $ncpus $1
local retval=$?
travis_fold end "make-$1"
travis_time_finish
return $retval
}

View File

@ -25,53 +25,13 @@ function retry {
}
function isCI {
[ "$CI" = "true" ] || [ "$TRAVIS" = "true" ] || [ "$TF_BUILD" = "True" ]
[ "$CI" = "true" ] || [ "$TF_BUILD" = "True" ]
}
function isOSX {
[ "$TRAVIS_OS_NAME" = "osx" ] || [ "$AGENT_OS" = "Darwin" ]
[ "$AGENT_OS" = "Darwin" ]
}
function getCIBranch {
if [ "$TRAVIS" = "true" ]; then
echo "$TRAVIS_BRANCH"
elif [ "$APPVEYOR" = "True" ]; then
echo "$APPVEYOR_REPO_BRANCH"
else
echo "$BUILD_SOURCEBRANCHNAME"
fi;
echo "$BUILD_SOURCEBRANCHNAME"
}
if ! declare -F travis_fold; then
if [ "${TRAVIS-false}" = 'true' ]; then
# This is a trimmed down copy of
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
travis_fold() {
echo -en "travis_fold:$1:$2\r\033[0K"
}
travis_time_start() {
travis_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
travis_start_time=$(travis_nanoseconds)
echo -en "travis_time:start:$travis_timer_id\r\033[0K"
}
travis_time_finish() {
travis_end_time=$(travis_nanoseconds)
local duration=$(($travis_end_time-$travis_start_time))
local msg="travis_time:end:$travis_timer_id"
echo -en "\n$msg:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r\033[0K"
}
if [ $(uname) = 'Darwin' ]; then
travis_nanoseconds() {
date -u '+%s000000000'
}
else
travis_nanoseconds() {
date -u '+%s%N'
}
fi
else
travis_fold() { return 0; }
travis_time_start() { return 0; }
travis_time_finish() { return 0; }
fi
fi

View File

@ -22,9 +22,8 @@ removing some of the modules and functions. Well show two ways to call the
the crate root. The `eat_at_restaurant` function is part of our library crates
public API, so we mark it with the `pub` keyword. In the [”Exposing Paths with
the `pub` Keyword”][pub]<!-- ignore --> section, well go into more detail
about `pub`.
Note that this example wont compile just yet; well explain why in a bit.
about `pub`. Note that this example wont compile just yet; well explain why
in a bit.
<span class="filename">Filename: src/lib.rs</span>

View File

@ -291,14 +291,14 @@ crate.
If were using multiple items defined in the same package or same module,
listing each item on its own line can take up a lot of vertical space in our
files. For example, these two `use` statements we had in Listing 2-4 in the
Guessing Game bring items from `std` into scope:
files. For example, these two `use` statements we had in the Guessing Game in
Listing 2-4 bring items from `std` into scope:
<span class="filename">Filename: src/main.rs</span>
```rust
use std::cmp::Ordering;
use std::io;
use std::cmp::Ordering;
// ---snip---
```

View File

@ -528,7 +528,7 @@ fn main() -> Result<(), Box<dyn Error>> {
}
```
The `Box<dyn Error>` type is called a *trait object*, which well talk about in
The `Box<dyn Error>` type is called a trait object, which well talk about in
the [“Using Trait Objects that Allow for Values of Different
Types”][trait-objects]<!-- ignore --> section in Chapter 17. For now, you can
read `Box<dyn Error>` to mean “any kind of error.” Using `?` in a `main`

View File

@ -282,11 +282,12 @@ larger rectangle can indeed hold a smaller rectangle</span>
Note that weve added a new line inside the `tests` module: `use super::*;`.
The `tests` module is a regular module that follows the usual visibility rules
we covered in Chapter 7 in the [“Modules as the Privacy
Boundary”][modules-as-privacy-boundary]<!-- ignore --> section. Because the
`tests` module is an inner module, we need to bring the code under test in the
outer module into the scope of the inner module. We use a glob here so anything
we define in the outer module is available to this `tests` module.
we covered in Chapter 7 in the [“Paths for Referring to an Item in the Module
Tree”][paths-for-referring-to-an-item-in-the-module-tree]<!-- ignore -->
section. Because the `tests` module is an inner module, we need to bring the
code under test in the outer module into the scope of the inner module. We use
a glob here so anything we define in the outer module is available to this
`tests` module.
Weve named our test `larger_can_hold_smaller`, and weve created the two
`Rectangle` instances that we need. Then we called the `assert!` macro and
@ -849,4 +850,4 @@ ch08-02-strings.html#concatenation-with-the--operator-or-the-format-macro
ch11-02-running-tests.html#controlling-how-tests-are-run
[derivable-traits]: appendix-03-derivable-traits.html
[doc-comments]: ch14-02-publishing-to-crates-io.html#documentation-comments-as-tests
[modules-as-privacy-boundary]: ch07-02-defining-modules-to-control-scope-and-privacy.html
[paths-for-referring-to-an-item-in-the-module-tree]: ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html

View File

@ -291,7 +291,7 @@ fn it_adds_two() {
```
Note that the `mod common;` declaration is the same as the module declaration
we demonstrated in Listing 7-25. Then in the test function, we can call the
we demonstrated in Listing 7-21. Then in the test function, we can call the
`common::setup()` function.
#### Integration Tests for Binary Crates

View File

@ -298,7 +298,7 @@ definition in `hello_macro`, well have to change the implementation of the
procedural macro in `hello_macro_derive` as well. The two crates will need to
be published separately, and programmers using these crates will need to add
both as dependencies and bring them both into scope. We could instead have the
`hello_macro` crate use `hello_macro_derive` as a dependency and reexport the
`hello_macro` crate use `hello_macro_derive` as a dependency and re-export the
procedural macro code. However, the way weve structured the project makes it
possible for programmers to use `hello_macro` even if they dont want the
`derive` functionality.

View File

@ -2,15 +2,14 @@
*by Steve Klabnik and Carol Nichols, with contributions from the Rust Community*
Welcome to *The Rust Programming Language* book! This version of the text assumes
youre using Rust 1.31.0 or later with `edition="2018"` in *Cargo.toml* of
all projects to use Rust 2018 Edition idioms. See the [“Installation” section
of Chapter 1][install]<!-- ignore --> to install or update Rust, and see the
new [Appendix E][editions]<!-- ignore --> for information on what editions of
Rust are.
This version of the text assumes youre using Rust 1.31.0 or later with
`edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition
idioms. See the [“Installation” section of Chapter 1][install]<!-- ignore -->
to install or update Rust, and see the new [Appendix E][editions]<!-- ignore
--> for information on editions.
The 2018 Edition of the Rust language includes a number of improvements that
make Rust more ergonomic and easier to learn. This printing of the book
make Rust more ergonomic and easier to learn. This iteration of the book
contains a number of changes to reflect those improvements:
- Chapter 7, “Managing Growing Projects with Packages, Crates, and Modules,”
@ -20,7 +19,7 @@ contains a number of changes to reflect those improvements:
Types that Implement Traits” that explain the new `impl Trait` syntax.
- Chapter 11 has a new section titled “Using `Result<T, E>` in Tests” that
shows how to write tests that use the `?` operator.
- The “Advanced Lifetimes” section of Chapter 19 was removed because compiler
- The “Advanced Lifetimes” section in Chapter 19 was removed because compiler
improvements have made the constructs in that section even rarer.
- The previous Appendix D, “Macros,” has been expanded to include procedural
macros and was moved to the “Macros” section in Chapter 19.
@ -31,7 +30,7 @@ contains a number of changes to reflect those improvements:
- We fixed a number of small errors and imprecise wording throughout the book.
Thank you to the readers who reported them!
Note that any code in the first printing of *The Rust Programming Language*
Note that any code in earlier iterations of *The Rust Programming Language*
that compiled will continue to compile without `edition="2018"` in the
projects *Cargo.toml*, even as you update the Rust compiler version youre
using. Thats Rusts backward compatibility guarantees at work!

View File

@ -2,9 +2,7 @@ language: rust
cache: cargo
rust: nightly
before_script:
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update)
- (test -x $HOME/.cargo/bin/mdbook || cargo install mdbook)
- cargo install-update -a
- cargo install mdbook -Z install-upgrade
- mdbook --version
script:
- mdbook build

View File

@ -1,6 +1,6 @@
# The Rust Edition Guide
[![Build Status](https://travis-ci.org/rust-lang-nursery/edition-guide.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/edition-guide)
[![Build Status](https://api.travis-ci.com/rust-lang-nursery/edition-guide.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/edition-guide)
This book explains the concept of "editions", major new eras in [Rust]'s
development. You can [read the book
@ -35,7 +35,7 @@ $ mdbook serve
```
This serves the book at http://localhost:3000, and rebuilds it on changes.
You can now view the book in your web browser. If you make changes to the book's source code,
You can now view the book in your web browser. If you make changes to the book's source code,
you should only need to refresh your browser to see them.
_Firefox:_

View File

@ -47,8 +47,8 @@ So how much speedup do you actually get? Like most performance related
questions, the answer is "it depends." Here are some very un-scientific
benchmarks at the time of writing.
| build | performance | check performance | speedup |
| use case | build performance | check performance | speedup |
|--------|-------------|-------------------|---------|
| initial compile | 11s | 5.6s | 1.96x |
| second compile (no changes) | 3s | 1.9s | 1.57x |
| third compile with small change | 5.8s | 3s | 1.93x |
| third compile with small change | 5.8s | 3s | 1.93x |

View File

@ -19,6 +19,8 @@ And then use it with
$ mdbook --help
```
## Cargo Extensions
As an example of extending Cargo, you can use the [`cargo-update`](https://crates.io/crates/cargo-update)
package. To install it:
@ -26,9 +28,5 @@ package. To install it:
$ cargo install cargo-update
```
This will allow you to use this command, which checks everything you've `cargo install`'d and
updates it to the latest version:
```console
$ cargo install-update -a
```
This will allow you to use `cargo install-update -a` command, which checks everything you've `cargo install`'d and
updates it to the latest version.

View File

@ -12,12 +12,12 @@ In Rust 2018, we have made a couple of changes to the macros-by-example syntax.
For example, consider the following Rust 2015 code:
```rust2018
```rust
macro_rules! foo {
($a:ident, $b:expr) => {
println!("{}", $a);
println!("{}", $b);
}
};
($a:ident) => {
println!("{}", $a);
}
@ -29,7 +29,7 @@ but you need a whole other matcher to represent this possibility. This is
annoying if your matchers are long. In Rust 2018, one can simply write the
following:
```rust2018
```rust
macro_rules! foo {
($a:ident $(, $b:expr)?) => {
println!("{}", $a);

View File

@ -169,10 +169,8 @@ mod submodule {
In Rust 2015, if you have a submodule:
```rust,ignore
/// foo.rs
/// or
/// foo/mod.rs
// This `mod` declaration looks for the `foo` module in
// `foo.rs` or `foo/mod.rs`.
mod foo;
```
@ -180,23 +178,43 @@ It can live in `foo.rs` or `foo/mod.rs`. If it has submodules of its own, it
*must* be `foo/mod.rs`. So a `bar` submodule of `foo` would live at
`foo/bar.rs`.
In Rust 2018, `mod.rs` is no longer needed.
```rust,ignore
/// foo.rs
/// foo/bar.rs
mod foo;
/// in foo.rs
mod bar;
```
`foo.rs` can just be `foo.rs`,
In Rust 2018 the restriction that a module with submodules must be named
`mod.rs` is lifted. `foo.rs` can just be `foo.rs`,
and the submodule is still `foo/bar.rs`. This eliminates the special
name, and if you have a bunch of files open in your editor, you can clearly
see their names, instead of having a bunch of tabs named `mod.rs`.
<table>
<thead>
<tr>
<th>Rust 2015</th>
<th>Rust 2018</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<pre>
.
├── lib.rs
└── foo/
   ├── mod.rs
   └── bar.rs
</pre>
</td>
<td>
<pre>
.
├── lib.rs
├── foo.rs
└── foo/
   └── bar.rs
</pre>
</td>
</tr>
</tbody>
</table>
### `use` paths
![Minimum Rust version: 1.32](https://img.shields.io/badge/Minimum%20Rust%20Version-1.32-brightgreen.svg)

View File

@ -16,11 +16,9 @@ struct StrWrap<'a>(&'a str);
In Rust 2015, you might have written:
```rust
// Rust 2015
use std::fmt;
# use std::fmt;
# struct StrWrap<'a>(&'a str);
// Rust 2015
fn make_wrapper(string: &str) -> StrWrap {
StrWrap(string)
@ -38,7 +36,6 @@ In Rust 2018, you can instead write:
```rust
# use std::fmt;
# struct StrWrap<'a>(&'a str);
// Rust 2018
fn make_wrapper(string: &str) -> StrWrap<'_> {

View File

@ -145,15 +145,7 @@ information to know more about the functions you're trying to call.
$ rustup component add rust-src
```
### The "preview" components
There are several components in a "preview" stage. These components currently
have `-preview` in their name, and this indicates that they're not quite 100%
ready for general consumption yet. Please try them out and give us feedback,
but know that they do not follow Rust's stability guarantees, and are still
actively changing, possibly in backwards-incompatible ways.
#### `rustfmt-preview` for automatic code formatting
### `rustfmt` for automatic code formatting
![Minimum Rust version: 1.24](https://img.shields.io/badge/Minimum%20Rust%20Version-1.24-brightgreen.svg)
@ -161,7 +153,7 @@ If you'd like to have your code automatically formatted, you can
install this component:
```console
$ rustup component add rustfmt-preview
$ rustup component add rustfmt
```
This will install two tools, `rustfmt` and `cargo-fmt`, that will reformat your
@ -173,7 +165,7 @@ $ cargo fmt
will reformat your entire Cargo project.
#### `rls-preview` for IDE integration
### `rls` for IDE integration
![Minimum Rust version: 1.21](https://img.shields.io/badge/Minimum%20Rust%20Version-1.21-brightgreen.svg)
@ -182,17 +174,18 @@ protocol](http://langserver.org/). To gain support for Rust with these IDEs,
you'll need to install the Rust language sever, aka the "RLS":
```console
$ rustup component add rls-preview
$ rustup component add rls
```
Your IDE should take it from there.
For more information about integrating this into your IDE, see the [RLS
documentation](https://github.com/rust-lang/rls).
#### `clippy-preview` for more lints
### `clippy` for more lints
For even more lints to help you write Rust code, you can install `clippy`:
```console
$ rustup component add clippy-preview
$ rustup component add clippy
```
This will install `cargo-clippy` for you:
@ -202,7 +195,15 @@ $ cargo clippy
```
For more, check out [clippy's
documentation](https://github.com/rust-lang-nursery/rust-clippy).
documentation](https://github.com/rust-lang/rust-clippy).
### The "preview" components
There are several components in a "preview" stage. These components currently
have `-preview` in their name, and this indicates that they're not quite 100%
ready for general consumption yet. Please try them out and give us feedback,
but know that they do not follow Rust's stability guarantees, and are still
actively changing, possibly in backwards-incompatible ways.
#### `llvm-tools-preview` for using extra LLVM tools

View File

@ -8,42 +8,43 @@ error message system was created.
For example, here's some code that produces an error:
```rust,ignore
```rust,compile_fail
fn main() {
let mut x = 5;
let y = &x;
x += 1;
println!("{} {}", x, y);
}
```
Here's the error in Rust 1.11:
```text
foo.rs:6:5: 6:11 error: cannot assign to `x` because it is borrowed [E0506]
foo.rs:6 x += 1;
foo.rs:4:5: 4:11 error: cannot assign to `x` because it is borrowed [E0506]
foo.rs:4 x += 1;
^~~~~~
foo.rs:4:14: 4:15 note: borrow of `x` occurs here
foo.rs:4 let y = &x;
foo.rs:3:14: 3:15 note: borrow of `x` occurs here
foo.rs:3 let y = &x;
^
foo.rs:6:5: 6:11 help: run `rustc --explain E0506` to see a detailed explanation
foo.rs:4:5: 4:11 help: run `rustc --explain E0506` to see a detailed explanation
error: aborting due to previous error
```
Here's the error in Rust 1.28:
```text
error[E0506]: cannot assign to `x` because it is borrowed
--> foo.rs:6:5
--> foo.rs:4:5
|
4 | let y = &x;
3 | let y = &x;
| - borrow of `x` occurs here
5 |
6 | x += 1;
4 | x += 1;
| ^^^^^^ assignment to borrowed `x` occurs here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0506`.
```
This error isn't terribly different, but shows off how the format has changed. It shows
off your code in context, rather than just showing the text of the lines themselves.
off your code in context, rather than just showing the text of the lines themselves.

View File

@ -512,6 +512,66 @@ Since we can't move the `GPIOA` out of the `&Option`, we need to convert it to
an `&Option<&GPIOA>` with `as_ref()`, which we can finally `unwrap()` to obtain
the `&GPIOA` which lets us modify the peripheral.
If we need a mutable references to shared resources, then `borrow_mut` and `deref_mut`
should be used instead. The following code shows an example using the TIM2 timer.
```rust,ignore
use core::cell::RefCell;
use core::ops::DerefMut;
use cortex_m::interrupt::{self, Mutex};
use cortex_m::asm::wfi;
use stm32f4::stm32f405;
static G_TIM: Mutex<RefCell<Option<Timer<stm32::TIM2>>>> =
Mutex::new(RefCell::new(None));
#[entry]
fn main() -> ! {
let mut cp = cm::Peripherals::take().unwrap();
let dp = stm32f405::Peripherals::take().unwrap();
// Some sort of timer configuration function.
// Assume it configures the TIM2 timer, its NVIC interrupt,
// and finally starts the timer.
let tim = configure_timer_interrupt(&mut cp, dp);
interrupt::free(|cs| {
G_TIM.borrow(cs).replace(Some(tim));
});
loop {
wfi();
}
}
#[interrupt]
fn timer() {
interrupt::free(|cs| {
if let Some(ref mut tim)) = G_TIM.borrow(cs).borrow_mut().deref_mut() {
tim.start(1.hz());
}
});
}
```
> **NOTE**
>
> At the moment, the `cortex-m` crate hides const versions of some functions
> (including `Mutex::new()`) behind the `const-fn` feature. So you need to add
> the `const-fn` feature as a dependency for cortex-m in the Cargo.toml to make
> the above examples work:
>
> ``` toml
> [dependencies.cortex-m]
> version="0.6.0"
> features=["const-fn"]
> ```
> Meanwhile, `const-fn` has been working on stable Rust for some time now.
> So this additional switch in Cargo.toml will not be needed as soon as
> it is enabled in `cortex-m` by default.
>
Whew! This is safe, but it is also a little unwieldy. Is there anything else
we can do?

View File

@ -84,8 +84,8 @@ Rather than manually generating these interfaces, which may be tedious and error
2. Write a `bindings.h` file, which `#include "..."`'s each of the files you gathered in step one
3. Feed this `bindings.h` file, along with any compilation flags used to compile
your code into `bindgen`. Tip: use `Builder.ctypes_prefix("cty")` /
`--ctypes-prefix=cty` to make the generated code `#![no_std]` compatible.
4. `bindgen` will produce the generated Rust code to the output of the terminal window. This file may be piped to a file in your project, such as `bindings.rs`. You may use this file in your Rust project to interact with C/C++ code compiled and linked as an external library
`--ctypes-prefix=cty` and `Builder.use_core()` to make the generated code `#![no_std]` compatible.
4. `bindgen` will produce the generated Rust code to the output of the terminal window. This file may be piped to a file in your project, such as `bindings.rs`. You may use this file in your Rust project to interact with C/C++ code compiled and linked as an external library. Tip: don't forget to use the [`cty`](https://crates.io/crates/cty) crate if your types in the generated bindings are prefixed with `cty`.
[bindgen]: https://github.com/rust-lang-nursery/rust-bindgen
[bindgen user's manual]: https://rust-lang.github.io/rust-bindgen/

View File

@ -45,7 +45,7 @@ The contents may not match exactly but you should get the last line about
breakpoints and watchpoints. If you got it then terminate the OpenOCD process
and move to the [next section].
[next section]: ../hardware.md
[next section]: ../../start/index.md
If you didn't get the "breakpoints" line then try the following command.

View File

@ -82,6 +82,7 @@ fn main() -> ! {
syst.set_clock_source(SystClkSource::Core);
// this is configured for the LM3S6965 which has a default CPU clock of 12 MHz
syst.set_reload(12_000_000);
syst.clear_current();
syst.enable_counter();
syst.enable_interrupt();

View File

@ -6,11 +6,11 @@ Nicknamed "the Nomicon."
## NOTE: This is a draft document, and may contain serious errors
> Instead of the programs I had hoped for, there came only a shuddering blackness
and ineffable loneliness; and I saw at last a fearful truth which no one had
ever dared to breathe before — the unwhisperable secret of secrets — The fact
that this language of stone and stridor is not a sentient perpetuation of Rust
as London is of Old London and Paris of Old Paris, but that it is in fact
> Instead of the programs I had hoped for, there came only a shuddering
blackness and ineffable loneliness; and I saw at last a fearful truth which no
one had ever dared to breathe before — the unwhisperable secret of secrets — The
fact that this language of stone and stridor is not a sentient perpetuation of
Rust as London is of Old London and Paris of Old Paris, but that it is in fact
quite unsafe, its sprawling body imperfectly embalmed and infested with queer
animate things which have nothing to do with it as it was in compilation.
@ -23,40 +23,30 @@ infinitesimal fragments of despair.
Building the Nomicon requires [mdBook]. To get it:
[mdBook]: https://github.com/azerupi/mdBook
[mdBook]: https://github.com/rust-lang-nursery/mdBook
```bash
$ cargo install mdbook
```
### Building
### `mdbook` usage
To build the Nomicon:
To build the Nomicon use the `build` sub-command:
```bash
$ mdbook build
```
The output will be in the `book` subdirectory. To check it out, open it in
your web browser.
The output will be placed in the `book` subdirectory. To check it out, open the
`index.html` file in your web browser. You can pass the `--open` flag to `mdbook
build` and it'll open the index page in your default browser (if the process is
successful) just like with `cargo doc --open`:
_Firefox:_
```bash
$ firefox book/index.html # Linux
$ open -a "Firefox" book/index.html # OS X
$ Start-Process "firefox.exe" .\book\index.html # Windows (PowerShell)
$ start firefox.exe .\book\index.html # Windows (Cmd)
$ mdbook build --open
```
_Chrome:_
```bash
$ google-chrome book/index.html # Linux
$ open -a "Google Chrome" book/index.html # OS X
$ Start-Process "chrome.exe" .\book\index.html # Windows (PowerShell)
$ start chrome.exe .\book\index.html # Windows (Cmd)
```
To run the tests:
There is also a `test` sub-command to test all code samples contained in the book:
```bash
$ mdbook test
@ -64,7 +54,8 @@ $ mdbook test
## Contributing
Given that the Nomicon is still in a draft state, we'd love your help! Please feel free to open
issues about anything, and send in PRs for things you'd like to fix or change. If your change is
large, please open an issue first, so we can make sure that it's something we'd accept before you
go through the work of getting a PR together.
Given that the Nomicon is still in a draft state, we'd love your help! Please
feel free to open issues about anything, and send in PRs for things you'd like
to fix or change. If your change is large, please open an issue first, so we can
make sure that it's something we'd accept before you go through the work of
getting a PR together.

View File

@ -17,7 +17,7 @@ language — this book contains lots of useful information.
Unlike *[The Rust Programming Language][trpl]*, we will be assuming considerable
prior knowledge. In particular, you should be comfortable with basic systems
programming and Rust. If you don't feel comfortable with these topics, you
should consider [reading The Book][trpl] first. That said, we won't assume you
should consider reading [The Book][trpl] first. That said, we won't assume you
have read it, and we will take care to occasionally give a refresher on the
basics where appropriate. You can skip straight to this book if you want;
just know that we won't be explaining everything from the ground up.

View File

@ -25,7 +25,7 @@ let y;
There are some more complex situations which are not possible to desugar using
scopes, but the order is still defined variables are dropped in the reverse
order of their definition, fields of structs and tuples in order of their
definition. There are some more details about order of drop in [rfc1875].
definition. There are some more details about order of drop in [RFC 1857][rfc1857].
Let's do this:

View File

@ -80,7 +80,6 @@ This will eventually get fixed.
```rust,edition2018,compile_fail
# use std::collections::HashMap;
# use std::cmp::Eq;
# use std::hash::Hash;
fn get_default<'m, K, V>(map: &'m mut HashMap<K, V>, key: K) -> &'m mut V
where

View File

@ -4,7 +4,7 @@ Get out of our way type system! We're going to reinterpret these bits or die
trying! Even though this book is all about doing things that are unsafe, I
really can't emphasize that you should deeply think about finding Another Way
than the operations covered in this section. This is really, truly, the most
horribly unsafe thing you can do in Rust. The railguards here are dental floss.
horribly unsafe thing you can do in Rust. The guardrails here are dental floss.
[`mem::transmute<T, U>`][transmute] takes a value of type `T` and reinterprets
it to have type `U`. The only restriction is that the `T` and `U` are verified

View File

@ -4,7 +4,7 @@ rust:
- nightly
install:
- travis_retry curl -Lf https://github.com/rust-lang-nursery/mdBook/releases/download/v0.1.7/mdbook-v0.1.7-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=$HOME/.cargo/bin
- travis_retry curl -Lf https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdbook-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=$HOME/.cargo/bin
script:
- export PATH=$PATH:/home/travis/.cargo/bin && mdbook test

View File

@ -4,5 +4,5 @@ title = "The Rust Reference"
author = "The Rust Project Developers"
[output.html]
additional-css = ["src/theme/reference.css"]
additional-css = ["theme/reference.css"]
git-repository-url = "https://github.com/rust-lang-nursery/reference/"

View File

@ -85,11 +85,11 @@ to specify the symbol name.
pub fn name_in_rust() { }
```
[_MetaNameValueStr_]: attributes.html#meta-item-attribute-syntax
[`static` items]: items/static-items.html
[attribute]: attributes.html
[extern functions]: items/functions.html#extern-functions
[external blocks]: items/external-blocks.html
[function]: items/functions.html
[item]: items.html
[static]: items/static-items.html
[_MetaNameValueStr_]: attributes.md#meta-item-attribute-syntax
[`static` items]: items/static-items.md
[attribute]: attributes.md
[extern functions]: items/functions.md#extern-functions
[external blocks]: items/external-blocks.md
[function]: items/functions.md
[item]: items.md
[static]: items/static-items.md

View File

@ -237,72 +237,72 @@ The following is an index of all built-in attributes.
- `feature` — Used to enable unstable or experimental compiler features. See
[The Unstable Book] for features implemented in `rustc`.
[Doc comments]: comments.html#doc-comments
[Doc comments]: comments.md#doc-comments
[ECMA-334]: https://www.ecma-international.org/publications/standards/Ecma-334.htm
[ECMA-335]: https://www.ecma-international.org/publications/standards/Ecma-335.htm
[Expression Attributes]: expressions.html#expression-attributes
[IDENTIFIER]: identifiers.html
[RAW_STRING_LITERAL]: tokens.html#raw-string-literals
[STRING_LITERAL]: tokens.html#string-literals
[Expression Attributes]: expressions.md#expression-attributes
[IDENTIFIER]: identifiers.md
[RAW_STRING_LITERAL]: tokens.md#raw-string-literals
[STRING_LITERAL]: tokens.md#string-literals
[The Rustdoc Book]: ../rustdoc/the-doc-attribute.html
[The Unstable Book]: ../unstable-book/index.html
[_DelimTokenTree_]: macros.html
[_LiteralExpression_]: expressions/literal-expr.html
[_SimplePath_]: paths.html#simple-paths
[`allow`]: attributes/diagnostics.html#lint-check-attributes
[`cfg_attr`]: conditional-compilation.html#the-cfg_attr-attribute
[`cfg`]: conditional-compilation.html#the-cfg-attribute
[`cold`]: attributes/codegen.html#the-cold-attribute
[`crate_name`]: crates-and-source-files.html#the-crate_name-attribute
[`crate_type`]: linkage.html
[`deny`]: attributes/diagnostics.html#lint-check-attributes
[`deprecated`]: attributes/diagnostics.html#the-deprecated-attribute
[`derive`]: attributes/derive.html
[`export_name`]: abi.html#the-export_name-attribute
[`forbid`]: attributes/diagnostics.html#lint-check-attributes
[`global_allocator`]: runtime.html#the-global_allocator-attribute
[`ignore`]: attributes/testing.html#the-ignore-attribute
[`inline`]: attributes/codegen.html#the-inline-attribute
[`link_name`]: items/external-blocks.html#the-link_name-attribute
[`link_section`]: abi.html#the-link_section-attribute
[`link`]: items/external-blocks.html#the-link-attribute
[`macro_export`]: macros-by-example.html#path-based-scope
[`macro_use`]: macros-by-example.html#the-macro_use-attribute
[`meta` macro fragment specifier]: macros-by-example.html
[`must_use`]: attributes/diagnostics.html#the-must_use-attribute
[`no_builtins`]: attributes/codegen.html#the-no_builtins-attribute
[`no_implicit_prelude`]: items/modules.html#prelude-items
[`no_link`]: items/extern-crates.html#the-no_link-attribute
[`no_main`]: crates-and-source-files.html#the-no_main-attribute
[`no_mangle`]: abi.html#the-no_mangle-attribute
[`no_std`]: crates-and-source-files.html#preludes-and-no_std
[`panic_handler`]: runtime.html#the-panic_handler-attribute
[`path`]: items/modules.html#the-path-attribute
[`proc_macro_attribute`]: procedural-macros.html#attribute-macros
[`proc_macro_derive`]: procedural-macros.html#derive-macros
[`proc_macro`]: procedural-macros.html#function-like-procedural-macros
[`recursion_limit`]: attributes/limits.html#the-recursion_limit-attribute
[`repr`]: type-layout.html#representations
[`should_panic`]: attributes/testing.html#the-should_panic-attribute
[`target_feature`]: attributes/codegen.html#the-target_feature-attribute
[`test`]: attributes/testing.html#the-test-attribute
[`type_length_limit`]: attributes/limits.html#the-type_length_limit-attribute
[`used`]: abi.html#the-used-attribute
[`warn`]: attributes/diagnostics.html#lint-check-attributes
[`windows_subsystem`]: runtime.html#the-windows_subsystem-attribute
[attribute macros]: procedural-macros.html#attribute-macros
[block expressions]: expressions/block-expr.html
[_DelimTokenTree_]: macros.md
[_LiteralExpression_]: expressions/literal-expr.md
[_SimplePath_]: paths.md#simple-paths
[`allow`]: attributes/diagnostics.md#lint-check-attributes
[`cfg_attr`]: conditional-compilation.md#the-cfg_attr-attribute
[`cfg`]: conditional-compilation.md#the-cfg-attribute
[`cold`]: attributes/codegen.md#the-cold-attribute
[`crate_name`]: crates-and-source-files.md#the-crate_name-attribute
[`crate_type`]: linkage.md
[`deny`]: attributes/diagnostics.md#lint-check-attributes
[`deprecated`]: attributes/diagnostics.md#the-deprecated-attribute
[`derive`]: attributes/derive.md
[`export_name`]: abi.md#the-export_name-attribute
[`forbid`]: attributes/diagnostics.md#lint-check-attributes
[`global_allocator`]: runtime.md#the-global_allocator-attribute
[`ignore`]: attributes/testing.md#the-ignore-attribute
[`inline`]: attributes/codegen.md#the-inline-attribute
[`link_name`]: items/external-blocks.md#the-link_name-attribute
[`link_section`]: abi.md#the-link_section-attribute
[`link`]: items/external-blocks.md#the-link-attribute
[`macro_export`]: macros-by-example.md#path-based-scope
[`macro_use`]: macros-by-example.md#the-macro_use-attribute
[`meta` macro fragment specifier]: macros-by-example.md
[`must_use`]: attributes/diagnostics.md#the-must_use-attribute
[`no_builtins`]: attributes/codegen.md#the-no_builtins-attribute
[`no_implicit_prelude`]: items/modules.md#prelude-items
[`no_link`]: items/extern-crates.md#the-no_link-attribute
[`no_main`]: crates-and-source-files.md#the-no_main-attribute
[`no_mangle`]: abi.md#the-no_mangle-attribute
[`no_std`]: crates-and-source-files.md#preludes-and-no_std
[`panic_handler`]: runtime.md#the-panic_handler-attribute
[`path`]: items/modules.md#the-path-attribute
[`proc_macro_attribute`]: procedural-macros.md#attribute-macros
[`proc_macro_derive`]: procedural-macros.md#derive-macros
[`proc_macro`]: procedural-macros.md#function-like-procedural-macros
[`recursion_limit`]: attributes/limits.md#the-recursion_limit-attribute
[`repr`]: type-layout.md#representations
[`should_panic`]: attributes/testing.md#the-should_panic-attribute
[`target_feature`]: attributes/codegen.md#the-target_feature-attribute
[`test`]: attributes/testing.md#the-test-attribute
[`type_length_limit`]: attributes/limits.md#the-type_length_limit-attribute
[`used`]: abi.md#the-used-attribute
[`warn`]: attributes/diagnostics.md#lint-check-attributes
[`windows_subsystem`]: runtime.md#the-windows_subsystem-attribute
[attribute macros]: procedural-macros.md#attribute-macros
[block expressions]: expressions/block-expr.md
[built-in attributes]: #built-in-attributes-index
[derive macro helper attributes]: procedural-macros.html#derive-macro-helper-attributes
[enum]: items/enumerations.html
[expression statement]: statements.html#expression-statements
[external blocks]: items/external-blocks.html
[functions]: items/functions.html
[generics]: items/generics.html
[implementations]: items/implementations.html
[item declarations]: items.html
[match expressions]: expressions/match-expr.html
[modules]: items/modules.html
[statements]: statements.html
[struct]: items/structs.html
[union]: items/unions.html
[derive macro helper attributes]: procedural-macros.md#derive-macro-helper-attributes
[enum]: items/enumerations.md
[expression statement]: statements.md#expression-statements
[external blocks]: items/external-blocks.md
[functions]: items/functions.md
[generics]: items/generics.md
[implementations]: items/implementations.md
[item declarations]: items.md
[match expressions]: expressions/match-expr.md
[modules]: items/modules.md
[statements]: statements.md
[struct]: items/structs.md
[union]: items/unions.md

View File

@ -139,15 +139,15 @@ feature detection on the x86 platforms.
> may be enabled or disabled for an entire crate with the
> [`-C target-feature`] flag.
[_MetaListNameValueStr_]: attributes.html#meta-item-attribute-syntax
[`-C target-cpu`]: ../rustc/codegen-options/index.html#target-cpu
[`-C target-feature`]: ../rustc/codegen-options/index.html#target-feature
[`is_x86_feature_detected`]: ../std/macro.is_x86_feature_detected.html
[`target_feature` conditional compilation option]: conditional-compilation.html#target_feature
[attribute]: attributes.html
[attributes]: attributes.html
[functions]: items/functions.html
[target architecture]: conditional-compilation.html#target_arch
[trait]: items/traits.html
[undefined behavior]: behavior-considered-undefined.html
[unsafe function]: unsafe-functions.html
[_MetaListNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
[`-C target-cpu`]: ../../rustc/codegen-options/index.html#target-cpu
[`-C target-feature`]: ../../rustc/codegen-options/index.html#target-feature
[`is_x86_feature_detected`]: ../../std/macro.is_x86_feature_detected.html
[`target_feature` conditional compilation option]: ../conditional-compilation.md#target_feature
[attribute]: ../attributes.md
[attributes]: ../attributes.md
[functions]: ../items/functions.md
[target architecture]: ../conditional-compilation.md#target_arch
[trait]: ../items/traits.md
[undefined behavior]: ../behavior-considered-undefined.md
[unsafe function]: ../unsafe-functions.md

Some files were not shown because too many files have changed in this diff Show More