]> git.lizzy.rs Git - rust.git/commit
Auto merge of #33553 - alexcrichton:cdylibs, r=brson
authorbors <bors@rust-lang.org>
Fri, 20 May 2016 07:34:50 +0000 (00:34 -0700)
committerbors <bors@rust-lang.org>
Fri, 20 May 2016 07:34:50 +0000 (00:34 -0700)
commitd27bdafc3eaab2729d664f82b7d650782640f31a
tree2940c1e6c24c8df00ff08e397042a5033f3b05c2
parentcde0fa5f673c99e8d534123187ee554452513dc3
parent0d2c26c261671f71002af13431fbd3c9720feff2
Auto merge of #33553 - alexcrichton:cdylibs, r=brson

rustc: Add a new crate type, cdylib

This commit is an implementation of [RFC 1510] which adds a new crate type,
`cdylib`, to the compiler. This new crate type differs from the existing `dylib`
crate type in a few key ways:

* No metadata is present in the final artifact
* Symbol visibility rules are the same as executables, that is only reachable
  `extern` functions are visible symbols
* LTO is allowed
* All libraries are always linked statically

This commit is relatively simple by just plubming the compiler with another
crate type which takes different branches here and there. The only major change
is an implementation of the `Linker::export_symbols` function on Unix which now
actually does something. This helps restrict the public symbols from a cdylib on
Unix.

With this PR a "hello world" `cdylib` is 7.2K while the same `dylib` is 2.4MB,
which is some nice size savings!

[RFC 1510]: https://github.com/rust-lang/rfcs/pull/1510

Closes #33132
src/librustc/session/config.rs
src/librustc_driver/driver.rs
src/librustc_metadata/creader.rs
src/librustc_trans/back/link.rs
src/librustc_trans/base.rs