Commit graph

88 commits

Author SHA1 Message Date
bors
8d52dfbace auto merge of #10984 : huonw/rust/clean-raw, r=cmr
See commits for details.
2013-12-15 06:56:27 -08:00
Huon Wilson
164f7a290e std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut []. 2013-12-15 23:37:41 +11:00
Huon Wilson
f53292f7ee Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}. 2013-12-15 23:05:30 +11:00
Huon Wilson
c126aa5692 std::rt: s/pausible/pausable/. 2013-12-15 16:29:17 +11:00
Kiet Tran
71ce559f7d Dead-code pass now marks and warns foreign items 2013-12-14 00:35:41 -05:00
bors
b8b16ae099 auto merge of #10791 : pcwalton/rust/decelling, r=pcwalton
34 uses of `Cell` remain.

r? @alexcrichton
2013-12-10 19:16:19 -08:00
Patrick Walton
fd7a513bef libstd: Remove Cell from the library. 2013-12-10 17:55:09 -08:00
Jack Moffitt
b349036e5f Make crate hash stable and externally computable.
This replaces the link meta attributes with a pkgid attribute and uses a hash
of this as the crate hash. This makes the crate hash computable by things
other than the Rust compiler. It also switches the hash function ot SHA1 since
that is much more likely to be available in shell, Python, etc than SipHash.

Fixes #10188, #8523.
2013-12-10 17:04:24 -07:00
Patrick Walton
6bd80f7450 librustuv: Change with_local_io to use RAII. 2013-12-10 15:13:12 -08:00
Patrick Walton
9a6ebbbecc librustdoc: Remove a couple of Cells. 2013-12-10 15:13:12 -08:00
Patrick Walton
7cac9fe763 librustuv: RAII-ify Local::borrow, and remove some 12 Cells. 2013-12-10 15:13:12 -08:00
Patrick Walton
786dea207d libextra: Another round of de-Cell-ing.
34 uses of `Cell` remain.
2013-12-10 15:13:12 -08:00
Kiet Tran
1755408d1a Remove dead codes 2013-12-08 02:55:28 -05:00
bors
b5bab85c1a auto merge of #10796 : kballard/rust/revert-new-naming, r=alexcrichton
Rename the `*::init()` functions back to `*::new()`, since `new` is not
going to become a keyword.
2013-12-04 23:26:19 -08:00
Kevin Ballard
b1705714d5 Rename std::rt::deque::*::init() to *::new() 2013-12-04 22:33:53 -08:00
Kevin Ballard
408dc5ad1b Revert "libstd: Change Path::new to Path::init."
This reverts commit c54427ddfb.

Leave the #[ignores] in that were added to rustpkg tests.

Conflicts:
	src/librustc/driver/driver.rs
	src/librustc/metadata/creader.rs
2013-12-04 22:33:53 -08:00
bors
10c8409c78 auto merge of #10804 : alexcrichton/rust/less-dup, r=pcwalton
This is just an implementation detail of using libuv, so move the libuv-specific
logic into librustuv.
2013-12-04 22:11:22 -08:00
Alex Crichton
e0264ff192 Don't dup the stdio file descriptors.
This is just an implementation detail of using libuv, so move the libuv-specific
logic into librustuv.
2013-12-04 08:51:47 -08:00
Huon Wilson
b0426edc0a std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter. 2013-12-04 22:35:53 +11:00
Huon Wilson
9d64e46013 std::str: remove from_utf8.
This function had type &[u8] -> ~str, i.e. it allocates a string
internally, even though the non-allocating version that take &[u8] ->
&str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-12-04 22:35:53 +11:00
Steven Fackler
a243360401 Move std::util::ignore to std::prelude::drop
It's a more fitting name for the most common use case of this function.
2013-12-03 20:40:38 -08:00
Alex Crichton
acc5e32e53 Register new snapshots 2013-12-03 14:31:54 -08:00
Alex Crichton
56e4c82a38 Test fixes and merge conflicts 2013-11-30 14:34:59 -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
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
Patrick Walton
c54427ddfb libstd: Change Path::new to Path::init. 2013-11-29 10:55:13 -08:00
Alex Crichton
ab387a6838 Register new snapshots 2013-11-28 20:27:56 -08:00
bors
e9a1869a5f auto merge of #10581 : pcwalton/rust/dedo, r=pcwalton
r? @alexcrichton
2013-11-26 12:13:03 -08:00
Patrick Walton
9521551b47 librustc: Fix merge fallout. 2013-11-26 11:04:39 -08:00
Alex Crichton
7f3501275d Correctly handle libuv errors in addrinfo calls
It turns out that libuv was returning ENOSPC to us in our usage of the
uv_ipX_name functions. It also turns out that there may be an off-by-one in
libuv. For now just add one to the buffer size and handle the return value
correctly.

Closes #10663
2013-11-26 09:10:10 -08:00
Patrick Walton
749ee53c6d librustc: Make || lambdas not infer to procs 2013-11-26 08:25:27 -08:00
Patrick Walton
38efa17bb8 test: Remove all remaining non-procedure uses of do. 2013-11-26 08:25:27 -08:00
Patrick Walton
a61a3678eb librustuv: Remove all non-proc uses of do from libextra and
`librustuv`.
2013-11-26 08:24:18 -08:00
Patrick Walton
6801bc8f55 libsyntax: Remove the old-style borrowed closure type syntax from the
language.
2013-11-26 08:20:59 -08:00
bors
fffacb34fe auto merge of #10646 : alexcrichton/rust/issue-10645, r=luqmana
This is a behavioral difference in libuv between different platforms in
different situations. It turns out that libuv on windows will immediately
allocate a buffer instead of waiting for data to be ready. What this implies is
that we must have our custom data set on the handle before we call
uv_read_start.

I wish I knew of a way to test this, but this relies to being on the windows
platform *and* reading from a true TTY handle which only happens when this is
actually attached to a terminal. I have manually verified this works.

Closes #10645
2013-11-25 05:46:37 -08:00
Alex Crichton
6acf227cc8 Set uv's custom data before uv_read_start
This is a behavioral difference in libuv between different platforms in
different situations. It turns out that libuv on windows will immediately
allocate a buffer instead of waiting for data to be ready. What this implies is
that we must have our custom data set on the handle before we call
uv_read_start.

I wish I knew of a way to test this, but this relies to being on the windows
platform *and* reading from a true TTY handle which only happens when this is
actually attached to a terminal. I have manually verified this works.

Closes #10645
2013-11-24 21:47:13 -08:00
bors
2cc1e16ac0 auto merge of #10603 : alexcrichton/rust/no-linked-failure, r=brson
The reasons for doing this are:

* The model on which linked failure is based is inherently complex
* The implementation is also very complex, and there are few remaining who
  fully understand the implementation
* There are existing race conditions in the core context switching function of
  the scheduler, and possibly others.
* It's unclear whether this model of linked failure maps well to a 1:1 threading
  model

Linked failure is often a desired aspect of tasks, but we would like to take a
much more conservative approach in re-implementing linked failure if at all.

Closes #8674
Closes #8318
Closes #8863
2013-11-24 21:32:13 -08:00
Alex Crichton
acca9e3834 Remove linked failure from the runtime
The reasons for doing this are:

* The model on which linked failure is based is inherently complex
* The implementation is also very complex, and there are few remaining who
  fully understand the implementation
* There are existing race conditions in the core context switching function of
  the scheduler, and possibly others.
* It's unclear whether this model of linked failure maps well to a 1:1 threading
  model

Linked failure is often a desired aspect of tasks, but we would like to take a
much more conservative approach in re-implementing linked failure if at all.

Closes #8674
Closes #8318
Closes #8863
2013-11-24 21:21:12 -08:00
Luqman Aden
6820ed4dcf Fix up mingw64 target. 2013-11-22 20:39:58 -05:00
bors
d57765d8a9 auto merge of #10558 : alexcrichton/rust/faster-stdout, r=pcwalton,pcwalton
There are issues with reading stdin when it is actually attached to a pipe, but
I have run into no problems in writing to stdout/stderr when they are attached
to pipes.
2013-11-19 05:16:24 -08:00
Patrick Walton
ba739b2135 librustc: Convert ~fn() to proc() everywhere. 2013-11-18 18:27:31 -08:00
Alex Crichton
10b956a012 Allow piped stdout/stderr use uv_tty_t
There are issues with reading stdin when it is actually attached to a pipe, but
I have run into no problems in writing to stdout/stderr when they are attached
to pipes.
2013-11-18 16:29:41 -08:00
Alex Crichton
9bcf557589 Implement native::IoFactory
This commit re-organizes the io::native module slightly in order to have a
working implementation of rtio::IoFactory which uses native implementations. The
goal is to seamlessly multiplex among libuv/native implementations wherever
necessary.

Right now most of the native I/O is unimplemented, but we have existing bindings
for file descriptors and processes which have been hooked up. What this means is
that you can now invoke println!() from libstd with no local task, no local
scheduler, and even without libuv.

There's still plenty of work to do on the native I/O factory, but this is the
first steps into making it an official portion of the standard library. I don't
expect anyone to reach into io::native directly, but rather only std::io
primitives will be used. Each std::io interface seamlessly falls back onto the
native I/O implementation if the local scheduler doesn't have a libuv one
(hurray trait ojects!)
2013-11-13 18:34:59 -08:00
Alex Crichton
49ee49296b Move std::rt::io to std::io 2013-11-11 20:44:07 -08:00
Matthew Iselin
f698decf37 Implemented a ProcessExit enum and helper methods to std::rt::io::process for getting process termination status, or the signal that terminated a process.
A test has been added to rtio-processes.rs to ensure signal termination is picked up correctly.
2013-11-12 11:37:14 +10:00
Alex Crichton
7755ffd013 Remove #[fixed_stack_segment] and #[rust_stack]
These two attributes are no longer useful now that Rust has decided to leave
segmented stacks behind. It is assumed that the rust task's stack is always
large enough to make an FFI call (due to the stack being very large).

There's always the case of stack overflow, however, to consider. This does not
change the behavior of stack overflow in Rust. This is still normally triggered
by the __morestack function and aborts the whole process.

C stack overflow will continue to corrupt the stack, however (as it did before
this commit as well). The future improvement of a guard page at the end of every
rust stack is still unimplemented and is intended to be the mechanism through
which we attempt to detect C stack overflow.

Closes #8822
Closes #10155
2013-11-11 10:40:34 -08:00
bors
4059b5c4b3 auto merge of #10409 : alexcrichton/rust/issue-10386, r=brson
Turns out the pipe names must have special names on windows. Once we have
special names, all the tests pass just fine.

Closes #10386
2013-11-11 07:46:18 -08:00
bors
c47986b675 auto merge of #10394 : yichoi/rust/make_check_pass_android, r=brson
To enable test on android bot #9120

some tests are disabled and can be fixed further.
2013-11-11 06:21:16 -08:00
Alex Crichton
681ea93d52 Enable uv pipe tests on windows
Turns out the pipe names must have special names on windows. Once we have
special names, all the tests pass just fine.

Closes #10386
2013-11-10 20:43:08 -08:00
Alex Crichton
e38a89d0b0 Fix usage of libuv for windows 2013-11-10 12:23:57 -08:00