mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
5ec36c358f
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]
140 lines
5.2 KiB
Makefile
140 lines
5.2 KiB
Makefile
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
# file at the top-level directory of this distribution and at
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
# option. This file may not be copied, modified, or distributed
|
|
# except according to those terms.
|
|
|
|
################################################################################
|
|
# Rust's standard distribution of crates and tools
|
|
#
|
|
# The crates outlined below are the standard distribution of libraries provided
|
|
# in a rust installation. These rules are meant to abstract over the
|
|
# dependencies (both native and rust) of crates and basically generate all the
|
|
# necessary makefile rules necessary to build everything.
|
|
#
|
|
# Here's an explanation of the variables below
|
|
#
|
|
# TARGET_CRATES
|
|
# This list of crates will be built for all targets, including
|
|
# cross-compiled targets
|
|
#
|
|
# HOST_CRATES
|
|
# This list of crates will be compiled for only host targets. Note that
|
|
# this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
|
|
# a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
|
|
# the HOST_CRATES set, but the HOST_CRATES set can depend on target
|
|
# crates.
|
|
#
|
|
# TOOLS
|
|
# A list of all tools which will be built as part of the compilation
|
|
# process. It is currently assumed that most tools are built through
|
|
# src/driver/driver.rs with a particular configuration (there's a
|
|
# corresponding library providing the implementation)
|
|
#
|
|
# DEPS_<crate>
|
|
# These lists are the dependencies of the <crate> that is to be built.
|
|
# Rust dependencies are listed bare (i.e. std, green) and native
|
|
# dependencies have a "native:" prefix (i.e. native:hoedown). All deps
|
|
# will be built before the crate itself is built.
|
|
#
|
|
# TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
|
|
# Similar to the DEPS variable, this is the library crate dependencies
|
|
# list for tool as well as the source file for the specified tool
|
|
#
|
|
# You shouldn't need to modify much other than these variables. Crates are
|
|
# automatically generated for all stage/host/target combinations.
|
|
################################################################################
|
|
|
|
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
|
|
uuid serialize sync getopts collections num test time rand \
|
|
url log regex graphviz core rlibc alloc debug rustrt
|
|
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
|
|
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
|
|
TOOLS := compiletest rustdoc rustc
|
|
|
|
DEPS_core :=
|
|
DEPS_rlibc :=
|
|
DEPS_alloc := core libc native:jemalloc
|
|
DEPS_debug := std
|
|
DEPS_rustrt := alloc core libc collections native:rustrt_native
|
|
DEPS_std := core libc rand alloc collections rustrt \
|
|
native:rust_builtin native:backtrace
|
|
DEPS_graphviz := std
|
|
DEPS_green := std native:context_switch
|
|
DEPS_rustuv := std native:uv native:uv_support
|
|
DEPS_native := std
|
|
DEPS_syntax := std term serialize log fmt_macros debug
|
|
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
|
|
time log graphviz debug
|
|
DEPS_rustdoc := rustc native:hoedown serialize sync getopts \
|
|
test time debug
|
|
DEPS_flate := std native:miniz
|
|
DEPS_arena := std
|
|
DEPS_graphviz := std
|
|
DEPS_glob := std
|
|
DEPS_serialize := std log
|
|
DEPS_term := std log
|
|
DEPS_semver := std
|
|
DEPS_uuid := std serialize
|
|
DEPS_sync := std alloc
|
|
DEPS_getopts := std
|
|
DEPS_collections := core alloc
|
|
DEPS_fourcc := syntax std
|
|
DEPS_hexfloat := syntax std
|
|
DEPS_num := std
|
|
DEPS_test := std getopts serialize term time regex native:rust_test_helpers
|
|
DEPS_time := std serialize sync
|
|
DEPS_rand := core
|
|
DEPS_url := std
|
|
DEPS_log := std sync
|
|
DEPS_regex := std
|
|
DEPS_regex_macros = syntax std regex
|
|
DEPS_fmt_macros = std
|
|
|
|
TOOL_DEPS_compiletest := test green rustuv getopts
|
|
TOOL_DEPS_rustdoc := rustdoc native
|
|
TOOL_DEPS_rustc := rustc native
|
|
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
|
|
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
|
|
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
|
|
|
|
ONLY_RLIB_core := 1
|
|
ONLY_RLIB_libc := 1
|
|
ONLY_RLIB_rlibc := 1
|
|
ONLY_RLIB_alloc := 1
|
|
ONLY_RLIB_rand := 1
|
|
ONLY_RLIB_collections := 1
|
|
|
|
################################################################################
|
|
# You should not need to edit below this line
|
|
################################################################################
|
|
|
|
DOC_CRATES := $(filter-out rustc, $(filter-out syntax, $(CRATES)))
|
|
COMPILER_DOC_CRATES := rustc syntax
|
|
|
|
# This macro creates some simple definitions for each crate being built, just
|
|
# some munging of all of the parameters above.
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_CRATE
|
|
CRATEFILE_$(1) := $$(S)src/lib$(1)/lib.rs
|
|
RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
|
|
RUST_DEPS_$(1) := $$(filter-out native:%,$$(DEPS_$(1)))
|
|
NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
|
|
endef
|
|
|
|
$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
|
|
|
|
# Similar to the macro above for crates, this macro is for tools
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_TOOL
|
|
TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
|
|
endef
|
|
|
|
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
|