Skip to content

Commit 4c853ad

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents d9d8772 + c4cca3a commit 4c853ad

File tree

362 files changed

+7947
-4155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

362 files changed

+7947
-4155
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ version.texi
103103
.cargo
104104
!src/vendor/**
105105
/src/target/
106+
107+
no_llvm_build
108+

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ For people new to Rust, and just starting to contribute, or even for
461461
more seasoned developers, some useful places to look for information
462462
are:
463463

464+
* [Rust Forge][rustforge] contains additional documentation, including write-ups of how to achieve common tasks
464465
* The [Rust Internals forum][rif], a place to ask questions and
465466
discuss Rust's internals
466467
* The [generated documentation for rust's compiler][gdfrustc]
@@ -476,6 +477,7 @@ are:
476477
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
477478
[rif]: http://internals.rust-lang.org
478479
[rr]: https://doc.rust-lang.org/book/README.html
480+
[rustforge]: https://forge.rust-lang.org/
479481
[tlgba]: http://tomlee.co/2014/04/a-more-detailed-tour-of-the-rust-compiler/
480482
[ro]: http://www.rustaceans.org/
481483
[rctd]: ./src/test/COMPILER_TESTS.md

src/Cargo.lock

+238-211
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ members = [
3838
"tools/rls/test_data/infer_custom_bin",
3939
"tools/rls/test_data/infer_lib",
4040
"tools/rls/test_data/omit_init_build",
41+
"tools/rls/test_data/unicødë",
42+
"tools/rls/test_data/workspace_symbol",
4143
]
4244

4345
# Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit
@@ -60,10 +62,5 @@ debug-assertions = false
6062
[patch."https://github.com/rust-lang/cargo"]
6163
cargo = { path = "tools/cargo" }
6264

63-
# Override rustfmt dependencies both on the repo and the crate (the RLS
64-
# sometimes uses either).
65-
# FIXME should only need the crates.io patch, long term.
66-
[patch."https://github.com/rust-lang-nursery/rustfmt"]
67-
rustfmt-nightly = { path = "tools/rustfmt" }
6865
[patch.crates-io]
6966
rustfmt-nightly = { path = "tools/rustfmt" }

src/bootstrap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cmake = "0.1.23"
3434
filetime = "0.1"
3535
num_cpus = "1.0"
3636
getopts = "0.2"
37-
gcc = "0.3.54"
37+
cc = "1.0"
3838
libc = "0.2"
3939
serde = "1.0.8"
4040
serde_derive = "1.0.8"

src/bootstrap/bin/sccache-plus-cl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
extern crate gcc;
11+
extern crate cc;
1212

1313
use std::env;
1414
use std::process::{self, Command};
@@ -18,7 +18,7 @@ fn main() {
1818
// Locate the actual compiler that we're invoking
1919
env::remove_var("CC");
2020
env::remove_var("CXX");
21-
let mut cfg = gcc::Build::new();
21+
let mut cfg = cc::Build::new();
2222
cfg.cargo_metadata(false)
2323
.out_dir("/")
2424
.target(&target)

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def bootstrap():
682682
try:
683683
with open(args.config or 'config.toml') as config:
684684
build.config_toml = config.read()
685-
except OSError:
685+
except (OSError, IOError):
686686
pass
687687

688688
if '\nverbose = 2' in build.config_toml:

src/bootstrap/builder.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'a> Builder<'a> {
306306
Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]),
307307
Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),
308308
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
309-
Subcommand::Clean => panic!(),
309+
Subcommand::Clean { .. } => panic!(),
310310
};
311311

312312
let builder = Builder {
@@ -531,7 +531,10 @@ impl<'a> Builder<'a> {
531531
// For other crates, however, we know that we've already got a standard
532532
// library up and running, so we can use the normal compiler to compile
533533
// build scripts in that situation.
534-
if mode == Mode::Libstd {
534+
//
535+
// If LLVM support is disabled we need to use the snapshot compiler to compile
536+
// build scripts, as the new compiler doesnt support executables.
537+
if mode == Mode::Libstd || !self.build.config.llvm_enabled {
535538
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
536539
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
537540
} else {

src/bootstrap/cc.rs renamed to src/bootstrap/cc_detect.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! 6. "cc"
2424
//!
2525
//! Some of this logic is implemented here, but much of it is farmed out to the
26-
//! `gcc` crate itself, so we end up having the same fallbacks as there.
26+
//! `cc` crate itself, so we end up having the same fallbacks as there.
2727
//! Similar logic is then used to find a C++ compiler, just some s/cc/c++/ is
2828
//! used.
2929
//!
@@ -35,7 +35,7 @@ use std::process::Command;
3535
use std::iter;
3636

3737
use build_helper::{cc2ar, output};
38-
use gcc;
38+
use cc;
3939

4040
use Build;
4141
use config::Target;
@@ -45,7 +45,7 @@ pub fn find(build: &mut Build) {
4545
// For all targets we're going to need a C compiler for building some shims
4646
// and such as well as for being a linker for Rust code.
4747
for target in build.targets.iter().chain(&build.hosts).cloned().chain(iter::once(build.build)) {
48-
let mut cfg = gcc::Build::new();
48+
let mut cfg = cc::Build::new();
4949
cfg.cargo_metadata(false).opt_level(0).warnings(false).debug(false)
5050
.target(&target).host(&build.build);
5151

@@ -67,7 +67,7 @@ pub fn find(build: &mut Build) {
6767

6868
// For all host triples we need to find a C++ compiler as well
6969
for host in build.hosts.iter().cloned().chain(iter::once(build.build)) {
70-
let mut cfg = gcc::Build::new();
70+
let mut cfg = cc::Build::new();
7171
cfg.cargo_metadata(false).opt_level(0).warnings(false).debug(false).cpp(true)
7272
.target(&host).host(&build.build);
7373
let config = build.config.target_config.get(&host);
@@ -82,7 +82,7 @@ pub fn find(build: &mut Build) {
8282
}
8383
}
8484

85-
fn set_compiler(cfg: &mut gcc::Build,
85+
fn set_compiler(cfg: &mut cc::Build,
8686
gnu_compiler: &str,
8787
target: Interned<String>,
8888
config: Option<&Target>,

src/bootstrap/check.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ impl Step for Rls {
254254

255255
builder.add_rustc_lib_path(compiler, &mut cargo);
256256

257-
try_run(build, &mut cargo);
257+
try_run_expecting(
258+
build,
259+
&mut cargo,
260+
builder.build.config.toolstate.rls.passes(ToolState::Testing),
261+
);
258262
}
259263
}
260264

@@ -295,7 +299,11 @@ impl Step for Rustfmt {
295299

296300
builder.add_rustc_lib_path(compiler, &mut cargo);
297301

298-
try_run(build, &mut cargo);
302+
try_run_expecting(
303+
build,
304+
&mut cargo,
305+
builder.build.config.toolstate.rustfmt.passes(ToolState::Testing),
306+
);
299307
}
300308
}
301309

src/bootstrap/clean.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,37 @@
1313
//! Responsible for cleaning out a build directory of all old and stale
1414
//! artifacts to prepare for a fresh build. Currently doesn't remove the
1515
//! `build/cache` directory (download cache) or the `build/$target/llvm`
16-
//! directory as we want that cached between builds.
16+
//! directory unless the --all flag is present.
1717
1818
use std::fs;
1919
use std::io::{self, ErrorKind};
2020
use std::path::Path;
2121

2222
use Build;
2323

24-
pub fn clean(build: &Build) {
24+
pub fn clean(build: &Build, all: bool) {
2525
rm_rf("tmp".as_ref());
26-
rm_rf(&build.out.join("tmp"));
27-
rm_rf(&build.out.join("dist"));
2826

29-
for host in &build.hosts {
30-
let entries = match build.out.join(host).read_dir() {
31-
Ok(iter) => iter,
32-
Err(_) => continue,
33-
};
27+
if all {
28+
rm_rf(&build.out);
29+
} else {
30+
rm_rf(&build.out.join("tmp"));
31+
rm_rf(&build.out.join("dist"));
3432

35-
for entry in entries {
36-
let entry = t!(entry);
37-
if entry.file_name().to_str() == Some("llvm") {
38-
continue
33+
for host in &build.hosts {
34+
let entries = match build.out.join(host).read_dir() {
35+
Ok(iter) => iter,
36+
Err(_) => continue,
37+
};
38+
39+
for entry in entries {
40+
let entry = t!(entry);
41+
if entry.file_name().to_str() == Some("llvm") {
42+
continue
43+
}
44+
let path = t!(entry.path().canonicalize());
45+
rm_rf(&path);
3946
}
40-
let path = t!(entry.path().canonicalize());
41-
rm_rf(&path);
4247
}
4348
}
4449
}

src/bootstrap/configure.py

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def v(*args):
109109
"arm-unknown-linux-musleabihf install directory")
110110
v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root",
111111
"armv7-unknown-linux-musleabihf install directory")
112+
v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root",
113+
"aarch64-unknown-linux-musl install directory")
112114
v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs",
113115
"rootfs in qemu testing, you probably don't want to use this")
114116
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",

src/bootstrap/dist.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1098,13 +1098,8 @@ impl Step for Rls {
10981098
.arg("--output-dir").arg(&distdir(build))
10991099
.arg("--non-installed-overlay").arg(&overlay)
11001100
.arg(format!("--package-name={}-{}", name, target))
1101-
.arg("--legacy-manifest-dirs=rustlib,cargo");
1102-
1103-
if build.config.channel == "nightly" {
1104-
cmd.arg("--component-name=rls");
1105-
} else {
1106-
cmd.arg("--component-name=rls-preview");
1107-
}
1101+
.arg("--legacy-manifest-dirs=rustlib,cargo")
1102+
.arg("--component-name=rls-preview");
11081103

11091104
build.run(&mut cmd);
11101105
distdir(build).join(format!("{}-{}.tar.gz", name, target))
@@ -1333,12 +1328,8 @@ impl Step for Extended {
13331328
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-std"), target))
13341329
.join(format!("rust-std-{}", target)),
13351330
&exe.join("rust-std"));
1336-
let rls_path = if build.config.channel == "nightly" {
1337-
work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls")
1338-
} else {
1339-
work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls-preview")
1340-
};
1341-
cp_r(&rls_path, &exe.join("rls"));
1331+
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls-preview"),
1332+
&exe.join("rls"));
13421333
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target))
13431334
.join(format!("rust-analysis-{}", target)),
13441335
&exe.join("rust-analysis"));

src/bootstrap/flags.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ pub enum Subcommand {
6060
paths: Vec<PathBuf>,
6161
test_args: Vec<String>,
6262
},
63-
Clean,
63+
Clean {
64+
all: bool,
65+
},
6466
Dist {
6567
paths: Vec<PathBuf>,
6668
},
@@ -147,6 +149,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
147149
opts.optmulti("", "test-args", "extra arguments", "ARGS");
148150
},
149151
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
152+
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
150153
_ => { },
151154
};
152155

@@ -250,17 +253,18 @@ Arguments:
250253
}
251254
});
252255

253-
// All subcommands can have an optional "Available paths" section
256+
// All subcommands except `clean` can have an optional "Available paths" section
254257
if matches.opt_present("verbose") {
255258
let config = Config::parse(&["build".to_string()]);
256259
let mut build = Build::new(config);
257260
metadata::build(&mut build);
258261

259262
let maybe_rules_help = Builder::get_help(&build, subcommand.as_str());
260263
extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str());
261-
} else {
262-
extra_help.push_str(format!("Run `./x.py {} -h -v` to see a list of available paths.",
263-
subcommand).as_str());
264+
} else if subcommand.as_str() != "clean" {
265+
extra_help.push_str(format!(
266+
"Run `./x.py {} -h -v` to see a list of available paths.",
267+
subcommand).as_str());
264268
}
265269

266270
// User passed in -h/--help?
@@ -290,10 +294,13 @@ Arguments:
290294
}
291295
"clean" => {
292296
if paths.len() > 0 {
293-
println!("\nclean takes no arguments\n");
297+
println!("\nclean does not take a path argument\n");
294298
usage(1, &opts, &subcommand_help, &extra_help);
295299
}
296-
Subcommand::Clean
300+
301+
Subcommand::Clean {
302+
all: matches.opt_present("all"),
303+
}
297304
}
298305
"dist" => {
299306
Subcommand::Dist {

src/bootstrap/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ extern crate lazy_static;
126126
extern crate serde_json;
127127
extern crate cmake;
128128
extern crate filetime;
129-
extern crate gcc;
129+
extern crate cc;
130130
extern crate getopts;
131131
extern crate num_cpus;
132132
extern crate toml;
@@ -148,7 +148,7 @@ use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppresse
148148

149149
use util::{exe, libdir, OutputFolder, CiEnv};
150150

151-
mod cc;
151+
mod cc_detect;
152152
mod channel;
153153
mod check;
154154
mod clean;
@@ -241,9 +241,9 @@ pub struct Build {
241241

242242
// Runtime state filled in later on
243243
// target -> (cc, ar)
244-
cc: HashMap<Interned<String>, (gcc::Tool, Option<PathBuf>)>,
244+
cc: HashMap<Interned<String>, (cc::Tool, Option<PathBuf>)>,
245245
// host -> (cc, ar)
246-
cxx: HashMap<Interned<String>, gcc::Tool>,
246+
cxx: HashMap<Interned<String>, cc::Tool>,
247247
crates: HashMap<Interned<String>, Crate>,
248248
is_sudo: bool,
249249
ci_env: CiEnv,
@@ -345,12 +345,12 @@ impl Build {
345345
job::setup(self);
346346
}
347347

348-
if let Subcommand::Clean = self.config.cmd {
349-
return clean::clean(self);
348+
if let Subcommand::Clean { all } = self.config.cmd {
349+
return clean::clean(self, all);
350350
}
351351

352352
self.verbose("finding compilers");
353-
cc::find(self);
353+
cc_detect::find(self);
354354
self.verbose("running sanity check");
355355
sanity::check(self);
356356
// If local-rust is the same major.minor as the current version, then force a local-rebuild
@@ -619,7 +619,7 @@ impl Build {
619619
/// specified.
620620
fn cflags(&self, target: Interned<String>) -> Vec<String> {
621621
// Filter out -O and /O (the optimization flags) that we picked up from
622-
// gcc-rs because the build scripts will determine that for themselves.
622+
// cc-rs because the build scripts will determine that for themselves.
623623
let mut base = self.cc[&target].0.args().iter()
624624
.map(|s| s.to_string_lossy().into_owned())
625625
.filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))

0 commit comments

Comments
 (0)