Skip to content
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

Update GCC to 11.2.0, align musl version with Rust #67

Merged
merged 11 commits into from
Sep 22, 2022
56 changes: 38 additions & 18 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
arch: ${{ steps.generate-matrix.outputs.arch }}
target: ${{ steps.generate-matrix.outputs.target }}
run-build: ${{ steps.generate-matrix.outputs.run-build }}
fail-fast: ${{ steps.generate-matrix.outputs.fail-fast }}
steps:
- uses: actions/setup-node@v2
with:
Expand Down Expand Up @@ -107,6 +108,20 @@ jobs:
core.setOutput('target', JSON.stringify(targetMatrix))
core.setOutput('run-build', 'false')
}

const matches = commitMessage.match(/(Try|Merge) #([0-9]+):/)
if (matches) {
const prNumber = matches[2]
const { data: { labels: labels } } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
})
const labelNames = labels.map(label => label.name)
if (labelNames.includes('CI-no-fail-fast')) {
core.setOutput('fail-fast', 'false')
}
}
} else {
core.setOutput('arch', JSON.stringify(archMatrix))
core.setOutput('target', JSON.stringify(targetMatrix))
Expand All @@ -116,7 +131,8 @@ jobs:
run: |
echo '${{ toJson(steps.generate-matrix.outputs.arch) }}'
echo '${{ toJson(steps.generate-matrix.outputs.target) }}'
echo Run build: ${{ steps.generate-matrix.outputs.run-build || 'true' }}
echo run build: ${{ steps.generate-matrix.outputs.run-build || 'true' }}
echo fail fast: ${{ steps.generate-matrix.outputs.fail-fast || 'true' }}
env:
COMMIT_MESSAGE: >
${{
Expand All @@ -133,51 +149,51 @@ jobs:
TARGET_MATRIX: |
- IMAGE_TAG: aarch64-musl
TARGET: aarch64-unknown-linux-musl
RUST_MUSL_MAKE_CONFIG: config.mak
RUST_MUSL_MAKE_CONFIG: config.mak.aarch64
TOOLCHAIN: stable
- IMAGE_TAG: arm-musleabi
TARGET: arm-unknown-linux-musleabi
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: arm-musleabihf
TARGET: arm-unknown-linux-musleabihf
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: armv5te-musleabi
TARGET: armv5te-unknown-linux-musleabi
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: armv7-musleabi
TARGET: armv7-unknown-linux-musleabi
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: armv7-musleabihf
TARGET: armv7-unknown-linux-musleabihf
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: i586-musl
TARGET: i586-unknown-linux-musl
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: i686-musl
TARGET: i686-unknown-linux-musl
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: mips-musl
TARGET: mips-unknown-linux-musl
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: mips64-muslabi64
TARGET: mips64-unknown-linux-muslabi64
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: mips64el-muslabi64
TARGET: mips64el-unknown-linux-muslabi64
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: mipsel-musl
TARGET: mipsel-unknown-linux-musl
RUST_MUSL_MAKE_CONFIG: config.mak.32
RUST_MUSL_MAKE_CONFIG: config.mak
TOOLCHAIN: stable
- IMAGE_TAG: powerpc64le-musl
TARGET: powerpc64le-unknown-linux-musl
Expand All @@ -198,6 +214,7 @@ jobs:
if: ${{ needs.setup.outputs.run-build != 'false' }}
needs: setup
strategy:
fail-fast: ${{ needs.setup.outputs.fail-fast != 'false' }}
matrix:
os: ${{ fromJson(needs.setup.outputs.arch) }}
env: ${{ fromJson(needs.setup.outputs.target) }}
Expand All @@ -210,7 +227,7 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.repository_owner == 'messense' }}
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
Expand All @@ -230,9 +247,10 @@ jobs:
TOOLCHAIN=${{ github.event.inputs.toolchain || matrix.env.TOOLCHAIN }}
tags: ghcr.io/${{ github.repository_owner }}/rust-musl-cross:${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }}
no-cache: ${{ github.event.inputs.no_cache == 'yes' }}
context: .
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/rust-musl-cross:buildcache-${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }}
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/rust-musl-cross:buildcache-${{ matrix.env.IMAGE_TAG }}-${{ matrix.os.arch }},mode=max
- name: Test Docker cargo build
if: ${{ matrix.os.arch == 'amd64' && !startsWith(matrix.env.TARGET, 'armv5te') && !startsWith(matrix.env.TARGET, 's390x') }}
run: |
Expand Down Expand Up @@ -269,7 +287,8 @@ jobs:
if docker manifest inspect ghcr.io/${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-armv7 > /dev/null; then
echo " - image: ghcr.io/${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-armv7
platform:
architecture: arm/v7
architecture: arm
variant: v7
os: linux" >> ghcr-manifest.yaml
fi

Expand Down Expand Up @@ -309,7 +328,8 @@ jobs:
skopeo copy docker://ghcr.io/${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-armv7 docker://${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-armv7
echo " - image: ${{ github.repository_owner }}/rust-musl-cross:$IMAGE_TAG-armv7
platform:
architecture: arm/v7
architecture: arm
variant: v7
os: linux" >> dockerhub-manifest.yaml
fi

Expand Down
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ RUN update-ca-certificates

ARG TARGET=x86_64-unknown-linux-musl
ENV RUST_MUSL_CROSS_TARGET=$TARGET
ARG RUST_MUSL_MAKE_VER=0.9.9
ARG RUST_MUSL_MAKE_CONFIG=config.mak

COPY $RUST_MUSL_MAKE_CONFIG /tmp/config.mak
RUN cd /tmp && curl -Lsq -o musl-cross-make.zip https://github.com/richfelker/musl-cross-make/archive/v$RUST_MUSL_MAKE_VER.zip && \
unzip -q musl-cross-make.zip && \
rm musl-cross-make.zip && \
mv musl-cross-make-$RUST_MUSL_MAKE_VER musl-cross-make && \
RUN cd /tmp && \
git clone --depth 1 https://github.com/richfelker/musl-cross-make.git && \
cp /tmp/config.mak /tmp/musl-cross-make/config.mak && \
cd /tmp/musl-cross-make && \
export TARGET=$TARGET && \
Expand Down
7 changes: 5 additions & 2 deletions build-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
set -e
if [[ "$TARGET" = "powerpc64le-unknown-linux-musl" || "$TARGET" = "s390x-unknown-linux-musl" ]]
then
export CARGO_NET_GIT_FETCH_WITH_CLI=true
export CARGO_UNSTABLE_SPARSE_REGISTRY=true

HOST=$(rustc -Vv | grep 'host:' | awk '{print $2}')
# patch unwind for s390x
if [[ "$TARGET" = "s390x-unknown-linux-musl" ]]
Expand All @@ -16,11 +19,11 @@ then
cd custom-std
cp /tmp/Xargo.toml .
rustc -Z unstable-options --print target-spec-json --target "$TARGET" | tee "$TARGET.json"
RUSTFLAGS="-L/usr/local/musl/$TARGET/lib -L/usr/local/musl/lib/gcc/$TARGET/9.2.0/" xargo build --target "$TARGET"
RUSTFLAGS="-L/usr/local/musl/$TARGET/lib -L/usr/local/musl/lib/gcc/$TARGET/11.2.0/" xargo build --target "$TARGET"
cp -r "/root/.xargo/lib/rustlib/$TARGET" "/root/.rustup/toolchains/$TOOLCHAIN-$HOST/lib/rustlib/"
mkdir "/root/.rustup/toolchains/$TOOLCHAIN-$HOST/lib/rustlib/$TARGET/lib/self-contained"
cp /usr/local/musl/"$TARGET"/lib/*.o "/root/.rustup/toolchains/$TOOLCHAIN-$HOST/lib/rustlib/$TARGET/lib/self-contained/"
cp /usr/local/musl/lib/gcc/"$TARGET"/9.2.0/c*.o "/root/.rustup/toolchains/$TOOLCHAIN-$HOST/lib/rustlib/$TARGET/lib/self-contained/"
cp /usr/local/musl/lib/gcc/"$TARGET"/11.2.0/c*.o "/root/.rustup/toolchains/$TOOLCHAIN-$HOST/lib/rustlib/$TARGET/lib/self-contained/"
cd ..
rm -rf /root/.xargo /root/.cargo/registry /root/.cargo/git custom-std

Expand Down
11 changes: 8 additions & 3 deletions config.mak
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ OUTPUT = /usr/local/musl
# headers, which are not needed unless compiling programs that use them.

# BINUTILS_VER =
# GCC_VER =
# MUSL_VER =
GCC_VER = 11.2.0

# https://github.com/rust-embedded/cross/issues/478
# https://github.com/rust-lang/libc/issues/1848

MUSL_VER = 1.1.24

# GMP_VER =
# MPC_VER =
# MPFR_VER =
Expand All @@ -39,7 +44,7 @@ DL_CMD = curl -C - -L -o

# Recommended options for smaller build for deploying binaries:

COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s"
COMMON_CONFIG += CFLAGS="-g0 -Os -w" CXXFLAGS="-g0 -Os -w" LDFLAGS="-s"

# Recommended options for faster/simpler build:

Expand Down
7 changes: 5 additions & 2 deletions config.mak.32 → config.mak.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ OUTPUT = /usr/local/musl
# headers, which are not needed unless compiling programs that use them.

# BINUTILS_VER =
# GCC_VER =

# undefined reference to `getauxval' on GCC 11.2.0
# https://github.com/messense/rust-musl-cross/pull/67#issuecomment-1251905512
GCC_VER = 9.2.0

# https://github.com/rust-embedded/cross/issues/478
# https://github.com/rust-lang/libc/issues/1848
Expand Down Expand Up @@ -44,7 +47,7 @@ DL_CMD = curl -C - -L -o

# Recommended options for smaller build for deploying binaries:

COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s"
COMMON_CONFIG += CFLAGS="-g0 -Os -w" CXXFLAGS="-g0 -Os -w" LDFLAGS="-s"

# Recommended options for faster/simpler build:

Expand Down