about summary refs log tree commit diff
path: root/src/bootstrap/compile.rs
AgeCommit message (Collapse)AuthorLines
2019-03-31Fix custom relative libdir.O01eg-4/+4
Uses relative libdir to place libraries on all stages. Adds verbose installation output.
2019-03-29Add a new wasm32-unknown-wasi targetAlex Crichton-0/+13
This commit adds a new wasm32-based target distributed through rustup, supported in the standard library, and implemented in the compiler. The `wasm32-unknown-wasi` target is intended to be a WebAssembly target which matches the [WASI proposal recently announced.][LINK]. In summary the WASI target is an effort to define a standard set of syscalls for WebAssembly modules, allowing WebAssembly modules to not only be portable across architectures but also be portable across environments implementing this standard set of system calls. The wasi target in libstd is still somewhat bare bones. This PR does not fill out the filesystem, networking, threads, etc. Instead it only provides the most basic of integration with the wasi syscalls, enabling features like: * `Instant::now` and `SystemTime::now` work * `env::args` is hooked up * `env::vars` will look up environment variables * `println!` will print to standard out * `process::{exit, abort}` should be hooked up appropriately None of these APIs can work natively on the `wasm32-unknown-unknown` target, but with the assumption of the WASI set of syscalls we're able to provide implementations of these syscalls that engines can implement. Currently the primary engine implementing wasi is [wasmtime], but more will surely emerge! In terms of future development of libstd, I think this is something we'll probably want to discuss. The purpose of the WASI target is to provide a standardized set of syscalls, but it's *also* to provide a standard C sysroot for compiling C/C++ programs. This means it's intended that functions like `read` and `write` are implemented for this target with a relatively standard definition and implementation. It's unclear, therefore, how we want to expose file descriptors and how we'll want to implement system primitives. For example should `std::fs::File` have a libc-based file descriptor underneath it? The raw wasi file descriptor? We'll see! Currently these details are all intentionally hidden and things we can change over time. A `WasiFd` sample struct was added to the standard library as part of this commit, but it's not currently used. It shows how all the wasi syscalls could be ergonomically bound in Rust, and they offer a possible implementation of primitives like `std::fs::File` if we bind wasi file descriptors exactly. Apart from the standard library, there's also the matter of how this target is integrated with respect to its C standard library. The reference sysroot, for example, provides managment of standard unix file descriptors and also standard APIs like `open` (as opposed to the relative `openat` inspiration for the wasi ssycalls). Currently the standard library relies on the C sysroot symbols for operations such as environment management, process exit, and `read`/`write` of stdio fds. We want these operations in Rust to be interoperable with C if they're used in the same process. Put another way, if Rust and C are linked into the same WebAssembly binary they should work together, but that requires that the same C standard library is used. We also, however, want the `wasm32-unknown-wasi` target to be usable-by-default with the Rust compiler without requiring a separate toolchain to get downloaded and configured. With that in mind, there's two modes of operation for the `wasm32-unknown-wasi` target: 1. By default the C standard library is statically provided inside of `liblibc.rlib` distributed as part of the sysroot. This means that you can `rustc foo.wasm --target wasm32-unknown-unknown` and you're good to go, a fully workable wasi binary pops out. This is incompatible with linking in C code, however, which may be compiled against a different sysroot than the Rust code was previously compiled against. In this mode the default of `rust-lld` is used to link binaries. 2. For linking with C code, the `-C target-feature=-crt-static` flag needs to be passed. This takes inspiration from the musl target for this flag, but the idea is that you're no longer using the provided static C runtime, but rather one will be provided externally. This flag is intended to also get coupled with an external `clang` compiler configured with its own sysroot. Therefore you'll typically use this flag with `-C linker=/path/to/clang-script-wrapper`. Using this mode the Rust code will continue to reference standard C symbols, but the definition will be pulled in by the linker configured. Alright so that's all the current state of this PR. I suspect we'll definitely want to discuss this before landing of course! This PR is coupled with libc changes as well which I'll be posting shortly. [LINK]: [wasmtime]:
2019-03-25compile all crates under test w/ -Zemit-stack-sizesJorge Aparicio-0/+4
2019-03-05Bootstrap changesJohn Kåre Alsaker-19/+55
2019-02-25bootstrap: deny(rust_2018_idioms)Taiki Endo-47/+66
2019-02-10rustc: doc commentsAlexander Regueiro-4/+4
2019-01-28Use multiple threads by default. Limits tests to one thread. Do some renaming.John Kåre Alsaker-2/+2
2019-01-26Workaround presence of LLVM library in stage0/libMark Rousskov-0/+1
This commit works around the newly-introduced LLVM shared library. This is needed such that llvm-config run from librustc_llvm's build script can correctly locate it's own LLVM, not the one in stage0/lib. The LLVM build system uses the DT_RUNPATH/RUNPATH header within the llvm-config binary, which we want to use, but because Cargo always adds the host compiler's "libdir" (stage0/lib in our case) to the dynamic linker's search path, we weren't properly finding the freshly-built LLVM in llvm/lib. By restoring the environment variable setting the search path to what bootstrap sees, the problem is resolved and librustc_llvm correctly links and finds the appropriate LLVM. Several run-make-fulldeps tests are also updated with similar handling.
2019-01-13Adding Build automation for x86_64-fortanix-unknown-sgxVardhan Thigle-20/+33
2019-01-07Rollup merge of #57369 - petrhosek:llvm-libcxx, r=alexcrichtonPietro Albini-0/+3
Provide the option to use libc++ even on all platforms This is the default on platforms which use libc++ as the default C++ library but this option allows using libc++ on others as well.
2019-01-05Provide the option to use libc++ even on all platformsPetr Hosek-0/+3
This is the default on platforms which use libc++ as the default C++ library but this option allows using libc++ on others as well.
2019-01-02bootstrap: Link LLVM as a dylib with ThinLTOAlex Crichton-41/+8
When building a distributed compiler on Linux where we use ThinLTO to create the LLVM shared object this commit switches the compiler to dynamically linking that LLVM artifact instead of statically linking to LLVM. The primary goal here is to reduce CI compile times, avoiding two+ ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll reuse the one ThinLTO step done by LLVM's build itself. Lots of discussion about this change can be found [here] and down. A perf run will show whether this is worth it or not! [here]: https://github.com/rust-lang/rust/pull/53245#issuecomment-417015334
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-25Revert "Rollup merge of #56944 - alexcrichton:less-thin2, r=michaelwoerister"kennytm-8/+41
This reverts commit f1051b574c26e20608ff26415a3dddd13f140925, reversing changes made to 833e0b3b8a9f1487a61152ca76f7f74a6b32cc0c.
2018-12-17bootstrap: Link LLVM as a dylib with ThinLTOAlex Crichton-41/+8
When building a distributed compiler on Linux where we use ThinLTO to create the LLVM shared object this commit switches the compiler to dynamically linking that LLVM artifact instead of statically linking to LLVM. The primary goal here is to reduce CI compile times, avoiding two+ ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll reuse the one ThinLTO step done by LLVM's build itself. Lots of discussion about this change can be found [here] and down. A perf run will show whether this is worth it or not! [here]: https://github.com/rust-lang/rust/pull/53245#issuecomment-417015334
2018-12-15Auto merge of #56600 - ljedrz:fix_edition, r=Mark-Simulacrumbors-5/+5
bootstrap: fix edition A byproduct of work on https://github.com/rust-lang/rust/pull/56595; done with `cargo fix --edition`.
2018-12-14std: Activate compiler_builtins `mem` feature for no_std targetsAlex Crichton-1/+3
This was an accidental regression from #56092, but for `no_std` targets being built and distributed we want to be sure to activate the compiler-builtins `mem` feature which demangles important memory-related intrinsics.
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-3/+2
Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from #52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-12-10bootstrap: fix editionljedrz-5/+5
2018-12-07use top level `fs` functions where appropriateAndy Russell-10/+9
This commit replaces many usages of `File::open` and reading or writing with `fs::read_to_string`, `fs::read` and `fs::write`. This reduces code complexity, and will improve performance for most reads, since the functions allocate the buffer to be the size of the file. I believe that this commit will not impact behavior in any way, so some matches will check the error kind in case the file was not valid UTF-8. Some of these cases may not actually care about the error.
2018-11-18Rollup merge of #55867 - RalfJung:dont-panic, r=Mark-SimulacrumPietro Albini-2/+2
do not panic just because cargo failed Currently, a rustc ICE during bootstrap shows *two* backtraces with `RUST_BACKTRACE`. Fix that by making bootstrap just exit when cargo fails. This matches what we do [when building a tool fails](https://github.com/rust-lang/rust/blob/master/src/bootstrap/tool.rs#L189) and [when other stuff (not called through `stream_cargo`, like `cargo test`) fails](https://github.com/rust-lang/rust/blob/master/src/build_helper/lib.rs#L43). Fixes https://github.com/rust-lang/rust/issues/53379
2018-11-11Fix typos.Bruce Mitchener-1/+1
2018-11-11do not panic just because cargo failedRalf Jung-2/+2
2018-11-04Update llvm-emscriptenNikita Popov-1/+1
This updates emscripten to version 1.38.15, which is based on LLVM 6.0.1.
2018-11-02Remove all jemalloc-related contentAlex Crichton-15/+1
This commit removes all jemalloc related submodules, configuration, etc, from the bootstrap, from the standard library, and from the compiler. This will be followed up with a change to use jemalloc specifically as part of rustc on blessed platforms.
2018-10-26bootstrap: clean up a few clippy findingsMatthias Krüger-5/+5
remove useless format!()s remove redundant field names in a few struct initializations pass slice instead of a vector to a function use is_empty() instead of comparisons to .len() No functional change intended.
2018-10-13Improve verify_llvm_ir config optionNikita Popov-0/+3
* Make it influence the behavior of the compiled rustc, rather than just the rustc build system. That is, if verify_llvm_ir=true, even manual invocations of the built rustc will verify LLVM IR. * Enable verification of LLVM IR in CI, for non-deploy and deploy-alt builds. This is similar to how LLVM assertions are handled.
2018-09-29Rename sanitizer runtime libraries on OSXAlex Crichton-1/+1
Currently we ship sanitizer libraries as they're built, but these names unfortunately conflict with the names of the sanitizer libraries installed on the system. If a crate, for example, links in C code that wants to use the system sanitizer and the Rust code doesn't use sanitizers at all, then using `cargo` may accidentally pull in the Rust-installed sanitizer library due to a conflict in names. This change is intended to be entirely transparent for Rust users of sanitizers, it should only hopefully improve our story with other users! Closes #54134
2018-09-18rustbuild: drop color handlingMarc-Antoine Perennou-33/+1
Let cargo handle that for us Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2018-09-17Auto merge of #52036 - collin5:b50509-2, r=collin5bors-24/+4
Clean up dependency tracking in Rustbuild [2/2] Make `clear_if_dirty` calls in `Builder::cargo` with stamp dependencies for the given Mode. Continuation of #50904 Ref issue #50509 r? @Mark-Simulacrum
2018-09-17refactor Builder::cargo, clean deps for cmd!=testCollins Abitekaniza-1/+0
2018-09-12remove struct CleanToolsCollins Abitekaniza-16/+4
2018-09-12clear_if_dirty in Builder::cargo with passed modeCollins Abitekaniza-7/+0
2018-09-10Add rustc SHA to released DWARF debuginfoAlex Crichton-2/+2
This commit updates the debuginfo that is encoded in all of our released artifacts by default. Currently it has paths like `/checkout/src/...` but these are a little inconsistent and have changed over time. This commit instead attempts to actually define the file paths in our debuginfo to be consistent between releases. All debuginfo paths are now intended to be `/rustc/$sha` where `$sha` is the git sha of the released compiler. Sub-paths are all paths into the git repo at that `$sha`.
2018-08-20bootstrap: Allow for building LLVM with ThinLTO.Michael Woerister-3/+44
2018-08-06Building librustc_codegen_llvm in a separate directoryMark Rousskov-4/+5
This allows clearing it out and building it separately from the compiler. Since it's essentially a different and separate crate this makes sense to do, each cargo invocation should generally happen in its own directory.
2018-07-30Remove the unstable std_unicode crate, deprecated since 1.27Simon Sapin-1/+0
Its former contents are now in libcore.
2018-07-14Change keep-stage to only affect the passed stageMark Rousskov-42/+34
The best way to build a stage 2 rustc is now probably ./x.py build --stage 2 src/rustc # once ./x.py build --stage 2 --keep-stage 1 src/rustc
2018-07-13Do not attempt to recompile codegen backend(s) with --keep-stageMark Rousskov-0/+10
Previously we'd attempt to recompile them and that would fail since we've essentially not built the entire compiler yet, or we're faking that fact. This commit should make us ignore the codegen backend build as well. Unlike the other compile steps, there is no CodegenBackendLink step that we run here, because that is done later as a part of assembling the final compiler and as an explicit function call.
2018-07-10Deny bare trait objects in `src/bootstrap`.ljedrz-1/+1
2018-07-05Auto merge of #51936 - japaric:rust-lld, r=alexcrichtonbors-2/+5
rename rustc's lld to rust-lld to not shadow the system installed LLD when linking with LLD. Before: - `-C linker=lld -Z linker-flavor=ld.lld` uses rustc's LLD - It's not possible to use a system installed LLD that's named `lld` With this commit: - `-C linker=rust-lld -Z linker-flavor=ld.lld` uses rustc's LLD - `-C linker=lld -Z linker-flavor=ld.lld` uses the system installed LLD we don't offer guarantees about the availability of LLD in the rustc sysroot so we can rename the tool as long as we don't break the wasm32-unknown-unknown target which depends on it. r? @alexcrichton we discussed this before
2018-07-02Change --keep-stage to apply moreMark Rousskov-20/+43
Previously, the --keep-stage argument would only function for compilers that were depended on by future stages. For example, if trying to build a stage 1 compiler you could --keep-stage 0 to avoid re-building the stage 0 compiler. However, this is often not what users want in practice. The new implementation essentially skips builds all higher stages of the compiler, so an argument of 1 to keep-stage will skip rebuilds of the libraries, just linking them into the sysroot. This is unlikely to work well in cases where metadata or similar changes have been made, but is likely fine otherwise. This change is somewhat untested, but since it shouldn't have any effect except with --keep-stage, I don't see that as a large problem.
2018-07-02Make explicit that assemble is not run from CLIMark Rousskov-1/+1
2018-06-30Notice non-toplevel dll dependencies in rustbuildMark Simulacrum-3/+3
Previously Cargo would hardlink all the dependencies into the "root" as foo.dll and the `toplevel` array would get populated with these, but that's no longer the case. Instead, cargo will only do this for the final artifacts/final libraries. Rustbuild is updated to continue looping through the artifacts mentioned instead of early-returning. This should fix the bug. @alexcrichton found the cause of this and suggested this fix.
2018-06-29rename rustc's lld to rust-lldJorge Aparicio-2/+5
to not shadow the system installed LLD when linking with LLD. Before: - `-C linker=lld -Z linker-flavor=ld.lld` uses rustc's LLD - It's not possible to use a system installed LLD that's named `lld` With this commit: - `-C linker=rust-lld -Z linker-flavor=ld.lld` uses rustc's LLD - `-C linker=lld -Z linker-flavor=ld.lld` uses the system installed LLD
2018-06-03refactor, make requested changesCollins Abitekaniza-3/+3
2018-06-03refactor Mode enumCollins Abitekaniza-16/+16
2018-05-17Auto merge of #50629 - Mark-Simulacrum:stage-step, r=alexcrichtonbors-1/+1
Switch to bootstrapping from 1.27 It's possible the Float trait could be removed from core, but I couldn't tell whether it was intended to be removed or not. @SimonSapin may be able to comment more here; we can presumably also do that in a follow up PR as this one is already quite large.
2018-05-17Fix rustc binary metadata overwriting librustc metadataMark Simulacrum-1/+1
In #49289, rustc was changed to emit metadata for binaries, which made it so that the librustc.rmeta file created when compiling librustc was overwritten by the rustc-main compilation. This commit renames the rustc-main binary to avoid this problem. https://github.com/rust-lang/cargo/issues/5524 has also been filed to see if Cargo can learn to warn on this situation instead of leaving it for the user to debug.
2018-05-17Rename trans to codegen everywhere.Irina Popa-8/+8