Skip to content

Commit 4b610e6

Browse files
committed
Auto merge of #1449 - xen0n:mips64-musl-targets, r=gnzlbg
Add musl support for MIPS64 & bump to 0.2.63 Tested with patched stage2; both static and dynamic binaries confirmed working. Initial CI support in the form of no-core targets are added.
2 parents abd5a3c + 435cdee commit 4b610e6

File tree

11 files changed

+1284
-201
lines changed

11 files changed

+1284
-201
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libc"
3-
version = "0.2.62"
3+
version = "0.2.63"
44
authors = ["The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"

ci/build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ i686-unknown-netbsd \
204204
i686-unknown-openbsd \
205205
mips-unknown-linux-uclibc \
206206
mipsel-unknown-linux-uclibc \
207+
mips64-unknown-linux-muslabi64 \
208+
mips64el-unknown-linux-muslabi64 \
207209
nvptx64-nvidia-cuda \
208210
powerpc-unknown-linux-gnuspe \
209211
powerpc-unknown-netbsd \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:19.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc make libc6-dev git curl ca-certificates \
5+
gcc-mips64-linux-gnuabi64 qemu-user
6+
7+
COPY install-musl.sh /
8+
RUN sh /install-musl.sh mips64
9+
10+
# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
11+
ENV PATH=$PATH:/musl-mips64/bin:/rust/bin \
12+
CC_mips64_unknown_linux_muslabi64=musl-gcc \
13+
RUSTFLAGS='-Clink-args=-lgcc' \
14+
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_LINKER=musl-gcc \
15+
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_RUNNER="qemu-mips64 -L /musl-mips64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:19.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc make libc6-dev git curl ca-certificates \
5+
gcc-mips64el-linux-gnuabi64 qemu-user
6+
7+
COPY install-musl.sh /
8+
RUN sh /install-musl.sh mips64el
9+
10+
# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
11+
ENV PATH=$PATH:/musl-mips64el/bin:/rust/bin \
12+
CC_mips64el_unknown_linux_muslabi64=musl-gcc \
13+
RUSTFLAGS='-Clink-args=-lgcc' \
14+
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER=musl-gcc \
15+
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_RUNNER="qemu-mips64el -L /musl-mips64el"

ci/install-musl.sh

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ case ${1} in
4646
./configure --prefix="/musl-${musl_arch}"
4747
make install -j4
4848
;;
49+
mips64)
50+
musl_arch=mips64
51+
kernel_arch=mips
52+
CC=mips64-linux-gnuabi64-gcc CFLAGS="-march=mips64r2 -mabi=64" \
53+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
54+
make install -j4
55+
;;
56+
mips64el)
57+
musl_arch=mips64el
58+
kernel_arch=mips
59+
CC=mips64el-linux-gnuabi64-gcc CFLAGS="-march=mips64r2 -mabi=64" \
60+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
61+
make install -j4
62+
;;
4963
*)
5064
echo "Unknown target arch: \"${1}\""
5165
exit 1

src/unix/linux_like/linux/musl/b64/aarch64.rs

+160
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,36 @@ s! {
4949
__unused: [::c_uint; 2],
5050
}
5151

52+
pub struct statfs {
53+
pub f_type: ::c_ulong,
54+
pub f_bsize: ::c_ulong,
55+
pub f_blocks: ::fsblkcnt_t,
56+
pub f_bfree: ::fsblkcnt_t,
57+
pub f_bavail: ::fsblkcnt_t,
58+
pub f_files: ::fsfilcnt_t,
59+
pub f_ffree: ::fsfilcnt_t,
60+
pub f_fsid: ::fsid_t,
61+
pub f_namelen: ::c_ulong,
62+
pub f_frsize: ::c_ulong,
63+
pub f_flags: ::c_ulong,
64+
pub f_spare: [::c_ulong; 4],
65+
}
66+
67+
pub struct statfs64 {
68+
pub f_type: ::c_ulong,
69+
pub f_bsize: ::c_ulong,
70+
pub f_blocks: ::fsblkcnt_t,
71+
pub f_bfree: ::fsblkcnt_t,
72+
pub f_bavail: ::fsblkcnt_t,
73+
pub f_files: ::fsfilcnt_t,
74+
pub f_ffree: ::fsfilcnt_t,
75+
pub f_fsid: ::fsid_t,
76+
pub f_namelen: ::c_ulong,
77+
pub f_frsize: ::c_ulong,
78+
pub f_flags: ::c_ulong,
79+
pub f_spare: [::c_ulong; 4],
80+
}
81+
5282
pub struct ipc_perm {
5383
pub __ipc_perm_key: ::key_t,
5484
pub uid: ::uid_t,
@@ -62,15 +92,36 @@ s! {
6292
}
6393
}
6494

95+
pub const O_ASYNC: ::c_int = 0x2000;
96+
pub const O_APPEND: ::c_int = 1024;
97+
pub const O_CREAT: ::c_int = 64;
98+
pub const O_EXCL: ::c_int = 128;
99+
pub const O_NOCTTY: ::c_int = 256;
100+
pub const O_NONBLOCK: ::c_int = 2048;
101+
pub const O_SYNC: ::c_int = 1052672;
102+
pub const O_RSYNC: ::c_int = 1052672;
103+
pub const O_DSYNC: ::c_int = 4096;
65104
pub const O_DIRECT: ::c_int = 0x10000;
66105
pub const O_DIRECTORY: ::c_int = 0x4000;
67106
pub const O_LARGEFILE: ::c_int = 0x20000;
68107
pub const O_NOFOLLOW: ::c_int = 0x8000;
108+
pub const POLLWRNORM: ::c_short = 0x100;
109+
pub const POLLWRBAND: ::c_short = 0x200;
69110

70111
pub const MINSIGSTKSZ: ::size_t = 6144;
71112
pub const SIGSTKSZ: ::size_t = 12288;
72113

73114
pub const MADV_SOFT_OFFLINE: ::c_int = 101;
115+
pub const MAP_ANON: ::c_int = 0x0020;
116+
pub const MAP_GROWSDOWN: ::c_int = 0x0100;
117+
pub const MAP_DENYWRITE: ::c_int = 0x0800;
118+
pub const MAP_EXECUTABLE: ::c_int = 0x01000;
119+
pub const MAP_LOCKED: ::c_int = 0x02000;
120+
pub const MAP_NORESERVE: ::c_int = 0x04000;
121+
pub const MAP_POPULATE: ::c_int = 0x08000;
122+
pub const MAP_NONBLOCK: ::c_int = 0x010000;
123+
pub const MAP_STACK: ::c_int = 0x020000;
124+
pub const MAP_HUGETLB: ::c_int = 0x040000;
74125
pub const SYS_io_setup: ::c_long = 0;
75126
pub const SYS_io_destroy: ::c_long = 1;
76127
pub const SYS_io_submit: ::c_long = 2;
@@ -341,6 +392,87 @@ pub const SYS_pkey_mprotect: ::c_long = 288;
341392
pub const SYS_pkey_alloc: ::c_long = 289;
342393
pub const SYS_pkey_free: ::c_long = 290;
343394

395+
pub const ENAMETOOLONG: ::c_int = 36;
396+
pub const ENOLCK: ::c_int = 37;
397+
pub const ENOSYS: ::c_int = 38;
398+
pub const ENOTEMPTY: ::c_int = 39;
399+
pub const ELOOP: ::c_int = 40;
400+
pub const ENOMSG: ::c_int = 42;
401+
pub const EIDRM: ::c_int = 43;
402+
pub const ECHRNG: ::c_int = 44;
403+
pub const EL2NSYNC: ::c_int = 45;
404+
pub const EL3HLT: ::c_int = 46;
405+
pub const EL3RST: ::c_int = 47;
406+
pub const ELNRNG: ::c_int = 48;
407+
pub const EUNATCH: ::c_int = 49;
408+
pub const ENOCSI: ::c_int = 50;
409+
pub const EL2HLT: ::c_int = 51;
410+
pub const EBADE: ::c_int = 52;
411+
pub const EBADR: ::c_int = 53;
412+
pub const EXFULL: ::c_int = 54;
413+
pub const ENOANO: ::c_int = 55;
414+
pub const EBADRQC: ::c_int = 56;
415+
pub const EBADSLT: ::c_int = 57;
416+
pub const EMULTIHOP: ::c_int = 72;
417+
pub const EBADMSG: ::c_int = 74;
418+
pub const EOVERFLOW: ::c_int = 75;
419+
pub const ENOTUNIQ: ::c_int = 76;
420+
pub const EBADFD: ::c_int = 77;
421+
pub const EREMCHG: ::c_int = 78;
422+
pub const ELIBACC: ::c_int = 79;
423+
pub const ELIBBAD: ::c_int = 80;
424+
pub const ELIBSCN: ::c_int = 81;
425+
pub const ELIBMAX: ::c_int = 82;
426+
pub const ELIBEXEC: ::c_int = 83;
427+
pub const EILSEQ: ::c_int = 84;
428+
pub const ERESTART: ::c_int = 85;
429+
pub const ESTRPIPE: ::c_int = 86;
430+
pub const EUSERS: ::c_int = 87;
431+
pub const ENOTSOCK: ::c_int = 88;
432+
pub const EDESTADDRREQ: ::c_int = 89;
433+
pub const EMSGSIZE: ::c_int = 90;
434+
pub const EPROTOTYPE: ::c_int = 91;
435+
pub const ENOPROTOOPT: ::c_int = 92;
436+
pub const EPROTONOSUPPORT: ::c_int = 93;
437+
pub const ESOCKTNOSUPPORT: ::c_int = 94;
438+
pub const EOPNOTSUPP: ::c_int = 95;
439+
pub const ENOTSUP: ::c_int = EOPNOTSUPP;
440+
pub const EPFNOSUPPORT: ::c_int = 96;
441+
pub const EAFNOSUPPORT: ::c_int = 97;
442+
pub const EADDRINUSE: ::c_int = 98;
443+
pub const EADDRNOTAVAIL: ::c_int = 99;
444+
pub const ENETDOWN: ::c_int = 100;
445+
446+
pub const F_GETLK: ::c_int = 5;
447+
pub const F_GETOWN: ::c_int = 9;
448+
pub const F_SETLK: ::c_int = 6;
449+
pub const F_SETLKW: ::c_int = 7;
450+
pub const F_SETOWN: ::c_int = 8;
451+
452+
pub const SIGCHLD: ::c_int = 17;
453+
pub const SIGBUS: ::c_int = 7;
454+
pub const SIGTTIN: ::c_int = 21;
455+
pub const SIGTTOU: ::c_int = 22;
456+
pub const SIGXCPU: ::c_int = 24;
457+
pub const SIGXFSZ: ::c_int = 25;
458+
pub const SIGVTALRM: ::c_int = 26;
459+
pub const SIGPROF: ::c_int = 27;
460+
pub const SIGWINCH: ::c_int = 28;
461+
pub const SIGUSR1: ::c_int = 10;
462+
pub const SIGUSR2: ::c_int = 12;
463+
pub const SIGCONT: ::c_int = 18;
464+
pub const SIGSTOP: ::c_int = 19;
465+
pub const SIGTSTP: ::c_int = 20;
466+
pub const SIGURG: ::c_int = 23;
467+
pub const SIGIO: ::c_int = 29;
468+
pub const SIGSYS: ::c_int = 31;
469+
pub const SIGSTKFLT: ::c_int = 16;
470+
pub const SIGPOLL: ::c_int = 29;
471+
pub const SIGPWR: ::c_int = 30;
472+
pub const SIG_SETMASK: ::c_int = 2;
473+
pub const SIG_BLOCK: ::c_int = 0x000000;
474+
pub const SIG_UNBLOCK: ::c_int = 0x01;
475+
344476
pub const RLIMIT_NLIMITS: ::c_int = 15;
345477
pub const TIOCINQ: ::c_int = ::FIONREAD;
346478
pub const MCL_CURRENT: ::c_int = 0x0001;
@@ -417,13 +549,39 @@ pub const FIONCLEX: ::c_int = 0x5450;
417549
pub const FIONBIO: ::c_int = 0x5421;
418550
pub const EDEADLK: ::c_int = 35;
419551
pub const EDEADLOCK: ::c_int = EDEADLK;
552+
pub const SA_ONSTACK: ::c_int = 0x08000000;
553+
pub const SA_SIGINFO: ::c_int = 0x00000004;
554+
pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
555+
pub const SOCK_STREAM: ::c_int = 1;
556+
pub const SOCK_DGRAM: ::c_int = 2;
557+
pub const SOL_SOCKET: ::c_int = 1;
558+
pub const SO_REUSEADDR: ::c_int = 2;
559+
pub const SO_TYPE: ::c_int = 3;
560+
pub const SO_ERROR: ::c_int = 4;
561+
pub const SO_DONTROUTE: ::c_int = 5;
562+
pub const SO_BROADCAST: ::c_int = 6;
563+
pub const SO_SNDBUF: ::c_int = 7;
564+
pub const SO_RCVBUF: ::c_int = 8;
565+
pub const SO_KEEPALIVE: ::c_int = 9;
566+
pub const SO_OOBINLINE: ::c_int = 10;
567+
pub const SO_NO_CHECK: ::c_int = 11;
568+
pub const SO_PRIORITY: ::c_int = 12;
569+
pub const SO_LINGER: ::c_int = 13;
570+
pub const SO_BSDCOMPAT: ::c_int = 14;
571+
pub const SO_REUSEPORT: ::c_int = 15;
572+
pub const SO_ACCEPTCONN: ::c_int = 30;
573+
pub const SO_SNDBUFFORCE: ::c_int = 32;
574+
pub const SO_RCVBUFFORCE: ::c_int = 33;
575+
pub const SO_PROTOCOL: ::c_int = 38;
576+
pub const SO_DOMAIN: ::c_int = 39;
420577
pub const SO_PASSCRED: ::c_int = 16;
421578
pub const SO_PEERCRED: ::c_int = 17;
422579
pub const SO_RCVLOWAT: ::c_int = 18;
423580
pub const SO_SNDLOWAT: ::c_int = 19;
424581
pub const SO_RCVTIMEO: ::c_int = 20;
425582
pub const SO_SNDTIMEO: ::c_int = 21;
426583
pub const EXTPROC: ::tcflag_t = 0x00010000;
584+
pub const VEOF: usize = 4;
427585
pub const VEOL: usize = 11;
428586
pub const VEOL2: usize = 16;
429587
pub const VMIN: usize = 6;
@@ -476,6 +634,8 @@ pub const TIOCM_DSR: ::c_int = 0x100;
476634
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
477635
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
478636

637+
pub const EHWPOISON: ::c_int = 133;
638+
479639
extern {
480640
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
481641
}

0 commit comments

Comments
 (0)