Commit Graph

260 Commits

Author SHA1 Message Date
Vadim Petrochenkov 10d3f8a484 Move `rustllvm` into `rustc_llvm` 2020-09-09 23:05:43 +03:00
Vadim Petrochenkov 7dfbf59f10 cleanup: Remove duplicate library names from `Cargo.toml`s 2020-08-30 22:57:54 +03:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
Joshua Nelson f7dcfcd45b Don't build rustc without std
- Set rustc to build only when explicitly asked for

This allows building the stage2 rustc artifacts, which nothing depends
on.

Previously the behavior was as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):

- `x.py build --stage 0`:
  - stage0 libstd
  - stage1 rustc (but without putting rustc in stage0/)

This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc
  - stage2 rustc

This leaves you with a broken stage2 rustc which doesn't even have
libcore and is effectively useless. Additionally, it compiles rustc
twice, which is not normally what you want.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 rustdoc and tools

This builds all tools in release mode. This is the correct usage for CI,
but takes far to long for development.

Now the behavior is as follows:

- `x.py build --stage 0`:
  - stage0 libstd

This is suitable for contributors only working on the standard library,
as it means rustc never has to be compiled.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc

This is suitable for contributors working on the compiler. It ensures
that you have a working rustc and libstd without having to pass
`src/libstd` in addition.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc

This is suitable for debugging errors which only appear with the stage2
compiler.

- `x.py build --stage 2 src/libstd src/rustc`
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc, tools, etc.
  - stage2 rustc artifacts ('stage3')

This is suitable for CI, which wants all tools in release mode.
However, most of the use cases for this should use `x.py dist` instead,
which builds all the tools without each having to be named individually.
2020-07-27 23:11:18 -04:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
Jake Goulding e2b337dc57 Teach bootstrap about target files vs target triples
`rustc` allows passing in predefined target triples as well as JSON
target specification files. This change allows bootstrap to have the
first inkling about those differences. This allows building a
cross-compiler for an out-of-tree architecture (even though that
compiler won't work for other reasons).

Even if no one ever uses this functionality, I think the newtype
around the `Interned<String>` improves the readability of the code.
2020-07-17 10:08:04 -04:00
Mark Rousskov 647d9b525f apply bootstrap cfgs 2020-07-16 19:36:49 -04:00
Lzu Tao 481988b083 Use str::strip* in bootstrap
This commit replaces the use of `trim_start_matches`
because in `rustc -Vv` output there are no lines
starting with multiple "release:".
2020-07-10 07:18:19 +00:00
bors 16957bd4d3 Auto merge of #73456 - tmiasko:musl-libdir, r=Mark-Simulacrum
bootstrap: Configurable musl libdir

Make it possible to customize the location of musl libdir using
musl-libdir in config.toml, e.g., to use lib64 instead of lib.
2020-06-30 15:41:50 +00:00
Manish Goregaokar 38cbf158b8
Rollup merge of #72937 - AdrianCX:master, r=nikomatsakis
Fortanix SGX target libunwind build process changes

Ticket: https://github.com/fortanix/rust-sgx/issues/174
LLVM related changes (merged): https://github.com/rust-lang/llvm-project/pull/57

Description: libunwind changes needed to run code in sgx environment via rust-sgx.

Target that uses this in rust: x86_64-fortanix-unknown-sgx.

Without this change, rust std for this toolchain is forced to use a precompiled library loaded via environment variable.

With this change we act the same as musl target.
2020-06-26 13:57:26 -07:00
Eric Huss 75983e137e Support configurable deny-warnings for all in-tree crates. 2020-06-25 21:17:21 -07:00
Adrian Cruceru 343a9212b0 Fix comments 2020-06-25 12:01:02 +02:00
Adrian Cruceru f3b1582bb9 Update libunwind build process for x86_64-fortanix-unknown-sgx target 2020-06-24 11:28:41 +02:00
Ralf Jung ea3c309700
Rollup merge of #72999 - mati865:separate-self-contained-dir, r=Mark-Simulacrum
Create self-contained directory and move there some of external binaries/libs

One of the steps to reach design described in https://github.com/rust-lang/rust/issues/68887#issuecomment-633048380
This PR moves things around and allows link code to handle the new directory structure.
2020-06-19 08:56:04 +02:00
Tomasz Miąsko 5c20ef433b bootstrap: Configurable musl libdir
Make it possible to customize the location of musl libdir using
musl-libdir in config.toml, e.g., to use lib64 instead of lib.
2020-06-18 07:36:22 +02:00
bors 2935d294ff Auto merge of #69890 - lenary:lenary/riscv-frame-pointers, r=hanna-kruppe,Mark-Simulacrum
[RISC-V] Do not force frame pointers

We have been seeing some very inefficient code that went away when using
`-Cforce-frame-pointers=no`. For instance `core::ptr::drop_in_place` at
`-Oz` was compiled into a function which consisted entirely of saving
registers to the stack, then using the frame pointer to restore the same
registers (without any instructions between the prolog and epilog).

The RISC-V LLVM backend supports frame pointer elimination, so it makes
sense to allow this to happen when using Rust. It's not clear to me that
frame pointers have ever been required in the general case.

In rust-lang/rust#61675 it was pointed out that this made reassembling
stack traces easier, which is true, but there is a code generation
option for forcing frame pointers, and I feel the default should not be
to require frame pointers, given it demonstrably makes code size worse
(around 10% in some embedded applications).

The kinds of targets mentioned in rust-lang/rust#61675 are popular, but
should not dictate that code generation should be worse for all RISC-V
targets, especially as there is a way to use CFI information to
reconstruct the stack when the frame pointer is eliminated. It is also
a misconception that `fp` is always used for the frame pointer. `fp` is
an ABI name for `x8` (aka `s0`), and if no frame pointer is required,
`x8` may be used for other callee-saved values.

---

I am partly posting this to get feedback from @fintelia who introduced the change to require frame pointers, and @hanna-kruppe who had issues with the original PR. I would understand if we wanted to remove this setting on only a subset of RISC-V targets, but my preference would be to remove this setting everywhere.

There are more details on the code size savings seen in Tock here: https://github.com/tock/tock/pull/1660
2020-06-17 11:30:56 +00:00
Mateusz Mikuła 5d298836f2 Move some libs to self-contained directory 2020-06-11 18:48:43 +02:00
Mateusz Mikuła 961974fe03 Use enum to distinguish dependency type 2020-06-11 18:48:32 +02:00
Mateusz Mikuła 638ebbc585 Move copying of MinGW CRT to the better location 2020-06-11 18:34:23 +02:00
Mateusz Mikuła 9ceb9bb203 Move copying of self-contained objects to new function 2020-06-11 18:33:42 +02:00
Ralf Jung f507748ce4 x.py: with --json-output, forward cargo's JSON 2020-06-10 18:59:48 +02:00
Sam Elliott 3da3d15f9f [RISC-V] Do not force frame pointers
We have been seeing some very inefficient code that went away when using
`-Cforce-frame-pointers=no`. For instance `core::ptr::drop_in_place` at
`-Oz` was compiled into a function which consisted entirely of saving
registers to the stack, then using the frame pointer to restore the same
registers (without any instructions between the prolog and epilog).

The RISC-V LLVM backend supports frame pointer elimination, so it makes
sense to allow this to happen when using Rust. It's not clear to me that
frame pointers have ever been required in the general case.

In rust-lang/rust#61675 it was pointed out that this made reassembling
stack traces easier, which is true, but there is a code generation
option for forcing frame pointers, and I feel the default should not be
to require frame pointers, given it demonstrably makes code size worse
(around 10% in some embedded applications).

The kinds of targets mentioned in rust-lang/rust#61675 are popular, but
should not dictate that code generation should be worse for all RISC-V
targets, especially as there is a way to use CFI information to
reconstruct the stack when the frame pointer is eliminated. It is also
a misconception that `fp` is always used for the frame pointer. `fp` is
an ABI name for `x8` (aka `s0`), and if no frame pointer is required,
`x8` may be used for other callee-saved values.

This commit does ensure that the standard library is built with unwind
tables, so that users do not need to rebuild the standard library in
order to get a backtrace that includes standard library calls (which is
the original reason for forcing frame pointers).
2020-05-30 18:24:19 +01:00
bors c60b675e28 Auto merge of #72000 - cuviper:dist-llvm, r=Mark-Simulacrum
Move the target libLLVM to llvm-tools-preview

For running the compiler, we usually only need LLVM from `$sysroot/lib`,
which rustup will make available with `LD_LIBRARY_PATH`. We've also been
shipping LLVM in the `$target/lib` directory, which bloats the download
and installed size. The only times we do need the latter are for the
RPATH of `llvm-tools-preview` binaries, and for linking `rustc-dev`
libraries. We'll move it to the `llvm-tools-preview` component directly,
and `rustc-dev` will have an implicit dependency on it.

Here are the dist sizes that I got before and after this change:

    llvm-tools-1.45.0-dev-x86_64-unknown-linux-gnu.tar.gz     1.3M   24M
    llvm-tools-1.45.0-dev-x86_64-unknown-linux-gnu.tar.xz     748K   17M
    rustc-1.45.0-dev-x86_64-unknown-linux-gnu.tar.gz          83M    61M
    rustc-1.45.0-dev-x86_64-unknown-linux-gnu.tar.xz          56M    41M

The installed size should reduce by exactly one `libLLVM.so` (~70-80M),
unless you also install `llvm-tools`, and then it should be identical.

Resolves #70838.
2020-05-22 04:52:38 +00:00
Josh Stone 9c97b3cbf1 Move the target libLLVM to llvm-tools-preview
For running the compiler, we usually only need LLVM from `$sysroot/lib`,
which rustup will make available with `LD_LIBRARY_PATH`. We've also been
shipping LLVM in the `$target/lib` directory, which bloats the download
and installed size. The only times we do need the latter are for the
RPATH of `llvm-tools-preview` binaries, and for linking `rustc-dev`
libraries. We'll move it to the `llvm-tools-preview` component directly,
and `rustc-dev` will have an implicit dependency on it.

Here are the dist sizes that I got before and after this change:

    llvm-tools-1.45.0-dev-x86_64-unknown-linux-gnu.tar.gz     1.3M   24M
    llvm-tools-1.45.0-dev-x86_64-unknown-linux-gnu.tar.xz     748K   17M
    rustc-1.45.0-dev-x86_64-unknown-linux-gnu.tar.gz          83M    61M
    rustc-1.45.0-dev-x86_64-unknown-linux-gnu.tar.xz          56M    41M

The installed size should reduce by exactly one `libLLVM.so` (~70-80M),
unless you also install `llvm-tools`, and then it should be identical.
2020-05-20 16:28:28 -07:00
Vadim Petrochenkov 49eb35c05e linker: More systematic handling of CRT objects 2020-05-14 10:45:11 +03:00
Mark Rousskov 7f645aba10 Don't skip building LLVM if already built 2020-05-02 18:43:55 -04:00
bors dae90c1959 Auto merge of #71716 - alexcrichton:bitcode-follow-up, r=nnethercote
Rename `bitcode-in-rlib` option to `embed-bitcode`

This commit finishes work first pioneered in #70458 and started in #71528.
The `-C bitcode-in-rlib` option, which has not yet reached stable, is
renamed to `-C embed-bitcode` since that more accurately reflects what
it does now anyway. Various tests and such are updated along the way as
well.

This'll also need to be backported to the beta channel to ensure we
don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-02 03:39:04 +00:00
Alex Crichton e1832fa4e4 Rename `bitcode-in-rlib` option to `embed-bitcode`
This commit finishes work first pioneered in #70458 and started in #71528.
The `-C bitcode-in-rlib` option, which has not yet reached stable, is
renamed to `-C embed-bitcode` since that more accurately reflects what
it does now anyway. Various tests and such are updated along the way as
well.

This'll also need to be backported to the beta channel to ensure we
don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01 09:05:13 -07:00
Mark Rousskov 5a5fa39909 Handle build completion message from Cargo
This was introduced in the recent bump to 1.43 bootstrap cargo
2020-04-25 19:14:58 -04:00
Nicholas Nethercote a105c5c2c0 Build libstd with `-Cbitcode-in-rlib=yes`.
So that the rlibs will work with both LTO and non-LTO builds.
2020-04-22 15:22:18 +10:00
Luca Barbieri 53d58dbf5f Require compiler-rt root at ../src/llvm-project/compiler-rt 2020-04-11 17:49:16 -04:00
bors 548afdbe1a Auto merge of #70726 - Centril:rollup-zrdkkpt, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #68334 (AArch64 bare-metal targets: Build rust-std)
 - #70224 (Clean up rustdoc js testers)
 - #70532 (Miri engine: stronger type-based sanity check for assignments)
 - #70698 (bootstrap: add `--json-output` for rust-analyzer)
 - #70715 (Fix typo in operands section)

Failed merges:

r? @ghost
2020-04-03 04:18:32 +00:00
Niko Matsakis e992565857 bootstrap: add `--json-output` for rust-analyzer 2020-04-02 10:36:25 -04:00
Eduard-Mihai Burtescu f5892c00ac Translate the virtual `/rustc/$hash` prefix back to a real directory. 2020-04-02 11:39:41 +03:00
Josh Stone e1a6a306ad Revert "Fix missing libLLVM.so in stage0 sysroot."
This reverts commit 8b9c5396ca.
2020-03-18 16:09:06 -07:00
Matthias Krüger 136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Matthias Krüger 5f979e9afa bootstrap: fix clippy warnings 2020-02-03 20:26:36 +01:00
Tomasz Miąsko ae57259403 Add bootstrap step for building sanitizer runtimes 2020-01-09 07:54:02 +01:00
Mark Rousskov ccd8c8c890 Clear out target directory if compiler has changed
Previously, we relied fully on Cargo to detect that the compiler had changed and
it needed to rebuild the standard library (or later "components"). This used to
not quite be the case prior to moving to LLVM be a separate cargo invocation;
subsequent compiles would recompile std and friends if LLVM had changed
(#67077 is the PR that changes things here).

This PR moves us to clearing out libstd when it is being compiled if the rustc
we're using has changed. We fairly harshly limit the cases in which we do this
(e.g., ignoring dry run mode, and so forth, as well as rustdoc invocations).
This is primarily because when we're not using the compiler directly, so
clearing out in other cases is likely to lead to bugs, particularly as our
deletion scheme is pretty blunt today (basically removing more than is needed,
i.e., not just the rustc artifacts).

In practice, this targeted fix does fix the known bug, though it may not fully
resolve the problem here. It's also not clear that there is a full fix hiding
here that doesn't involve a more major change (like -Zbinary-dep-depinfo was).

As a drive-by fix, don't delete the compiler before calling Build::copy, as that
also deletes the compiler.
2020-01-01 20:06:56 -05:00
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mateusz Mikuła 44603a5cd6 Reenable static linking of libstdc++ on windows-gnu 2019-12-18 22:48:24 +01:00
Aaron Hill 9245182420
Add comment explaining original `maybe_install_llvm_dylib` call 2019-12-11 09:50:12 -05:00
Aaron Hill 8b9c5396ca
Fix missing libLLVM.so in stage0 sysroot.
When we dynamically link against libLLVM.so (as opposed to statically
linking LLVM), we need libLLVM.so to be present in the stage0 sysroot,
so that stage1 tools (which are built against the stage0
compiler+sysroot) can see it at build time (when the linker is run)

See the comment in the commit for more details
2019-12-11 09:50:12 -05:00
Alex Crichton 91b25a84df
Fix some linking of LLVM's dynamic library
Ensure it shows up in the same places it did before so tools can find it
at runtime.
2019-12-11 09:50:11 -05:00
Alex Crichton 7f23e6e8d7
rustc: Link LLVM directly into rustc again
This commit builds on #65501 continue to simplify the build system and
compiler now that we no longer have multiple LLVM backends to ship by
default. Here this switches the compiler back to what it once was long
long ago, which is linking LLVM directly to the compiler rather than
dynamically loading it at runtime. The `codegen-backends` directory of
the sysroot no longer exists and all relevant support in the build
system is removed. Note that `rustc` still supports a dynamically loaded
codegen backend as it did previously, it just no longer supports
dynamically loaded codegen backends in its own sysroot.

Additionally as part of this the `librustc_codegen_llvm` crate now once
again explicitly depends on all of its crates instead of implicitly
loading them through the sysroot. This involved filling out its
`Cargo.toml` and deleting all the now-unnecessary `extern crate`
annotations in the header of the crate. (this in turn required adding a
number of imports for names of macros too).

The end results of this change are:

* Rustbuild's build process for the compiler as all the "oh don't forget
  the codegen backend" checks can be easily removed.
* Building `rustc_codegen_llvm` is much simpler since it's simply
  another compiler crate.
* Managing the dependencies of `rustc_codegen_llvm` is much simpler since
  it's "just another `Cargo.toml` to edit"
* The build process should be a smidge faster because there's more
  parallelism in the main rustc build step rather than splitting
  `librustc_codegen_llvm` out to its own step.
* The compiler is expected to be slightly faster by default because the
  codegen backend does not need to be dynamically loaded.
* Disabling LLVM as part of rustbuild is still supported, supporting
  multiple codegen backends is still supported, and dynamic loading of a
  codegen backend is still supported.
2019-12-11 09:50:11 -05:00
Brian Wignall 16fabd8efd Fix spelling typos 2019-11-26 22:19:54 -05:00
Mateusz Mikuła b20d8d3396 Statically link libstdc++ on windows-gnu 2019-10-30 23:18:57 +01:00
bors 8e0007f829 Auto merge of #65474 - Mark-Simulacrum:rustc-dev-split, r=pietroalbini
Split the rustc target libraries into separate rustc-dev component

This is re-applies a squashed version of #64823 as well as including #65337 to fix bugs noted after merging the first PR.

The second PR is confirmed as fixing windows-gnu, and presumably also fixes other platforms, such as musl (i.e. #65335 should be fixed); `RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup toolchain install nightly-2019-10-16` can be installed to confirm that this is indeed the case.
2019-10-24 07:27:00 +00:00
Alex Crichton c7d285b781 Remove `src/llvm-emscripten` submodule
With #65251 landed there's no need to build two LLVM backends and ship
them with rustc, every target we have now uses the same LLVM backend!

This removes the `src/llvm-emscripten` submodule and additionally
removes all support from rustbuild for building the emscripten LLVM
backend. Multiple codegen backend support is left in place for now, and
this is intended to be an easy 10-15 minute win on CI times by avoiding
having to build LLVM twice.
2019-10-21 13:05:31 -07:00
Jethro Beekman 7ccf492ae6 Package non-rust objects 2019-10-15 18:38:18 -04:00