Skip to content

Commit 5ee53b0

Browse files
committed
Auto merge of #782 - tjkirch:master, r=alexcrichton
Add support for aarch64-unknown-linux-musl This adds support for aarch64-unknown-linux-musl as requested in rust-lang/rust#44779 by @alexcrichton The new file `ci/docker/aarch64-unknown-linux-musl/Dockerfile` essentially merges the aarch64-unknown-linux-gnu and x86_64-unknown-linux-musl Dockerfiles. The bigger changes are under `src/unix/notbsd/linux/`, though they're fairly superficial: Previously, some constants could be shared between all 64-bit musl triples, but aarch64 differs, so a number of things were moved from `musl/b64/mod.rs` to specific arches: `musl/b64/powerpc64.rs` and `musl/b64/x86_64.rs`, with the aarch64-specific differences being added to `musl/b64/aarch64.rs`. Similarly, some constants moved from `musl/mod.rs` to lower levels: `musl/b32/mod.rs`, `musl/b64/powerpc64.rs`, and `musl/b64/x86_64.rs`, with the aarch64-specific differences added to `musl/b64/aarch64.rs`. Finally, some things that were true of all Linux builds moved from `mod.rs` into lower levels: `mips/mod.rs`, `other/mod.rs`, `musl/b32/mod.rs`, `musl/b64/powerpc64.rs`, and `musl/b64/x86_64.rs`, with the aarch64-specific differences added to `musl/b64/aarch64.rs`. Testing: All linux-based triples under `ci/docker` were run through `ci/run-docker.sh` successfully, which checks that the size and alignment of definitions match for each triple, among other tests. (The local build of rust from rust-lang/rust#44779 was set for the aarch64-unknown-linux-musl build.) I also confirmed that it has "good style!" according to `ci/style.rs`.
2 parents 209468a + b9fdcf9 commit 5ee53b0

File tree

12 files changed

+282
-70
lines changed

12 files changed

+282
-70
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Tested:
138138
* [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc/)
139139
(Linux MUSL)
140140
* [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc/)
141+
(Linux)
142+
* [`aarch64-unknown-linux-musl`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-musl/libc/)
143+
(Linux MUSL)
141144
* [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc/)
142145
* [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc/)
143146
* [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc/)

ci/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ running tests. The triples tested are:
3939
* `{i686,x86_64}-pc-windows-{msvc,gnu}`
4040
* Travis
4141
* `{i686,x86_64,mips,aarch64}-unknown-linux-gnu`
42-
* `x86_64-unknown-linux-musl`
42+
* `{x86_64,aarch64}-unknown-linux-musl`
4343
* `arm-unknown-linux-gnueabihf`
4444
* `arm-linux-androideabi`
4545
* `{i686,x86_64}-apple-{darwin,ios}`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:17.10
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc make libc6-dev git curl ca-certificates \
5+
gcc-aarch64-linux-gnu qemu-user
6+
RUN curl https://www.musl-libc.org/releases/musl-1.1.16.tar.gz | \
7+
tar xzf - && \
8+
cd musl-1.1.16 && \
9+
CC=aarch64-linux-gnu-gcc \
10+
./configure --prefix=/musl-aarch64 --enable-wrapper=yes && \
11+
make install -j4 && \
12+
cd .. && \
13+
rm -rf musl-1.1.16 && \
14+
# Install linux kernel headers sanitized for use with musl
15+
curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \
16+
tar xzf - && \
17+
cd kernel-headers-3.12.6-5 && \
18+
make ARCH=arm64 prefix=/musl-aarch64 install -j4 && \
19+
cd .. && \
20+
rm -rf kernel-headers-3.12.6-5
21+
ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \
22+
CC_aarch64_unknown_linux_musl=musl-gcc \
23+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \
24+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-aarch64 -L /musl-aarch64"

src/unix/notbsd/linux/mips/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,11 @@ pub const EHWPOISON: ::c_int = 168;
646646
pub const SIGEV_THREAD_ID: ::c_int = 4;
647647
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
648648

649+
#[doc(hidden)]
650+
pub const AF_MAX: ::c_int = 42;
651+
#[doc(hidden)]
652+
pub const PF_MAX: ::c_int = AF_MAX;
653+
649654
#[link(name = "util")]
650655
extern {
651656
pub fn sysctl(name: *mut ::c_int,

src/unix/notbsd/linux/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ s! {
100100
__align: [::c_int; 0],
101101
#[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
102102
target_arch = "mips64", target_arch = "s390x",
103-
target_arch = "sparc64")))]
103+
target_arch = "sparc64", target_arch = "aarch64")))]
104104
__align: [::c_long; 0],
105+
#[cfg(all(target_arch = "aarch64", target_env = "gnu"))]
106+
__align: [::c_long; 0],
107+
#[cfg(all(target_arch = "aarch64", target_env = "musl"))]
108+
__align: [::c_int; 0],
105109
size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
106110
}
107111

@@ -737,14 +741,10 @@ pub const AF_IB: ::c_int = 27;
737741
pub const AF_MPLS: ::c_int = 28;
738742
pub const AF_NFC: ::c_int = 39;
739743
pub const AF_VSOCK: ::c_int = 40;
740-
#[doc(hidden)]
741-
pub const AF_MAX: ::c_int = 42;
742744
pub const PF_IB: ::c_int = AF_IB;
743745
pub const PF_MPLS: ::c_int = AF_MPLS;
744746
pub const PF_NFC: ::c_int = AF_NFC;
745747
pub const PF_VSOCK: ::c_int = AF_VSOCK;
746-
#[doc(hidden)]
747-
pub const PF_MAX: ::c_int = AF_MAX;
748748

749749
// System V IPC
750750
pub const IPC_PRIVATE: ::key_t = 0;

src/unix/notbsd/linux/musl/b32/mod.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type c_long = i32;
22
pub type c_ulong = u32;
33
pub type nlink_t = u32;
4+
pub type blksize_t = ::c_long;
45
pub type __u64 = ::c_ulonglong;
56

67
s! {
@@ -31,11 +32,31 @@ s! {
3132
pub struct sem_t {
3233
__val: [::c_int; 4],
3334
}
35+
36+
pub struct ipc_perm {
37+
pub __ipc_perm_key: ::key_t,
38+
pub uid: ::uid_t,
39+
pub gid: ::gid_t,
40+
pub cuid: ::uid_t,
41+
pub cgid: ::gid_t,
42+
pub mode: ::mode_t,
43+
pub __seq: ::c_int,
44+
__unused1: ::c_long,
45+
__unused2: ::c_long
46+
}
3447
}
3548

49+
pub const SIGSTKSZ: ::size_t = 8192;
50+
pub const MINSIGSTKSZ: ::size_t = 2048;
51+
3652
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
3753
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
3854

55+
#[doc(hidden)]
56+
pub const AF_MAX: ::c_int = 42;
57+
#[doc(hidden)]
58+
pub const PF_MAX: ::c_int = AF_MAX;
59+
3960
cfg_if! {
4061
if #[cfg(any(target_arch = "x86"))] {
4162
mod x86;
+74
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,81 @@
11
pub type c_char = u8;
22
pub type __u64 = ::c_ulonglong;
3+
pub type wchar_t = u32;
4+
pub type nlink_t = u32;
5+
pub type blksize_t = ::c_int;
6+
7+
s! {
8+
pub struct stat {
9+
pub st_dev: ::dev_t,
10+
pub st_ino: ::ino_t,
11+
pub st_mode: ::mode_t,
12+
pub st_nlink: ::nlink_t,
13+
pub st_uid: ::uid_t,
14+
pub st_gid: ::gid_t,
15+
pub st_rdev: ::dev_t,
16+
__pad0: ::c_ulong,
17+
pub st_size: ::off_t,
18+
pub st_blksize: ::blksize_t,
19+
__pad1: ::c_int,
20+
pub st_blocks: ::blkcnt_t,
21+
pub st_atime: ::time_t,
22+
pub st_atime_nsec: ::c_long,
23+
pub st_mtime: ::time_t,
24+
pub st_mtime_nsec: ::c_long,
25+
pub st_ctime: ::time_t,
26+
pub st_ctime_nsec: ::c_long,
27+
__unused: [::c_uint; 2],
28+
}
29+
30+
pub struct stat64 {
31+
pub st_dev: ::dev_t,
32+
pub st_ino: ::ino_t,
33+
pub st_mode: ::mode_t,
34+
pub st_nlink: ::nlink_t,
35+
pub st_uid: ::uid_t,
36+
pub st_gid: ::gid_t,
37+
pub st_rdev: ::dev_t,
38+
__pad0: ::c_ulong,
39+
pub st_size: ::off_t,
40+
pub st_blksize: ::blksize_t,
41+
__pad1: ::c_int,
42+
pub st_blocks: ::blkcnt_t,
43+
pub st_atime: ::time_t,
44+
pub st_atime_nsec: ::c_long,
45+
pub st_mtime: ::time_t,
46+
pub st_mtime_nsec: ::c_long,
47+
pub st_ctime: ::time_t,
48+
pub st_ctime_nsec: ::c_long,
49+
__unused: [::c_uint; 2],
50+
}
51+
52+
pub struct ipc_perm {
53+
pub __ipc_perm_key: ::key_t,
54+
pub uid: ::uid_t,
55+
pub gid: ::gid_t,
56+
pub cuid: ::uid_t,
57+
pub cgid: ::gid_t,
58+
pub mode: ::mode_t,
59+
pub __seq: ::c_ushort,
60+
__unused1: ::c_ulong,
61+
__unused2: ::c_ulong,
62+
}
63+
}
364

465
pub const SYS_pivot_root: ::c_long = 41;
566
pub const SYS_gettid: ::c_long = 178;
667
pub const SYS_perf_event_open: ::c_long = 241;
768
pub const SYS_memfd_create: ::c_long = 279;
69+
70+
pub const O_DIRECT: ::c_int = 0x10000;
71+
pub const O_DIRECTORY: ::c_int = 0x4000;
72+
pub const O_LARGEFILE: ::c_int = 0x20000;
73+
pub const O_NOFOLLOW: ::c_int = 0x8000;
74+
75+
pub const MINSIGSTKSZ: ::size_t = 6144;
76+
pub const SIGSTKSZ: ::size_t = 12288;
77+
78+
#[doc(hidden)]
79+
pub const PF_MAX: ::c_int = 43;
80+
#[doc(hidden)]
81+
pub const AF_MAX: ::c_int = PF_MAX;

src/unix/notbsd/linux/musl/b64/mod.rs

-49
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,7 @@
1-
pub type wchar_t = i32;
21
pub type c_long = i64;
32
pub type c_ulong = u64;
4-
pub type nlink_t = u64;
53

64
s! {
7-
pub struct stat {
8-
pub st_dev: ::dev_t,
9-
pub st_ino: ::ino_t,
10-
pub st_nlink: ::nlink_t,
11-
pub st_mode: ::mode_t,
12-
pub st_uid: ::uid_t,
13-
pub st_gid: ::gid_t,
14-
__pad0: ::c_int,
15-
pub st_rdev: ::dev_t,
16-
pub st_size: ::off_t,
17-
pub st_blksize: ::blksize_t,
18-
pub st_blocks: ::blkcnt_t,
19-
pub st_atime: ::time_t,
20-
pub st_atime_nsec: ::c_long,
21-
pub st_mtime: ::time_t,
22-
pub st_mtime_nsec: ::c_long,
23-
pub st_ctime: ::time_t,
24-
pub st_ctime_nsec: ::c_long,
25-
__unused: [::c_long; 3],
26-
}
27-
28-
pub struct stat64 {
29-
pub st_dev: ::dev_t,
30-
pub st_ino: ::ino64_t,
31-
pub st_nlink: ::nlink_t,
32-
pub st_mode: ::mode_t,
33-
pub st_uid: ::uid_t,
34-
pub st_gid: ::gid_t,
35-
__pad0: ::c_int,
36-
pub st_rdev: ::dev_t,
37-
pub st_size: ::off_t,
38-
pub st_blksize: ::blksize_t,
39-
pub st_blocks: ::blkcnt64_t,
40-
pub st_atime: ::time_t,
41-
pub st_atime_nsec: ::c_long,
42-
pub st_mtime: ::time_t,
43-
pub st_mtime_nsec: ::c_long,
44-
pub st_ctime: ::time_t,
45-
pub st_ctime_nsec: ::c_long,
46-
__reserved: [::c_long; 3],
47-
}
48-
495
pub struct statfs64 {
506
pub f_type: ::c_ulong,
517
pub f_bsize: ::c_ulong,
@@ -167,11 +123,7 @@ s! {
167123
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
168124
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
169125

170-
pub const O_DIRECT: ::c_int = 0x4000;
171-
pub const O_DIRECTORY: ::c_int = 0x10000;
172-
pub const O_NOFOLLOW: ::c_int = 0x20000;
173126
pub const O_ASYNC: ::c_int = 0x2000;
174-
pub const O_LARGEFILE: ::c_int = 0;
175127

176128
pub const FIOCLEX: ::c_int = 0x5451;
177129
pub const FIONBIO: ::c_int = 0x5421;
@@ -202,7 +154,6 @@ pub const MAP_NORESERVE: ::c_int = 0x04000;
202154
pub const MAP_POPULATE: ::c_int = 0x08000;
203155
pub const MAP_NONBLOCK: ::c_int = 0x010000;
204156
pub const MAP_STACK: ::c_int = 0x020000;
205-
pub const MAP_32BIT: ::c_int = 0x0040;
206157

207158
pub const SOCK_STREAM: ::c_int = 1;
208159
pub const SOCK_DGRAM: ::c_int = 2;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,80 @@
11
pub type c_char = u8;
2+
pub type wchar_t = i32;
23
pub type __u64 = ::c_ulong;
4+
pub type nlink_t = u64;
5+
pub type blksize_t = ::c_long;
6+
7+
s! {
8+
pub struct stat {
9+
pub st_dev: ::dev_t,
10+
pub st_ino: ::ino_t,
11+
pub st_nlink: ::nlink_t,
12+
pub st_mode: ::mode_t,
13+
pub st_uid: ::uid_t,
14+
pub st_gid: ::gid_t,
15+
__pad0: ::c_int,
16+
pub st_rdev: ::dev_t,
17+
pub st_size: ::off_t,
18+
pub st_blksize: ::blksize_t,
19+
pub st_blocks: ::blkcnt_t,
20+
pub st_atime: ::time_t,
21+
pub st_atime_nsec: ::c_long,
22+
pub st_mtime: ::time_t,
23+
pub st_mtime_nsec: ::c_long,
24+
pub st_ctime: ::time_t,
25+
pub st_ctime_nsec: ::c_long,
26+
__unused: [::c_long; 3],
27+
}
28+
29+
pub struct stat64 {
30+
pub st_dev: ::dev_t,
31+
pub st_ino: ::ino64_t,
32+
pub st_nlink: ::nlink_t,
33+
pub st_mode: ::mode_t,
34+
pub st_uid: ::uid_t,
35+
pub st_gid: ::gid_t,
36+
__pad0: ::c_int,
37+
pub st_rdev: ::dev_t,
38+
pub st_size: ::off_t,
39+
pub st_blksize: ::blksize_t,
40+
pub st_blocks: ::blkcnt64_t,
41+
pub st_atime: ::time_t,
42+
pub st_atime_nsec: ::c_long,
43+
pub st_mtime: ::time_t,
44+
pub st_mtime_nsec: ::c_long,
45+
pub st_ctime: ::time_t,
46+
pub st_ctime_nsec: ::c_long,
47+
__reserved: [::c_long; 3],
48+
}
49+
50+
pub struct ipc_perm {
51+
pub __ipc_perm_key: ::key_t,
52+
pub uid: ::uid_t,
53+
pub gid: ::gid_t,
54+
pub cuid: ::uid_t,
55+
pub cgid: ::gid_t,
56+
pub mode: ::mode_t,
57+
pub __seq: ::c_int,
58+
__unused1: ::c_long,
59+
__unused2: ::c_long
60+
}
61+
}
362

463
pub const SYS_pivot_root: ::c_long = 203;
564
pub const SYS_gettid: ::c_long = 207;
665
pub const SYS_perf_event_open: ::c_long = 319;
766
pub const SYS_memfd_create: ::c_long = 360;
67+
68+
pub const MAP_32BIT: ::c_int = 0x0040;
69+
pub const O_DIRECT: ::c_int = 0x4000;
70+
pub const O_DIRECTORY: ::c_int = 0x10000;
71+
pub const O_LARGEFILE: ::c_int = 0;
72+
pub const O_NOFOLLOW: ::c_int = 0x20000;
73+
74+
pub const SIGSTKSZ: ::size_t = 8192;
75+
pub const MINSIGSTKSZ: ::size_t = 2048;
76+
77+
#[doc(hidden)]
78+
pub const AF_MAX: ::c_int = 42;
79+
#[doc(hidden)]
80+
pub const PF_MAX: ::c_int = AF_MAX;

0 commit comments

Comments
 (0)