Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc: Implement #[link(cfg(..))] and crt-static #37545
Conversation
rust-highfive
assigned
eddyb
Nov 3, 2016
This comment has been minimized.
This comment has been minimized.
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
r? @brson |
rust-highfive
assigned
brson
and unassigned
eddyb
Nov 3, 2016
This comment has been minimized.
This comment has been minimized.
|
I tested bootstrapping this with this commit: alexcrichton/libc@5699631. With that I was able to produce static/dynamic MSVC and musl binaries with the flip of this switch, so it's at least confirmed to work there! |
This comment has been minimized.
This comment has been minimized.
|
If possible, it would be really nice to have options for the debug versions of the CRT, |
japaric
referenced this pull request
Nov 4, 2016
Open
How to compile rust in a musl libc based linux system #31322
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
from
4487091
to
6da63c8
Nov 6, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added a commit
to alexcrichton/libc
that referenced
this pull request
Nov 10, 2016
alexcrichton
referenced this pull request
Nov 10, 2016
Merged
Use `#[link(cfg(..))]` in preparation for libstd #446
bors
added a commit
to rust-lang/libc
that referenced
this pull request
Nov 10, 2016
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
from
6da63c8
to
f5c9fb6
Nov 10, 2016
This comment has been minimized.
This comment has been minimized.
|
Ok, I've updated this and now that beta has been released I went ahead and included the update to liblibc. |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
from
f5c9fb6
to
0d329a2
Nov 10, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
2 times, most recently
from
51af985
to
aede832
Nov 10, 2016
alexcrichton
added
the
T-tools
label
Nov 10, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r- Seems like we should feature-gate the |
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
2 times, most recently
from
21d77be
to
791763b
Nov 11, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: r=brson Hooked up |
This comment has been minimized.
This comment has been minimized.
|
|
eddyb
added a commit
to eddyb/rust
that referenced
this pull request
Nov 11, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: r=brson |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 15, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
from
957d3e9
to
9a9189c
Nov 15, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: r=brson |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 15, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:crt-static
branch
from
9a9189c
to
06242ff
Nov 16, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: r=brson |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton commentedNov 3, 2016
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 fora target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.
This commit first adds the new target-feature,
crt-static. If enabled, thenthe
cfg(target_feature = "crt-static")will be available. Targets like muslwill have this enabled by default. This feature can be controlled through the
standard target-feature interface,
-C target-feature=+crt-staticor-C target-feature=-crt-static.Next this adds an gated and unstable
#[link(cfg(..))]feature to enable thecrt-staticsemantics we want with libc. The exact behavior of this attributeis 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
cfgvalue 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
cfgis evaluated as if it were defined in the final artifact and thelibrary is decided to be linked or not.
Essentially, what'll happen is:
-C target-feature=-crt-static, themsvcrt.liblibrary will belinked to.
-C target-feature=+crt-static, thelibcmt.liblibrary will belinked to.
-C target-feature=-crt-static, the object files in liblibc.rlibare removed and
-lcis passed instead.-C target-feature=+crt-static, the object files in liblibc.rlibare used and
-lcis 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