Commit Graph

25052 Commits

Author SHA1 Message Date
Alex Crichton
87add53327 rustc: Improve crate id extraction
Right now the --crate-id and related flags are all process *after* the entire
crate is parsed. This is less than desirable when used with makefiles because it
means that just to learn the output name of the crate you have to parse the
entire crate (unnecessary).

This commit changes the behavior to lift the handling of these flags much sooner
in the compilation process. This allows us to not have to parse the entire crate
and only have to worry about parsing the crate attributes themselves. The
related methods have all been updated to take an array of attributes rather than
a crate.

Additionally, this ceases duplication of the "what output are we producing"
logic in order to correctly handle things in the case of --test.

Finally, this adds tests for all of this functionality to ensure that it does
not regress.
2013-12-20 09:10:11 -08:00
bors
5399c82d56 auto merge of #11081 : alexcrichton/rust/comm-adapters, r=huonw
I accidentally removed this module from compilation awhile back, this adds it
back in.

Closes #11076
2013-12-20 04:36:32 -08:00
bors
6023350082 auto merge of #11017 : alexcrichton/rust/faster-read, r=thestinger
We were previously reading metadata via `ar p`, but as learned from rustdoc
awhile back, spawning a process to do something is pretty slow. Turns out LLVM
has an Archive class to read archives, but it cannot write archives.

This commits adds bindings to the read-only version of the LLVM archive class
(with a new type that only has a read() method), and then it uses this class
when reading the metadata out of rlibs. When you put this in tandem of not
compressing the metadata, reading the metadata is 4x faster than it used to be
The timings I got for reading metadata from the respective libraries was:

    libstd-04ff901e-0.9-pre.dylib    => 100ms
    libstd-04ff901e-0.9-pre.rlib     => 23ms
    librustuv-7945354c-0.9-pre.dylib => 4ms
    librustuv-7945354c-0.9-pre.rlib  => 1ms
    librustc-5b94a16f-0.9-pre.dylib  => 87ms
    librustc-5b94a16f-0.9-pre.rlib   => 35ms
    libextra-a6ebb16f-0.9-pre.dylib  => 63ms
    libextra-a6ebb16f-0.9-pre.rlib   => 15ms
    libsyntax-2e4c0458-0.9-pre.dylib => 86ms
    libsyntax-2e4c0458-0.9-pre.rlib  => 22ms

In order to always take advantage of these faster metadata read-times, I sort
the files in filesearch based on whether they have an rlib extension or not
(prefer all rlib files first).

Overall, this halved the compile time for a `fn main() {}` crate from 0.185s to
0.095s on my system (when preferring dynamic linking). Reading metadata is still
the slowest pass of the compiler at 0.035s, but it's getting pretty close to
linking at 0.021s! The next best optimization is to just not copy the metadata
from LLVM because that's the most expensive part of reading metadata right now.
2013-12-20 02:06:34 -08:00
Alex Crichton
64faafba19 rustc: Optimize reading metadata by 4x
We were previously reading metadata via `ar p`, but as learned from rustdoc
awhile back, spawning a process to do something is pretty slow. Turns out LLVM
has an Archive class to read archives, but it cannot write archives.

This commits adds bindings to the read-only version of the LLVM archive class
(with a new type that only has a read() method), and then it uses this class
when reading the metadata out of rlibs. When you put this in tandem of not
compressing the metadata, reading the metadata is 4x faster than it used to be
The timings I got for reading metadata from the respective libraries was:

    libstd-04ff901e-0.9-pre.dylib    => 100ms
    libstd-04ff901e-0.9-pre.rlib     => 23ms
    librustuv-7945354c-0.9-pre.dylib => 4ms
    librustuv-7945354c-0.9-pre.rlib  => 1ms
    librustc-5b94a16f-0.9-pre.dylib  => 87ms
    librustc-5b94a16f-0.9-pre.rlib   => 35ms
    libextra-a6ebb16f-0.9-pre.dylib  => 63ms
    libextra-a6ebb16f-0.9-pre.rlib   => 15ms
    libsyntax-2e4c0458-0.9-pre.dylib => 86ms
    libsyntax-2e4c0458-0.9-pre.rlib  => 22ms

In order to always take advantage of these faster metadata read-times, I sort
the files in filesearch based on whether they have an rlib extension or not
(prefer all rlib files first).

Overall, this halved the compile time for a `fn main() {}` crate from 0.185s to
0.095s on my system (when preferring dynamic linking). Reading metadata is still
the slowest pass of the compiler at 0.035s, but it's getting pretty close to
linking at 0.021s! The next best optimization is to just not copy the metadata
from LLVM because that's the most expensive part of reading metadata right now.
2013-12-19 23:34:32 -08:00
bors
bb02d147fe auto merge of #11073 : klutzy/rust/issue-10978, r=alexcrichton
This patchset fixes small glitches which caused #10978.
2013-12-19 20:06:36 -08:00
bors
415e55a02c auto merge of #11071 : huonw/rust/quiet-test, r=cmr 2013-12-19 18:51:39 -08:00
Huon Wilson
48fedcb36f extra: remove sort in favour of the std method.
Fixes #9676.
2013-12-20 12:38:46 +11:00
Huon Wilson
721609e4ae std::vec: implement a stable merge sort, deferring to insertion sort for
very small runs.

This uses a lot of unsafe code for speed, otherwise we would be having
to sort by sorting lists of indices and then do a pile of swaps to put
everything in the correct place.

Fixes #9819.
2013-12-20 12:38:46 +11:00
bors
5c24bfa8c3 auto merge of #11057 : alexcrichton/rust/no-at-in-ebml, r=pcwalton
Now that the metadata is an owned value with a lifetime of a borrowed byte
slice, it's possible to have future optimizations where the metadata doesn't
need to be copied around (very expensive operation).
2013-12-19 17:11:40 -08:00
Alex Crichton
73fceca7d6 Purge @-boxes from the reading half of EBML
Now that the metadata is an owned value with a lifetime of a borrowed byte
slice, it's possible to have future optimizations where the metadata doesn't
need to be copied around (very expensive operation).
2013-12-19 17:08:05 -08:00
Alex Crichton
f89b61ba3a Get comm_adapters building again
I accidentally removed this module from compilation awhile back, this adds it
back in.

Closes #11076
2013-12-19 15:42:44 -08:00
bors
d069d58e31 auto merge of #11060 : pcwalton/rust/tydecode-pod, r=pcwalton
r? @brson
2013-12-19 15:06:40 -08:00
Chris Morgan
22055802cf Fix two regressions introduced by #11072.
There, concrete evidence that I shouldn't try doing such things at 1:30am.
2013-12-20 09:33:47 +11:00
Patrick Walton
b982f08a66 librustc: Add missing case for the Pod bound in tydecode. 2013-12-19 14:13:19 -08:00
bors
3906823765 auto merge of #11072 : chris-morgan/rust/ctags-tweaks, r=cmr
Anchoring the keyword as the first non-whitespace on a line may mean
that the occasional genuine-but-unconventionally-formatted tag is
missed, but it avoids a large number of false positives.

I changed the type descriptive texts about a bit too. That part's purely
cosmetic.

I also changed the ignored file list to use a filename matching the make
rule, `TAGS.vi` instead of `TAGS.vim`.
2013-12-19 12:01:59 -08:00
bors
bc17e4fda7 auto merge of #11070 : ezyang/rust/better-errors, r=alexcrichton
On the advice of @huonw, I've just replaced item_span outright.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2013-12-19 09:51:40 -08:00
Alex Crichton
bfb760c697 Accept trailing commas in struct patterns
We decided in the 12/10/13 weekly meeting that trailing commas should be
accepted pretty much anywhere. They are currently not allowed in struct
patterns, and this commit adds support for that.

Closes #10392
2013-12-19 09:29:41 -08:00
klutzy
da818e9a26 mklldeps.py: Ignore extra whitespaces of argument 2013-12-20 01:53:41 +09:00
klutzy
2afa97a346 rustc: Handle #[link(name = "")] error 2013-12-20 01:53:41 +09:00
bors
d760f994de auto merge of #11041 : cmr/rust/pkgid_changes, r=cmr,metajack 2013-12-19 07:51:36 -08:00
Corey Richardson
b25a0524dc Add some things to inspect crate-id's 2013-12-19 10:18:37 -05:00
Corey Richardson
dee1107571 Rename pkgid to crate_id
Closes #11035
2013-12-19 10:10:23 -05:00
Chris Morgan
a1ca7458f1 Remove many false positives from the ctags results
Anchoring the keyword as the first non-whitespace on a line may mean
that the occasional genuine-but-unconventionally-formatted tag is
missed, but it avoids a large number of false positives.

I changed the type descriptive texts about a bit too. That part's purely
cosmetic.

I also changed the ignored file list to use a filename matching the make
rule, `TAGS.vi` instead of `TAGS.vim`.
2013-12-20 01:59:01 +11:00
Huon Wilson
f13d57f8d3 extra: silence warnings during testing. 2013-12-20 01:26:03 +11:00
Huon Wilson
c00104f36a std: silence warnings when compiling test. 2013-12-20 01:26:03 +11:00
bors
e86cdaf23d auto merge of #11061 : huonw/rust/opt-unsafe-vec, r=alexcrichton
Before:

```
test vec::bench::random_inserts                     ... bench:     15025 ns/iter (+/- 409)
test vec::bench::random_removes                     ... bench:     16063 ns/iter (+/- 276)
```

After:

```
test vec::bench::random_inserts                     ... bench:      5257 ns/iter (+/- 321)
test vec::bench::random_removes                     ... bench:      4980 ns/iter (+/- 94)
```
2013-12-19 04:26:34 -08:00
Huon Wilson
acd2be46f1 std::vec: use some unsafe code to optimise remove.
Also, add `.remove_opt` and replace `.unshift` with `.remove(0)`. The
code size reduction seem to compensate for not having the optimised
special cases.

This makes the included benchmark more than 3 times faster.
2013-12-19 23:20:20 +11:00
Edward Z. Yang
6ad1c8e044 Generalize item_span into node_span, which works on more types.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2013-12-19 19:58:08 +08:00
bors
b3cee62034 auto merge of #11065 : huonw/rust/slice-chars-example, r=cmr 2013-12-19 02:36:34 -08:00
bors
ac28718f73 auto merge of #11038 : alexcrichton/rust/fix-osx-leak, r=cmr
I haven't landed this fix upstream just yet, but it's opened as
joyent/libuv#1048. For now, I've locally merged it into my fork, and I've
upgraded our repo to point to the new revision.

Closes #11027
2013-12-19 00:16:35 -08:00
Alex Crichton
9578af8876 Upgrade libuv to fix a leak on OSX
I haven't landed this fix upstream just yet, but it's opened as
joyent/libuv#1048. For now, I've locally merged it into my fork, and I've
upgraded our repo to point to the new revision.

Closes #11027
2013-12-18 23:00:04 -08:00
bors
52769b6180 auto merge of #11050 : alexcrichton/rust/snapshots, r=brson
Time for a visit from the snapshot fairy!
2013-12-18 22:41:36 -08:00
Huon Wilson
cacf58caff std::str: fix .slice_chars example. Fixes #11014. 2013-12-19 17:36:44 +11:00
bors
b760ed6573 auto merge of #10977 : brson/rust/androidtest, r=brson
#10975

For a while I thought the android test bot was succeeding but it wasn't really testing anything at all.
2013-12-18 20:06:33 -08:00
Huon Wilson
81632513c1 std::vec: replace .insert with a small amount of unsafe code.
This makes the included benchmark more than 3 times faster. Also,
`.unshift(x)` is now faster as `.insert(0, x)` which can reuse the
allocation if necessary.
2013-12-19 14:00:44 +11:00
bors
b4ed6f9695 auto merge of #10927 : g3xzh/rust/sum_bugfix, r=huonw
`[1e20, 1.0, -1e20].sum()` returns `0.0`. This happens because during
the summation, `1.0` is too small relative to `1e20`, making it
negligible.

I have tried Kahan summation but it hasn't fixed the problem.
Therefore, I've used Python's `fsum()` implementation.
For more details, read:
www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps
https://github.com/mozilla/rust/issues/10851

Python's fsum (msum)
http://code.activestate.com/recipes/393090/

@huonw, your feedback is more than welcome.
It looks unpolished; Do you have suggestions how to make it more beautiful and elegant?

Thanks in advance,
2013-12-18 18:41:35 -08:00
Brian Anderson
4a03e04755 Make Android tests fail if no device is available 2013-12-18 18:12:46 -08:00
bors
3c2c13bae4 auto merge of #11029 : huonw/rust/rm-vec-as-buf, r=cmr
For `str.as_mut_buf`, un-closure-ification is achieved by outright removal (see commit message). The others are replaced by `.as_ptr`, `.as_mut_ptr` and `.len`
2013-12-18 17:11:42 -08:00
g3xzh
05395cba88 Fix sum() accuracy
`[1e20, 1.0, -1e20].sum()` returns `0.0`. This happens because during
the summation, `1.0` is too small relative to `1e20`, making it
negligible.

I have tried Kahan summation but it hasn't fixed the problem.
Therefore, I've used Python's `fsum()` implementation with some
help from Jason Fager and Huon Wilson.
For more details, read:
www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps

Moreover, benchmark and unit tests were added.

Note: `Status.sum` is still not fully fixed. It doesn't handle
NaNs, infinities and overflow correctly. See issue 11059:
https://github.com/mozilla/rust/issues/11059
2013-12-19 02:13:51 +02:00
Cadence Marseille
f24787dbfb Fix #10755 - ICE: --linker=
Trap the io_error condition so that a more informative error message is
displayed when the linker program cannot be started, such as when the
name of the linker binary is accidentally mistyped.

closes #10755
2013-12-18 18:33:33 -05:00
Huon Wilson
b906a8b256 std::str: remove .as_mut_buf & rewrite/simplify .push_char.
`.as_mut_buf` was used exactly once, in `.push_char` which could be
written in a simpler way, using the `&mut ~[u8]` that it already
retrieved. In the rare situation when someone really needs
`.as_mut_buf`-like functionality (getting a `*mut u8`), they can go via
`str::raw::as_owned_vec`.
2013-12-19 10:18:02 +11:00
Huon Wilson
17ac2aa523 std::str: replace .as_imm_buf with .as_ptr. 2013-12-19 10:18:02 +11:00
Huon Wilson
9177f7ecb4 std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len. 2013-12-19 10:18:02 +11:00
bors
b6933f8d8b auto merge of #11032 : cmr/rust/rustdoc_test, r=alexcrichton
This is just a smoke test which verifies that the expected files are
generated.
2013-12-18 15:16:39 -08:00
Huon Wilson
4c79b22ef2 std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.
There's no need for the restrictions of a closure with the above methods.
2013-12-19 09:26:13 +11:00
Corey Richardson
21bec4f11b rustdoc: thread through the context for rendering
This partially reverts 8b5a317.
2013-12-18 15:21:34 -05:00
Corey Richardson
5d45170b02 Add a rustdoc test
This is just a smoke test which verifies that the expected files are
generated. Also makes the rmake tests have the right deps.
2013-12-18 15:21:30 -05:00
bors
c87b9d37f7 auto merge of #11013 : klutzy/rust/win-no-pthread, r=alexcrichton
llvm supports both win32 native threads and pthread,
but configure tries to find pthread first.
This manually disables pthread to use native api.

This removes libpthreads-2.dll dependency on librustc.
2013-12-18 12:16:35 -08:00
bors
6d2e61bc6c auto merge of #11012 : alexcrichton/rust/needstest, r=alexcrichton
Closes #5806
Closes #8259
Closes #8578
Closes #8851
Closes #10412
2013-12-18 10:36:51 -08:00
Alex Crichton
d4825b92bc Register new snapshots
Time for a visit from the snapshot fairy!
2013-12-18 09:32:03 -08:00