Skip to content

[breaking change] Cleanup linux and update MUSL #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ matrix:
install: true
script:
- shellcheck --version
- shellcheck ci/*.sh
# FIXME: https://github.com/koalaman/shellcheck/issues/1591
- shellcheck -e SC2103 ci/*.sh
stage: tools-and-build-and-tier1
- name: "Style"
install: true
Expand Down
18 changes: 3 additions & 15 deletions ci/docker/aarch64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@ FROM ubuntu:19.04
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc make libc6-dev git curl ca-certificates \
gcc-aarch64-linux-gnu qemu-user
RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.22.tar.gz | \
tar xzf - && \
cd musl-1.1.22 && \
CC=aarch64-linux-gnu-gcc \
./configure --prefix=/musl-aarch64 --enable-wrapper=yes && \
make install -j4 && \
cd .. && \
rm -rf musl-1.1.22
# Install linux kernel headers sanitized for use with musl
RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \
tar xzf - && \
cd kernel-headers-3.12.6-6 && \
make ARCH=arm64 prefix=/musl-aarch64 install -j4 && \
cd .. && \
rm -rf kernel-headers-3.12.6-6

COPY install-musl.sh /
RUN sh /install-musl.sh aarch64

# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd?
ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \
Expand Down
16 changes: 2 additions & 14 deletions ci/docker/arm-unknown-linux-musleabihf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc make libc6-dev git curl ca-certificates \
gcc-arm-linux-gnueabihf qemu-user

RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.22.tar.gz | tar xzf -
WORKDIR /musl-1.1.22
RUN CC=arm-linux-gnueabihf-gcc \
CFLAGS="-march=armv6 -marm -mfpu=vfp" \
./configure --prefix=/musl-arm --enable-wrapper=yes
RUN make install -j4

# Install linux kernel headers sanitized for use with musl
RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \
tar xzf - && \
cd kernel-headers-3.12.6-6 && \
make ARCH=arm prefix=/musl-arm install -j4 && \
cd .. && \
rm -rf kernel-headers-3.12.6-6
COPY install-musl.sh /
RUN sh /install-musl.sh arm

ENV PATH=$PATH:/musl-arm/bin:/rust/bin \
CC_arm_unknown_linux_musleabihf=musl-gcc \
Expand Down
25 changes: 3 additions & 22 deletions ci/docker/i686-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,9 @@ RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc-multilib make libc6-dev git curl ca-certificates libc6:i386
# Below we're cross-compiling musl for i686 using the system compiler on an
# x86_64 system. This is an awkward thing to be doing and so we have to jump
# through a couple hoops to get musl to be happy. In particular:
#
# * We specifically pass -m32 in CFLAGS and override CC when running ./configure,
# since otherwise the script will fail to find a compiler.
# * We manually unset CROSS_COMPILE when running make; otherwise the makefile
# will call the non-existent binary 'i686-ar'.
RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.22.tar.gz | \
tar xzf - && \
cd musl-1.1.22 && \
CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \
make CROSS_COMPILE= install -j4 && \
cd .. && \
rm -rf musl-1.1.22
# Install linux kernel headers sanitized for use with musl
RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \
tar xzf - && \
cd kernel-headers-3.12.6-6 && \
make ARCH=i386 prefix=/musl-i686 install -j4 && \
cd .. && \
rm -rf kernel-headers-3.12.6-6

COPY install-musl.sh /
RUN sh /install-musl.sh i686

ENV PATH=$PATH:/musl-i686/bin:/rust/bin \
CC_i686_unknown_linux_musl=musl-gcc
2 changes: 1 addition & 1 deletion ci/docker/mips-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:19.04
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libc6-dev qemu-user ca-certificates \
gcc-mips-linux-gnu libc6-dev-mips-cross \
qemu-system-mips
qemu-system-mips linux-headers-generic

ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \
CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/mips-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN mkdir /toolchain
# Note that this originally came from:
# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
tar xjf - -C /toolchain --strip-components=1
tar xjf - -C /toolchain --strip-components=1

ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:19.04
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libc6-dev qemu-user ca-certificates \
gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \
qemu-system-mips64
qemu-system-mips64 linux-headers-generic

ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:19.04
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libc6-dev qemu-user ca-certificates \
gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \
qemu-system-mips64el
qemu-system-mips64el linux-headers-generic

ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \
Expand Down
6 changes: 5 additions & 1 deletion ci/docker/x86_64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM ubuntu:19.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates
gcc libc6-dev ca-certificates linux-headers-generic

RUN apt search linux-headers
RUN ls /usr/src

ENV PATH=$PATH:/rust/bin
18 changes: 4 additions & 14 deletions ci/docker/x86_64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@ FROM ubuntu:19.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc make libc6-dev git curl ca-certificates
RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.22.tar.gz | \
tar xzf - && \
cd musl-1.1.22 && \
./configure --prefix=/musl-x86_64 && \
make install -j4 && \
cd .. && \
rm -rf musl-1.1.22
# Install linux kernel headers sanitized for use with musl
RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \
tar xzf - && \
cd kernel-headers-3.12.6-6 && \
make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \
cd .. && \
rm -rf kernel-headers-3.12.6-6

COPY install-musl.sh /
RUN sh /install-musl.sh x86_64

ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin
69 changes: 69 additions & 0 deletions ci/install-musl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env sh
#
# Install musl and musl-sanitized linux kernel headers
# to musl-{$1} directory

set -ex

MUSL_VERSION=1.1.22
MUSL="musl-${MUSL_VERSION}"

# Download, configure, build, and install musl:
curl --retry 5 https://www.musl-libc.org/releases/${MUSL}.tar.gz | tar xzf -

cd $MUSL
case ${1} in
aarch64)
musl_arch=aarch64
kernel_arch=arm64
CC=aarch64-linux-gnu-gcc \
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
make install -j4
;;
arm)
musl_arch=arm
kernel_arch=arm
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
make install -j4
;;
i686)
# cross-compile musl for i686 using the system compiler on an x86_64
# system.
musl_arch=i686
kernel_arch=i386
# Specifically pass -m32 in CFLAGS and override CC when running
# ./configure, since otherwise the script will fail to find a compiler.
CC=gcc CFLAGS="-m32" \
./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686
# unset CROSS_COMPILE when running make; otherwise the makefile will
# call the non-existent binary 'i686-ar'.
make CROSS_COMPILE= install -j4
;;
x86_64)
musl_arch=x86_64
kernel_arch=x86_64
./configure --prefix="/musl-${musl_arch}"
make install -j4
;;
*)
echo "Unknown target arch: \"${1}\""
exit 1
;;
esac


# shellcheck disable=SC2103
cd ..
rm -rf $MUSL

# Download, configure, build, and install musl-sanitized kernel headers:
KERNEL_HEADER_VER="4.4.2-2"
curl --retry 5 -L \
"https://github.com/sabotage-linux/kernel-headers/archive/v${KERNEL_HEADER_VER}.tar.gz" | \
tar xzf -
(
cd kernel-headers-${KERNEL_HEADER_VER}
make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4
)
rm -rf kernel-headers-${KERNEL_HEADER_VER}
20 changes: 20 additions & 0 deletions libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ name = "linux-fcntl"
path = "test/linux_fcntl.rs"
harness = false

[[test]]
name = "linux-ipv6"
path = "test/linux_ipv6.rs"
harness = false

[[test]]
name = "linux-elf"
path = "test/linux_elf.rs"
harness = false

[[test]]
name = "linux-strerror_r"
path = "test/linux_strerror_r.rs"
harness = false

[[test]]
name = "linux-termios"
path = "test/linux_termios.rs"
harness = false

[[test]]
name = "cmsg"
path = "test/cmsg.rs"
Expand Down
Loading