Commit Graph

156 Commits

Author SHA1 Message Date
Jonathan Turner 6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
Ariel Ben-Yehuda 70c25c848c remove the librustc_trans -> librustc_mir dependency 2016-06-08 23:58:53 +03:00
Alex Crichton 0ec321f7b5 rustc: Implement custom panic runtimes
This commit is an implementation of [RFC 1513] which allows applications to
alter the behavior of panics at compile time. A new compiler flag, `-C panic`,
is added and accepts the values `unwind` or `panic`, with the default being
`unwind`. This model affects how code is generated for the local crate, skipping
generation of landing pads with `-C panic=abort`.

[RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md

Panic implementations are then provided by crates tagged with
`#![panic_runtime]` and lazily required by crates with
`#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic
runtime must match the final product, and if the panic strategy is not `abort`
then the entire DAG must have the same panic strategy.

With the `-C panic=abort` strategy, users can expect a stable method to disable
generation of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the `-C
panic=unwind` strategy users can expect the existing ability to isolate failure
in Rust code from the outside world.

Organizationally, this commit dismantles the `sys_common::unwind` module in
favor of some bits moving part of it to `libpanic_unwind` and the rest into the
`panicking` module in libstd. The custom panic runtime support is pretty similar
to the custom allocator support with the only major difference being how the
panic runtime is injected (takes the `-C panic` flag into account).
2016-05-09 08:22:36 -07:00
Eduard Burtescu 78884b7659 mir: qualify and promote constants. 2016-05-07 19:14:28 +03:00
Nick Cameron e7b8c5e3ab save-analysis: implement JSON dumps 2016-04-25 20:54:00 +12:00
Niko Matsakis 01d2b4ab6b port compiletest to use JSON output
This uncovered a lot of bugs in compiletest and also some shortcomings
of our existing JSON output. We had to add information to the JSON
output, such as suggested text and macro backtraces. We also had to fix
various bugs in the existing tests.

Joint work with jntrnr.
2016-04-21 04:42:24 -04:00
bors 92e3fb3ebe Auto merge of #31709 - ranma42:target_feature-from-llvm, r=alexcrichton
Compute `target_feature` from LLVM

This is a work-in-progress fix for #31662.

The logic that computes the target features from the command line has been replaced with queries to the `TargetMachine`.
2016-04-20 09:57:57 -07:00
Alex Crichton b325baf0ae rustbuild: Add support for compiletest test suites
This commit adds support in rustbuild for running all of the compiletest test
suites as part of `make check`. The `compiletest` program was moved to
`src/tools` (like `rustbook` and others) and is now just compiled like any other
old tool. Each test suite has a pretty standard set of dependencies and just
tweaks various parameters to the final compiletest executable.

Note that full support is lacking in terms of:

* Once a test suite has passed, that's not remembered. When a test suite is
  requested to be run, it's always run.
* The arguments to compiletest probably don't work for every possible
  combination of platforms and testing environments just yet. There will likely
  need to be future updates to tweak various pieces here and there.
* Cross compiled test suites probably don't work just yet, support for that will
  come in a follow-up patch.
2016-04-18 16:30:01 -07:00
Andrea Canciani 64a35f9d23 Reintroduce rustc_llvm dependency in rustc
The dependency was removed in
352b44d1fa, but it is needed in order to
compute the target features.
2016-04-09 00:39:04 +02:00
Niko Matsakis 4914b5fc6d patch name in incremental's Cargo.toml 2016-04-06 12:43:17 -04:00
Niko Matsakis b1e68b9e2d make an incremental crate
for now, this houses `svh` and the code to check `assert_dep_graph` is
sane
2016-04-06 12:42:02 -04:00
Eduard Burtescu 8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00
Oliver Schneider 3eac64747f move `const_eval` and `check_match` out of `librustc` 2016-03-30 13:43:36 +02:00
Oliver Schneider 6cc449ad24 rename `rustc_const_eval` to `rustc_const_math` 2016-03-30 11:10:21 +02:00
Eduard Burtescu f22ec2992b mk: move rustc_const_eval to RUSTC_CRATES where it belongs. 2016-03-29 19:36:02 +03:00
Eduard Burtescu 0abd3139db rustc_platform_intrinsics: remove unused rustc dependency. 2016-03-29 19:36:01 +03:00
Eduard Burtescu 352b44d1fa Remove unnecessary dependencies on rustc_llvm. 2016-03-29 19:36:01 +03:00
Alex Burka dd5972ee35 mk: add missing dep compiletest=>log 2016-03-27 01:25:47 -04:00
Eduard Burtescu 98359283a4 rustc_trans: move save to librustc_save_analysis. 2016-03-27 01:05:54 +02:00
Felix S. Klock II 5757e65f7a scaffolding for borrowck on MIR.
emit (via debug!) scary message from `fn borrowck_mir` until basic
prototype is in place.

Gather children of move paths and set their kill bits in
dataflow. (Each node has a link to the child that is first among its
siblings.)

Hooked in libgraphviz based rendering, including of borrowck dataflow
state.

doing this well required some refactoring of the code, so I cleaned it
up more generally (adding comments to explain what its trying to do
and how it is doing it).

Update: this newer version addresses most review comments (at least
the ones that were largely mechanical changes), but I left the more
interesting revisions to separate followup commits (in this same PR).
2016-03-21 18:36:22 +01:00
bors 01118928fc Auto merge of #30587 - oli-obk:eager_const_eval2, r=nikomatsakis
typestrong const integers

~~It would be great if someone could run crater on this PR, as this has a high danger of breaking valid code~~ Crater ran. Good to go.

----

So this PR does a few things:

1. ~~const eval array values when const evaluating an array expression~~
2. ~~const eval repeat value when const evaluating a repeat expression~~
3. ~~const eval all struct and tuple fields when evaluating a struct/tuple expression~~
4. remove the `ConstVal::Int` and `ConstVal::Uint` variants and replace them with a single enum (`ConstInt`) which has variants for all integral types
  * `usize`/`isize` are also enums with variants for 32 and 64 bit. At creation and various usage steps there are assertions in place checking if the target bitwidth matches with the chosen enum variant
5. enum discriminants (`ty::Disr`) are now `ConstInt`
6. trans has its own `Disr` type now (newtype around `u64`)

This obviously can't be done without breaking changes (the ones that are noticable in stable)
We could probably write lints that find those situations and error on it for a cycle or two. But then again, those situations are rare and really bugs imo anyway:

```rust
let v10 = 10 as i8;
let v4 = 4 as isize;
assert_eq!(v10 << v4 as usize, 160 as i8);
 ```

stops compiling because 160 is not a valid i8

```rust
struct S<T, S> {
    a: T,
    b: u8,
    c: S
}
let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 };
```

stops compiling because `0xaa_aa_aa_aa` is not a valid i32

----

cc @eddyb @pnkfelix

related: https://github.com/rust-lang/rfcs/issues/1071
2016-03-14 11:38:23 -07:00
bors aeb85a9533 Auto merge of #32133 - alexcrichton:linkchecker, r=brson
Add a link validator to rustbuild

This commit was originally targeted at just adding a link checking script to the rustbuild system. This ended up snowballing a bit to extend rustbuild to be amenable to various tools we have as part of the build system in general.

There's a new `src/tools` directory which has a number of scripts/programs that are purely intended to be used as part of the build system and CI of this repository. This is currently inhabited by rustbook, the error index generator, and a new linkchecker script added as part of this PR. I suspect that more tools like compiletest, tidy scripts, snapshot scripts, etc will migrate their way into this directory over time.

The commit which adds the error index generator shows the steps necessary to add new tools to the build system, namely:

1. New steps are defined for building the tool and running the tool
2. The dependencies are configured
3. The steps are implemented

In terms of the link checker, these commits do a few things:

* A new `src/tools/linkchecker` script is added. This will read an entire documentation tree looking for broken relative links (HTTP links aren't followed yet).
* A large number of broken links throughout the documentation were fixed. Many of these were just broken when viewed from core as opposed to std, but were easily fixed.
* A few rustdoc bugs here and there were fixed
2016-03-11 04:38:04 -08:00
Oliver Schneider 7bde56e149 typestrong constant integers 2016-03-10 12:50:12 +01:00
Alex Crichton 3e6fed3a7a rustbuild: Add the error-index-generator
This adds a step and a rule for building the error index as part of rustbuild.
2016-03-08 13:44:14 -08:00
Alex Crichton ee6df13f0c rustbuild: Move rustbook to a `src/tools` directory
We've actually got quite a few tools that are compiled as part of our build,
let's start housing them all in a `tools` directory.
2016-03-08 11:52:09 -08:00
bors eabfc160f8 Auto merge of #32009 - alexcrichton:trim-fulldeps, r=brson
mk: Distribute fewer TARGET_CRATES

Right now everything in TARGET_CRATES is built by default for all non-fulldeps
tests and is distributed by default for all target standard library packages.
Currenly this includes a number of unstable crates which are rarely used such as
`graphviz` and `rbml`>

This commit trims down the set of `TARGET_CRATES`, moves a number of tests to
`*-fulldeps` as a result, and trims down the dependencies of libtest so we can
distribute fewer crates in the `rust-std` packages.
2016-03-08 07:34:28 -08:00
bors 8b7c3f20e8 Auto merge of #29734 - Ryman:whitespace_consistency, r=Aatch
libsyntax: be more accepting of whitespace in lexer

Fixes #29590.

Perhaps this may need more thorough testing?

r? @Aatch
2016-03-07 20:06:17 -08:00
Alex Crichton 0d5cfd9117 mk: Distribute fewer TARGET_CRATES
Right now everything in TARGET_CRATES is built by default for all non-fulldeps
tests and is distributed by default for all target standard library packages.
Currenly this includes a number of unstable crates which are rarely used such as
`graphviz` and `rbml`>

This commit trims down the set of `TARGET_CRATES`, moves a number of tests to
`*-fulldeps` as a result, and trims down the dependencies of libtest so we can
distribute fewer crates in the `rust-std` packages.
2016-03-07 13:05:12 -08:00
Alex Crichton b980f22877 mk: Move disable-jemalloc logic into makefiles
The `--disable-jemalloc` configure option has a failure mode where it will
create a distribution that is not compatible with other compilers. For example
the nightly for Linux will assume that it will link to jemalloc by default as
an allocator for executable crates. If, however, a standard library is used
which was built via `./configure --disable-jemalloc` then this will fail
because the jemalloc crate wasn't built.

While this seems somewhat reasonable as a niche situation, the same mechanism is
used for disabling jemalloc for platforms that just don't support it. For
example if the rumprun target is compiled then the sibiling Linux target *also*
doesn't have jemalloc. This is currently a problem for our cross-build nightlies
which build many targets. If rumprun is also built, it will disable jemalloc for
all targets, which isn't desired.

This commit moves the platform-specific disabling of jemalloc as hardcoded logic
into the makefiles that is scoped per-platform. This way when configuring
multiple targets **without the `--disable-jemalloc` option specified** all
targets will get jemalloc as they should.
2016-02-25 21:05:59 -08:00
Dirk Gadsden 2766e254b1 Rename `error-index-generator` to `error_index_generator`
This is because the tool compiler passes the name of the tool
as a command line `--cfg`. The improved session config parser
is stricter and no longer permits invalid meta items (such as
"error-index-generator").
2016-02-14 22:29:45 -08:00
Alex Crichton 55dd595c08 rustc_back: Fix disabling jemalloc
When building with Cargo we need to detect `feature = "jemalloc"` to enable
jemalloc, so propagate this same change to the build system to pass the right
`--cfg` argument.
2016-02-11 11:12:33 -08:00
Oliver Schneider 4b067183ba Allow registering MIR-passes through compiler plugins 2016-02-09 16:53:43 +01:00
Alex Crichton 178d4b0fd3 Revert "mk: fix some undefined variable warnings"
This reverts commit d03712977d.
2016-02-01 23:27:04 -08:00
Tamir Duberstein d03712977d mk: fix some undefined variable warnings
Some of this is scary stuff. Probably time to lint against this.

Found with `make --warn-undefined-variables`.
2016-02-01 05:21:06 -05:00
Oliver Schneider c124deca7b move more checks out of librustc 2016-01-21 10:52:37 +01:00
Kevin Butler 24578e0fe5 libsyntax: accept only whitespace with the PATTERN_WHITE_SPACE property
This aligns with unicode recommendations and should be stable for all future
unicode releases. See http://unicode.org/reports/tr31/#R3.

This renames `libsyntax::lexer::is_whitespace` to `is_pattern_whitespace`
so potentially breaks users of libsyntax.
2016-01-16 00:57:12 +00:00
Oliver Schneider 1471d932a9 move const block checks before lowering step
this makes sure the checks run before typeck (which might use the constant or const
function to calculate an array length) and gives prettier error messages in case of for
loops and such (since they aren't expanded yet).
2016-01-15 13:16:54 +01:00
Manish Goregaokar 1246f43bf9 Rollup merge of #30863 - jseyfried:no_rc, r=eddyb
Use arena allocation instead of reference counting for `Module`s to fix memory leaks from `Rc` cycles.

A module references its module children and its import resolutions, and an import resolution references the module defining the imported name, so there is a cycle whenever a module imports something from an ancestor module.

For example,
```rust
mod foo { // `foo` references `bar`.
    fn baz() {}
    mod bar { // `bar` references the import.
        use foo::baz; // The import references `foo`.
    }
}
```
2016-01-14 11:04:43 +05:30
Jeffrey Seyfried a8514d3ecc resolve: use arena allocation instead of reference counting for `Module`s to fix memory leaks from Rc cycles 2016-01-13 00:54:16 +00:00
Amanieu d'Antras e304fb43a3 Replace no_elf_tls with target_thread_local 2016-01-11 10:38:36 +00:00
Alex Crichton 2f42ac438e std: Remove rust_builtin C support library
All these definitions can now be written in Rust, so do so!
2015-12-21 22:12:48 -08:00
Seo Sanghyeon f9ba107824 Move built-in syntax extensions to a separate crate 2015-12-15 15:04:46 +09:00
Michael Woerister f65823e39c Add scoped thread-local encoding and decoding contexts to cstore.
With this commit, metadata encoding and decoding can make use of
thread-local encoding and decoding contexts. These allow implementers
of serialize::Encodable and Decodable to access information and
datastructures that would otherwise not be available to them. For
example, we can automatically translate def-id and span information
during decoding because the decoding context knows which crate the
data is decoded from. Or it allows to make ty::Ty decodable because
the context has access to the ty::ctxt that is needed for creating
ty::Ty instances.
2015-12-09 09:47:32 -05:00
Ariel Ben-Yehuda 0a8bb4c509 split the metadata code into rustc_metadata
tests & rustdoc still broken
2015-11-26 18:22:40 +02:00
Ariel Ben-Yehuda 1430a35000 move librustc/plugin to librustc_plugin
this is a [breaking-change] to all plugin authors - sorry
2015-11-26 18:22:39 +02:00
Alex Crichton 3d28b8b98e std: Migrate to the new libc
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself
* Update all references to use `libc` as a result.
* Update all references to the new flat namespace.
* Moves all windows bindings into sys::c
2015-11-09 22:55:50 -08:00
Niko Matsakis 3c07b46118 Pass the mir map to trans 2015-11-03 04:34:59 -05:00
Nick Cameron a62a529eea review comments 2015-10-09 21:44:44 +13:00
Nick Cameron 20083c1e1f Move `for` loop desugaring to lowering 2015-10-09 11:53:41 +13:00
Niko Matsakis faa9ec81b5 add MIR crate and link it into the driver 2015-09-06 07:27:23 -04:00