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

fix: s390x for build-images/rust-bullseye-stable-1-s390x #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 20 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library 'magic-butler-catalogue'
def TRIGGER_PATTERN = '.*@logdnabot.*'

pipeline {
agent none
Expand All @@ -8,7 +9,8 @@ pipeline {
ansiColor 'xterm'
}
triggers {
issueCommentTrigger('.*@logdnabot.*')

issueCommentTrigger(TRIGGER_PATTERN)
parameterizedCron(
env.BRANCH_NAME ==~ 'main' ? 'H 8 * * 7 % PUBLISH_GCR_IMAGE=true;PUBLISH_ICR_IMAGE=true' : ''
)
Expand All @@ -31,7 +33,8 @@ pipeline {
}
}
steps {
error("A maintainer needs to approve this PR for with comment containing '.*@logdnabot.*'")

error("A maintainer needs to approve this PR for with comment containing ${TRIGGER_PATTERN}")
}
}

Expand All @@ -49,8 +52,8 @@ pipeline {
// Host architecture of the built image
axis {
name 'PLATFORM'
// Support for x86_64 and arm64 for Mac M1s/AWS graviton devs/builders
values 'linux/amd64', 'linux/arm64'
// Support for x86_64 and arm64 and s390x for Mac M1s/AWS graviton devs/builders
values 'linux/amd64', 'linux/arm64', 'linux/s390x'
}
}
agent {
Expand Down Expand Up @@ -164,12 +167,12 @@ pipeline {
// Target ISA for musl cross comp toolchain and precompiled libs
axis {
name 'CROSS_COMPILER_TARGET_ARCH'
values 'x86_64', 'aarch64'
values 'x86_64', 'aarch64', 's390x'
}
// Host architecture of the built image
axis {
name 'PLATFORM'
values 'linux/amd64', 'linux/arm64'
values 'linux/amd64', 'linux/arm64', 'linux/s390x'
}
}
agent {
Expand Down Expand Up @@ -312,7 +315,7 @@ pipeline {
// Target ISA for musl cross comp toolchain and precompiled libs
axis {
name 'CROSS_COMPILER_TARGET_ARCH'
values 'x86_64', 'aarch64'
values 'x86_64', 'aarch64', 's390x'
}
}
agent {
Expand Down Expand Up @@ -559,6 +562,15 @@ def createMultiArchImageManifest(Map config = [:]){
, image_suffix: "${config.image_suffix}-linux-arm64"
, append_git_sha: append_git_sha
)
sh("docker manifest create ${manifest_name} --amend ${arm64_image_name} --amend ${amd64_image_name}")
def s390x_image_name = generateImageName(
repo_base: repo_base
, name: config.name
, variant_base: config.variant_base
, variant_version: config.variant_version
, version: config.version
, image_suffix: "${config.image_suffix}-linux-s390x"
, append_git_sha: append_git_sha
)
sh("docker manifest create ${manifest_name} --amend ${arm64_image_name} --amend ${amd64_image_name} --amend ${s390x_image_name}")
return manifest_name
}
23 changes: 19 additions & 4 deletions rust/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG CROSS_COMPILER_TARGET_ARCH=x86_64
ARG CROSS_COMPILER_TARGET_ARCH="$(uname -m)"
ARG BASE_IMAGE=logdna/build-images/rust-buster-1-stable-base-${CROSS_COMPILER_TARGET_ARCH}

# Image that runs natively on the BUILDPLATFORM to produce cross compile
Expand All @@ -19,7 +19,11 @@ ARG SCCACHE_SERVER_PORT=4226

ARG CARGO_BINSTALL_URL_BASE="https://github.com/cargo-bins/cargo-binstall/releases/latest/download"

RUN rustup target add "${!TARGETARCH}-unknown-linux-musl"
RUN if [[ "${CROSS_COMPILER_TARGET_ARCH}" == "s390x" ]]; then \
rustup target add "${!TARGETARCH}-unknown-linux-gnu" ; \
else \
rustup target add "${!TARGETARCH}-unknown-linux-musl" ; \
fi

RUN dpkg --add-architecture ${TARGETARCH} && \
dpkg --add-architecture ${!CROSS_COMPILER_TARGET_ARCH} && \
Expand All @@ -29,6 +33,8 @@ ENV CC_aarch64_unknown_linux_musl=clang
ENV CFLAGS_aarch64_unknown_linux_musl="-isystem /usr/include/aarch64-linux-musl"
ENV CC_x86_64_unknown_linux_musl=clang
ENV CFLAGS_x86_64_unknown_linux_musl="-isystem /usr/include/x86_64-linux-musl"
ENV CC_s390x_unknown_linux_gnu=clang
ENV CFLAGS_s390x_unknown_linux_gnu="-isystem /usr/include/s390x-linux-gnu"

RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
mkdir -p /out/tools /usr/local/bin/ && \
Expand Down Expand Up @@ -271,10 +277,13 @@ RUN mkdir -p /usr/local/rocksdb/${CROSS_COMPILER_TARGET_ARCH}-linux-musl/include
RUN printf "#!/usr/bin/env bash\nclang -fuse-ld=lld --target=aarch64-unknown-linux-musl \$@" > /usr/local/bin/aarch64-unknown-linux-musl-clang && \
chmod +x /usr/local/bin/aarch64-unknown-linux-musl-clang && \
printf "#!/usr/bin/env bash\nclang -fuse-ld=lld --target=x86_64-unknown-linux-musl \$@" > /usr/local/bin/x86_64-unknown-linux-musl-clang && \
chmod +x /usr/local/bin/x86_64-unknown-linux-musl-clang
chmod +x /usr/local/bin/x86_64-unknown-linux-musl-clang && \
printf "#!/usr/bin/env bash\nclang -fuse-ld=lld --target=s390x-unknown-linux-musl \$@" > /usr/local/bin/s390x-unknown-linux-musl-clang && \
chmod +x /usr/local/bin/s390x-unknown-linux-musl-clang

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="/usr/local/bin/aarch64-unknown-linux-musl-clang"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="/usr/local/bin/x86_64-unknown-linux-musl-clang"
ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_MUSL_LINKER="/usr/local/bin/s390x-unknown-linux-musl-clang"

ENV XWIN_CACHE_DIR="${CARGO_HOME}/xwin"
ENV XWIN_TOOLKIT_BIN_PATH="/usr/local/bin"
Expand Down Expand Up @@ -303,6 +312,7 @@ ENV STATIC_RUSTFLAGS="${COMMON_RUSTFLAGS} -Ctarget-feature=+crt-static -Clink-ar

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="${STATIC_RUSTFLAGS} -Clink-args=--target=aarch64-unknown-linux-musl"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="${STATIC_RUSTFLAGS} -Clink-args=--target=x86_64-unknown-linux-musl"
ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_MUSL_RUSTFLAGS="${STATIC_RUSTFLAGS} -Clink-args=--target=s390x-unknown-linux-musl"

ENV CC_aarch64_unknown_linux_musl="clang"
ENV CFLAGS_aarch64_unknown_linux_musl="--target=aarch64-unknown-linux-musl -fuse-ld=lld -static -fPIC -nostdlib -nodefaultlibs -nostdinc -isystem $LLVM_SYSROOT/usr/lib/clang/${LLVM_VERSION}/include/ -isystem $LLVM_SYSROOT/usr/aarch64-unknown-linux-musl/include/ -isystem $LLVM_SYSROOT/usr/include/linux/ -L ${LLVM_SYSROOT}/usr/aarch64-unknown-linux-musl/lib -lc -L ${LLVM_SYSROOT}/usr/lib/linux/ -lclang_rt.builtins-aarch64"
Expand All @@ -314,6 +324,11 @@ ENV CFLAGS_x86_64_unknown_linux_musl="--target=x86_64-unknown-linux-musl -fuse-l
ENV CXX_x86_64_unknown_linux_musl="clang++"
ENV CXXFLAGS_x86_64_unknown_linux_musl="--target=x86_64-unknown-linux-musl -fuse-ld=lld -nostdinc -static-libstdc++ --stdlib=c++ --rtlib=compiler-rt -nodefaultlibs -nostdinc++ -isystem $LLVM_SYSROOT/usr/include/c++/v1/ -isystem $LLVM_SYSROOT/usr/x86_64-unknown-linux-musl/include/ -isystem $LLVM_SYSROOT/usr/lib/clang/${LLVM_VERSION}/include/ -isystem $LLVM_SYSROOT/usr/x86_64-unknown-linux-musl/include/ -isystem $LLVM_SYSROOT/usr/include/linux/ "

ENV CC_s390x_unknown_linux_gnu="clang"
ENV CFLAGS_s390x_unknown_linux_gnu="--target=s390x-unknown-linux-gnu -fuse-ld=lld -static -fPIC -nostdlib -nodefaultlibs -nostdinc -isystem $LLVM_SYSROOT/usr/lib/clang/${LLVM_VERSION}/include/ -isystem $LLVM_SYSROOT/usr/s390x-unknown-linux-gnu/include/ -isystem $LLVM_SYSROOT/usr/include/linux/ -L ${LLVM_SYSROOT}/usr/s390x-unknown-linux-gnu/lib -lc -L ${LLVM_SYSROOT}/usr/lib/linux/ -lclang_rt.builtins-s390x"
ENV CXX_s390x_unknown_linux_gnu="clang++"
ENV CXXFLAGS_s390x_unknown_linux_gnu="--target=s390x-unknown-linux-gnu -fuse-ld=lld -nostdinc -static-libstdc++ --stdlib=c++ --rtlib=compiler-rt -nodefaultlibs -nostdinc++ -isystem $LLVM_SYSROOT/usr/include/c++/v1/ -isystem $LLVM_SYSROOT/usr/s390x-unknown-linux-musl/include/ -isystem $LLVM_SYSROOT/usr/lib/clang/${LLVM_VERSION}/include/ -isystem $LLVM_SYSROOT/usr/s390x-unknown-linux-musl/include/ -isystem $LLVM_SYSROOT/usr/include/linux/ "

ENV PCRE2_SYS_STATIC=1
ENV SYSTEMD_LIB_DIR="/lib/${CROSS_COMPILER_TARGET_ARCH}-linux-gnu"

Expand All @@ -324,4 +339,4 @@ ENV PKG_CONFIG_ALLOW_CROSS=true \

ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse

CMD ["bash"]
CMD ["bash"]
19 changes: 17 additions & 2 deletions rust/debian/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARG VARIANT_VERSION=buster
ARG CROSS_COMPILER_TARGET_ARCH="$(uname -m)"
FROM buildpack-deps:${VARIANT_VERSION}-curl

# Needs to be in this scope too
Expand All @@ -25,6 +26,7 @@ ENV amd64=x86_64
ENV arm64=aarch64
ENV x86_64=amd64
ENV aarch64=arm64
ENV s390x=s390x

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US
Expand Down Expand Up @@ -72,7 +74,7 @@ RUN unmunch /usr/share/hunspell/en_GB.dic /usr/share/hunspell/en_GB.aff 2> /dev/
################################################################################################

# msitools not avail on buster
RUN if [[ "${VARIANT_VERSION}" != "buster" ]] ; then \
RUN if [[ "${CROSS_COMPILER_TARGET_ARCH}" != "s390x" ]] ; then \
apt update -y && \
apt install -y meson valac-bin valac valac-0.48-vapi libgsf-1-dev bats bison libgcab-dev libgirepository1.0-dev wine && \
git clone --recurse-submodules https://github.com/GNOME/msitools.git && \
Expand Down Expand Up @@ -109,13 +111,21 @@ ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=clang
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_AR=llvm-ar
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-args=-fuse-ld=lld \
-Clink-args=--target=x86_64-unknown-linux-musl"

ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_MUSL_LINKER=clang
ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_MUSL_AR=llvm-ar
ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-args=-fuse-ld=lld \
-Clink-args=--target=s390x-unknown-linux-musl"
# Teach cargo to use clang as the linker driver
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_AR=llvm-ar

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_AR=llvm-ar

ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_GNU_LINKER=clang
ENV CARGO_TARGET_s390x_UNKNOWN_LINUX_GNU_AR=llvm-ar

# Set up basic gnu C configuration for to use clang as the linker driver, llvm-ar, ETC
ENV CC_aarch64_unknown_linux_gnu="clang"
ENV CFLAGS_aarch64_unknown_linux_gnu="--target=aarch64-unknown-linux-gnu -fuse-ld=lld -fPIC"
Expand All @@ -127,6 +137,11 @@ ENV CFLAGS_x86_64_unknown_linux_gnu="--target=x86_64-unknown-linux-gnu -fuse-ld=
ENV CXX_x86_64_unknown_linux_gnu="clang++"
ENV CXXFLAGS_x86_64_unknown_linux_gnu="--target=x86_64-unknown-linux-gnu -fuse-ld=lld -fPIC"

ENV CC_s390x_unknown_linux_gnu="clang"
ENV CFLAGS_s390x_unknown_linux_gnu="--target=s390x-unknown-linux-gnu -fuse-ld=lld -fPIC"
ENV CXX_s390x_unknown_linux_gnu="clang++"
ENV CXXFLAGS_s390x_unknown_linux_gnu="--target=s390x-unknown-linux-gnu -fuse-ld=lld -fPIC"

ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse

CMD ["bash"]
CMD ["bash"]