about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTimon Van Overveldt <timonvo@gmail.com>2016-04-27 18:02:31 -0700
committerJorge Aparicio <japaricious@gmail.com>2016-07-30 15:39:13 -0500
commitf7247d1071206db45103c994b0077fcb0d8f75cf (patch)
tree33d5ac9fa78bce8d09e6f6e0a3271b1fa2b53fa6 /src/libstd
parent57cad5722db3043804bc4c38ec3b456e9ff497be (diff)
downloadrust-f7247d1071206db45103c994b0077fcb0d8f75cf.tar.gz
rust-f7247d1071206db45103c994b0077fcb0d8f75cf.zip
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
https://github.com/rust-lang/compiler-rt/pull/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).
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rtdeps.rs4
-rw-r--r--src/libstd/sys/unix/thread.rs8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs
index a11200873d5..f23ac32f51c 100644
--- a/src/libstd/rtdeps.rs
+++ b/src/libstd/rtdeps.rs
@@ -19,7 +19,9 @@
 //
 // 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",
+                                       target_env = "musleabi",
+                                       target_env = "musleabihf"))))]
 #[link(name = "dl")]
 #[link(name = "pthread")]
 extern {}
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 1061ca87f64..7f05aec4e6e 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -171,7 +171,9 @@ impl Drop for Thread {
     }
 }
 
-#[cfg(all(not(all(target_os = "linux", not(target_env = "musl"))),
+#[cfg(all(not(all(target_os = "linux", not(any(target_env = "musl",
+                                               target_env = "musleabi",
+                                               target_env = "musleabihf")))),
           not(target_os = "freebsd"),
           not(target_os = "macos"),
           not(target_os = "bitrig"),
@@ -185,7 +187,9 @@ pub mod guard {
 }
 
 
-#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
+#[cfg(any(all(target_os = "linux", not(any(target_env = "musl",
+                                           target_env = "musleabi",
+                                           target_env = "musleabihf"))),
           target_os = "freebsd",
           target_os = "macos",
           target_os = "bitrig",