wip: working for riscv/i386

This commit is contained in:
Marcus Holland-Moritz 2025-07-23 23:32:33 +02:00
parent 493dd49541
commit 21d896ec08
5 changed files with 51 additions and 16 deletions

View File

@ -41,6 +41,7 @@ RUN apk add --no-cache \
mpc1-dev \
isl-dev \
texinfo \
linux-headers \
rsync \
qemu-riscv64 \
qemu-i386
@ -49,12 +50,18 @@ RUN apk add --no-cache \
ARG ARCH
# UPX isn't supported on RISC-V/S390 (yet), so skip this
RUN if [ "$ARCH" ~= "^(riscv|s390)" ]; 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"; \
wget -O - https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-$(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 $ARCH architecture while it is not supported."; \
echo "See https://github.com/upx/upx/discussions/793 for details."; \
fi
# Install mold
COPY install-mold.sh /usr/local/bin/install-mold.sh
RUN bash /usr/local/bin/install-mold.sh
RUN apk del linux-headers
# Install size-optimized and static-link-optimized libstdc++
#COPY install-libstdcxx.sh /usr/local/bin/install-libstdcxx.sh
#RUN bash /usr/local/bin/install-libstdcxx.sh
@ -64,13 +71,7 @@ RUN bash /usr/local/bin/install-toolchain.sh build riscv64 s
RUN bash /usr/local/bin/install-toolchain.sh build i386 s
RUN bash /usr/local/bin/install-toolchain.sh cleanup
RUN apk add --no-cache linux-headers
# Install mold
COPY install-mold.sh /usr/local/bin/install-mold.sh
RUN bash /usr/local/bin/install-mold.sh
RUN apk del linux-headers zlib-dev
RUN apk del zlib-dev
# Install all static libraries
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
@ -100,8 +101,9 @@ RUN bash /usr/local/bin/install-static-libs.sh riscv64,i386 :alpine:flac
RUN bash /usr/local/bin/install-static-libs.sh riscv64,i386 :alpine:libdwarf
RUN bash /usr/local/bin/install-static-libs.sh riscv64,i386 :alpine:cpptrace
RUN bash /usr/local/bin/install-static-libs.sh riscv64,i386 :alpine:range-v3
RUN bash /usr/local/bin/install-static-libs.sh riscv64,i386 :alpine:parallel-hashmap
### # 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
# Set up git & user
RUN git config --global --add safe.directory /workspace

View File

@ -28,6 +28,8 @@ repositories = [
"nlohmann/json",
"HowardHinnant/date",
"nemtrif/utfcpp",
"ericniebler/range-v3",
"greg7mdp/parallel-hashmap",
]

View File

@ -11,7 +11,7 @@ cd "$HOME"
mkdir pkgs
cd pkgs
MOLD_VERSION=2.37.1
MOLD_VERSION=2.40.2
wget -O mold-${MOLD_VERSION}.tar.gz https://github.com/rui314/mold/archive/refs/tags/v${MOLD_VERSION}.tar.gz
tar xf mold-${MOLD_VERSION}.tar.gz

View File

@ -33,7 +33,7 @@ XXHASH_VERSION=0.8.3 # 2024-12-30
LZ4_VERSION=1.10.0 # 2024-07-22
BROTLI_VERSION=1.1.0 # 2023-08-31
ZSTD_VERSION=1.5.7 # 2025-02-19
LIBFUSE_VERSION=3.17.2 # 2025-04-23
LIBFUSE_VERSION=3.17.3 # 2025-07-19
MIMALLOC_VERSION=2.1.7 # 2024-05-21
JEMALLOC_VERSION=5.3.0 # 2022-05-02
XZ_VERSION=5.8.1 # 2025-04-03
@ -43,6 +43,7 @@ NLOHMANN_VERSION=3.12.0 # 2025-04-07
DATE_VERSION=3.0.4 # 2025-05-28
UTFCPP_VERSION=4.0.6 # 2024-11-03
RANGE_V3_VERSION=0.12.0 # 2022-06-21
PARALLEL_HASHMAP_VERSION=2.0.0 # 2025-01-21
echo "Using $GCC and $CLANG"
@ -51,7 +52,7 @@ if [[ "$PKGS" == ":ubuntu" ]]; then
COMPILERS="clang gcc"
elif [[ "$PKGS" == ":alpine"* ]]; then
if [[ "$PKGS" == ":alpine" ]]; then
PKGS="benchmark,boost,brotli,cpptrace,date,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libdwarf,libevent,libucontext,libunwind,libressl,lz4,mimalloc,nlohmann,range-v3,openssl,utfcpp,xxhash,xz,zstd"
PKGS="benchmark,boost,brotli,cpptrace,date,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libdwarf,libevent,libucontext,libunwind,libressl,lz4,mimalloc,nlohmann,parallel-hashmap,range-v3,openssl,utfcpp,xxhash,xz,zstd"
else
PKGS="${PKGS#:alpine:}"
fi
@ -98,6 +99,7 @@ LIBEVENT_TARBALL="libevent-${LIBEVENT_VERSION}-stable.tar.gz"
DATE_TARBALL="date-${DATE_VERSION}.tar.gz"
UTFCPP_TARBALL="utfcpp-${UTFCPP_VERSION}.tar.gz"
RANGE_V3_TARBALL="range-v3-${RANGE_V3_VERSION}.tar.gz"
PARALLEL_HASHMAP_TARBALL="parallel-hashmap-${PARALLEL_HASHMAP_VERSION}.tar.gz"
use_lib() {
local lib="$1"
@ -160,6 +162,7 @@ fetch_lib nlohmann https://github.com/nlohmann/json/releases/download/v${NLOHMAN
fetch_lib date https://github.com/HowardHinnant/date/archive/refs/tags/v${DATE_VERSION}.tar.gz ${DATE_TARBALL}
fetch_lib utfcpp https://github.com/nemtrif/utfcpp/archive/refs/tags/v${UTFCPP_VERSION}.tar.gz ${UTFCPP_TARBALL}
fetch_lib range-v3 https://github.com/ericniebler/range-v3/archive/refs/tags/${RANGE_V3_VERSION}.tar.gz ${RANGE_V3_TARBALL}
fetch_lib parallel-hashmap https://github.com/greg7mdp/parallel-hashmap/archive/refs/tags/v${PARALLEL_HASHMAP_VERSION}.tar.gz ${PARALLEL_HASHMAP_TARBALL}
set_build_flags() {
if [[ $CFLAGS =~ ^[[:space:]]*$ ]]; then
@ -209,9 +212,17 @@ opt_perf() {
set_build_flags
}
read -ra TARGET_ARCHS <<< "${TARGET_ARCH_STR//,/$'\n'}"
for target_arch in ${TARGET_ARCH_STR//,/ }; do
echo "==========================================================="
echo "Building for target architecture: $target_arch"
echo "==========================================================="
if [ "$target_arch" != "$ARCH" ]; then
export TARGETARCH="$target_arch"
else
unset TARGETARCH
fi
for TARGETARCH in "${TARGET_ARCHS[@]}"; do
export CARCH="$TARGETARCH"
rm -f /tmp/meson-$CARCH.txt
@ -684,13 +695,27 @@ EOF
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DRANGE_V3_EXAMPLES=OFF \
-DBUILD_SHARED_LIBS=OFF -DRANGE_V3_EXAMPLES=OFF \
-DRANGE_V3_PERF=OFF -DRANGE_V3_TESTS=OFF -DRANGE_V3_HEADER_CHECKS=ON \
-DRANGES_ENABLE_WERROR=OFF -DRANGES_NATIVE=OFF -DRANGES_DEBUG_INFO=OFF \
${CMAKE_ARGS}
make -j$(nproc)
make install
fi
if use_lib parallel-hashmap; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${PARALLEL_HASHMAP_TARBALL}
cd parallel-hashmap-${PARALLEL_HASHMAP_VERSION}
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DBUILD_SHARED_LIBS=OFF -DPHMAP_BUILD_EXAMPLES=OFF -DPHMAP_BUILD_TESTS=OFF \
${CMAKE_ARGS}
make -j$(nproc)
make install
fi
done
done

View File

@ -32,6 +32,12 @@ case "$CARCH" in
loongarch*) CARCH="loongarch" ;;
esac
case "$CARCH" in
i386)
GCC_CONFIGURE_ARGS="--with-arch=i486 --with-tune=generic"
;;
esac
CFLAGS="-O${OPT} -ffunction-sections -fdata-sections -fmerge-all-constants -fPIC"
CXXFLAGS="-O${OPT} -ffunction-sections -fdata-sections -fmerge-all-constants -fPIC"
LDFLAGS="-Wl,--gc-sections"
@ -151,7 +157,7 @@ case "$TASK" in
# --libdir=$PREFIX/lib --includedir=$PREFIX/include \
"$HOME"/pkgs/gcc-${GCC_VERSION}/configure \
--target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT \
--target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT ${GCC_CONFIGURE_ARGS} \
--disable-shared --enable-tls --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers \
--enable-threads --enable-__cxa_atexit --enable-languages=c,c++ --enable-link-serialization=2 --enable-linker-build-id \
--enable-libssp --disable-libsanitizer --with-system-zlib --enable-checking=release --disable-cet --disable-fixed-point \