]> git.lizzy.rs Git - rust.git/commit
Add generation of static libraries to rustc
authorAlex Crichton <alex@alexcrichton.com>
Fri, 15 Nov 2013 22:03:29 +0000 (14:03 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 30 Nov 2013 02:36:13 +0000 (18:36 -0800)
commite338a4154b134fc1d4628496d4ccf85b7af7c443
tree2df88fca04ee3b42530df237eb1bce9101e5d90e
parent80991bb578329ca921fdc910d9b6b064e8f521d2
Add generation of static libraries to rustc

This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.

When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.

Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.

Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:

* If both a .dylib and .rlib are found for a rust library, the compiler will
  prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
  overridable by explicitly saying what flavor you'd like (rlib, staticlib,
  dylib).
* If no options are passed to the command line, and no crate_type is found in
  the destination crate, then an executable is generated

With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.

This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.

Closes #552
43 files changed:
Makefile.in
configure
doc/rust.md
mk/clean.mk
mk/host.mk
mk/install.mk
mk/platform.mk
mk/target.mk
mk/tests.mk
src/libextra/flate.rs
src/libextra/lib.rs
src/librustc/back/archive.rs [new file with mode: 0644]
src/librustc/back/arm.rs
src/librustc/back/link.rs
src/librustc/back/mips.rs
src/librustc/back/rpath.rs
src/librustc/back/target_strs.rs
src/librustc/back/x86.rs
src/librustc/back/x86_64.rs
src/librustc/driver/driver.rs
src/librustc/driver/session.rs
src/librustc/front/feature_gate.rs
src/librustc/lib.rs
src/librustc/lib/llvm.rs
src/librustc/metadata/common.rs
src/librustc/metadata/creader.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/cstore.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/loader.rs
src/librustc/middle/trans/base.rs
src/librustdoc/html/markdown.rs
src/librustdoc/lib.rs
src/librustpkg/lib.rs
src/librustpkg/tests.rs
src/librustpkg/util.rs
src/librustuv/lib.rs
src/librustuv/uvll.rs
src/libstd/lib.rs
src/libstd/rtdeps.rs [new file with mode: 0644]
src/libsyntax/lib.rs
src/rustllvm/rustllvm.def.in