about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-21 03:41:45 +0000
committerbors <bors@rust-lang.org>2014-11-21 03:41:45 +0000
commitc9f6d696420107f82304b992cf623b806995fe18 (patch)
treed2224bd566aaf93132fb5a959e0ba33192bde035 /src/libstd
parent98300516072c6afd0e93654b325f5924b60dea53 (diff)
parent32c3d027801b8f30f741b1b5340682e7009d02ac (diff)
downloadrust-c9f6d696420107f82304b992cf623b806995fe18.tar.gz
rust-c9f6d696420107f82304b992cf623b806995fe18.zip
auto merge of #18967 : aturon/rust/remove-runtime, r=alexcrichton
This PR completes the removal of the runtime system and green-threaded abstractions as part of implementing [RFC 230](https://github.com/rust-lang/rfcs/pull/230).

Specifically:

* It removes the `Runtime` trait, welding the scheduling infrastructure directly to native threads.

* It removes `libgreen` and `libnative` entirely.

* It rewrites `sync::mutex` as a trivial layer on top of native mutexes. Eventually, the two modules will be merged.

* It hides the vast majority of `std::rt`.

This completes the basic task of removing the runtime system (I/O and scheduling) and components that depend on it. 

After this lands, a follow-up PR will pull the `rustrt` crate back into `std`, turn `std::task` into `std::thread` (with API changes to go along with it), and completely cut out the remaining startup/teardown sequence. Other changes, including new [TLS](https://github.com/rust-lang/rfcs/pull/461) and synchronization are in the RFC or pre-RFC phase.

Closes #17325
Closes #18687

[breaking-change]

r? @alexcrichton 
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/dynamic_lib.rs2
-rw-r--r--src/libstd/failure.rs2
-rw-r--r--src/libstd/io/pipe.rs2
-rw-r--r--src/libstd/io/process.rs2
-rw-r--r--src/libstd/io/stdio.rs8
-rw-r--r--src/libstd/lib.rs4
-rw-r--r--src/libstd/os.rs6
-rw-r--r--src/libstd/rt/backtrace.rs4
-rw-r--r--src/libstd/rt/mod.rs84
-rw-r--r--src/libstd/sys/common/helper_thread.rs8
-rw-r--r--src/libstd/sys/common/net.rs2
-rw-r--r--src/libstd/sys/unix/mod.rs2
-rw-r--r--src/libstd/sys/unix/pipe.rs2
-rw-r--r--src/libstd/sys/windows/mod.rs2
-rw-r--r--src/libstd/sys/windows/pipe.rs2
-rw-r--r--src/libstd/task.rs140
16 files changed, 120 insertions, 152 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index 8bb82d5bc1e..0f119d44485 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -229,7 +229,7 @@ pub mod dl {
     }
 
     pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> {
-        use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+        use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
         static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             // dlerror isn't thread safe, so we need to lock around this entire
diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs
index 07759974356..c23e043c174 100644
--- a/src/libstd/failure.rs
+++ b/src/libstd/failure.rs
@@ -18,7 +18,7 @@ use kinds::Send;
 use option::{Some, None};
 use result::Ok;
 use rt::backtrace;
-use rt::{Stderr, Stdio};
+use rustrt::{Stderr, Stdio};
 use rustrt::local::Local;
 use rustrt::task::Task;
 use str::Str;
diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs
index 5137db305f0..8c20ea08863 100644
--- a/src/libstd/io/pipe.rs
+++ b/src/libstd/io/pipe.rs
@@ -45,7 +45,7 @@ impl PipeStream {
     ///
     /// # Example
     ///
-    /// ```rust
+    /// ```{rust,no_run}
     /// # #![allow(unused_must_use)]
     /// extern crate libc;
     ///
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 592ec0681a9..d4d24c1e12f 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -740,8 +740,6 @@ impl Drop for Process {
 mod tests {
     #![allow(unused_imports)]
 
-    extern crate native;
-
     use super::*;
     use prelude::*;
     use io::timer::*;
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 362e80f9f12..7374668a69d 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -40,9 +40,9 @@ use option::{Option, Some, None};
 use boxed::Box;
 use sys::{fs, tty};
 use result::{Ok, Err};
-use rt;
-use rt::local::Local;
-use rt::task::Task;
+use rustrt;
+use rustrt::local::Local;
+use rustrt::task::Task;
 use slice::SlicePrelude;
 use str::StrPrelude;
 use uint;
@@ -207,7 +207,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) {
         local_stdout.replace(Some(my_stdout));
         result
     } else {
-        let mut io = rt::Stdout;
+        let mut io = rustrt::Stdout;
         f(&mut io as &mut Writer)
     };
     match result {
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 7f2a4c7e365..b35c49efdd8 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -117,7 +117,6 @@
 
 #![reexport_test_harness_main = "test_main"]
 
-#[cfg(test)] extern crate green;
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
 
 extern crate alloc;
@@ -163,7 +162,6 @@ pub use core::result;
 pub use core::option;
 
 pub use alloc::boxed;
-
 pub use alloc::rc;
 
 pub use core_collections::slice;
@@ -248,8 +246,6 @@ pub mod fmt;
 
 #[path = "sys/common/mod.rs"] mod sys_common;
 
-// FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
-// but name resolution doesn't work without it being pub.
 pub mod rt;
 mod failure;
 
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 68ddabfd48f..d7ba4877086 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -208,7 +208,7 @@ Accessing environment variables is not generally threadsafe.
 Serialize access through a global lock.
 */
 fn with_env_lock<T>(f: || -> T) -> T {
-    use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+    use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
 
     static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
@@ -1039,9 +1039,9 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
           target_os = "freebsd",
           target_os = "dragonfly"))]
 fn real_args_as_bytes() -> Vec<Vec<u8>> {
-    use rt;
+    use rustrt;
 
-    match rt::args::clone() {
+    match rustrt::args::clone() {
         Some(args) => args,
         None => panic!("process arguments not initialized")
     }
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 11257d506b0..107518ef27c 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -238,7 +238,7 @@ mod imp {
     use mem;
     use option::{Some, None, Option};
     use result::{Ok, Err};
-    use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+    use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
 
     /// As always - iOS on arm uses SjLj exceptions and
     /// _Unwind_Backtrace is even not available there. Still,
@@ -667,7 +667,7 @@ mod imp {
     use option::{Some, None};
     use path::Path;
     use result::{Ok, Err};
-    use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+    use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
     use slice::SlicePrelude;
     use str::StrPrelude;
     use dynamic_lib::DynamicLibrary;
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index b97e80d0dc1..21b4edb6375 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -54,8 +54,11 @@ Several modules in `core` are clients of `rt`:
 // FIXME: this should not be here.
 #![allow(missing_docs)]
 
+#![allow(dead_code)]
+
 use failure;
 use rustrt;
+use os;
 
 // Reexport some of our utilities which are expected by other crates.
 pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
@@ -63,9 +66,7 @@ pub use self::util::{default_sched_threads, min_stack, running_on_valgrind};
 // Reexport functionality from librustrt and other crates underneath the
 // standard library which work together to create the entire runtime.
 pub use alloc::heap;
-pub use rustrt::{task, local, mutex, exclusive, stack, args, rtio, thread};
-pub use rustrt::{Stdio, Stdout, Stderr, begin_unwind, begin_unwind_fmt};
-pub use rustrt::{bookkeeping, at_exit, unwind, DEFAULT_ERROR_CODE, Runtime};
+pub use rustrt::{begin_unwind, begin_unwind_fmt, at_exit};
 
 // Simple backtrace functionality (to print on panic)
 pub mod backtrace;
@@ -81,7 +82,82 @@ mod util;
 #[allow(experimental)]
 pub fn init(argc: int, argv: *const *const u8) {
     rustrt::init(argc, argv);
-    unsafe { unwind::register(failure::on_fail); }
+    unsafe { rustrt::unwind::register(failure::on_fail); }
+}
+
+#[cfg(any(windows, android))]
+static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
+#[cfg(all(unix, not(android)))]
+static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
+
+#[cfg(not(test))]
+#[lang = "start"]
+fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
+    use mem;
+    start(argc, argv, proc() {
+        let main: extern "Rust" fn() = unsafe { mem::transmute(main) };
+        main();
+    })
+}
+
+/// Executes the given procedure after initializing the runtime with the given
+/// argc/argv.
+///
+/// This procedure is guaranteed to run on the thread calling this function, but
+/// the stack bounds for this rust task will *not* be set. Care must be taken
+/// for this function to not overflow its stack.
+///
+/// This function will only return once *all* native threads in the system have
+/// exited.
+pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
+    use prelude::*;
+    use rt;
+    use rustrt::task::Task;
+    use str;
+
+    let something_around_the_top_of_the_stack = 1;
+    let addr = &something_around_the_top_of_the_stack as *const int;
+    let my_stack_top = addr as uint;
+
+    // FIXME #11359 we just assume that this thread has a stack of a
+    // certain size, and estimate that there's at most 20KB of stack
+    // frames above our current position.
+    let my_stack_bottom = my_stack_top + 20000 - OS_DEFAULT_STACK_ESTIMATE;
+
+    // When using libgreen, one of the first things that we do is to turn off
+    // the SIGPIPE signal (set it to ignore). By default, some platforms will
+    // send a *signal* when a EPIPE error would otherwise be delivered. This
+    // runtime doesn't install a SIGPIPE handler, causing it to kill the
+    // program, which isn't exactly what we want!
+    //
+    // Hence, we set SIGPIPE to ignore when the program starts up in order to
+    // prevent this problem.
+    #[cfg(windows)] fn ignore_sigpipe() {}
+    #[cfg(unix)] fn ignore_sigpipe() {
+        use libc;
+        use libc::funcs::posix01::signal::signal;
+        unsafe {
+            assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != -1);
+        }
+    }
+    ignore_sigpipe();
+
+    init(argc, argv);
+    let mut exit_code = None;
+    let mut main = Some(main);
+    let mut task = box Task::new(Some((my_stack_bottom, my_stack_top)),
+                                 Some(rustrt::thread::main_guard_page()));
+    task.name = Some(str::Slice("<main>"));
+    drop(task.run(|| {
+        unsafe {
+            rustrt::stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top);
+        }
+        (main.take().unwrap())();
+        exit_code = Some(os::get_exit_status());
+    }).destroy());
+    unsafe { rt::cleanup(); }
+    // If the exit code wasn't set, then the task block must have panicked.
+    return exit_code.unwrap_or(rustrt::DEFAULT_ERROR_CODE);
 }
 
 /// One-time runtime cleanup.
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs
index 87907fde277..9508d8d9232 100644
--- a/src/libstd/sys/common/helper_thread.rs
+++ b/src/libstd/sys/common/helper_thread.rs
@@ -21,9 +21,9 @@
 //! time.
 
 use mem;
-use rt::bookkeeping;
-use rt::mutex::StaticNativeMutex;
-use rt;
+use rustrt::bookkeeping;
+use rustrt::mutex::StaticNativeMutex;
+use rustrt;
 use cell::UnsafeCell;
 use sys::helper_signal;
 use prelude::*;
@@ -83,7 +83,7 @@ impl<M: Send> Helper<M> {
                     self.lock.lock().signal()
                 });
 
-                rt::at_exit(proc() { self.shutdown() });
+                rustrt::at_exit(proc() { self.shutdown() });
                 *self.initialized.get() = true;
             }
         }
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs
index 9b2b594a9c7..029fc852742 100644
--- a/src/libstd/sys/common/net.rs
+++ b/src/libstd/sys/common/net.rs
@@ -16,7 +16,7 @@ use libc::{mod, c_char, c_int};
 use mem;
 use num::Int;
 use ptr::{mod, null, null_mut};
-use rt::mutex;
+use rustrt::mutex;
 use io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr};
 use io::net::addrinfo;
 use io::{IoResult, IoError};
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs
index 4db9e8a9df8..664a6a1e70c 100644
--- a/src/libstd/sys/unix/mod.rs
+++ b/src/libstd/sys/unix/mod.rs
@@ -25,7 +25,7 @@ use sys_common::mkerr_libc;
 
 macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
     static $name: Helper<$m> = Helper {
-        lock: ::rt::mutex::NATIVE_MUTEX_INIT,
+        lock: ::rustrt::mutex::NATIVE_MUTEX_INIT,
         chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
         signal: ::cell::UnsafeCell { value: 0 },
         initialized: ::cell::UnsafeCell { value: false },
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index 3fba06e0c7f..4d3469a9c24 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -12,7 +12,7 @@ use alloc::arc::Arc;
 use libc;
 use c_str::CString;
 use mem;
-use rt::mutex;
+use rustrt::mutex;
 use sync::atomic;
 use io::{mod, IoResult, IoError};
 use prelude::*;
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index f316b2d8493..815ace21f87 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -26,7 +26,7 @@ use sync::{Once, ONCE_INIT};
 
 macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
     static $name: Helper<$m> = Helper {
-        lock: ::rt::mutex::NATIVE_MUTEX_INIT,
+        lock: ::rustrt::mutex::NATIVE_MUTEX_INIT,
         chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
         signal: ::cell::UnsafeCell { value: 0 },
         initialized: ::cell::UnsafeCell { value: false },
diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs
index e38202302fb..a623c2cd8e2 100644
--- a/src/libstd/sys/windows/pipe.rs
+++ b/src/libstd/sys/windows/pipe.rs
@@ -90,7 +90,7 @@ use c_str::CString;
 use mem;
 use ptr;
 use sync::atomic;
-use rt::mutex;
+use rustrt::mutex;
 use io::{mod, IoError, IoResult};
 use prelude::*;
 
diff --git a/src/libstd/task.rs b/src/libstd/task.rs
index c7e31dae3d4..4f5f47e980c 100644
--- a/src/libstd/task.rs
+++ b/src/libstd/task.rs
@@ -11,11 +11,7 @@
 //! Task creation
 //!
 //! An executing Rust program consists of a collection of tasks, each
-//! with their own stack and local state. A Rust task is typically
-//! backed by an operating system thread, making tasks 'just threads',
-//! but may also be implemented via other strategies as well
-//! (e.g. Rust comes with the [`green`](../../green/index.html)
-//! scheduling crate for creating tasks backed by green threads).
+//! with their own stack and local state.
 //!
 //! Tasks generally have their memory *isolated* from each other by
 //! virtue of Rust's owned types (which of course may only be owned by
@@ -36,13 +32,6 @@
 //! the main task panics the application will exit with a non-zero
 //! exit code.
 //!
-//! # Basic task scheduling
-//!
-//! By default, every task is created with the same "flavor" as the calling task.
-//! This flavor refers to the scheduling mode, with two possibilities currently
-//! being 1:1 and M:N modes. Green (M:N) tasks are cooperatively scheduled and
-//! native (1:1) tasks are scheduled by the OS kernel.
-//!
 //! ## Example
 //!
 //! ```rust
@@ -50,46 +39,6 @@
 //!     println!("Hello, World!");
 //! })
 //! ```
-//!
-//! # Advanced task scheduling
-//!
-//! Task spawning can also be configured to use a particular scheduler, to
-//! redirect the new task's output, or to yield a `future` representing the
-//! task's final result. The configuration is established using the
-//! `TaskBuilder` API:
-//!
-//! ## Example
-//!
-//! ```rust
-//! extern crate green;
-//! extern crate native;
-//!
-//! use std::task::TaskBuilder;
-//! use green::{SchedPool, PoolConfig, GreenTaskBuilder};
-//! use native::NativeTaskBuilder;
-//!
-//! # fn main() {
-//! // Create a green scheduler pool with the default configuration
-//! let mut pool = SchedPool::new(PoolConfig::new());
-//!
-//! // Spawn a task in the green pool
-//! let mut fut_green = TaskBuilder::new().green(&mut pool).try_future(proc() {
-//!     /* ... */
-//! });
-//!
-//! // Spawn a native task
-//! let mut fut_native = TaskBuilder::new().native().try_future(proc() {
-//!     /* ... */
-//! });
-//!
-//! // Wait for both tasks to finish, recording their outcome
-//! let res_green  = fut_green.unwrap();
-//! let res_native = fut_native.unwrap();
-//!
-//! // Shut down the green scheduler pool
-//! pool.shutdown();
-//! # }
-//! ```
 
 #![unstable = "The task spawning model will be changed as part of runtime reform, and the module \
                will likely be renamed from `task` to `thread`."]
@@ -101,33 +50,13 @@ use kinds::{Send, marker};
 use option::{None, Some, Option};
 use boxed::Box;
 use result::Result;
-use rt::local::Local;
-use rt::task;
-use rt::task::Task;
+use rustrt::local::Local;
+use rustrt::task;
+use rustrt::task::Task;
 use str::{Str, SendStr, IntoMaybeOwned};
 use string::{String, ToString};
 use sync::Future;
 
-/// A means of spawning a task
-pub trait Spawner {
-    /// Spawn a task, given low-level task options.
-    fn spawn(self, opts: task::TaskOpts, f: proc():Send);
-}
-
-/// The default task spawner, which spawns siblings to the current task.
-pub struct SiblingSpawner;
-
-impl Spawner for SiblingSpawner {
-    fn spawn(self, opts: task::TaskOpts, f: proc():Send) {
-        // bind tb to provide type annotation
-        let tb: Option<Box<Task>> = Local::try_take();
-        match tb {
-            Some(t) => t.spawn_sibling(opts, f),
-            None => panic!("need a local task to spawn a sibling task"),
-        };
-    }
-}
-
 /// The task builder type.
 ///
 /// Provides detailed control over the properties and behavior of new tasks.
@@ -139,7 +68,7 @@ impl Spawner for SiblingSpawner {
 // when you try to reuse the builder to spawn a new task. We'll just
 // sidestep that whole issue by making builders uncopyable and making
 // the run function move them in.
-pub struct TaskBuilder<S = SiblingSpawner> {
+pub struct TaskBuilder {
     // A name for the task-to-be, for identification in panic messages
     name: Option<SendStr>,
     // The size of the stack for the spawned task
@@ -148,88 +77,60 @@ pub struct TaskBuilder<S = SiblingSpawner> {
     stdout: Option<Box<Writer + Send>>,
     // Task-local stderr
     stderr: Option<Box<Writer + Send>>,
-    // The mechanics of actually spawning the task (i.e.: green or native)
-    spawner: S,
     // Optionally wrap the eventual task body
     gen_body: Option<proc(v: proc():Send):Send -> proc():Send>,
     nocopy: marker::NoCopy,
 }
 
-impl TaskBuilder<SiblingSpawner> {
+impl TaskBuilder {
     /// Generate the base configuration for spawning a task, off of which more
     /// configuration methods can be chained.
-    pub fn new() -> TaskBuilder<SiblingSpawner> {
+    pub fn new() -> TaskBuilder {
         TaskBuilder {
             name: None,
             stack_size: None,
             stdout: None,
             stderr: None,
-            spawner: SiblingSpawner,
             gen_body: None,
             nocopy: marker::NoCopy,
         }
     }
 }
 
-impl<S: Spawner> TaskBuilder<S> {
+impl TaskBuilder {
     /// Name the task-to-be. Currently the name is used for identification
     /// only in panic messages.
     #[unstable = "IntoMaybeOwned will probably change."]
-    pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder<S> {
+    pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder {
         self.name = Some(name.into_maybe_owned());
         self
     }
 
     /// Set the size of the stack for the new task.
-    pub fn stack_size(mut self, size: uint) -> TaskBuilder<S> {
+    pub fn stack_size(mut self, size: uint) -> TaskBuilder {
         self.stack_size = Some(size);
         self
     }
 
     /// Redirect task-local stdout.
     #[experimental = "May not want to make stdio overridable here."]
-    pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder<S> {
+    pub fn stdout(mut self, stdout: Box<Writer + Send>) -> TaskBuilder {
         self.stdout = Some(stdout);
         self
     }
 
     /// Redirect task-local stderr.
     #[experimental = "May not want to make stdio overridable here."]
-    pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder<S> {
+    pub fn stderr(mut self, stderr: Box<Writer + Send>) -> TaskBuilder {
         self.stderr = Some(stderr);
         self
     }
 
-    /// Set the spawning mechanism for the task.
-    ///
-    /// The `TaskBuilder` API configures a task to be spawned, but defers to the
-    /// "spawner" to actually create and spawn the task. The `spawner` method
-    /// should not be called directly by `TaskBuiler` clients. It is intended
-    /// for use by downstream crates (like `native` and `green`) that implement
-    /// tasks. These downstream crates then add extension methods to the
-    /// builder, like `.native()` and `.green(pool)`, that actually set the
-    /// spawner.
-    pub fn spawner<T: Spawner>(self, spawner: T) -> TaskBuilder<T> {
-        // repackage the entire TaskBuilder since its type is changing.
-        let TaskBuilder {
-            name, stack_size, stdout, stderr, spawner: _, gen_body, nocopy
-        } = self;
-        TaskBuilder {
-            name: name,
-            stack_size: stack_size,
-            stdout: stdout,
-            stderr: stderr,
-            spawner: spawner,
-            gen_body: gen_body,
-            nocopy: nocopy,
-        }
-    }
-
     // Where spawning actually happens (whether yielding a future or not)
     fn spawn_internal(self, f: proc():Send,
                       on_exit: Option<proc(Result<(), Box<Any + Send>>):Send>) {
         let TaskBuilder {
-            name, stack_size, stdout, stderr, spawner, mut gen_body, nocopy: _
+            name, stack_size, stdout, stderr, mut gen_body, nocopy: _
         } = self;
         let f = match gen_body.take() {
             Some(gen) => gen(f),
@@ -241,13 +142,13 @@ impl<S: Spawner> TaskBuilder<S> {
             stack_size: stack_size,
         };
         if stdout.is_some() || stderr.is_some() {
-            spawner.spawn(opts, proc() {
+            Task::spawn(opts, proc() {
                 let _ = stdout.map(stdio::set_stdout);
                 let _ = stderr.map(stdio::set_stderr);
                 f();
             })
         } else {
-            spawner.spawn(opts, f)
+            Task::spawn(opts, f)
         }
     }
 
@@ -336,7 +237,7 @@ pub fn try_future<T:Send>(f: proc():Send -> T) -> Future<Result<T, Box<Any + Sen
 /// Read the name of the current task.
 #[stable]
 pub fn name() -> Option<String> {
-    use rt::task::Task;
+    use rustrt::task::Task;
 
     let task = Local::borrow(None::<Task>);
     match task.name {
@@ -348,18 +249,15 @@ pub fn name() -> Option<String> {
 /// Yield control to the task scheduler.
 #[unstable = "Name will change."]
 pub fn deschedule() {
-    use rt::local::Local;
-
-    // FIXME(#7544): Optimize this, since we know we won't block.
-    let task: Box<Task> = Local::take();
-    task.yield_now();
+    use rustrt::task::Task;
+    Task::yield_now();
 }
 
 /// True if the running task is currently panicking (e.g. will return `true` inside a
 /// destructor that is run while unwinding the stack after a call to `panic!()`).
 #[unstable = "May move to a different module."]
 pub fn failing() -> bool {
-    use rt::task::Task;
+    use rustrt::task::Task;
     Local::borrow(None::<Task>).unwinder.unwinding()
 }