rust/mk
bors cadc67e8fd Auto merge of #24777 - alexcrichton:musl, r=brson
These commits build on [some great work on reddit](http://www.reddit.com/r/rust/comments/33boew/weekend_experiment_link_rust_programs_against/) for adding MUSL support to the compiler. This goal of this PR is to enable a `--target x86_64-unknown-linux-musl` argument to the compiler to work A-OK. The outcome here is that there are 0 compile-time dependencies for a MUSL-targeting build *except for a linker*. Currently this also assumes that MUSL is being used for statically linked binaries so there is no support for dynamically linked binaries with MUSL.

MUSL support largely just entailed munging around with the linker and where libs are located, and the major highlights are:

* The entirety of `libc.a` is included in `liblibc.rlib` (statically included as an archive).
* The entirety of `libunwind.a` is included in `libstd.rlib` (like with liblibc).
* The target specification for MUSL passes a number of ... flavorful options! Each option is documented in the relevant commit.
* The entire test suite currently passes with MUSL as a target, except for:
  * Dynamic linking tests are all ignored as it's not supported with MUSL
  * Stack overflow detection is not working MUSL yet (I'm not sure why)
* There is a language change included in this PR to add a `target_env` `#[cfg]` directive. This is used to conditionally build code for only MUSL (or for linux distros not MUSL). I highly suspect that this will also be used by Windows to target MSVC instead of a MinGW-based toolchain.

To build a compiler targeting MUSL you need to follow these steps:

1. Clone the current MUSL repo from `git://git.musl-libc.org/musl`. Build this as usual and install it.
2. Clone and build LLVM's [libcxxabi](http://libcxxabi.llvm.org/) library. Only the `libunwind.a` artifact is needed. I have tried using upstream libunwind's source repo but I have not gotten unwinding to work with it unfortunately. Move `libunwind.a` adjacent to MUSL's `libc.a`
3. Configure a Rust checkout with `--target=x86_64-unknown-linux-musl --musl-root=$MUSL_ROOT` where `MUSL_ROOT` is where you installed MUSL in step 1.

I hope to improve building a copy of libunwind as it's still a little sketchy and difficult to do today, but other than that everything should "just work"! This PR is not intended to include 100% comprehensive support for MUSL, as future modifications will probably be necessary.
2015-04-28 20:12:59 +00:00
..
cfg mk: Add support for musl-based builds 2015-04-27 10:11:15 -07:00
clean.mk
crates.mk mk: Add support for musl-based builds 2015-04-27 10:11:15 -07:00
ctags.mk
debuggers.mk Make build timestamp files robust in face of concurrent source modification. 2015-03-03 15:11:01 +01:00
dist.mk extract libcollections tests into libcollectionstest 2015-03-16 21:57:42 -05:00
docs.mk mk: Stop documenating non-facade crates 2015-04-07 17:54:34 -07:00
grammar.mk Add a LALR grammar for Rust with testing support 2015-01-20 18:47:17 -08:00
host.mk
install.mk configure: Remove obsolete --disable-verify option 2015-04-08 12:16:47 -07:00
llvm.mk Avoid passing -L "" to rustc. 2015-03-12 04:09:12 -07:00
main.mk mk: Add support for musl-based builds 2015-04-27 10:11:15 -07:00
perf.mk
platform.mk Run valgrind with fair scheduling when available 2015-04-17 07:45:16 -07:00
prepare.mk mk: Add support for musl-based builds 2015-04-27 10:11:15 -07:00
reconfig.mk
rt.mk test: Fix some tests to run with musl 2015-04-28 09:35:22 -07:00
rustllvm.mk mk: Remove a bunch of unused directives 2015-04-27 09:22:05 -07:00
snap.mk
stage0.mk
target.mk mk: Add support for musl-based builds 2015-04-27 10:11:15 -07:00
tests.mk Add a new test group, rfail-full that runs rfail tests with fulldeps. 2015-04-26 06:05:38 -07:00
util.mk mk: Add a printer helper to the make setup 2015-04-10 17:10:03 -07:00