Commit Graph

24104 Commits

Author SHA1 Message Date
Alex Crichton
6d6ccb75ff Add a new run-make test directory
This infrastructure is meant to support runnings tests that involve various
interesting interdependencies about the types of crates being linked or possibly
interacting with C libraries. The goal of these make tests is to not restrict
them to a particular test runner, but allow each test to run its own tests.

To this end, there is a new src/test/run-make directory which has sub-folders of
tests. Each test requires a `Makefile`, and running the tests constitues simply
running `make` inside the directory. The new target is `check-stageN-rmake`.

These tests will have the destination directory (as TMPDIR) and the local rust
compiler (as RUSTC) passed along to them. There is also some helpful
cross-platform utilities included in src/test/run-make/tools.mk to aid with
compiling C programs and running them.

The impetus for adding this new test suite is to allow various interesting forms
of testing rust linkage. All of the tests initially added are various flavors of
compiling Rust and C with one another as well as just making sure that rust
linkage works in general.

Closes #10434
2013-11-29 18:36:14 -08:00
Alex Crichton
9fbba7b2ee Statically link librustrt to libstd
This commit alters the build process of the compiler to build a static
librustrt.a instead of a dynamic version. This means that we can stop
distributing librustrt as well as default linking against it in the compiler.

This also means that if you attempt to build rust code without libstd, it will
no longer work if there are any landing pads in play. The reason for this is
that LLVM and rustc will emit calls to the various upcalls in librustrt used to
manage exception handling. In theory we could split librustrt into librustrt and
librustupcall. We would then distribute librustupcall and link to it for all
programs using landing pads, but I would rather see just one librustrt artifact
and simplify the build process.

The major benefit of doing this is that building a static rust library for use
in embedded situations all of a sudden just became a whole lot more feasible.

Closes #3361
2013-11-29 18:36:14 -08:00
Alex Crichton
e338a4154b Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.

When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.

Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.

Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:

* If both a .dylib and .rlib are found for a rust library, the compiler will
  prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
  overridable by explicitly saying what flavor you'd like (rlib, staticlib,
  dylib).
* If no options are passed to the command line, and no crate_type is found in
  the destination crate, then an executable is generated

With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.

This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.

Closes #552
2013-11-29 18:36:13 -08:00
bors
80991bb578 auto merge of #10719 : Kimundi/rust/switch_to_multi_item_macros, r=alexcrichton
- Removed module reexport workaround for the integer module macros
- Removed legacy reexports of `cmp::{min, max}` in the integer module macros
- Combined a few macros in `vec` into one
- Documented a few issues
2013-11-29 14:01:48 -08:00
bors
dd1184eedb auto merge of #10678 : alexcrichton/rust/issue-4877, r=pcwalton
This adds an implementation of the Chase-Lev work-stealing deque to libstd
under std::rt::deque. I've been unable to break the implementation of the deque
itself, and it's not super highly optimized just yet (everything uses a SeqCst
memory ordering).

The major snag in implementing the chase-lev deque is that the buffers used to
store data internally cannot get deallocated back to the OS. In the meantime, a
shared buffer pool (synchronized by a normal mutex) is used to
deallocate/allocate buffers from. This is done in hope of not overcommitting too
much memory. It is in theory possible to eventually free the buffers, but one
must be very careful in doing so.

I was unable to get some good numbers from src/test/bench tests (I don't think
many of them are slamming the work queue that much), but I was able to get some
good numbers from one of my own tests. In a recent rewrite of select::select(),
I found that my implementation was incredibly slow due to contention on the
shared work queue. Upon switching to the parallel deque, I saw the contention
drop to 0 and the runtime go from 1.6s to 0.9s with the most amount of time
spent in libuv awakening the schedulers (plus allocations).

Closes #4877
2013-11-29 12:31:49 -08:00
Alex Crichton
a70f9d7324 Implement a lock-free work-stealing deque
This adds an implementation of the Chase-Lev work-stealing deque to libstd
under std::rt::deque. I've been unable to break the implementation of the deque
itself, and it's not super highly optimized just yet (everything uses a SeqCst
memory ordering).

The major snag in implementing the chase-lev deque is that the buffers used to
store data internally cannot get deallocated back to the OS. In the meantime, a
shared buffer pool (synchronized by a normal mutex) is used to
deallocate/allocate buffers from. This is done in hope of not overcommitting too
much memory. It is in theory possible to eventually free the buffers, but one
must be very careful in doing so.

I was unable to get some good numbers from src/test/bench tests (I don't think
many of them are slamming the work queue that much), but I was able to get some
good numbers from one of my own tests. In a recent rewrite of select::select(),
I found that my implementation was incredibly slow due to contention on the
shared work queue. Upon switching to the parallel deque, I saw the contention
drop to 0 and the runtime go from 1.6s to 0.9s with the most amount of time
spent in libuv awakening the schedulers (plus allocations).

Closes #4877
2013-11-29 12:19:16 -08:00
Marvin Löbel
4840064f85 Removed module macro workaround for signed and unsigned integers 2013-11-29 20:36:47 +01:00
Marvin Löbel
0d8ace823b Removed useless cmp::{min, max} reexports from the integer modules 2013-11-29 20:19:22 +01:00
bors
08f4d1ff9f auto merge of #10697 : pcwalton/rust/path-new, r=pcwalton
r+

(carrying over from @alexcrichton's review)
2013-11-29 11:01:50 -08:00
Patrick Walton
c54427ddfb libstd: Change Path::new to Path::init. 2013-11-29 10:55:13 -08:00
bors
631cbd2e11 auto merge of #10726 : pnkfelix/rust/fsk-remove-at-fn-artifact, r=thestinger
While tracking down how this function became dead, identified a spot
(@fn cannot happen) where we probably would prefer to ICE rather than
pass silently; so added fail! invocation.
2013-11-29 09:36:40 -08:00
Felix S. Klock II
fffa10c175 Removed some dead code.
While tracking down how this function became dead, identified a spot
(@fn cannot happen) where we probably would prefer to ICE rather than
pass silently; so added fail! invocation.
2013-11-29 18:20:27 +01:00
Marvin Löbel
90f9eb3b1e Removed a few macro-expanding-to-module workarounds
Also documented a few issues
2013-11-29 17:33:36 +01:00
bors
6c672ee094 auto merge of #10715 : alexcrichton/rust/fix-log-twice, r=huonw
It may mislead you into thinking tasks are spawning twice, when in fact they are
not.
2013-11-29 01:31:47 -08:00
Alex Crichton
bfba120133 Fix initial debug statements printing twice
It may mislead you into thinking tasks are spawning twice, when in fact they are
not.
2013-11-28 23:46:22 -08:00
bors
bf6964ecb6 auto merge of #10709 : alexcrichton/rust/snapshot, r=pcwalton 2013-11-28 20:31:39 -08:00
Alex Crichton
ab387a6838 Register new snapshots 2013-11-28 20:27:56 -08:00
bors
90d06ecf6b auto merge of #10704 : TeXitoi/rust/spectralnorm-resurected, r=alexcrichton 2013-11-28 12:26:31 -08:00
Guillaume Pinot
6bd22494e9 shootout-spectralnorm resurection with parallelization 2013-11-28 20:46:59 +01:00
bors
859c3baf64 auto merge of #10519 : nikomatsakis/rust/issue-8624-borrowck-overly-permissive, r=pnkfelix
See #8624 for details.

r? @pnkfelix
2013-11-28 03:51:32 -08:00
Niko Matsakis
09e12fa553 Test that reborrowing contents of an &'a mut &'b mut pointer can only
be done for at most lifetime `'a`

Fixes #8624
2013-11-28 06:43:39 -05:00
Niko Matsakis
bc4164d4c0 Modify iterators to make them safe with the new rules. 2013-11-28 06:43:39 -05:00
bors
42ea44ba27 auto merge of #10694 : klutzy/rust/rustdoc-closure, r=alexcrichton 2013-11-27 21:02:52 -08:00
bors
68e3292fd7 auto merge of #10691 : g3xzh/rust/benchm, r=cmr
I have written some benchmark tests to `push`, `push_many`, `join`,
`join_many` and `ends_with_path`.

Let me know what you think (@cmr).
Thanks in advance.
2013-11-27 19:47:15 -08:00
bors
db5b51ae63 auto merge of #10687 : alexcrichton/rust/issue-10686, r=thestinger
Turns out android doesn't support LLVM's thread_local attribute and accompanying
implementation.

Closes #10686
2013-11-27 18:32:30 -08:00
bors
503e5df3f2 auto merge of #10621 : Florob/rust/unicode63, r=cmr
This update the unicode.rs file to the latest Unicode version released 2013-09-30.
2013-11-27 16:47:14 -08:00
bors
d2c405eeff auto merge of #10642 : cmr/rust/strict_doccomment, r=alexcrichton
Previously, `//// foo` and `/*** foo ***/` were accepted as doc comments. This
changes that, so that only `/// foo` and `/** foo ***/` are accepted. This
confuses many newcomers and it seems weird.

Also update the manual for these changes, and modernify the EBNF for comments.

Closes #10638
2013-11-27 15:32:18 -08:00
Corey Richardson
b50b162884 Be more strict about doc comments
Previously, `//// foo` and `/*** foo ***/` were accepted as doc comments. This
changes that, so that only `/// foo` and `/** foo ***/` are accepted. This
confuses many newcomers and it seems weird.

Also update the manual for these changes, and modernify the EBNF for comments.

Closes #10638
2013-11-27 18:00:50 -05:00
Florian Zeitz
dfe38dbca4 Fix handling of upper/lowercase, and whitespace 2013-11-27 23:36:20 +01:00
Florian Zeitz
c234614950 Update Unicode data to version 6.3 2013-11-27 23:25:19 +01:00
Florian Zeitz
e9ab9bf01a Update unicode.py to reflect language changes 2013-11-27 23:21:22 +01:00
bors
d662820b29 auto merge of #10680 : alexcrichton/rust/relax-feature-gate, r=thestinger
Instead of forcibly always aborting compilation, allow usage of
 #[warn(unknown_features)] and related lint attributes to selectively abort
 compilation. By default, this lint is deny.
2013-11-27 14:17:41 -08:00
Alex Crichton
1686bfabf5 Use the native tls implementation on android
Turns out android doesn't support LLVM's thread_local attribute and accompanying
implementation.

Closes #10686
2013-11-27 11:56:43 -08:00
bors
e147a090a5 auto merge of #10685 : ebiggers/rust/ascii_fixes, r=alexcrichton
is_digit() incorrectly returned false for '0'.
is_control() incorrectly returned true for ' ' (space).
2013-11-27 11:52:09 -08:00
bors
e4136bd552 auto merge of #10662 : alexcrichton/rust/thread-detach, r=pcwalton
This has one commit from a separate pull request (because these commits depend on that one), but otherwise the extra details can be found in the commit messages. The `rt::thread` module has been generally cleaned up for everyday safe usage (and it's a bug if it's not safe).
2013-11-27 09:57:05 -08:00
Alex Crichton
a9bd049fc0 Relax restrictions on unknown feature directives
Instead of forcibly always aborting compilation, allow usage of
 #[warn(unknown_features)] and related lint attributes to selectively abort
 compilation. By default, this lint is deny.
2013-11-27 09:54:30 -08:00
Alex Crichton
5d6dbf3f26 Improve the rt::thread module
* Added doc comments explaining what all public functionality does.
* Added the ability to spawn a detached thread
* Added the ability for the procs to return a value in 'join'
2013-11-27 09:53:48 -08:00
klutzy
79ed898f64 rustdoc: Use new ||/proc syntax 2013-11-28 02:27:04 +09:00
bors
a6fc577ab5 auto merge of #10693 : eddyb/rust/freeze-ast, r=thestinger
It's truly immutable now, which will allow us to remove some cloning in the parser and box parts of the AST in `Rc<T>` (if desired).
2013-11-27 08:07:56 -08:00
Eric Biggers
64883242eb std::ascii: Add tests for is_digit() and is_control() 2013-11-27 09:54:54 -06:00
Eduard Burtescu
f09b7b0ecd Freeze the AST by removing a couple of unused @mut ~[T] from token_tree. 2013-11-27 17:48:58 +02:00
bors
23674be0b1 auto merge of #10684 : jld/rust/unstruct-unhack-typekind, r=alexcrichton 2013-11-27 06:17:40 -08:00
bors
17af6f7d0c auto merge of #10688 : bjz/rust/recv_iter, r=brson
I've noticed I use this pattern quite a bit:

~~~rust
do spawn {
    loop {
        match port.try_recv() {
            Some(x) => ...,
            None => ...,
        }
    }
}
~~~

The `RecvIterator`, returned from a default `recv_iter` method on the `GenericPort` trait, allows you to reduce this down to:

~~~rust
do spawn {
    for x in port.recv_iter() {
        ...
    }
}
~~~

As demonstrated in the tests, you can also access the port from within the `for` block for further `recv`ing and `peek`ing with no borrow errors, which is quite nice.
2013-11-27 01:52:10 -08:00
g3xzh
26ba64dca9 Add benchmark tests to path/posix
I have written some benchmark tests to `push`, `push_many`, `join`,
`join_many` and `ends_with_path`.
2013-11-27 11:39:07 +02:00
bors
faf4c939fb auto merge of #10670 : eddyb/rust/node-u32, r=alexcrichton
### Rationale
There is no reason to support more than 2³² nodes or names at this moment, as compiling something that big (even without considering the quadratic space usage of some analysis passes) would take at least **64GB**.
Meanwhile, some can't (or barely can) compile rustc because it requires almost **1.5GB**.

### Potential problems
Can someone confirm this doesn't affect metadata (de)serialization? I can't tell myself, I know nothing about it.

### Results
Some structures have a size reduction of 25% to 50%: [before](https://gist.github.com/luqmana/3a82a51fa9c86d9191fa) - [after](https://gist.github.com/eddyb/5a75f8973d3d8018afd3).
Sadly, there isn't a massive change in the memory used for compiling stage2 librustc (it doesn't go over **1.4GB** as [before](http://huonw.github.io/isrustfastyet/mem/), but I can barely see the difference).
However, my own testcase (previously peaking at **1.6GB** in typeck) shows a reduction of **200**-**400MB**.
2013-11-26 22:07:44 -08:00
Alex Crichton
ed86b48cc9 Clean up statically initialized data on shutdown
Whenever the runtime is shut down, add a few hooks to clean up some of the
statically initialized data of the runtime. Note that this is an unsafe
operation because there's no guarantee on behalf of the runtime that there's no
other code running which is using the runtime.

This helps turn down the noise a bit in the valgrind output related to
statically initialized mutexes. It doesn't turn the noise down to 0 because
there are still statically initialized mutexes in dynamic_lib and
os::with_env_lock, but I believe that it would be easy enough to add exceptions
for those cases and I don't think that it's the runtime's job to go and clean up
that data.
2013-11-26 21:11:17 -08:00
Brendan Zabarauskas
31da6b7698 Add an iterator for receiving messages from GenericPorts 2013-11-27 15:10:12 +10:00
Eduard Burtescu
7ed27b5531 Shink NodeId, CrateNum, Name and Mrk down to 32 bits on x64. 2013-11-27 07:02:25 +02:00
bors
82d9033b67 auto merge of #10679 : alexcrichton/rust/no-routine, r=pcwalton 2013-11-26 19:37:38 -08:00
Eric Biggers
7b96f13d7d std::ascii: Fix is_digit() and is_control()
is_digit() incorrectly returned false for '0'.
is_control() incorrectly returned true for ' ' (space).
2013-11-26 20:13:25 -06:00