Skip to content

Commit df283db

Browse files
committed
Merge branch 'master' of github.com:1011X/rust
2 parents 4e4c1b5 + 1e1bfc7 commit df283db

File tree

103 files changed

+849
-1095
lines changed

Some content is hidden

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

103 files changed

+849
-1095
lines changed

.gitmodules

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@
4141
[submodule "src/dlmalloc"]
4242
path = src/dlmalloc
4343
url = https://github.com/alexcrichton/dlmalloc-rs.git
44-
[submodule "src/binaryen"]
45-
path = src/binaryen
46-
url = https://github.com/alexcrichton/binaryen.git
4744
[submodule "src/doc/rust-by-example"]
4845
path = src/doc/rust-by-example
4946
url = https://github.com/rust-lang/rust-by-example
5047
[submodule "src/llvm-emscripten"]
5148
path = src/llvm-emscripten
5249
url = https://github.com/rust-lang/llvm
50+
[submodule "src/stdsimd"]
51+
path = src/stdsimd
52+
url = https://github.com/rust-lang-nursery/stdsimd
53+
[submodule "src/tools/lld"]
54+
path = src/tools/lld
55+
url = https://github.com/rust-lang/lld.git

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ matrix:
8181
# OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7.
8282
- env: >
8383
RUST_CHECK_TARGET=dist
84-
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-extended --enable-profiler --enable-emscripten"
84+
RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-full-tools --enable-profiler"
8585
SRC=.
8686
DEPLOY=1
8787
RUSTC_RETRY_LINKER_ON_SEGFAULT=1
@@ -95,7 +95,7 @@ matrix:
9595
9696
- env: >
9797
RUST_CHECK_TARGET=dist
98-
RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-extended --enable-sanitizers --enable-profiler --enable-emscripten"
98+
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"
9999
SRC=.
100100
DEPLOY=1
101101
RUSTC_RETRY_LINKER_ON_SEGFAULT=1

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.
129129
python x.py build
130130
```
131131

132-
If you are seeing build failure when compiling `rustc_binaryen`, make sure the path
133-
length of the rust folder is not longer than 22 characters.
134-
135132
#### Specifying an ABI
136133
[specifying-an-abi]: #specifying-an-abi
137134

appveyor.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,27 @@ environment:
6767
# 32/64 bit MSVC and GNU deployment
6868
- RUST_CONFIGURE_ARGS: >
6969
--build=x86_64-pc-windows-msvc
70-
--enable-extended
70+
--enable-full-tools
7171
--enable-profiler
72-
--enable-emscripten
7372
SCRIPT: python x.py dist
7473
DEPLOY: 1
7574
- RUST_CONFIGURE_ARGS: >
7675
--build=i686-pc-windows-msvc
7776
--target=i586-pc-windows-msvc
78-
--enable-extended
77+
--enable-full-tools
7978
--enable-profiler
80-
--enable-emscripten
8179
SCRIPT: python x.py dist
8280
DEPLOY: 1
8381
- MSYS_BITS: 32
84-
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-extended --enable-emscripten
82+
RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools
8583
SCRIPT: python x.py dist
8684
MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror
8785
MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z
8886
MINGW_DIR: mingw32
8987
DEPLOY: 1
9088
- MSYS_BITS: 64
9189
SCRIPT: python x.py dist
92-
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-extended --enable-emscripten
90+
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools
9391
MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror
9492
MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z
9593
MINGW_DIR: mingw64

config.toml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,18 @@
321321
# bootstrap)
322322
#codegen-backends = ["llvm"]
323323

324+
# This is the name of the directory in which codegen backends will get installed
325+
#codegen-backends-dir = "codegen-backends"
326+
324327
# Flag indicating whether `libstd` calls an imported function to handle basic IO
325328
# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
326329
# target, as without this option the test output will not be captured.
327330
#wasm-syscall = false
328331

332+
# Indicates whether LLD will be compiled and made available in the sysroot for
333+
# rustc to execute.
334+
#lld = false
335+
329336
# =============================================================================
330337
# Options for specific targets
331338
#

src/Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/binaryen

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/bootstrap/bin/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn main() {
224224
// flesh out rpath support more fully in the future.
225225
cmd.arg("-Z").arg("osx-rpath-install-name");
226226
Some("-Wl,-rpath,@loader_path/../lib")
227-
} else if !target.contains("windows") {
227+
} else if !target.contains("windows") && !target.contains("wasm32") {
228228
Some("-Wl,-rpath,$ORIGIN/../lib")
229229
} else {
230230
None

src/bootstrap/bootstrap.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ def __init__(self):
314314
self.build_dir = os.path.join(os.getcwd(), "build")
315315
self.clean = False
316316
self.config_toml = ''
317-
self.printed = False
318317
self.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
319318
self.use_locked_deps = ''
320319
self.use_vendored_sources = ''
@@ -336,7 +335,6 @@ def download_stage0(self):
336335
if self.rustc().startswith(self.bin_root()) and \
337336
(not os.path.exists(self.rustc()) or
338337
self.program_out_of_date(self.rustc_stamp())):
339-
self.print_what_bootstrap_means()
340338
if os.path.exists(self.bin_root()):
341339
shutil.rmtree(self.bin_root())
342340
filename = "rust-std-{}-{}.tar.gz".format(
@@ -351,10 +349,17 @@ def download_stage0(self):
351349
with open(self.rustc_stamp(), 'w') as rust_stamp:
352350
rust_stamp.write(self.date)
353351

352+
# This is required so that we don't mix incompatible MinGW
353+
# libraries/binaries that are included in rust-std with
354+
# the system MinGW ones.
355+
if "pc-windows-gnu" in self.build:
356+
filename = "rust-mingw-{}-{}.tar.gz".format(
357+
rustc_channel, self.build)
358+
self._download_stage0_helper(filename, "rust-mingw")
359+
354360
if self.cargo().startswith(self.bin_root()) and \
355361
(not os.path.exists(self.cargo()) or
356362
self.program_out_of_date(self.cargo_stamp())):
357-
self.print_what_bootstrap_means()
358363
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
359364
self._download_stage0_helper(filename, "cargo")
360365
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
@@ -555,23 +560,6 @@ def exe_suffix():
555560
return '.exe'
556561
return ''
557562

558-
def print_what_bootstrap_means(self):
559-
"""Prints more information about the build system"""
560-
if hasattr(self, 'printed'):
561-
return
562-
self.printed = True
563-
if os.path.exists(self.bootstrap_binary()):
564-
return
565-
if '--help' not in sys.argv or len(sys.argv) == 1:
566-
return
567-
568-
print('info: the build system for Rust is written in Rust, so this')
569-
print(' script is now going to download a stage0 rust compiler')
570-
print(' and then compile the build system itself')
571-
print('')
572-
print('info: in the meantime you can read more about rustbuild at')
573-
print(' src/bootstrap/README.md before the download finishes')
574-
575563
def bootstrap_binary(self):
576564
"""Return the path of the boostrap binary
577565
@@ -585,7 +573,6 @@ def bootstrap_binary(self):
585573

586574
def build_bootstrap(self):
587575
"""Build bootstrap"""
588-
self.print_what_bootstrap_means()
589576
build_dir = os.path.join(self.build_dir, "bootstrap")
590577
if self.clean and os.path.exists(build_dir):
591578
shutil.rmtree(build_dir)
@@ -654,6 +641,10 @@ def update_submodules(self):
654641
continue
655642
if self.get_toml('jemalloc'):
656643
continue
644+
if module.endswith("lld"):
645+
config = self.get_toml('lld')
646+
if config is None or config == 'false':
647+
continue
657648
filtered_submodules.append(module)
658649
run(["git", "submodule", "update",
659650
"--init", "--recursive"] + filtered_submodules,
@@ -670,8 +661,16 @@ def set_dev_environment(self):
670661
self._download_url = 'https://dev-static.rust-lang.org'
671662

672663

673-
def bootstrap():
664+
def bootstrap(help_triggered):
674665
"""Configure, fetch, build and run the initial bootstrap"""
666+
667+
# If the user is asking for help, let them know that the whole download-and-build
668+
# process has to happen before anything is printed out.
669+
if help_triggered:
670+
print("info: Downloading and building bootstrap before processing --help")
671+
print(" command. See src/bootstrap/README.md for help with common")
672+
print(" commands.")
673+
675674
parser = argparse.ArgumentParser(description='Build rust')
676675
parser.add_argument('--config')
677676
parser.add_argument('--build')
@@ -708,7 +707,7 @@ def bootstrap():
708707
print(' and so in order to preserve your $HOME this will now')
709708
print(' use vendored sources by default. Note that if this')
710709
print(' does not work you should run a normal build first')
711-
print(' before running a command like `sudo make install`')
710+
print(' before running a command like `sudo ./x.py install`')
712711

713712
if build.use_vendored_sources:
714713
if not os.path.exists('.cargo'):
@@ -734,7 +733,10 @@ def bootstrap():
734733
if 'dev' in data:
735734
build.set_dev_environment()
736735

737-
build.update_submodules()
736+
# No help text depends on submodules. This check saves ~1 minute of git commands, even if
737+
# all the submodules are present and downloaded!
738+
if not help_triggered:
739+
build.update_submodules()
738740

739741
# Fetch/build the bootstrap
740742
build.build = args.build or build.build_triple()
@@ -760,7 +762,7 @@ def main():
760762
help_triggered = (
761763
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
762764
try:
763-
bootstrap()
765+
bootstrap(help_triggered)
764766
if not help_triggered:
765767
print("Build completed successfully in {}".format(
766768
format_build_time(time() - start_time)))

src/bootstrap/builder.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'a> Builder<'a> {
316316
tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest,
317317
tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient,
318318
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
319-
native::Llvm, tool::Rustfmt, tool::Miri),
319+
native::Llvm, tool::Rustfmt, tool::Miri, native::Lld),
320320
Kind::Check => describe!(check::Std, check::Test, check::Rustc),
321321
Kind::Test => describe!(test::Tidy, test::Bootstrap, test::Ui, test::RunPass,
322322
test::CompileFail, test::ParseFail, test::RunFail, test::RunPassValgrind,
@@ -464,7 +464,7 @@ impl<'a> Builder<'a> {
464464

465465
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
466466
self.sysroot_libdir(compiler, compiler.host)
467-
.with_file_name("codegen-backends")
467+
.with_file_name(self.build.config.rust_codegen_backends_dir.clone())
468468
}
469469

470470
/// Returns the compiler's libdir where it stores the dynamic libraries that
@@ -688,9 +688,25 @@ impl<'a> Builder<'a> {
688688
//
689689
// FIXME: the guard against msvc shouldn't need to be here
690690
if !target.contains("msvc") {
691-
let cc = self.cc(target);
692-
cargo.env(format!("CC_{}", target), cc)
693-
.env("CC", cc);
691+
let ccache = self.config.ccache.as_ref();
692+
let ccacheify = |s: &Path| {
693+
let ccache = match ccache {
694+
Some(ref s) => s,
695+
None => return s.display().to_string(),
696+
};
697+
// FIXME: the cc-rs crate only recognizes the literal strings
698+
// `ccache` and `sccache` when doing caching compilations, so we
699+
// mirror that here. It should probably be fixed upstream to
700+
// accept a new env var or otherwise work with custom ccache
701+
// vars.
702+
match &ccache[..] {
703+
"ccache" | "sccache" => format!("{} {}", ccache, s.display()),
704+
_ => s.display().to_string(),
705+
}
706+
};
707+
let cc = ccacheify(&self.cc(target));
708+
cargo.env(format!("CC_{}", target), &cc)
709+
.env("CC", &cc);
694710

695711
let cflags = self.cflags(target).join(" ");
696712
cargo.env(format!("CFLAGS_{}", target), cflags.clone())
@@ -705,8 +721,9 @@ impl<'a> Builder<'a> {
705721
}
706722

707723
if let Ok(cxx) = self.cxx(target) {
708-
cargo.env(format!("CXX_{}", target), cxx)
709-
.env("CXX", cxx)
724+
let cxx = ccacheify(&cxx);
725+
cargo.env(format!("CXX_{}", target), &cxx)
726+
.env("CXX", &cxx)
710727
.env(format!("CXXFLAGS_{}", target), cflags.clone())
711728
.env("CXXFLAGS", cflags);
712729
}

src/bootstrap/cc_detect.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub fn find(build: &mut Build) {
7979
let mut cfg = cc::Build::new();
8080
cfg.cargo_metadata(false).opt_level(0).warnings(false).debug(false)
8181
.target(&target).host(&build.build);
82+
if target.contains("msvc") {
83+
cfg.static_crt(true);
84+
}
8285

8386
let config = build.config.target_config.get(&target);
8487
if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {

src/bootstrap/compile.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ fn rustc_cargo_env(build: &Build, cargo: &mut Command) {
514514
cargo.env("CFG_RELEASE", build.rust_release())
515515
.env("CFG_RELEASE_CHANNEL", &build.config.channel)
516516
.env("CFG_VERSION", build.rust_version())
517-
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
517+
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default())
518+
.env("CFG_CODEGEN_BACKENDS_DIR", &build.config.rust_codegen_backends_dir);
518519

519520
let libdir_relative = build.config.libdir_relative().unwrap_or(Path::new("lib"));
520521
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
@@ -746,6 +747,21 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
746747
}
747748
}
748749

750+
fn copy_lld_to_sysroot(builder: &Builder,
751+
target_compiler: Compiler,
752+
lld_install_root: &Path) {
753+
let target = target_compiler.host;
754+
755+
let dst = builder.sysroot_libdir(target_compiler, target)
756+
.parent()
757+
.unwrap()
758+
.join("bin");
759+
t!(fs::create_dir_all(&dst));
760+
761+
let exe = exe("lld", &target);
762+
copy(&lld_install_root.join("bin").join(&exe), &dst.join(&exe));
763+
}
764+
749765
/// Cargo's output path for the standard library in a given stage, compiled
750766
/// by a particular compiler for the specified target.
751767
pub fn libstd_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
@@ -895,6 +911,14 @@ impl Step for Assemble {
895911
}
896912
}
897913

914+
let lld_install = if build.config.lld_enabled && target_compiler.stage > 0 {
915+
Some(builder.ensure(native::Lld {
916+
target: target_compiler.host,
917+
}))
918+
} else {
919+
None
920+
};
921+
898922
let stage = target_compiler.stage;
899923
let host = target_compiler.host;
900924
println!("Assembling stage{} compiler ({})", stage, host);
@@ -914,6 +938,9 @@ impl Step for Assemble {
914938
copy_codegen_backends_to_sysroot(builder,
915939
build_compiler,
916940
target_compiler);
941+
if let Some(lld_install) = lld_install {
942+
copy_lld_to_sysroot(builder, target_compiler, &lld_install);
943+
}
917944

918945
// Link the compiler binary itself into place
919946
let out_dir = build.cargo_out(build_compiler, Mode::Librustc, host);

0 commit comments

Comments
 (0)