Skip to content

Commit fd95db2

Browse files
committed
Merge remote-tracking branch 'origin/master' into proc_macro_api
2 parents d316874 + 692b572 commit fd95db2

File tree

605 files changed

+6479
-3691
lines changed

Some content is hidden

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

605 files changed

+6479
-3691
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
.hg/
5252
.hgignore
5353
.idea
54+
*.iml
5455
__pycache__/
5556
*.py[cod]
5657
*$py.class

.travis.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,22 @@ before_script:
171171
if [[ "$SKIP_BUILD" == true ]]; then
172172
export RUN_SCRIPT="echo 'skipping, not a full build'";
173173
else
174-
RUN_SCRIPT="stamp src/ci/init_repo.sh . $HOME/rustsrc";
174+
RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
175175
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
176-
export RUN_SCRIPT="$RUN_SCRIPT && stamp src/ci/run.sh";
176+
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
177177
else
178-
export RUN_SCRIPT="$RUN_SCRIPT && stamp src/ci/docker/run.sh $IMAGE";
178+
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
179179
fi
180180
fi
181181
182+
# Log time information from this machine and an external machine for insight into possible
183+
# clock drift. Timezones don't matter since relative deltas give all the necessary info.
182184
script:
183-
- sh -x -c "$RUN_SCRIPT"
185+
- >
186+
date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'
187+
- stamp sh -x -c "$RUN_SCRIPT"
188+
- >
189+
date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'
184190
185191
after_success:
186192
- >

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ Read ["Installation"] from [The Book].
4040

4141
> ***Note:*** Install locations can be adjusted by copying the config file
4242
> from `./src/bootstrap/config.toml.example` to `./config.toml`, and
43-
> adjusting the `prefix` option under `[install]`. Various other options are
44-
> also supported, and are documented in the config file.
43+
> adjusting the `prefix` option under `[install]`. Various other options, such
44+
> as enabling debug information, are also supported, and are documented in
45+
> the config file.
4546

4647
When complete, `sudo ./x.py install` will place several programs into
4748
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the

src/Cargo.lock

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

src/bootstrap/bin/rustc.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,11 @@ fn main() {
7575
Err(_) => 0,
7676
};
7777

78-
// Build scripts always use the snapshot compiler which is guaranteed to be
79-
// able to produce an executable, whereas intermediate compilers may not
80-
// have the standard library built yet and may not be able to produce an
81-
// executable. Otherwise we just use the standard compiler we're
82-
// bootstrapping with.
83-
//
84-
// Also note that cargo will detect the version of the compiler to trigger
85-
// a rebuild when the compiler changes. If this happens, we want to make
86-
// sure to use the actual compiler instead of the snapshot compiler becase
87-
// that's the one that's actually changing.
78+
// Use a different compiler for build scripts, since there may not yet be a
79+
// libstd for the real compiler to use. However, if Cargo is attempting to
80+
// determine the version of the compiler, the real compiler needs to be
81+
// used. Currently, these two states are differentiated based on whether
82+
// --target and -vV is/isn't passed.
8883
let (rustc, libdir) = if target.is_none() && version.is_none() {
8984
("RUSTC_SNAPSHOT", "RUSTC_SNAPSHOT_LIBDIR")
9085
} else {

src/bootstrap/bootstrap.py

+34-19
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626

2727
def get(url, path, verbose=False):
28-
sha_url = url + ".sha256"
28+
suffix = '.sha256'
29+
sha_url = url + suffix
2930
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
3031
temp_path = temp_file.name
31-
with tempfile.NamedTemporaryFile(suffix=".sha256", delete=False) as sha_file:
32+
with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as sha_file:
3233
sha_path = sha_file.name
3334

3435
try:
@@ -55,6 +56,7 @@ def get(url, path, verbose=False):
5556

5657

5758
def delete_if_present(path, verbose):
59+
"""Remove the given file if present"""
5860
if os.path.isfile(path):
5961
if verbose:
6062
print("removing " + path)
@@ -92,12 +94,13 @@ def _download(path, url, probably_big, verbose, exception):
9294

9395

9496
def verify(path, sha_path, verbose):
97+
"""Check if the sha256 sum of the given path is valid"""
9598
if verbose:
9699
print("verifying " + path)
97-
with open(path, "rb") as f:
98-
found = hashlib.sha256(f.read()).hexdigest()
99-
with open(sha_path, "r") as f:
100-
expected = f.readline().split()[0]
100+
with open(path, "rb") as source:
101+
found = hashlib.sha256(source.read()).hexdigest()
102+
with open(sha_path, "r") as sha256sum:
103+
expected = sha256sum.readline().split()[0]
101104
verified = found == expected
102105
if not verified:
103106
print("invalid checksum:\n"
@@ -107,6 +110,7 @@ def verify(path, sha_path, verbose):
107110

108111

109112
def unpack(tarball, dst, verbose=False, match=None):
113+
"""Unpack the given tarball file"""
110114
print("extracting " + tarball)
111115
fname = os.path.basename(tarball).replace(".tar.gz", "")
112116
with contextlib.closing(tarfile.open(tarball)) as tar:
@@ -128,6 +132,7 @@ def unpack(tarball, dst, verbose=False, match=None):
128132
shutil.move(tp, fp)
129133
shutil.rmtree(os.path.join(dst, fname))
130134

135+
131136
def run(args, verbose=False, exception=False, **kwargs):
132137
if verbose:
133138
print("running: " + ' '.join(args))
@@ -245,7 +250,8 @@ def fix_executable(self, fname):
245250
return
246251

247252
# At this point we're pretty sure the user is running NixOS
248-
print("info: you seem to be running NixOS. Attempting to patch " + fname)
253+
nix_os_msg = "info: you seem to be running NixOS. Attempting to patch"
254+
print(nix_os_msg, fname)
249255

250256
try:
251257
interpreter = subprocess.check_output(
@@ -293,18 +299,22 @@ def stage0_cargo_channel(self):
293299
return self._cargo_channel
294300

295301
def rustc_stamp(self):
302+
"""Return the path for .rustc-stamp"""
296303
return os.path.join(self.bin_root(), '.rustc-stamp')
297304

298305
def cargo_stamp(self):
306+
"""Return the path for .cargo-stamp"""
299307
return os.path.join(self.bin_root(), '.cargo-stamp')
300308

301309
def rustc_out_of_date(self):
310+
"""Check if rustc is out of date"""
302311
if not os.path.exists(self.rustc_stamp()) or self.clean:
303312
return True
304313
with open(self.rustc_stamp(), 'r') as f:
305314
return self.stage0_date() != f.read()
306315

307316
def cargo_out_of_date(self):
317+
"""Check if cargo is out of date"""
308318
if not os.path.exists(self.cargo_stamp()) or self.clean:
309319
return True
310320
with open(self.cargo_stamp(), 'r') as f:
@@ -357,16 +367,15 @@ def get_string(self, line):
357367
def exe_suffix(self):
358368
if sys.platform == 'win32':
359369
return '.exe'
360-
else:
361-
return ''
370+
return ''
362371

363372
def print_what_it_means_to_bootstrap(self):
364373
if hasattr(self, 'printed'):
365374
return
366375
self.printed = True
367376
if os.path.exists(self.bootstrap_binary()):
368377
return
369-
if not '--help' in sys.argv or len(sys.argv) == 1:
378+
if '--help' not in sys.argv or len(sys.argv) == 1:
370379
return
371380

372381
print('info: the build system for Rust is written in Rust, so this')
@@ -461,8 +470,8 @@ def build_triple(self):
461470
# always emit 'i386' on x86/amd64 systems). As such, isainfo -k
462471
# must be used instead.
463472
try:
464-
cputype = subprocess.check_output(['isainfo',
465-
'-k']).strip().decode(default_encoding)
473+
cputype = subprocess.check_output(
474+
['isainfo', '-k']).strip().decode(default_encoding)
466475
except (subprocess.CalledProcessError, OSError):
467476
err = "isainfo not found"
468477
if self.verbose:
@@ -562,21 +571,26 @@ def update_submodules(self):
562571
default_encoding = sys.getdefaultencoding()
563572
run(["git", "submodule", "-q", "sync"], cwd=self.rust_root)
564573
submodules = [s.split(' ', 1)[1] for s in subprocess.check_output(
565-
["git", "config", "--file", os.path.join(self.rust_root, ".gitmodules"),
574+
["git", "config", "--file",
575+
os.path.join(self.rust_root, ".gitmodules"),
566576
"--get-regexp", "path"]
567577
).decode(default_encoding).splitlines()]
568578
submodules = [module for module in submodules
569579
if not ((module.endswith("llvm") and
570-
(self.get_toml('llvm-config') or self.get_mk('CFG_LLVM_ROOT'))) or
580+
(self.get_toml('llvm-config') or
581+
self.get_mk('CFG_LLVM_ROOT'))) or
571582
(module.endswith("jemalloc") and
572-
(self.get_toml('jemalloc') or self.get_mk('CFG_JEMALLOC_ROOT'))))
573-
]
583+
(self.get_toml('jemalloc') or
584+
self.get_mk('CFG_JEMALLOC_ROOT'))))]
574585
run(["git", "submodule", "update",
575-
"--init"] + submodules, cwd=self.rust_root, verbose=self.verbose)
586+
"--init"] + submodules,
587+
cwd=self.rust_root, verbose=self.verbose)
576588
run(["git", "submodule", "-q", "foreach", "git",
577-
"reset", "-q", "--hard"], cwd=self.rust_root, verbose=self.verbose)
589+
"reset", "-q", "--hard"],
590+
cwd=self.rust_root, verbose=self.verbose)
578591
run(["git", "submodule", "-q", "foreach", "git",
579-
"clean", "-qdfx"], cwd=self.rust_root, verbose=self.verbose)
592+
"clean", "-qdfx"],
593+
cwd=self.rust_root, verbose=self.verbose)
580594

581595

582596
def bootstrap():
@@ -692,5 +706,6 @@ def main():
692706
format_build_time(time() - start_time))
693707
sys.exit(exit_code)
694708

709+
695710
if __name__ == '__main__':
696711
main()

src/bootstrap/cc.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ use config::Target;
4242
pub fn find(build: &mut Build) {
4343
// For all targets we're going to need a C compiler for building some shims
4444
// and such as well as for being a linker for Rust code.
45-
for target in build.config.target.iter() {
45+
//
46+
// This includes targets that aren't necessarily passed on the commandline
47+
// (FIXME: Perhaps it shouldn't?)
48+
for target in &build.config.target {
4649
let mut cfg = gcc::Config::new();
4750
cfg.cargo_metadata(false).opt_level(0).debug(false)
48-
.target(target).host(&build.config.build);
51+
.target(target).host(&build.build);
4952

5053
let config = build.config.target_config.get(target);
5154
if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
@@ -64,10 +67,13 @@ pub fn find(build: &mut Build) {
6467
}
6568

6669
// For all host triples we need to find a C++ compiler as well
67-
for host in build.config.host.iter() {
70+
//
71+
// This includes hosts that aren't necessarily passed on the commandline
72+
// (FIXME: Perhaps it shouldn't?)
73+
for host in &build.config.host {
6874
let mut cfg = gcc::Config::new();
6975
cfg.cargo_metadata(false).opt_level(0).debug(false).cpp(true)
70-
.target(host).host(&build.config.build);
76+
.target(host).host(&build.build);
7177
let config = build.config.target_config.get(host);
7278
if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
7379
cfg.compiler(cxx);

src/bootstrap/channel.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use build_helper::output;
2323
use Build;
2424

2525
// The version number
26-
pub const CFG_RELEASE_NUM: &'static str = "1.20.0";
26+
pub const CFG_RELEASE_NUM: &str = "1.20.0";
2727

2828
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
2929
// Be sure to make this starts with a dot to conform to semver pre-release
3030
// versions (section 9)
31-
pub const CFG_PRERELEASE_VERSION: &'static str = ".1";
31+
pub const CFG_PRERELEASE_VERSION: &str = ".1";
3232

3333
pub struct GitInfo {
3434
inner: Option<Info>,
@@ -99,6 +99,10 @@ impl GitInfo {
9999
version.push_str(&inner.commit_date);
100100
version.push_str(")");
101101
}
102-
return version
102+
version
103+
}
104+
105+
pub fn is_git(&self) -> bool {
106+
self.inner.is_some()
103107
}
104108
}

0 commit comments

Comments
 (0)