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 upExperimental MUSL target support for the compiler #24777
Conversation
rust-highfive
assigned
pcwalton
Apr 24, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @pcwalton (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
pcwalton
Apr 24, 2015
This comment has been minimized.
This comment has been minimized.
|
Why 'x86_64-unknown-linux-musl'? It seems reasonable to me, but Google doesn't have a lot of hits for it. |
This comment has been minimized.
This comment has been minimized.
|
Neat! |
This comment has been minimized.
This comment has been minimized.
|
@brson I found it followed clang's target triple format, but I personally got the idea from the reddit post. |
This comment has been minimized.
This comment has been minimized.
|
r=me |
This comment has been minimized.
This comment has been minimized.
|
@brson I've pushed some more commits clarifying some documentation and also feature gating |
alexcrichton
force-pushed the
alexcrichton:musl
branch
from
fe31352
to
01963a6
Apr 24, 2015
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
Apr 25, 2015
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added some commits
Apr 21, 2015
alexcrichton
force-pushed the
alexcrichton:musl
branch
from
01963a6
to
faa1a81
Apr 27, 2015
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
Apr 28, 2015
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:musl
branch
from
faa1a81
to
d6e7c7a
Apr 28, 2015
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
Apr 28, 2015
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:musl
branch
from
d6e7c7a
to
247842b
Apr 28, 2015
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 28, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
merged commit 247842b
into
rust-lang:master
Apr 28, 2015
alexcrichton
deleted the
alexcrichton:musl
branch
Apr 30, 2015
aidanhs
referenced this pull request
May 9, 2015
Closed
Add support for alternative C libraries #625
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton got any details of the issues you had with libunwind upstream? I only ask because a toy program I tried seemed to work ok, so I guess it's related to the additional complexity in the compiler? |
This comment has been minimized.
This comment has been minimized.
|
@aidanhs unfortunately I could never get any more detail other than "unwinding didn't work". I was able to build libunwind upstream with In your test program, did you trigger an unwind, or was it just running as usual? Also, did you configure libunwind with any special flags or anything? |
nagisa
reviewed
May 10, 2015
| let lib = match DynamicLibrary::open(None) { | ||
| Ok(l) => l, | ||
| Err(..) => return, | ||
| }; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
May 10, 2015
Author
Member
Hm, could you elaborate a little more? This should in theory just affect the return value of this function, which I'm not sure how connected it is to stack sizes.
This comment has been minimized.
This comment has been minimized.
nagisa
May 10, 2015
Contributor
Before it failed loud and clear when this didn’t work, but now min_stack_size returns PTHREAD_STACK_MIN instead which might or might not be a correct value to use in the stack size calculations.
/me shrugs.
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton oops, I didn't get unwinding working (though normal execution worked). I did get a different error to you though:
Sorry for the noise! |
This comment has been minimized.
This comment has been minimized.
Ah that's actually the same error that I was seeing, oh well! |
alexcrichton commentedApr 24, 2015
These commits build on some great work on reddit for adding MUSL support to the compiler. This goal of this PR is to enable a
--target x86_64-unknown-linux-muslargument 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:
libc.ais included inliblibc.rlib(statically included as an archive).libunwind.ais included inlibstd.rlib(like with liblibc).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:
git://git.musl-libc.org/musl. Build this as usual and install it.libunwind.aartifact is needed. I have tried using upstream libunwind's source repo but I have not gotten unwinding to work with it unfortunately. Movelibunwind.aadjacent to MUSL'slibc.a--target=x86_64-unknown-linux-musl --musl-root=$MUSL_ROOTwhereMUSL_ROOTis 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.