Skip to content

Commit c4e858e

Browse files
author
Seiichi Uchida
authored
Merge branch 'master' into master
2 parents cd7b0fc + 1572bf1 commit c4e858e

File tree

172 files changed

+2005
-820
lines changed

Some content is hidden

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

172 files changed

+2005
-820
lines changed

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ matrix:
4545
os: osx
4646
osx_image: xcode8.2
4747
install: &osx_install_sccache >
48-
curl -L https://api.pub.build.mozilla.org/tooltool/sha512/d0025b286468cc5ada83b23d3fafbc936b9f190eaa7d4a981715b18e8e3bf720a7bcee7bfe758cfdeb8268857f6098fd52dcdd8818232692a30ce91039936596 |
49-
tar xJf - -C /usr/local/bin --strip-components=1
48+
curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
49+
chmod +x /usr/local/bin/sccache
5050
- env: >
5151
RUST_CHECK_TARGET=check
5252
RUST_CONFIGURE_ARGS=--build=i686-apple-darwin
@@ -63,8 +63,10 @@ matrix:
6363
os: osx
6464
osx_image: xcode8.2
6565
install: >
66-
curl -L https://api.pub.build.mozilla.org/tooltool/sha512/d0025b286468cc5ada83b23d3fafbc936b9f190eaa7d4a981715b18e8e3bf720a7bcee7bfe758cfdeb8268857f6098fd52dcdd8818232692a30ce91039936596 |
67-
tar xJf - -C /usr/local/bin --strip-components=1 && brew uninstall --ignore-dependencies openssl && brew install openssl --universal --without-test
66+
curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
67+
chmod +x /usr/local/bin/sccache &&
68+
brew uninstall --ignore-dependencies openssl &&
69+
brew install openssl --universal --without-test
6870
- env: >
6971
RUST_CHECK_TARGET=dist
7072
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended"

appveyor.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,9 @@ install:
115115
- set PATH=C:\Python27;%PATH%
116116

117117
# Download and install sccache
118-
- appveyor DownloadFile https://api.pub.build.mozilla.org/tooltool/sha512/%SCCACHE_DIGEST%
119-
- mv %SCCACHE_DIGEST% sccache.tar.bz2
120-
- 7z x -y sccache.tar.bz2 > nul
121-
- 7z x -y sccache.tar > nul
122-
- set PATH=%PATH%;%CD%\sccache2
118+
- appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-pc-windows-msvc
119+
- mv 2017-02-24-sccache-x86_64-pc-windows-msvc sccache
120+
- set PATH=%PATH%;%CD%
123121

124122
# Install InnoSetup to get `iscc` used to produce installers
125123
- choco install -y InnoSetup

src/Cargo.lock

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

src/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
members = [
33
"bootstrap",
44
"rustc",
5-
"rustc/std_shim",
6-
"rustc/test_shim",
5+
"libstd",
6+
"libtest",
77
"tools/cargotest",
88
"tools/compiletest",
99
"tools/error_index_generator",

src/bootstrap/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ build/
267267
The current build is unfortunately not quite as simple as `cargo build` in a
268268
directory, but rather the compiler is split into three different Cargo projects:
269269

270-
* `src/rustc/std_shim` - a project which builds and compiles libstd
271-
* `src/rustc/test_shim` - a project which builds and compiles libtest
270+
* `src/libstd` - the standard library
271+
* `src/libtest` - testing support, depends on libstd
272272
* `src/rustc` - the actual compiler itself
273273

274274
Each "project" has a corresponding Cargo.lock file with all dependencies, and

src/bootstrap/bin/rustc.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn main() {
6868
};
6969
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
7070
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
71+
let mut on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
7172

7273
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
7374
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
@@ -217,9 +218,20 @@ fn main() {
217218
}
218219

219220
// Actually run the compiler!
220-
std::process::exit(match exec_cmd(&mut cmd) {
221-
Ok(s) => s.code().unwrap_or(0xfe),
222-
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
221+
std::process::exit(if let Some(ref mut on_fail) = on_fail {
222+
match cmd.status() {
223+
Ok(s) if s.success() => 0,
224+
_ => {
225+
println!("\nDid not run successfully:\n{:?}\n-------------", cmd);
226+
exec_cmd(on_fail).expect("could not run the backup command");
227+
1
228+
}
229+
}
230+
} else {
231+
std::process::exit(match exec_cmd(&mut cmd) {
232+
Ok(s) => s.code().unwrap_or(0xfe),
233+
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
234+
})
223235
})
224236
}
225237

src/bootstrap/bootstrap.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,33 @@ def delete_if_present(path, verbose):
5959

6060

6161
def download(path, url, probably_big, verbose):
62+
for x in range(0, 4):
63+
try:
64+
_download(path, url, probably_big, verbose, True)
65+
return
66+
except RuntimeError:
67+
print("\nspurious failure, trying again")
68+
_download(path, url, probably_big, verbose, False)
69+
70+
71+
def _download(path, url, probably_big, verbose, exception):
6272
if probably_big or verbose:
6373
print("downloading {}".format(url))
6474
# see http://serverfault.com/questions/301128/how-to-download
6575
if sys.platform == 'win32':
6676
run(["PowerShell.exe", "/nologo", "-Command",
6777
"(New-Object System.Net.WebClient)"
6878
".DownloadFile('{}', '{}')".format(url, path)],
69-
verbose=verbose)
79+
verbose=verbose,
80+
exception=exception)
7081
else:
7182
if probably_big or verbose:
7283
option = "-#"
7384
else:
7485
option = "-s"
75-
run(["curl", option, "--retry", "3", "-Sf", "-o", path, url], verbose=verbose)
86+
run(["curl", option, "--retry", "3", "-Sf", "-o", path, url],
87+
verbose=verbose,
88+
exception=exception)
7689

7790

7891
def verify(path, sha_path, verbose):
@@ -112,7 +125,7 @@ def unpack(tarball, dst, verbose=False, match=None):
112125
shutil.move(tp, fp)
113126
shutil.rmtree(os.path.join(dst, fname))
114127

115-
def run(args, verbose=False):
128+
def run(args, verbose=False, exception=False):
116129
if verbose:
117130
print("running: " + ' '.join(args))
118131
sys.stdout.flush()
@@ -122,7 +135,7 @@ def run(args, verbose=False):
122135
code = ret.wait()
123136
if code != 0:
124137
err = "failed to run: " + ' '.join(args)
125-
if verbose:
138+
if verbose or exception:
126139
raise RuntimeError(err)
127140
sys.exit(err)
128141

@@ -342,8 +355,12 @@ def build_bootstrap(self):
342355
env = os.environ.copy()
343356
env["CARGO_TARGET_DIR"] = build_dir
344357
env["RUSTC"] = self.rustc()
345-
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
346-
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
358+
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
359+
(os.pathsep + env["LD_LIBRARY_PATH"]) \
360+
if "LD_LIBRARY_PATH" in env else ""
361+
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
362+
(os.pathsep + env["DYLD_LIBRARY_PATH"]) \
363+
if "DYLD_LIBRARY_PATH" in env else ""
347364
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
348365
os.pathsep + env["PATH"]
349366
if not os.path.isfile(self.cargo()):
@@ -472,6 +489,8 @@ def build_triple(self):
472489
ostype += 'abi64'
473490
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
474491
cputype = 'powerpc'
492+
elif cputype == 'sparcv9':
493+
pass
475494
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
476495
cputype = 'x86_64'
477496
else:

src/bootstrap/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ pub fn krate(build: &Build,
346346
krate: Option<&str>) {
347347
let (name, path, features, root) = match mode {
348348
Mode::Libstd => {
349-
("libstd", "src/rustc/std_shim", build.std_features(), "std_shim")
349+
("libstd", "src/libstd", build.std_features(), "std")
350350
}
351351
Mode::Libtest => {
352-
("libtest", "src/rustc/test_shim", String::new(), "test_shim")
352+
("libtest", "src/libtest", String::new(), "test")
353353
}
354354
Mode::Librustc => {
355355
("librustc", "src/rustc", build.rustc_features(), "rustc-main")

src/bootstrap/compile.rs

+23-15
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::fs::{self, File};
2121
use std::path::{Path, PathBuf};
2222
use std::process::Command;
2323

24-
use build_helper::{output, mtime};
24+
use build_helper::{output, mtime, up_to_date};
2525
use filetime::FileTime;
2626

2727
use util::{exe, libdir, is_dylib, copy};
@@ -64,7 +64,7 @@ pub fn std(build: &Build, target: &str, compiler: &Compiler) {
6464
}
6565
cargo.arg("--features").arg(features)
6666
.arg("--manifest-path")
67-
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
67+
.arg(build.src.join("src/libstd/Cargo.toml"));
6868

6969
if let Some(target) = build.config.target_config.get(target) {
7070
if let Some(ref jemalloc) = target.jemalloc {
@@ -132,21 +132,29 @@ pub fn build_startup_objects(build: &Build, for_compiler: &Compiler, target: &st
132132

133133
let compiler = Compiler::new(0, &build.config.build);
134134
let compiler_path = build.compiler_path(&compiler);
135-
let into = build.sysroot_libdir(for_compiler, target);
136-
t!(fs::create_dir_all(&into));
137-
138-
for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
139-
let file = t!(file);
140-
let mut cmd = Command::new(&compiler_path);
141-
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
142-
.arg("--target").arg(target)
143-
.arg("--emit=obj")
144-
.arg("--out-dir").arg(&into)
145-
.arg(file.path()));
135+
let src_dir = &build.src.join("src/rtstartup");
136+
let dst_dir = &build.native_dir(target).join("rtstartup");
137+
let sysroot_dir = &build.sysroot_libdir(for_compiler, target);
138+
t!(fs::create_dir_all(dst_dir));
139+
t!(fs::create_dir_all(sysroot_dir));
140+
141+
for file in &["rsbegin", "rsend"] {
142+
let src_file = &src_dir.join(file.to_string() + ".rs");
143+
let dst_file = &dst_dir.join(file.to_string() + ".o");
144+
if !up_to_date(src_file, dst_file) {
145+
let mut cmd = Command::new(&compiler_path);
146+
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
147+
.arg("--target").arg(target)
148+
.arg("--emit=obj")
149+
.arg("--out-dir").arg(dst_dir)
150+
.arg(src_file));
151+
}
152+
153+
copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
146154
}
147155

148156
for obj in ["crt2.o", "dllcrt2.o"].iter() {
149-
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
157+
copy(&compiler_file(build.cc(target), obj), &sysroot_dir.join(obj));
150158
}
151159
}
152160

@@ -162,7 +170,7 @@ pub fn test(build: &Build, target: &str, compiler: &Compiler) {
162170
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
163171
let mut cargo = build.cargo(compiler, Mode::Libtest, target, "build");
164172
cargo.arg("--manifest-path")
165-
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
173+
.arg(build.src.join("src/libtest/Cargo.toml"));
166174
build.run(&mut cargo);
167175
update_mtime(build, &libtest_stamp(build, compiler, target));
168176
}

src/bootstrap/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn std(build: &Build, stage: u32, target: &str) {
148148

149149
let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
150150
cargo.arg("--manifest-path")
151-
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
151+
.arg(build.src.join("src/libstd/Cargo.toml"))
152152
.arg("--features").arg(build.std_features());
153153

154154
// We don't want to build docs for internal std dependencies unless
@@ -194,7 +194,7 @@ pub fn test(build: &Build, stage: u32, target: &str) {
194194

195195
let mut cargo = build.cargo(&compiler, Mode::Libtest, target, "doc");
196196
cargo.arg("--manifest-path")
197-
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
197+
.arg(build.src.join("src/libtest/Cargo.toml"));
198198
build.run(&mut cargo);
199199
cp_r(&out_dir, &out)
200200
}

src/bootstrap/flags.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use step;
2828
/// Deserialized version of all flags for this compile.
2929
pub struct Flags {
3030
pub verbose: usize, // verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
31+
pub on_fail: Option<String>,
3132
pub stage: Option<u32>,
3233
pub keep_stage: Option<u32>,
3334
pub build: String,
@@ -81,6 +82,7 @@ impl Flags {
8182
opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
8283
opts.optmulti("", "host", "host targets to build", "HOST");
8384
opts.optmulti("", "target", "target targets to build", "TARGET");
85+
opts.optopt("", "on-fail", "command to run on failure", "CMD");
8486
opts.optopt("", "stage", "stage to build", "N");
8587
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
8688
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
@@ -283,6 +285,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
283285
Flags {
284286
verbose: m.opt_count("v"),
285287
stage: stage,
288+
on_fail: m.opt_str("on-fail"),
286289
keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()),
287290
build: m.opt_str("build").unwrap_or_else(|| {
288291
env::var("BUILD").unwrap()

src/bootstrap/lib.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ impl Build {
499499
cargo.env("RUSTC_INCREMENTAL", incr_dir);
500500
}
501501

502+
if let Some(ref on_fail) = self.flags.on_fail {
503+
cargo.env("RUSTC_ON_FAIL", on_fail);
504+
}
505+
502506
let verbose = cmp::max(self.config.verbose, self.flags.verbose);
503507
cargo.env("RUSTC_VERBOSE", format!("{}", verbose));
504508

@@ -828,17 +832,6 @@ impl Build {
828832
if target.contains("apple-darwin") {
829833
base.push("-stdlib=libc++".into());
830834
}
831-
// This is a hack, because newer binutils broke things on some vms/distros
832-
// (i.e., linking against unknown relocs disabled by the following flag)
833-
// See: https://github.com/rust-lang/rust/issues/34978
834-
match target {
835-
"i586-unknown-linux-gnu" |
836-
"i686-unknown-linux-musl" |
837-
"x86_64-unknown-linux-musl" => {
838-
base.push("-Wa,-mrelax-relocations=no".into());
839-
},
840-
_ => {},
841-
}
842835
return base
843836
}
844837

src/bootstrap/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ struct ResolveNode {
4343
}
4444

4545
pub fn build(build: &mut Build) {
46-
build_krate(build, "src/rustc/std_shim");
47-
build_krate(build, "src/rustc/test_shim");
46+
build_krate(build, "src/libstd");
47+
build_krate(build, "src/libtest");
4848
build_krate(build, "src/rustc");
4949
}
5050

0 commit comments

Comments
 (0)