Skip to content

Commit bd8034c

Browse files
committed
wip: RISC-V build
1 parent 0731bf7 commit bd8034c

5 files changed

Lines changed: 43 additions & 7 deletions

File tree

.docker/Dockerfile.alpine

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ RUN apk add --no-cache \
5151

5252
# Install UPX
5353
ARG ARCH
54-
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"
54+
# UPX isn't supported on RISC-V yet, so skip this
55+
RUN if [ "$ARCH" != "riscv64" ]; then \
56+
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"; \
57+
else \
58+
echo "Skipping UPX installation for RISC-V architecture while it is not supported."; \
59+
echo "See https://github.com/upx/upx/discussions/793 for details."; \
60+
fi
5561

5662
# Install mistletoe
5763
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
@@ -67,7 +73,11 @@ RUN bash /usr/local/bin/install-mold.sh
6773

6874
# Install bloaty
6975
COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh
70-
RUN bash /usr/local/bin/install-bloaty.sh
76+
RUN if [ "$ARCH" != "riscv64" ]; then \
77+
bash /usr/local/bin/install-bloaty.sh; \
78+
else \
79+
echo "Skipping bloaty installation for RISC-V."; \
80+
fi
7181

7282
# Install all static libraries
7383
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh

.docker/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
IMAGE_UBUNTU="dwarfs-buildenv"
22
IMAGE_ALPINE="dwarfs-buildenv-alpine"
3+
IMAGE_ALPINE_RISCV="dwarfs-buildenv-alpine-riscv64"
34
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
45
IMAGE_FEDORA="dwarfs-buildenv-fedora"
56
IMAGE_ARCH="dwarfs-buildenv-arch"
@@ -31,6 +32,12 @@ build_alpine:
3132
run_alpine:
3233
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
3334

35+
build_alpine_riscv:
36+
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE_RISCV) --build-arg ARCH=riscv64 .
37+
38+
run_alpine_riscv:
39+
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_RISCV)
40+
3441
build_ubuntu2204:
3542
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .
3643

.docker/install-static-libs.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,22 @@ echo "Using $GCC and $CLANG"
4141
if [[ "$PKGS" == ":ubuntu" ]]; then
4242
PKGS="file,bzip2,libarchive,flac,libunwind,benchmark,openssl,cpptrace"
4343
COMPILERS="clang gcc"
44-
elif [[ "$PKGS" == ":alpine" ]]; then
45-
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libunwind,libressl,lz4,mimalloc,openssl,xxhash,xz,zstd"
44+
elif [[ "$PKGS" == ":alpine"* ]]; then
45+
if [[ "$PKGS" == ":alpine" ]]; then
46+
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libunwind,libressl,lz4,mimalloc,openssl,xxhash,xz,zstd"
47+
else
48+
PKGS="${PKGS#:alpine:}"
49+
fi
4650
export COMMON_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
4751
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
52+
export COMMON_LDFLAGS="-fuse-ld=mold"
4853
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
49-
COMPILERS="clang clang-minsize-lto gcc"
54+
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
55+
# Let's keep it simple for more exotic architectures
56+
COMPILERS="clang-minsize-lto"
57+
else
58+
COMPILERS="clang clang-minsize-lto gcc"
59+
fi
5060
elif [[ "$PKGS" == ":none" ]]; then
5161
echo "No libraries to build"
5262
exit 0
@@ -451,7 +461,9 @@ for COMPILER in $COMPILERS; do
451461
./configure --prefix="$prefix" \
452462
--without-iconv --without-xml2 --without-expat \
453463
--without-bz2lib --without-zlib \
454-
--disable-shared --disable-acl --disable-xattr
464+
--disable-shared --disable-acl --disable-xattr \
465+
--disable-bsdtar --disable-bsdcat --disable-bsdcpio \
466+
--disable-bsdunzip
455467
make -j$(nproc)
456468
make install
457469
done
@@ -472,7 +484,8 @@ for COMPILER in $COMPILERS; do
472484
cd "$HOME/pkgs/$COMPILER"
473485
tar xf ../${FLAC_TARBALL}
474486
cd flac-${FLAC_VERSION}
475-
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no --disable-doxygen-docs --disable-ogg --disable-programs --disable-examples
487+
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no \
488+
--disable-doxygen-docs --disable-ogg --disable-programs --disable-examples
476489
make -j$(nproc)
477490
make install
478491
fi

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ jobs:
200200
- arch: arm64v8
201201
dist: alpine
202202
build_type: clang-relsize-libressl-lto-ninja-static
203+
- arch: riscv64
204+
dist: alpine
205+
build_type: clang-relsize-libressl-lto-ninja-static
203206
- arch: amd64
204207
dist: alpine
205208
build_type: clang-relsize-minimal-lto-ninja-static

.github/workflows/docker-run-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- Linux
3737
- ${{ inputs.build_arch }}
3838

39+
# Building a docker container on RISC-V can take an awful long time
40+
timeout-minutes: 2880
41+
3942
steps:
4043
- name: Checkout
4144
uses: actions/checkout@v4

0 commit comments

Comments
 (0)