Add ARM MUSL targets #35060

Merged
merged 9 commits into from Jul 31, 2016

Conversation

Projects
None yet
7 participants
@japaric
Member

japaric commented Jul 27, 2016

Rebase of #33189.

I tested this by producing a std for arm-unknown-linux-musleabi then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU.

This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged.

I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot.

r? @alexcrichton
cc @timonvo

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Jul 27, 2016

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented Jul 27, 2016

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

src/librustc_back/target/musl_base.rs
@@ -0,0 +1,72 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT

This comment has been minimized.

@eefriedman

eefriedman Jul 27, 2016

Contributor

Is this an exact copy of src/librustc_back/target/linux_musl_base.rs?

@eefriedman

eefriedman Jul 27, 2016

Contributor

Is this an exact copy of src/librustc_back/target/linux_musl_base.rs?

This comment has been minimized.

@japaric

japaric Jul 27, 2016

Member

Indeed, it is! I'll remove it.

@japaric

japaric Jul 27, 2016

Member

Indeed, it is! I'll remove it.

src/libstd/rtdeps.rs
@@ -19,7 +19,7 @@
//
// On Linux, librt and libdl are indirect dependencies via std,
// and binutils 2.22+ won't add them automatically
-#[cfg(all(target_os = "linux", not(target_env = "musl")))]
+#[cfg(all(target_os = "linux", not(any(target_env = "musl"))))]

This comment has been minimized.

@alexcrichton

alexcrichton Jul 27, 2016

Member

The addition of any(...) here and below may no longer be necessary

@alexcrichton

alexcrichton Jul 27, 2016

Member

The addition of any(...) here and below may no longer be necessary

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jul 27, 2016

Member

Looks great to me, thanks @japaric! I'll r+ once the libc PR has merged

Member

alexcrichton commented Jul 27, 2016

Looks great to me, thanks @japaric! I'll r+ once the libc PR has merged

@japaric

This comment has been minimized.

Show comment
Hide comment
@japaric

japaric Jul 27, 2016

Member

Addressed comment about any and updated the libc submodule.

@bors: r=alexcrichton

Member

japaric commented Jul 27, 2016

Addressed comment about any and updated the libc submodule.

@bors: r=alexcrichton

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jul 27, 2016

Contributor

📌 Commit 3b955b0 has been approved by alexcrichton

Contributor

bors commented Jul 27, 2016

📌 Commit 3b955b0 has been approved by alexcrichton

@japaric

This comment has been minimized.

Show comment
Hide comment
@japaric

japaric Jul 27, 2016

Member

Once I verified those work, I'll send a PR to rust-buildbot.

See rust-lang-deprecated/rust-buildbot#109

Member

japaric commented Jul 27, 2016

Once I verified those work, I'll send a PR to rust-buildbot.

See rust-lang-deprecated/rust-buildbot#109

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jul 29, 2016

Member

@bors: rollup

assuming this isn't very platform-specific and green travis means it's good to go whenever

Member

alexcrichton commented Jul 29, 2016

@bors: rollup

assuming this isn't very platform-specific and green travis means it's good to go whenever

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Jul 30, 2016

Rollup merge of #35060 - japaric:arm-musl, r=alexcrichton
Add ARM MUSL targets

Rebase of #33189.

I tested this by producing a std for `arm-unknown-linux-musleabi` then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU.

This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged.

I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot.

r? @alexcrichton
cc @timonvo

bors added a commit that referenced this pull request Jul 30, 2016

Auto merge of #35125 - steveklabnik:rollup, r=steveklabnik
Rollup of 11 pull requests

- Successful merges: #34904, #35004, #35049, #35058, #35060, #35063, #35080, #35090, #35094, #35104, #35106
- Failed merges:
@cardoe

This comment has been minimized.

Show comment
Hide comment
@cardoe

cardoe Jul 30, 2016

Contributor

Any reason why the GNU Make files aren't being populated and we have to use the new build system to build these targets? We build these targets in Yocto and will likely have to patch this support in. https://github.com/meta-rust/meta-rust/blob/master/recipes-devtools/rust/files/rust/0001-Add-config-for-musl-based-arm-builds.patch

Contributor

cardoe commented Jul 30, 2016

Any reason why the GNU Make files aren't being populated and we have to use the new build system to build these targets? We build these targets in Yocto and will likely have to patch this support in. https://github.com/meta-rust/meta-rust/blob/master/recipes-devtools/rust/files/rust/0001-Add-config-for-musl-based-arm-builds.patch

+
+use target::Target;
+
+pub fn target() -> Target {

This comment has been minimized.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

+
+use target::Target;
+
+pub fn target() -> Target {

This comment has been minimized.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

+
+use target::Target;
+
+pub fn target() -> Target {

This comment has been minimized.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

@cardoe

cardoe Jul 30, 2016

Contributor

This needs to return TargetResult now.

timonvo and others added some commits Apr 28, 2016

Update gcc crate dependency to 0.3.27.
This is to pull in changes to support ARM MUSL targets.

This change also commits a couple of other cargo-generated changes
to other dependencies in the various Cargo.toml files.
Add ARM MUSL targets.
The targets are:
- `arm-unknown-linux-musleabi`
- `arm-unknown-linux-musleabihf`
- `armv7-unknown-linux-musleabihf`

These mirror the existing `gnueabi` targets.

All of these targets produce fully static binaries, similar to the
x86 MUSL targets.

For now these targets can only be used with `--rustbuild` builds, as
rust-lang/compiler-rt#22 only made the
necessary compiler-rt changes in the CMake configs, not the plain
GNU Make configs.

I've tested these targets GCC 5.3.0 compiled again musl-1.1.12
(downloaded from http://musl.codu.org/). An example `./configure`
invocation is:

```
./configure \
    --enable-rustbuild
    --target=arm-unknown-linux-musleabi \
    --musl-root="$MUSL_ROOT"
```

where `MUSL_ROOT` points to the `arm-linux-musleabi` prefix.
Usually that path will be of the form
`/foobar/arm-linux-musleabi/arm-linux-musleabi`.

Usually the cross-compile toolchain will live under
`/foobar/arm-linux-musleabi/bin`. That path should either by added
to your `PATH` variable, or you should add a section to your
`config.toml` as follows:

```
[target.arm-unknown-linux-musleabi]
cc = "/foobar/arm-linux-musleabi/bin/arm-linux-musleabi-gcc"
cxx = "/foobar/arm-linux-musleabi/bin/arm-linux-musleabi-g++"
```

As a prerequisite you'll also have to put a cross-compiled static
`libunwind.a` library in `$MUSL_ROOT/lib`. This is similar to [how
the x86_64 MUSL targets are built]
(https://doc.rust-lang.org/book/advanced-linking.html).
rustc_back/target: remove musl_base
it's the same as linux_musl_base
@japaric

This comment has been minimized.

Show comment
Hide comment
@japaric

japaric Jul 30, 2016

Member

This needs to return TargetResult now.

Thanks.

Any reason why the GNU Make files aren't being populated and we have to use the new build system to build these targets?

Probably it just hasn't been tested.

@bors r=alexcrichton rollup

Member

japaric commented Jul 30, 2016

This needs to return TargetResult now.

Thanks.

Any reason why the GNU Make files aren't being populated and we have to use the new build system to build these targets?

Probably it just hasn't been tested.

@bors r=alexcrichton rollup

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jul 30, 2016

Contributor

📌 Commit eb61738 has been approved by alexcrichton

Contributor

bors commented Jul 30, 2016

📌 Commit eb61738 has been approved by alexcrichton

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jul 31, 2016

Contributor

⌛️ Testing commit eb61738 with merge 724f811...

Contributor

bors commented Jul 31, 2016

⌛️ Testing commit eb61738 with merge 724f811...

bors added a commit that referenced this pull request Jul 31, 2016

Auto merge of #35060 - japaric:arm-musl, r=alexcrichton
Add ARM MUSL targets

Rebase of #33189.

I tested this by producing a std for `arm-unknown-linux-musleabi` then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU.

This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged.

I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot.

r? @alexcrichton
cc @timonvo

@bors bors merged commit eb61738 into rust-lang:master Jul 31, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@japaric japaric referenced this pull request in japaric/rust-cross Aug 8, 2016

Closed

static arm musl #21

bors added a commit that referenced this pull request Aug 15, 2016

Auto merge of #35427 - cardoe:arm-musl-targets, r=alexcrichton
add GNU make files for arm-unknown-linux-musleabi

For Yocto (Embedded Linux meta distro) Rust is provided via the [meta-rust layer](https://github.com/meta-rust/meta-rust). In this project there have been patches to add `arm-unknown-linux-musleabi`. Rust recently acquired that support via #35060 but only for rustbuild. meta-rust is currently only able to build Rust support with the existing GNU Makefiles. This adds `arm-unknown-linux-musleabi` support to Rust for the GNU Makefiles until meta-rust is able to sort out why using rustbuild does not work for it.

/cc @srwalter @derekstraka @jmesmon @japaric

@japaric japaric deleted the japaric:arm-musl branch Sep 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment