rust/src/libsyntax
bors 9d4b6fa51d Auto merge of #37545 - alexcrichton:crt-static, r=brson
rustc: Implement #[link(cfg(..))] and crt-static

This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.

[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md

This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.

Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.

Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.

Essentially, what'll happen is:

* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
  linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
  linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
  are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
  are used and `-lc` is not passed.

This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.

cc #37406
2016-11-16 08:25:38 -08:00
..
diagnostics libsyntax: clearer names for some AST parts 2016-09-28 22:31:18 +02:00
ext Remove extra level of nesting. 2016-11-12 07:41:47 -07:00
parse Auto merge of #37278 - matklad:lone-lifetime, r=jseyfried 2016-11-14 02:46:12 -08:00
print syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00
util Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
abi.rs check target abi support 2016-10-24 15:59:53 +02:00
ast.rs syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00
attr.rs do not use deprecated text for unstable docs 2016-11-13 19:00:56 -05:00
Cargo.toml Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
codemap.rs Rename Parser::last_span as prev_span. 2016-10-05 08:53:18 +11:00
config.rs Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
diagnostic_list.rs Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
entry.rs [breaking-change] don't glob export ast::Item_ variants 2016-02-11 12:34:48 +01:00
feature_gate.rs rustc: Implement #[link(cfg(..))] and crt-static 2016-11-16 07:00:09 -08:00
fold.rs syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00
json.rs Allow supplying an error destination via the compiler driver 2016-09-28 16:20:30 +13:00
lib.rs Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
ptr.rs Documentation for default types modified 2016-09-11 22:58:01 +05:30
show_span.rs Remove the type parameter from syntax::visit::Visitor 2016-06-14 07:40:32 +00:00
std_inject.rs Combine std_inject::{no_core, no_std} into std_inject::injected_crate_name. 2016-10-07 21:54:01 +00:00
str.rs syntax: Copy unstable str::char_at into libsyntax 2015-04-21 10:23:53 -07:00
test.rs Changed most vec! invocations to use square braces 2016-10-31 22:51:40 +00:00
tokenstream.rs Move doc comment desugaring into the parser. 2016-11-03 23:48:24 +00:00
visit.rs syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00