wip: RISC-V build

This commit is contained in:
Marcus Holland-Moritz 2025-06-28 08:22:49 +02:00
parent dac22296f5
commit 63b7a1c1eb
3 changed files with 40 additions and 8 deletions

View File

@ -51,7 +51,13 @@ RUN apk add --no-cache \
# Install UPX
ARG ARCH
RUN wget -O - https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-$(bash -c "echo \${0//v8/}" $ARCH)_linux.tar.xz | tar -xJf - -C /usr/local/bin --strip-components=1 --wildcards "*/upx"
# UPX isn't supported on RISC-V yet, so skip this
RUN if [ "$ARCH" != "riscv64" ]; then \
wget -O - https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-$(bash -c "echo \${0//v8/}" $ARCH)_linux.tar.xz | tar -xJf - -C /usr/local/bin --strip-components=1 --wildcards "*/upx"; \
else \
echo "Skipping UPX installation for RISC-V architecture while it is not supported."; \
echo "See https://github.com/upx/upx/discussions/793 for details."; \
fi
# Install mistletoe
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
@ -67,11 +73,17 @@ RUN bash /usr/local/bin/install-mold.sh
# Install bloaty
COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh
RUN bash /usr/local/bin/install-bloaty.sh
RUN if [ "$ARCH" != "riscv64" ]; then \
bash /usr/local/bin/install-bloaty.sh; \
else \
echo "Skipping bloaty installation for RISC-V."; \
fi
# Install all static libraries
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine:benchmark,boost,brotli,double-conversion,fmt,fuse,glog,jemalloc,libunwind,lz4,mimalloc,xxhash,xz,zstd
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine:cpptrace,flac
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine:libressl,openssl,libarchive
# Install the *real* ninja...
# TODO: move this up if we change anything

View File

@ -1,5 +1,6 @@
IMAGE_UBUNTU="dwarfs-buildenv"
IMAGE_ALPINE="dwarfs-buildenv-alpine"
IMAGE_ALPINE_RISCV="dwarfs-buildenv-alpine-riscv64"
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
IMAGE_FEDORA="dwarfs-buildenv-fedora"
IMAGE_ARCH="dwarfs-buildenv-arch"
@ -31,6 +32,12 @@ build_alpine:
run_alpine:
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
build_alpine_riscv:
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE_RISCV) --build-arg ARCH=riscv64 --platform=linux/riscv64 .
run_alpine_riscv:
@docker run --platform=linux/riscv64 $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_RISCV)
build_ubuntu2204:
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .

View File

@ -41,12 +41,22 @@ echo "Using $GCC and $CLANG"
if [[ "$PKGS" == ":ubuntu" ]]; then
PKGS="file,bzip2,libarchive,flac,libunwind,benchmark,openssl,cpptrace"
COMPILERS="clang gcc"
elif [[ "$PKGS" == ":alpine" ]]; then
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libunwind,libressl,lz4,mimalloc,openssl,xxhash,xz,zstd"
elif [[ "$PKGS" == ":alpine"* ]]; then
if [[ "$PKGS" == ":alpine" ]]; then
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libunwind,libressl,lz4,mimalloc,openssl,xxhash,xz,zstd"
else
PKGS="${PKGS#:alpine:}"
fi
export COMMON_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
export COMMON_LDFLAGS="-fuse-ld=mold"
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
COMPILERS="clang clang-minsize-lto gcc"
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
# We have to emulate all other architectures, so let's keep it simple
COMPILERS="clang-minsize-lto"
else
COMPILERS="clang clang-minsize-lto gcc"
fi
elif [[ "$PKGS" == ":none" ]]; then
echo "No libraries to build"
exit 0
@ -451,7 +461,9 @@ for COMPILER in $COMPILERS; do
./configure --prefix="$prefix" \
--without-iconv --without-xml2 --without-expat \
--without-bz2lib --without-zlib \
--disable-shared --disable-acl --disable-xattr
--disable-shared --disable-acl --disable-xattr \
--disable-bsdtar --disable-bsdcat --disable-bsdcpio \
--disable-bsdunzip
make -j$(nproc)
make install
done
@ -472,7 +484,8 @@ for COMPILER in $COMPILERS; do
cd "$HOME/pkgs/$COMPILER"
tar xf ../${FLAC_TARBALL}
cd flac-${FLAC_VERSION}
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no --disable-doxygen-docs --disable-ogg --disable-programs --disable-examples
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no \
--disable-doxygen-docs --disable-ogg --disable-programs --disable-examples
make -j$(nproc)
make install
fi