Commit Graph

249 Commits

Author SHA1 Message Date
Luqman Aden 6820ed4dcf Fix up mingw64 target. 2013-11-22 20:39:58 -05:00
Alex Crichton 508b7b996e Move runtime files to C instead of C++
Explicitly have the only C++ portion of the runtime be one file with exception
handling. All other runtime files must now live in C and be fully defined in C.
2013-11-18 21:45:58 -08:00
Alex Crichton e8bf078802 Remove the C++ lock_and_signal type
A the same time this purges all runtime support needed for statically
initialized mutexes, moving all users over to the new Mutex type instead.
2013-11-18 20:06:40 -08:00
Alex Crichton 86a321b65d Another round of test fixes from previous commits 2013-11-10 01:37:12 -08:00
Alex Crichton 3a3eefc5c3 Update to the latest libuv
At this time, also point the libuv submodule to the official repo instead of my
own off to the side.

cc #10246
Closes #10329
2013-11-10 01:37:11 -08:00
bors 22eb11c09b auto merge of #10227 : kud1ing/rust/ios, r=alexcrichton 2013-11-06 14:01:14 -08:00
kud1ing 2a333ed088 Fixes for compilation to iOS:
- remove /usr/include from the include path since the iOS SDK provides the correct version
- `_NSGetEnviron()` is private and not available on iOS
- `.align` without an argument is not allowed with the Apple tools. 2^2 should be the default alignment
- ignore error messages for XCode < 5
- pass include path to libuv
2013-11-06 22:11:09 +01:00
Dirkjan Bussink 47e0bd403a Move implementation for threads to Rust
This binds to the appropriate pthreads_* and Windows specific functions
and calls them from Rust. This allows for removal of the C++ support
code for threads.

Fixes #10162
2013-11-05 17:49:46 +01:00
Alex Crichton 0ce1b2f04d Statically link libuv to librustuv
Similarly to the previous commit, libuv is only used by this library, so there's
no need for it to be linked into librustrt and available to all crates by
default.
2013-11-02 21:28:17 -07:00
Alex Crichton 7f31b079e5 Statically link sundown to librustdoc
Closes #10103
2013-11-01 21:28:48 -07:00
Heather 8a593a8bdb support for GNU configure syntax 2013-10-29 16:22:08 -07:00
Alex Crichton 201cab84e8 Move rust's uv implementation to its own crate
There are a few reasons that this is a desirable move to take:

1. Proof of concept that a third party event loop is possible
2. Clear separation of responsibility between rt::io and the uv-backend
3. Enforce in the future that the event loop is "pluggable" and replacable

Here's a quick summary of the points of this pull request which make this
possible:

* Two new lang items were introduced: event_loop, and event_loop_factory.
  The idea of a "factory" is to define a function which can be called with no
  arguments and will return the new event loop as a trait object. This factory
  is emitted to the crate map when building an executable. The factory doesn't
  have to exist, and when it doesn't then an empty slot is in the crate map and
  a basic event loop with no I/O support is provided to the runtime.

* When building an executable, then the rustuv crate will be linked by default
  (providing a default implementation of the event loop) via a similar method to
  injecting a dependency on libstd. This is currently the only location where
  the rustuv crate is ever linked.

* There is a new #[no_uv] attribute (implied by #[no_std]) which denies
  implicitly linking to rustuv by default

Closes #5019
2013-10-29 08:39:22 -07:00
Alex Crichton 357ef1f69c Rewrite boxed_region/memory_region in Rust
This drops more of the old C++ runtime to rather be written in rust. A few
features were lost along the way, but hopefully not too many. The main loss is
that there are no longer backtraces associated with allocations (rust doesn't
have a way of acquiring those just yet). Other than that though, I believe that
the rest of the debugging utilities made their way over into rust.

Closes #8704
2013-10-26 01:10:39 -07:00
bors 31a209ca42 auto merge of #9834 : alexcrichton/rust/morestack, r=brson
This commit re-introduces the functionality of __morestack in a way that it was
not originally anticipated. Rust does not currently have segmented stacks,
rather just large stack segments. We do not detect when these stack segments are
overrun currently, but this commit leverages __morestack in order to check this.

This commit purges a lot of the old __morestack and stack limit C++
functionality, migrating the necessary chunks to rust. The stack limit is now
entirely maintained in rust, and the "main logic bits" of __morestack are now
also implemented in rust as well.

I put my best effort into validating that this currently builds and runs successfully on osx and linux 32/64 bit, but I was unable to get this working on windows. We never did have unwinding through __morestack frames, and although I tried poking at it for a bit, I was unable to understand why we don't get unwinding right now.

A focus of this commit is to implement as much of the logic in rust as possible. This involved some liberal usage of `no_split_stack` in various locations, along with some use of the `asm!` macro (scary). I modified a bit of C++ to stop calling `record_sp_limit` because this is no longer defined in C++, rather in rust.

Another consequence of this commit is that `thread_local_storage::{get, set}` must both be flagged with `#[rust_stack]`. I've briefly looked at the implementations on osx/linux/windows to ensure that they're pretty small stacks, and I'm pretty sure that they're definitely less than 20K stacks, so we probably don't have a lot to worry about.

Other things worthy of note:
* The default stack size is now 4MB instead of 2MB. This is so that when we request 2MB to call a C function you don't immediately overflow because you have consumed any stack at all.
* `asm!` is actually pretty cool, maybe we could actually define context switching with it?
* I wanted to add links to the internet about all this jazz of storing information in TLS, but I was only able to find a link for the windows implementation. Otherwise my suggestion is just "disassemble on that arch and see what happens"
* I put my best effort forward on arm/mips to tweak __morestack correctly, we have no ability to test this so an extra set of eyes would be useful on these spots.
* This is all really tricky stuff, so I tried to put as many comments as I thought were necessary, but if anything is still unclear (or I completely forgot to take something into account), I'm willing to write more!
2013-10-19 09:46:18 -07:00
Alex Crichton 6d8330afb6 Use __morestack to detect stack overflow
This commit resumes management of the stack boundaries and limits when switching
between tasks. This additionally leverages the __morestack function to run code
on "stack overflow". The current behavior is to abort the process, but this is
probably not the best behavior in the long term (for deails, see the comment I
wrote up in the stack exhaustion routine).
2013-10-19 09:43:31 -07:00
Alex Crichton 90911d7259 Remove jemalloc from the runtime
As discovered in #9925, it turns out that we weren't using jemalloc on most
platforms. Additionally, on some platforms we were using it incorrectly and
mismatching the libc version of malloc with the jemalloc version of malloc.

Additionally, it's not clear that using jemalloc is indeed a large performance
win in particular situtations. This could be due to building jemalloc
incorrectly, or possibly due to using jemalloc incorrectly, but it is unclear at
this time.

Until jemalloc can be confirmed to integrate correctly on all platforms and has
verifiable large performance wins on platforms as well, it shouldn't be part of
the default build process. It should still be available for use via the
LD_PRELOAD trick on various architectures, but using it as the default allocator
for everything would require guaranteeing that it works in all situtations,
which it currently doesn't.

Closes #9925
2013-10-18 10:38:21 -07:00
Daniel Micay f766acad62 drop the linenoise library
Closes #5038
2013-10-16 22:57:51 -04:00
Huon Wilson 29e3b33a09 std::rand: make the windows OSRng more correct, remove some C++.
This lets the C++ code in the rt handle the (slightly) tricky parts of
random number generation: e.g. error detection/handling, and using the
values of the `#define`d options to the various functions.
2013-10-09 22:22:42 +11:00
Alex Crichton d858360483 Build libuv/jemalloc only once (not per stage)
Reorganize the makefiles to stop building these once per stage because there's
no need to do this at all.

Closes #7002
2013-10-08 14:26:56 -07:00
Alex Crichton 6aba140fa7 rustdoc: Add sundown to src/rt/
This also starts compiling it in the same manner as linenoise, it's just bundled
with librustrt directly, and we export just a few symbols out of it.
2013-09-25 14:27:41 -07:00
Huon Wilson 0951313c1e Remove the C(++) ISAAC Rng from the old rt.
This has to leave rust_gen_seed and rng_gen_seed around since they're
used to initialise the std::rand RNGs.
2013-09-23 00:11:43 +10:00
bors 3c0013134c auto merge of #9280 : alexcrichton/rust/less-c++, r=brson
Some of the functions could be converted to rust, but the functions dealing with
signals were moved to rust_builtin.cpp instead (no reason to keep the original
file around for one function).

Closes #2674

Because less C++ is better C++!
2013-09-18 22:15:59 -07:00
Alex Crichton c3ad785d83 Remove rust_run_program.cpp
Some of the functions could be converted to rust, but the functions dealing with
signals were moved to rust_builtin.cpp instead (no reason to keep the original
file around for one function).

Closes #2674
2013-09-18 20:58:56 -07:00
Vadim Chugunov c3fd430603 The purpose of these headers is to fix issues with mingw v4.0, as described in #9246.
This works by adding this directory to GCC include search path before mingw system headers directories,
so we can intercept their inclusions and add missing definitions without having to modify files in mingw/include.
2013-09-17 01:06:01 -07:00
Seo Sanghyeon 51998d22b0 Pass OS to gyp_uv 2013-09-16 23:09:50 +09:00
Florian Hahn 2b5f4b55c0 Convert rust_crate_map.cpp to Rust
Conflicts:
	src/libstd/rt/logging.rs
2013-09-13 00:47:30 +02:00
bors 60a0dbc095 auto merge of #9033 : alexcrichton/rust/libuv-makefile-dep, r=brson
This way the rule isn't always built whenever you fire off a new build
2013-09-09 11:51:03 -07:00
Alex Crichton 594531a1c8 Give the libuv makefile generation a dependency
This way the rule isn't always built whenever you fire off a new build
2013-09-07 10:46:47 -07:00
Alex Crichton 75afcffc2f Run gyp with CFG_PYTHON which is python < 3
This is required for systems where /usr/bin/python is actually python 3
2013-09-07 10:22:36 -07:00
Alex Crichton b4c36c2d1b Upgrade libuv to the current master (again)
This is a reopening of the libuv-upgrade part of #8645. Hopefully this won't
cause random segfaults all over the place. The windows regression in testing
should also be fixed (it shouldn't build the whole compiler twice).

A notable difference from before is that gyp is now a git submodule instead of
always git-cloned at make time. This allows bundling for releases more easily.

Closes #8850
2013-09-06 11:12:49 -07:00
bors 422dcbd56d auto merge of #8975 : alexcrichton/rust/reorganize, r=pnkfelix
Closes #2302
2013-09-05 01:05:47 -07:00
Alex Crichton 7b3dd32797 Move the `rt` build directory under $target
Closes #2302
2013-09-04 23:34:09 -07:00
Florian Hahn e38739bb44 Convert rust_log.cpp to Rust, closes #8703 2013-09-04 14:18:56 +02:00
Brian Anderson 3c5a43e5b6 Revert "auto merge of #8645 : alexcrichton/rust/issue-6436-run-non-blocking, r=brson"
This reverts commit b8d1fa3994, reversing
changes made to f22b4b1698.

Conflicts:
	mk/rt.mk
	src/libuv
2013-08-29 14:23:44 -07:00
Ilyong Cho 4cf8671d20 mk: Fix libuv makefile generation on android 2013-08-29 17:44:23 +09:00
Alex Crichton 188a9dd210 Fix compilation issues with libuv on OSX
It turns out that gyp (libuv's new build system) wants x64 for a 64-bit x86
architecture and ia32 for a 32-bit architecture, so this performs the relevant
mapping and then invokes libuv's configure script with the appropriate target
architecture.

This can be verified by running make with VERBOSE=1 and seeing that beforehand
on a 64-bit build libuv was passed "-arch i386" and now it's passed
"-arch x86_64"

Closes #8826
2013-08-28 17:32:27 -07:00
Alex Crichton 66a07b0550 Run gyp_uv with CFG_PYTHON instead of directly
The syntax of the script requires python < 3, and so does our build system so we
can just use CFG_PYTHON to run the script. This prevents build failures where
`python` is actually python3 or later.
2013-08-28 02:17:13 -07:00
Alex Crichton 2ad05ae014 Fix various issues associated with building on windows 2013-08-27 20:46:43 -07:00
Alex Crichton b89e1c000e Implement process bindings to libuv
Closes #6436
2013-08-27 20:46:43 -07:00
Alex Crichton ed204257a0 Upgrade libuv to the current master + our patches
There were two main differences with the old libuv and the master version:

1. The uv_last_error function is now gone. The error code returned by each
   function is the "last error" so now a UvError is just a wrapper around a
   c_int.
2. The repo no longer includes a makefile, and the build system has change.
   According to the build directions on joyent/libuv, this now downloads a `gyp`
   program into the `libuv/build` directory and builds using that. This
   shouldn't add any dependences on autotools or anything like that.

Closes #8407
Closes #6567
Closes #6315
2013-08-27 20:46:17 -07:00
Brian Anderson 9cdfe1e603 rt: Remove rust_abi 2013-08-23 18:38:59 -07:00
Brian Anderson 0ee24437ce rt: Remove rust_util.cpp 2013-08-23 18:38:59 -07:00
Brian Anderson b72c43739d rt: Remove old precise GC code 2013-08-23 18:38:59 -07:00
Brian Anderson 0a1baef4f5 rt: Remove timer 2013-08-23 18:38:56 -07:00
Brian Anderson b3fa43f6e0 rt: Remove rust_exchange_alloc 2013-08-23 14:46:23 -07:00
bors 5034792c88 auto merge of #8584 : thestinger/rust/jemalloc, r=graydon
This reverts commit 371a316ec9.

Closes #7217
2013-08-19 20:21:58 -07:00
Daniel Micay 0dceabda7f Revert "Turn off jemalloc"
This reverts commit 371a316ec9.

Closes #7217
2013-08-17 19:54:23 -04:00
Brian Anderson da7d79dfbe rt: Remove rust_stack 2013-08-16 13:24:25 -07:00
Brian Anderson 5923cc3745 rt: Remove rust_env 2013-08-16 13:24:24 -07:00
Brian Anderson b75915d0ca Remove the C++ runtime. Sayonara 2013-08-09 16:45:50 -07:00
Brian Anderson 371a316ec9 Turn off jemalloc 2013-06-18 12:03:14 -07:00
Young-il Choi 00ff170e7f mk: arm support - disable tls of jemalloc on rt.mk 2013-06-13 11:48:22 +09:00
James Miller cf536e013a Pass the correct build flags to jemalloc
Apparently the standard --build and --host flags don't actually
_do_ anything. This re-uses the libuv flags, since they are the
same for getting jemalloc to cross-compile
2013-06-10 18:26:24 +12:00
Daniel Micay a593d8f67c pass correct flags to jemalloc for cross-compiling 2013-06-07 18:27:15 -04:00
bors 5d2cadbfea auto merge of #6895 : cmr/rust/jemalloc, r=brson 2013-06-06 18:43:37 -07:00
Brian Anderson f702b900d8 mk: Fix _RUST_STAGEX variables under cross compile. Fix incoming 2013-06-06 17:27:22 -07:00
Corey Richardson 2d635179f0 Windows fixes 2013-06-01 17:50:26 -04:00
Daniel Micay 933897c5f5 integrate jemalloc into the build 2013-06-01 11:31:44 -04:00
Tom Lee e69e80938b Define _RUST_STAGEN when building rustrt.
This lets us use #ifdefs to determine which stage of the build we happen
to be in, which is useful in the event we need to make changes to rustrt
that are incompatible with the code generated by stage0.

This should help pave the way to completing #6575, which will likely
require changes to type signatures for spawn_fn & glue_fn in rustrt.
2013-05-24 00:30:01 -07:00
bors d68c0279ea auto merge of #6249 : crabtw/rust/arm, r=brson
It uses the private field of TCB head to store stack limit. I tested on my Raspberry PI. A simple hello world program ran without any problem. However, for a more complex program, it segfaulted as #6231.
2013-05-17 18:19:27 -07:00
Young-il Choi db38ab9ad9 mk: rt.mk regression patch for mingw32 after #6176 2013-05-07 15:26:55 +09:00
Jyun-Yan You 48b6262b38 preliminary Linux ARM support 2013-05-07 13:17:14 +08:00
Daniel Micay 86efd97a10 add gitattributes and fix whitespace issues 2013-05-03 20:01:42 -04:00
Daniel Micay d6697e7027 pass along CFLAGS/LINK_FLAGS to libuv
Closes #6142
2013-05-01 22:13:33 -04:00
Brian Anderson 7cd681684f rt: Move test functions to rust_test_helpers.cpp 2013-04-15 13:39:15 -07:00
Jyun-Yan You 99b156e78a mk: mips toolchain config 2013-04-04 18:52:24 +08:00
bors 251d0c4557 auto merge of #5350 : yichoi/rust/pull-0313-2, r=graydon,pcwalton
FIX #5330

rename arm-unknown-android to arm-linux-androideabi
2013-03-19 17:06:55 -07:00
Young-il Choi 2657723cc5 mk: rt.mk ar desinated by target-triples 2013-03-14 02:26:09 +09:00
Young-il Choi 268faef63a mk: target triple rename arm-unknown-android->arm-linux-androideabi 2013-03-13 09:21:12 +09:00
Brian Anderson 14e5a6e5f7 mk: Cleanup. Minor fixes 2013-03-06 22:37:52 -08:00
Young-il Choi e971d0ce9f mk: rt.mk fix for libuv cross compile 2013-03-04 13:49:01 +09:00
Young-il Choi 7714d52cd9 mk: cleanup - lib and executable suffix handling 2013-03-02 21:25:12 +09:00
Young-il Choi 26a5dc593c mk: rewrite make files 2013-02-27 14:53:35 +09:00
Brian Anderson 15c0c35352 mk: Split target triples into bulid triple + host triples + target triples
For cross compiling to targets that don't want to build a compiler
2013-02-21 17:51:55 -08:00
Chris Peterson f4320b6195 move isaac RNG utility functions to new rust_rng.cpp file 2013-02-14 22:30:27 -08:00
Jeff Olson a74296a39f build: ifdef for mingw/non-mingw builds 2013-02-10 11:51:05 -08:00
Jeff Olson a38b16651f build: tweak rt.mk, as per graydon.. CFLAGS had to stay 2013-02-10 11:51:05 -08:00
Jeff Olson 3a813e29b6 etc: rework of how libuv is integrated into the build
- thanks to work in libuv's upstream, we can call libuv's Makefile directly
with parameters, instead of descending in gyp-uv madness and generating
our own.
2013-02-10 11:51:05 -08:00
Brian Anderson e43c5bdc6b Rewrite the exchange allocator to work without an active scheduler. #4457 2013-02-06 14:27:36 -08:00
Brian Anderson 02fbd5a164 rt: Remove circular_buffer 2013-02-01 21:22:49 -08:00
Brian Anderson 4f6516969e rt: Remove ports 2013-02-01 21:22:49 -08:00
Brian Anderson 53ec6c3f9b rt: Remove shape code 2012-11-05 15:22:35 -08:00
Brian Anderson 1b0c6665d9 Merge remote-tracking branch 'brson/repl'
Conflicts:
	mk/install.mk
	src/rt/rustrt.def.in
2012-11-04 13:42:39 -08:00
Brian Anderson 799eb105b9 Use a linenoise with win32 support 2012-11-04 13:34:14 -08:00
Zack Corr ea996556b9 rusti: Remove linenoise module, add to rt, remove core::rl 2012-10-30 11:08:36 +10:00
Zack Corr 4912428cb5 rusti: Add linenoise, wrap into core::rl and add rusti REPL tool
Add Brian Leibig to AUTHORS.txt for REPL contributions
2012-10-27 18:03:15 +10:00
Brian Anderson 8d932160d9 rt: Remove box annihilator 2012-10-23 12:14:46 -07:00
Patrick Walton f813f519a5 rt: Remove the cycle collector 2012-09-25 12:13:20 -07:00
Elliott Slaughter 3f0d207b32 gc: Add stack walker for new garbage collector.
Safe points are exported in a per-module list via the crate map. A C
runtime call walks the crate map at startup and aggregates the list of
safe points for the program.

Currently the GC doesn't actually deallocate memory on malloc and
free. Adding the GC at this stage is primarily of testing value.

The GC does attempt to clean up exchange heap and stack-allocated
resource on failure.

A result of this patch is that the user now needs to be careful about
what code they write in destructors, because the GC and/or failure
cleanup may need to call destructors. Specifically, calls to malloc
are considered unsafe and may result in infinite loops or segfaults.
2012-09-07 09:21:21 -07:00
Graydon Hoare b769e29680 Compress metadata section. Seems a minor speed win, major space win. 2012-08-28 14:50:39 -07:00
Ben Blum bdbad614ac Remove rust_cond_lock and sys::condition (rename to little_lock) 2012-08-07 18:18:48 -04:00
Eric Holk dc718d97a6 Adding a lock/condition variable to libcore. 2012-06-19 10:31:12 -07:00
Michael Sullivan 88ec259cee Put type descriptors in strings created by the runtime. Progress on #2638. 2012-06-18 15:54:37 -07:00
Tim Chevalier 3e2006a570 Revert "Adding a lock/condition variable to libcore."
This reverts commit e394ebda37.
2012-06-16 15:34:15 -07:00
Eric Holk e394ebda37 Adding a lock/condition variable to libcore. 2012-06-15 22:00:24 -04:00
Michael Sullivan f99f2e8ce2 Update the build system to handle dependency on header files. Closes #2547. 2012-06-14 14:50:14 -07:00
Michael Sullivan 3a36ffe5ff Revert "Update the build system to handle dependency on header files. Closes #2547."
This reverts commit 31f4b63dff.
2012-06-13 18:37:07 -07:00
Michael Sullivan 31f4b63dff Update the build system to handle dependency on header files. Closes #2547. 2012-06-13 16:39:09 -07:00
Michael Sullivan f8afe107fa Minor makefile cleanup. 2012-06-13 16:39:09 -07:00
Patrick Walton 851fde879d rt: Add architecture-specific general-purpose register definitions
This will be used for stack crawling, which in turn will be used for GC and
unwinding.
2012-04-04 21:40:34 -07:00