rust/mk
Alex Crichton 5ec36c358f std: Extract librustrt out of libstd
As part of the libstd facade efforts, this commit extracts the runtime interface
out of the standard library into a standalone crate, librustrt. This crate will
provide the following services:

* Definition of the rtio interface
* Definition of the Runtime interface
* Implementation of the Task structure
* Implementation of task-local-data
* Implementation of task failure via unwinding via libunwind
* Implementation of runtime initialization and shutdown
* Implementation of thread-local-storage for the local rust Task

Notably, this crate avoids the following services:

* Thread creation and destruction. The crate does not require the knowledge of
  an OS threading system, and as a result it seemed best to leave out the
  `rt::thread` module from librustrt. The librustrt module does depend on
  mutexes, however.
* Implementation of backtraces. There is no inherent requirement for the runtime
  to be able to generate backtraces. As will be discussed later, this
  functionality continues to live in libstd rather than librustrt.

As usual, a number of architectural changes were required to make this crate
possible. Users of "stable" functionality will not be impacted by this change,
but users of the `std::rt` module will likely note the changes. A list of
architectural changes made is:

* The stdout/stderr handles no longer live directly inside of the `Task`
  structure. This is a consequence of librustrt not knowing about `std::io`.
  These two handles are now stored inside of task-local-data.

  The handles were originally stored inside of the `Task` for perf reasons, and
  TLD is not currently as fast as it could be. For comparison, 100k prints goes
  from 59ms to 68ms (a 15% slowdown). This appeared to me to be an acceptable
  perf loss for the successful extraction of a librustrt crate.

* The `rtio` module was forced to duplicate more functionality of `std::io`. As
  the module no longer depends on `std::io`, `rtio` now defines structures such
  as socket addresses, addrinfo fiddly bits, etc. The primary change made was
  that `rtio` now defines its own `IoError` type. This type is distinct from
  `std::io::IoError` in that it does not have an enum for what error occurred,
  but rather a platform-specific error code.

  The native and green libraries will be updated in later commits for this
  change, and the bulk of this effort was put behind updating the two libraries
  for this change (with `rtio`).

* Printing a message on task failure (along with the backtrace) continues to
  live in libstd, not in librustrt. This is a consequence of the above decision
  to move the stdout/stderr handles to TLD rather than inside the `Task` itself.
  The unwinding API now supports registration of global callback functions which
  will be invoked when a task fails, allowing for libstd to register a function
  to print a message and a backtrace.

  The API for registering a callback is experimental and unsafe, as the
  ramifications of running code on unwinding is pretty hairy.

* The `std::unstable::mutex` module has moved to `std::rt::mutex`.

* The `std::unstable::sync` module has been moved to `std::rt::exclusive` and
  the type has been rewritten to not internally have an Arc and to have an RAII
  guard structure when locking. Old code should stop using `Exclusive` in favor
  of the primitives in `libsync`, but if necessary, old code should port to
  `Arc<Exclusive<T>>`.

* The local heap has been stripped down to have fewer debugging options. None of
  these were tested, and none of these have been used in a very long time.

[breaking-change]
2014-06-06 22:19:41 -07:00
..
clean.mk mk: Don't rm 'dist' during clean, just its contents 2014-03-24 14:29:19 -07:00
crates.mk std: Extract librustrt out of libstd 2014-06-06 22:19:41 -07:00
ctags.mk Don't make tags for our dependencies and tests. 2013-11-16 13:44:52 +11:00
dist.mk mk: Bundle jemalloc with make dist 2014-05-11 17:41:36 -04:00
docs.mk rustdoc: Submit examples to play.rust-lang.org 2014-06-06 20:00:16 -07:00
host.mk mk: Add libcore 2014-05-07 08:12:48 -07:00
install.mk Made 'make install' include libs for additional targets 2014-04-08 00:03:12 -07:00
llvm.mk llvm: Add an option to statically link libstdc++ 2014-04-17 11:39:51 -07:00
main.mk Refactoring: Introduce distinct host and target rpath var setters. 2014-05-18 22:56:26 +02:00
perf.mk support for GNU configure syntax 2013-10-29 16:22:08 -07:00
platform.mk Add clang specific flag more selectively. 2014-05-23 17:27:13 -07:00
prepare.mk mk: Fix make install 2014-05-07 23:23:17 -07:00
reconfig.mk mk: Move most of Makefile.in to .mk files 2014-02-14 17:45:54 -08:00
rt.mk std: Extract librustrt out of libstd 2014-06-06 22:19:41 -07:00
rustllvm.mk Remove VPATH usage in Makefiles 2014-02-02 10:59:14 -08:00
snap.mk support for GNU configure syntax 2013-10-29 16:22:08 -07:00
stage0.mk configure: Make rustlibdir non-configurable 2014-03-25 21:35:10 -07:00
target.mk mk: Replace 'oxidize' with 'rustc'. Closes #13781 2014-05-21 11:01:59 -07:00
tests.mk mk: Run doc tests with --cfg dox 2014-06-06 19:51:52 -07:00
util.mk mk: Address review feedback 2014-02-14 19:17:50 -08:00