mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-03 17:56:12 -04:00
build: support RISCV64 build (fixes gh #266)
This commit is contained in:
parent
d96e2d39b4
commit
c0725c40fb
@ -51,7 +51,13 @@ RUN apk add --no-cache \
|
|||||||
|
|
||||||
# Install UPX
|
# Install UPX
|
||||||
ARG ARCH
|
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
|
# Install mistletoe
|
||||||
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
|
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
|
||||||
@ -67,7 +73,11 @@ RUN bash /usr/local/bin/install-mold.sh
|
|||||||
|
|
||||||
# Install bloaty
|
# Install bloaty
|
||||||
COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh
|
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
|
# Install all static libraries
|
||||||
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
|
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
IMAGE_UBUNTU="dwarfs-buildenv"
|
IMAGE_UBUNTU="dwarfs-buildenv"
|
||||||
IMAGE_ALPINE="dwarfs-buildenv-alpine"
|
IMAGE_ALPINE="dwarfs-buildenv-alpine"
|
||||||
|
IMAGE_ALPINE_RISCV="dwarfs-buildenv-alpine-riscv64"
|
||||||
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
|
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
|
||||||
IMAGE_FEDORA="dwarfs-buildenv-fedora"
|
IMAGE_FEDORA="dwarfs-buildenv-fedora"
|
||||||
IMAGE_ARCH="dwarfs-buildenv-arch"
|
IMAGE_ARCH="dwarfs-buildenv-arch"
|
||||||
@ -31,6 +32,12 @@ build_alpine:
|
|||||||
run_alpine:
|
run_alpine:
|
||||||
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
|
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
|
||||||
|
|
||||||
|
build_alpine_riscv:
|
||||||
|
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE_RISCV) --build-arg ARCH=riscv64 .
|
||||||
|
|
||||||
|
run_alpine_riscv:
|
||||||
|
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_RISCV)
|
||||||
|
|
||||||
build_ubuntu2204:
|
build_ubuntu2204:
|
||||||
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .
|
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .
|
||||||
|
|
||||||
|
@ -41,12 +41,22 @@ echo "Using $GCC and $CLANG"
|
|||||||
if [[ "$PKGS" == ":ubuntu" ]]; then
|
if [[ "$PKGS" == ":ubuntu" ]]; then
|
||||||
PKGS="file,bzip2,libarchive,flac,libunwind,benchmark,openssl,cpptrace"
|
PKGS="file,bzip2,libarchive,flac,libunwind,benchmark,openssl,cpptrace"
|
||||||
COMPILERS="clang gcc"
|
COMPILERS="clang gcc"
|
||||||
elif [[ "$PKGS" == ":alpine" ]]; then
|
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"
|
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_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
|
||||||
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
|
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
|
||||||
|
export COMMON_LDFLAGS="-fuse-ld=mold"
|
||||||
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
|
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
|
||||||
COMPILERS="clang clang-minsize-lto gcc"
|
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
|
||||||
|
# Let's keep it simple for more exotic architectures
|
||||||
|
COMPILERS="clang-minsize-lto"
|
||||||
|
else
|
||||||
|
COMPILERS="clang clang-minsize-lto gcc"
|
||||||
|
fi
|
||||||
elif [[ "$PKGS" == ":none" ]]; then
|
elif [[ "$PKGS" == ":none" ]]; then
|
||||||
echo "No libraries to build"
|
echo "No libraries to build"
|
||||||
exit 0
|
exit 0
|
||||||
@ -451,7 +461,9 @@ for COMPILER in $COMPILERS; do
|
|||||||
./configure --prefix="$prefix" \
|
./configure --prefix="$prefix" \
|
||||||
--without-iconv --without-xml2 --without-expat \
|
--without-iconv --without-xml2 --without-expat \
|
||||||
--without-bz2lib --without-zlib \
|
--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 -j$(nproc)
|
||||||
make install
|
make install
|
||||||
done
|
done
|
||||||
@ -472,7 +484,8 @@ for COMPILER in $COMPILERS; do
|
|||||||
cd "$HOME/pkgs/$COMPILER"
|
cd "$HOME/pkgs/$COMPILER"
|
||||||
tar xf ../${FLAC_TARBALL}
|
tar xf ../${FLAC_TARBALL}
|
||||||
cd flac-${FLAC_VERSION}
|
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 -j$(nproc)
|
||||||
make install
|
make install
|
||||||
fi
|
fi
|
||||||
|
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@ -200,6 +200,9 @@ jobs:
|
|||||||
- arch: arm64v8
|
- arch: arm64v8
|
||||||
dist: alpine
|
dist: alpine
|
||||||
build_type: clang-relsize-libressl-lto-ninja-static
|
build_type: clang-relsize-libressl-lto-ninja-static
|
||||||
|
- arch: riscv64
|
||||||
|
dist: alpine
|
||||||
|
build_type: clang-relsize-libressl-lto-ninja-static
|
||||||
- arch: amd64
|
- arch: amd64
|
||||||
dist: alpine
|
dist: alpine
|
||||||
build_type: clang-relsize-minimal-lto-ninja-static
|
build_type: clang-relsize-minimal-lto-ninja-static
|
||||||
|
3
.github/workflows/docker-run-build.yml
vendored
3
.github/workflows/docker-run-build.yml
vendored
@ -36,6 +36,9 @@ jobs:
|
|||||||
- Linux
|
- Linux
|
||||||
- ${{ inputs.build_arch }}
|
- ${{ inputs.build_arch }}
|
||||||
|
|
||||||
|
# Building a docker container on RISC-V can take an awful long time
|
||||||
|
timeout-minutes: 2880
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -1053,6 +1053,13 @@ if(STATIC_BUILD_DO_NOT_USE OR WIN32)
|
|||||||
COMMAND ${UPX_EXE} -9 --best -o ${UNIVERSAL_OUT} $<TARGET_FILE:${tgt}>
|
COMMAND ${UPX_EXE} -9 --best -o ${UNIVERSAL_OUT} $<TARGET_FILE:${tgt}>
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${UNIVERSAL_OUT}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${tgt}> ${UNIVERSAL_OUT}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
COMMENT "UPX not found, copying binary without compression"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -150,6 +150,11 @@ target_include_directories(
|
|||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/folly>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/folly>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# On platforms other than x86 / arm, we need to use the fallback
|
||||||
|
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|aarch64")
|
||||||
|
target_compile_definitions(dwarfs_folly_lite PUBLIC FOLLY_F14_FORCE_FALLBACK=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT PREFER_SYSTEM_FAST_FLOAT)
|
if(NOT PREFER_SYSTEM_FAST_FLOAT)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
dwarfs_folly_lite SYSTEM PRIVATE
|
dwarfs_folly_lite SYSTEM PRIVATE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user