Commit Graph

172 Commits

Author SHA1 Message Date
bjorn3 b7314c7caf
Actually make rustc_driver compile without llvm 2017-08-11 14:00:05 +02:00
bjorn3 b43c02b0aa
Make librustc_driver work without librustc_trans 2017-08-11 10:38:31 +02:00
Danek Duvall 9c5397d033 Update libc to 0.2.29
Cargo pulls in libc from crates.io for a number of dependencies, but
0.2.27 is too old to work properly with Solaris.  In particular, it
needs the change to make Solaris' PTHREAD_PROCESS_PRIVATE a 16-bit
integer.
2017-08-07 15:42:30 -07:00
Nick Cameron 17d5f6a086 update rls 2017-08-07 12:16:04 +12:00
bors 2b82b7e50a Auto merge of #43554 - eddyb:apfloat, r=nikomatsakis
APFloat: Rewrite It In Rust and use it for deterministic floating-point CTFE.

As part of the CTFE initiative, we're forced to find a solution for floating-point operations.
By design, IEEE-754 does not explicitly define everything in a deterministic manner, and there is some variability between platforms, at the very least (e.g. NaN payloads).

If types are to evaluate constant expressions involving type (or in the future, const) generics, that evaluation needs to be *fully deterministic*, even across `rustc` host platforms.
That is, if `[T; T::X]` was used in a cross-compiled library, and the evaluation of `T::X` executed a floating-point operation, that operation has to be reproducible on *any other host*, only knowing `T` and the definition of the `X` associated const (as either AST or HIR).

Failure to uphold those rules allows an associated type (e.g. `<Foo as Iterator>::Item`) to be seen as two (or more) different types, depending on the current host, and such type safety violations typically allow writing of a `transmute` in safe code, given enough generics.

The options considered by @rust-lang/compiler were:
1. Ban floating-point operations in generic const-evaluation contexts
2. Emulate floating-point operations in an uniformly deterministic fashion

The former option may seem appealing at first, but floating-point operations *are allowed today*, so they can't be banned wholesale, a distinction has to be made between the code that already works, and future generic contexts. *Moreover*, every computation that succeeded *has to be cached*, otherwise the generic case can be reproduced without any generics. IMO there are too many ways it can go wrong, and a single violation can be enough for an unsoundness hole.
Not to mention we may end up really wanting floating-point operations *anyway*, in CTFE.

I went with the latter option, and seeing how LLVM *already* has a library for this exact purpose (as it needs to perform optimizations independently of host floating-point capabilities), i.e. `APFloat`, that was what I ended up basing this PR on.
But having been burned by the low reusability of bindings that link to LLVM, and because I would *rather* the floating-point operations to be wrong than not deterministic or not memory-safe (`APFloat` does far more pointer juggling than I'm comfortable with), I decided to RIIR.

This way, we have a guarantee of *no* `unsafe` code, a bit more control over the where native floating-point might accidentally be involved, and non-LLVM backends can share it.
I've also ported all the testcases over, *before* any functionality, to catch any mistakes.

Currently the PR replaces all CTFE operations to go through `apfloat::ieee::{Single,Double}`, keeping only the bits of the `f32` / `f64` memory representation in between operations.
Converting from a string also double-checks that `core::num` and `apfloat` agree on the interpretation of a floating-point number literal, in case either of them has any bugs left around.

r? @nikomatsakis
f? @nagisa @est31

<hr/>

Huge thanks to @edef1c for first demoing usable `APFloat` bindings and to @chandlerc for fielding my questions on IRC about `APFloat` peculiarities (also upstreaming some bugfixes).
2017-08-05 13:12:56 +00:00
Nick Cameron 5abbf798e7 Update RLS 2017-08-02 17:53:37 +12:00
Nick Cameron 8c1699d874 Update rls-data dep 2017-08-02 16:57:50 +12:00
Eduard-Mihai Burtescu 877ec94654 rustc_apfloat: introduce the base Float API. 2017-08-02 03:45:03 +03:00
bors e772c28d2e Auto merge of #43506 - michaelwoerister:async-llvm, r=alexcrichton
Run translation and LLVM in parallel when compiling with multiple CGUs

This is still a work in progress but the bulk of the implementation is done, so I thought it would be good to get it in front of more eyes.

This PR makes the compiler start running LLVM while translation is still in progress, effectively allowing for more parallelism towards the end of the compilation pipeline. It also allows the main thread to switch between either translation or running LLVM, which allows to reduce peak memory usage since not all LLVM module have to be kept in memory until linking. This is especially good for incr. comp. but it works just as well when running with `-Ccodegen-units=N`.

In order to help tuning and debugging the work scheduler, the PR adds the `-Ztrans-time-graph` flag which spits out html files that show how work packages where scheduled:
![Building regex](https://user-images.githubusercontent.com/1825894/28679272-f6752bd8-72f2-11e7-8a6c-56207855ce95.png)
(red is translation, green is llvm)

One side effect here is that `-Ztime-passes` might show something not quite correct because trans and LLVM are not strictly separated anymore. I plan to have some special handling there that will try to produce useful output.

One open question is how to determine whether the trans-thread should switch to intermediate LLVM processing.

TODO:
- [x] Restore `-Z time-passes` output for LLVM.
- [x] Update documentation, esp. for work package scheduling.
- [x] Tune the scheduling algorithm.

cc @alexcrichton @rust-lang/compiler
2017-08-01 17:21:24 +00:00
bors df90a54662 Auto merge of #43533 - nrc:macro-save, r=jseyfried,
Three small fixes for save-analysis

First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use).

Second commit is basically a typo fix.

Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., `x` in `println!("...", x)`). If `format!` had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so `DUMMY_SP` is the best we can do (using the span in the callee really breaks save-analysis because it thinks `x` is a definition as well as a reference).

There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests).

r? @jseyfried
2017-08-01 03:52:14 +00:00
Nick Cameron 27b9182d5b review changes 2017-08-01 15:06:22 +12:00
Michael Woerister bd36df84a5 async-llvm(24): Improve scheduling and documentation. 2017-07-31 15:15:44 +02:00
bors 53bf7903fa Auto merge of #43009 - GuillaumeGomez:unused-doc-comments, r=nrc
Throw errors when doc comments are added where they're unused

#42617
2017-07-29 23:01:45 +00:00
Guillaume Gomez 5636d325ed Update cargo version 2017-07-29 15:11:31 +02:00
Mark Simulacrum e2e9b40e9a Build rustdoc on-demand.
Rustdoc is no longer compiled in every stage, alongside rustc, instead
it is only compiled when requested, and generally only for the last
stage.
2017-07-27 05:51:22 -06:00
Nick Cameron b23c83e0c2 Update RLS 2017-07-26 18:51:32 +12:00
Alex Crichton 9010567dcc Bump master to 1.21.0
This commit bumps the master branch's version to 1.21.0 and also updates the
bootstrap compiler from the freshly minted beta release.
2017-07-25 07:03:19 -07:00
bors 513906c43d Auto merge of #43327 - nrc:rls-config, r=eddyb
Use a config struct for save-analysis

Replaces some existing customisation options, including removing the -Zsave-analysis-api flag

r? @eddyb
2017-07-24 07:29:25 +00:00
Nick Cameron ad8ecc20a2 Point RLS submodule at a branch with required changes
And cargo update
2017-07-24 17:25:15 +12:00
bors 8d22af87d8 Auto merge of #43059 - Mark-Simulacrum:rustbuild-2.0, r=alexcrichton
Rework Rustbuild to an eagerly compiling approach

This introduces a new dependency on `serde`; I don't believe that's a problem since bootstrap is compiled with nightly/beta always so proc macros are available. Compile times are slightly longer -- about 2-3x (30 seconds vs. 10 seconds). I don't think this is too big a problem, especially since recompiling bootstrap is somewhat rare. I think we can remove the dependency on Serde if necessary, though, so let me know.

r? @alexcrichton
2017-07-22 18:27:29 +00:00
Nick Cameron 84d93a4edd Use a config file with save-analysis
Replaces the output path env var. Can be passed to save-analysis via a function call or env var.
2017-07-22 16:35:40 +12:00
Simon Sapin b77ff24060 Update Cargo to ffab51954ec32d55631c37a8730bb24915fc090b
https://github.com/rust-lang/cargo/pull/4123 added the [patch] section of the manifest
2017-07-21 11:13:18 +02:00
Mark Simulacrum dec44b0656 Resolve rebase errors 2017-07-20 11:24:36 -06:00
Mark Simulacrum 528646e127 Utilize interning to allow Copy/Clone steps 2017-07-20 11:24:32 -06:00
Mark Simulacrum a1fa2681cf Update to toml 0.4 2017-07-20 11:23:59 -06:00
Mark Simulacrum 60388303c7 Fixes warnings and errors introduced while moving code around 2017-07-20 11:23:58 -06:00
Nick Cameron 04415dc64c Run RLS tests 2017-07-17 17:21:46 +12:00
bors c4373bd6a2 Auto merge of #43207 - alexcrichton:update-cargo, r=nikomatsakis
Update the `cargo` submodule

Notably pull in an update to the `jobserver` crate to have Cargo set the
`CARGO_MAKEFLAGS` environment variable instead of the `MAKEFLAGS` environment
variable.

cc https://github.com/rust-lang/rust/issues/42635
2017-07-15 11:02:35 +00:00
Alex Crichton bdcebc938b Update the `cargo` submodule
Notably pull in an update to the `jobserver` crate to have Cargo set the
`CARGO_MAKEFLAGS` environment variable instead of the `MAKEFLAGS` environment
variable.
2017-07-13 07:54:28 -07:00
Oliver Schneider cb92ab93a2 Reduce the usage of features in compiletest and libtest 2017-07-13 16:37:57 +02:00
steveklabnik 4871dba5d4 update crate dependencies
I wanted to update mdbook's version. This ended up updating a bunch of other stuff too.
2017-07-11 21:18:44 -04:00
Vadim Petrochenkov 9ac79e4934 Update rls to pull rustfmt with libsyntax changes 2017-07-10 00:20:25 +03:00
bors 8cab2c73d4 Auto merge of #42899 - alexcrichton:compiler-builtins, r=nikomatsakis
Switch to rust-lang-nursery/compiler-builtins

This commit migrates the in-tree `libcompiler_builtins` to the upstream version
at https://github.com/rust-lang-nursery/compiler-builtins. The upstream version
has a number of intrinsics written in Rust and serves as an in-progress rewrite
of compiler-rt into Rust. Additionally it also contains all the existing
intrinsics defined in `libcompiler_builtins` for 128-bit integers.

It's been the intention since the beginning to make this transition but
previously it just lacked the manpower to get done. As this PR likely shows it
wasn't a trivial integration! Some highlight changes are:

* The PR rust-lang-nursery/compiler-builtins#166 contains a number of fixes
  across platforms and also some refactorings to make the intrinsics easier to
  read. The additional testing added there also fixed a number of integration
  issues when pulling the repository into this tree.

* LTO with the compiler-builtins crate was fixed to link in the entire crate
  after the LTO process as these intrinsics are excluded from LTO.

* Treatment of hidden symbols was updated as previously the
  `#![compiler_builtins]` crate would mark all symbol *imports* as hidden
  whereas it was only intended to mark *exports* as hidden.
2017-07-06 02:34:29 +00:00
bors 1685c92986 Auto merge of #42727 - alexcrichton:allocators-new, r=eddyb
rustc: Implement the #[global_allocator] attribute

This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/1974

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389
2017-07-06 00:16:16 +00:00
Alex Crichton 695dee063b rustc: Implement the #[global_allocator] attribute
This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389
2017-07-05 14:37:01 -07:00
Alex Crichton fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
Alex Crichton 7e6c9f3635 Switch to rust-lang-nursery/compiler-builtins
This commit migrates the in-tree `libcompiler_builtins` to the upstream version
at https://github.com/rust-lang-nursery/compiler-builtins. The upstream version
has a number of intrinsics written in Rust and serves as an in-progress rewrite
of compiler-rt into Rust. Additionally it also contains all the existing
intrinsics defined in `libcompiler_builtins` for 128-bit integers.

It's been the intention since the beginning to make this transition but
previously it just lacked the manpower to get done. As this PR likely shows it
wasn't a trivial integration! Some highlight changes are:

* The PR rust-lang-nursery/compiler-builtins#166 contains a number of fixes
  across platforms and also some refactorings to make the intrinsics easier to
  read. The additional testing added there also fixed a number of integration
  issues when pulling the repository into this tree.

* LTO with the compiler-builtins crate was fixed to link in the entire crate
  after the LTO process as these intrinsics are excluded from LTO.

* Treatment of hidden symbols was updated as previously the
  `#![compiler_builtins]` crate would mark all symbol *imports* as hidden
  whereas it was only intended to mark *exports* as hidden.
2017-07-05 07:08:36 -07:00
est31 3b91f9406c Update cargo
... to get https://github.com/rust-lang/cargo/pull/4244 and
https://github.com/rust-lang/cargo/pull/4246
2017-07-02 16:42:13 +02:00
bors d41b791c1a Auto merge of #42971 - stepancheg:ir-demangle, r=nagisa
When writing LLVM IR output demangled fn name in comments

`--emit=llvm-ir` looks like this now:

```
; <alloc::vec::Vec<T> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
; Function Attrs: inlinehint uwtable
define internal { i8*, i64 } @"_ZN106_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..index..IndexMut$LT$core..ops..range..RangeFull$GT$$GT$9index_mut17h7f7b576609f30262E"(%"alloc::vec::Vec<u8>"* dereferenceable(24)) unnamed_addr #0 {
start:
  ...
```

cc https://github.com/integer32llc/rust-playground/issues/15
2017-07-01 05:52:08 +00:00
Stepan Koltsov b62bdaafe0 When writing LLVM IR output demangled fn name in comments
`--emit=llvm-ir` looks like this now:

```
; <alloc::vec::Vec<T> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
; Function Attrs: inlinehint uwtable
define internal { i8*, i64 } @"_ZN106_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..ops..index..IndexMut$LT$core..ops..range..RangeFull$GT$$GT$9index_mut17h7f7b576609f30262E"(%"alloc::vec::Vec<u8>"* dereferenceable(24)) unnamed_addr #0 {
start:
  ...
```

cc https://github.com/integer32llc/rust-playground/issues/15
2017-07-01 03:16:43 +03:00
Nick Cameron 3dad1977a5 Update RLS submodule 2017-06-28 06:40:23 +12:00
Mark Simulacrum 38b468832f Update Cargo 2017-06-26 10:30:36 -06:00
Jeffrey Seyfried e42836b208 Implement `quote!` and other `proc_macro` API. 2017-06-26 02:06:26 +00:00
bors 80271e8edf Auto merge of #42682 - alexcrichton:jobserver, r=michaelwoerister
Integrate jobserver support to parallel codegen

This commit integrates the `jobserver` crate into the compiler. The crate was
previously integrated in to Cargo as part of rust-lang/cargo#4110. The purpose
here is to two-fold:

* Primarily the compiler can cooperate with Cargo on parallelism. When you run
  `cargo build -j4` then this'll make sure that the entire build process between
  Cargo/rustc won't use more than 4 cores, whereas today you'd get 4 rustc
  instances which may all try to spawn lots of threads.

* Secondarily rustc/Cargo can now integrate with a foreign GNU `make` jobserver.
  This means that if you call cargo/rustc from `make` or another
  jobserver-compatible implementation it'll use foreign parallelism settings
  instead of creating new ones locally.

As the number of parallel codegen instances in the compiler continues to grow
over time with the advent of incremental compilation it's expected that this'll
become more of a problem, so this is intended to nip concurrent concerns in the
bud by having all the tools to cooperate!

Note that while rustc has support for itself creating a jobserver it's far more
likely that rustc will always use the jobserver configured by Cargo. Cargo today
will now set a jobserver unconditionally for rustc to use.
2017-06-22 00:32:42 +00:00
Corey Farwell 80e14a0fe3 Rollup merge of #42766 - nrc:versions, r=nagisa
Update rls-data version

And update the RLS submod
2017-06-21 10:40:17 -04:00
Alex Crichton 201f06988f Integrate jobserver support to parallel codegen
This commit integrates the `jobserver` crate into the compiler. The crate was
previously integrated in to Cargo as part of rust-lang/cargo#4110. The purpose
here is to two-fold:

* Primarily the compiler can cooperate with Cargo on parallelism. When you run
  `cargo build -j4` then this'll make sure that the entire build process between
  Cargo/rustc won't use more than 4 cores, whereas today you'd get 4 rustc
  instances which may all try to spawn lots of threads.

* Secondarily rustc/Cargo can now integrate with a foreign GNU `make` jobserver.
  This means that if you call cargo/rustc from `make` or another
  jobserver-compatible implementation it'll use foreign parallelism settings
  instead of creating new ones locally.

As the number of parallel codegen instances in the compiler continues to grow
over time with the advent of incremental compilation it's expected that this'll
become more of a problem, so this is intended to nip concurrent concerns in the
bud by having all the tools to cooperate!

Note that while rustc has support for itself creating a jobserver it's far more
likely that rustc will always use the jobserver configured by Cargo. Cargo today
will now set a jobserver unconditionally for rustc to use.
2017-06-21 07:16:43 -07:00
Alex Crichton 5c3d0e6de3 Switch to the crates.io `getopts` crate
This commit deletes the in-tree `getopts` crate in favor of the crates.io-based
`getopts` crate. The main difference here is with a new builder-style API, but
otherwise everything else remains relatively standard.
2017-06-20 12:43:12 -07:00
bors 753fee4ab6 Auto merge of #42495 - alexcrichton:new-stage0, r=Mark-Simulacrum
Bump to 1.20.0 and update stage0 compiler

Betas are hot off the bots, let's get them while they're fresh.
2017-06-20 07:22:38 +00:00
Nick Cameron 7a18a77e1b Update rls-data dep 2017-06-20 18:55:14 +12:00
Alex Crichton be7ebdd512 Bump version and stage0 compiler 2017-06-19 22:25:05 -07:00