diff options
| author | bors <bors@rust-lang.org> | 2013-11-30 14:41:40 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-30 14:41:40 -0800 |
| commit | 4252a24ae1236207a99c1d313d4b1b1eda3ebb58 (patch) | |
| tree | c0b36a1a14bf504be40acb188934e65497745848 /src/libstd | |
| parent | dfe46f788bd080fed67c63e7a04dad10468502b3 (diff) | |
| parent | 56e4c82a38cfb2bcf7de2d6323dab0073a70726d (diff) | |
| download | rust-4252a24ae1236207a99c1d313d4b1b1eda3ebb58.tar.gz rust-4252a24ae1236207a99c1d313d4b1b1eda3ebb58.zip | |
auto merge of #10528 : alexcrichton/rust/static-linking-v2, r=pcwalton
In this series of commits, I've implemented static linking for rust. The scheme I implemented was the same as my [mailing list post](https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html). The commits have more details to the nitty gritty of what went on. I've rebased this on top of my native mutex pull request (#10479), but I imagine that it will land before this lands, I just wanted to pre-emptively get all the rebase conflicts out of the way (becuase this is reorganizing building librustrt as well). Some contentious points I want to make sure are all good: * I've added more "compiler chooses a default" behavior than I would like, I want to make sure that this is all very clearly outlined in the code, and if not I would like to remove behavior or make it clearer. * I want to make sure that the new "fancy suite" tests are ok (using make/python instead of another rust crate) If we do indeed pursue this, I would be more than willing to write up a document describing how linking in rust works. I believe that this behavior should be very understandable, and the compiler should never hinder someone just because linking is a little fuzzy.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/lib.rs | 15 | ||||
| -rw-r--r-- | src/libstd/rtdeps.rs | 54 |
2 files changed, 59 insertions, 10 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index a72bc6b8328..296091d26e6 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -51,7 +51,9 @@ #[comment = "The Rust standard library"]; #[license = "MIT/ASL2"]; -#[crate_type = "lib"]; +#[crate_type = "lib"]; // NOTE: remove after stage0 snapshot +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", @@ -64,6 +66,7 @@ #[deny(non_camel_case_types)]; #[deny(missing_doc)]; +#[allow(attribute_usage)]; // NOTE: remove after the next snapshot // When testing libstd, bring in libuv as the I/O backend so tests can print // things and all of the std::io tests have an I/O interface to run on top @@ -79,15 +82,7 @@ #[cfg(test)] pub use ops = realstd::ops; #[cfg(test)] pub use cmp = realstd::cmp; -// On Linux, link to the runtime with -lrt. -#[cfg(target_os = "linux")] -#[doc(hidden)] -pub mod linkhack { - #[link_args="-lrustrt -lrt"] - #[link_args = "-lpthread"] - extern { - } -} +mod rtdeps; /* The Prelude. */ diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs new file mode 100644 index 00000000000..ba4f120f626 --- /dev/null +++ b/src/libstd/rtdeps.rs @@ -0,0 +1,54 @@ +// Copyright 2013 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. + +//! This module contains the linkage attributes to all runtime dependencies of +//! the stndard library This varies per-platform, but these libraries are +//! necessary for running libstd. + +// All platforms need to link to rustrt +#[link(name = "rustrt", kind = "static")] +extern {} + +// LLVM implements the `frem` instruction as a call to `fmod`, which lives in +// libm. Hence, we must explicitly link to it. +// +// On linux librt and libdl are indirect dependencies via rustrt, +// and binutils 2.22+ won't add them automatically +#[cfg(target_os = "linux")] +#[link(name = "rt")] +#[link(name = "dl")] +#[link(name = "m")] +#[link(name = "pthread")] +#[link(name = "stdc++")] +extern {} + +#[cfg(target_os = "android")] +#[link(name = "dl")] +#[link(name = "log")] +#[link(name = "supc++")] +#[link(name = "gnustl_shared")] +#[link(name = "m")] +extern {} + +#[cfg(target_os = "freebsd")] +#[link(name = "execinfo")] +#[link(name = "rt")] +#[link(name = "stdc++")] +#[link(name = "pthread")] +extern {} + +#[cfg(target_os = "macos")] +#[link(name = "pthread")] +#[link(name = "stdc++")] +extern {} + +#[cfg(stage0)] +#[link_args = "-lstdc++"] +extern {} |
