Add linux32 target

crosstool-ng is set to build gcc targetting -march=i686 (Pentium Pro), as there
is little to no sense to support anything lower than that.
This commit is contained in:
Alibek Omarov
2024-12-12 23:20:45 +03:00
committed by BtbN
parent 8410769796
commit dc38e41621
11 changed files with 1184 additions and 0 deletions

View File

@ -0,0 +1,68 @@
ARG GH_REPO=ghcr.io/fwgs/ffmpeg-builds
FROM $GH_REPO/base:latest
RUN --mount=src=ct-ng-config,dst=/.config \
git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \
./bootstrap && \
./configure --enable-local && \
make -j$(nproc) && \
cp /.config .config && \
./ct-ng build && \
cd / && \
rm -rf ct-ng
# Prepare "cross" environment to heavily favour static builds
RUN \
find /opt/ct-ng -type l \
-and -name '*.so' \
-and -not -ipath '*plugin*' \
-and -not -name 'libdl.*' \
-and -not -name 'libc.*' \
-and -not -name 'libm.*' \
-and -not -name 'libmvec.*' \
-and -not -name 'librt.*' \
-and -not -name 'libpthread.*' \
-delete && \
find /opt/ct-ng \
-name 'libdl.a' \
-or -name 'libc.a' \
-or -name 'libm.a' \
-or -name 'libmvec.a' \
-or -name 'librt.a' \
-or -name 'libpthread.a' \
-delete && \
mkdir /opt/ffbuild
ENV FFBUILD_TOOLCHAIN=i686-ffbuild-linux-gnu \
FFBUILD_RUST_TARGET="i686-unknown-linux-gnu"
#RUN \
# rustup default nightly && \
# echo "[unstable]\ntarget-applies-to-host = true\nhost-config = true\n" > "$CARGO_HOME"/config.toml && \
# echo "[target.$FFBUILD_RUST_TARGET]\nlinker = \"${FFBUILD_TOOLCHAIN}-gcc\"\nar = \"${FFBUILD_TOOLCHAIN}-gcc-ar\"\n" >> "$CARGO_HOME"/config.toml && \
# echo "[target.host]\nlinker = \"gcc\"\nar = \"ar\"\n" >> "$CARGO_HOME"/config.toml
ADD toolchain.cmake /toolchain.cmake
ADD cross.meson /cross.meson
ADD gen-implib.sh /usr/bin/gen-implib
RUN git clone --filter=blob:none --depth=1 https://github.com/yugr/Implib.so /opt/implib
ENV PATH="/opt/ct-ng/bin:${PATH}" \
FFBUILD_TARGET_FLAGS="--pkg-config=pkg-config --cross-prefix=${FFBUILD_TOOLCHAIN}- --arch=i686 --target-os=linux" \
FFBUILD_CROSS_PREFIX="${FFBUILD_TOOLCHAIN}-" \
FFBUILD_PREFIX=/opt/ffbuild \
FFBUILD_CMAKE_TOOLCHAIN=/toolchain.cmake \
PKG_CONFIG=pkg-config \
PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig:/opt/ffbuild/share/pkgconfig \
CC="${FFBUILD_TOOLCHAIN}-gcc" \
CXX="${FFBUILD_TOOLCHAIN}-g++" \
LD="${FFBUILD_TOOLCHAIN}-ld" \
AR="${FFBUILD_TOOLCHAIN}-gcc-ar" \
RANLIB="${FFBUILD_TOOLCHAIN}-gcc-ranlib" \
NM="${FFBUILD_TOOLCHAIN}-gcc-nm" \
CFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \
CXXFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \
LDFLAGS="-static-libgcc -static-libstdc++ -L/opt/ffbuild/lib -O2 -pipe -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro,-z,now -pthread -lm" \
STAGE_CFLAGS="-fvisibility=hidden -fno-semantic-interposition" \
STAGE_CXXFLAGS="-fvisibility=hidden -fno-semantic-interposition"

View File

@ -0,0 +1,13 @@
[binaries]
c = 'i686-ffbuild-linux-gnu-gcc'
cpp = 'i686-ffbuild-linux-gnu-g++'
ld = 'i686-ffbuild-linux-gnu-ld'
ar = 'i686-ffbuild-linux-gnu-gcc-ar'
ranlib = 'i686-ffbuild-linux-gnu-gcc-ranlib'
strip = 'i686-ffbuild-linux-gnu-strip'
[host_machine]
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -e
if [[ $# != 2 ]]; then
echo "Invalid arguments"
exit 1
fi
IN="$1"
OUT="$2"
TMPDIR="$(mktemp -d)"
trap "rm -rf '$TMPDIR'" EXIT
cd "$TMPDIR"
set -x
python3 /opt/implib/implib-gen.py --target i686-linux-gnu --dlopen --lazy-load --verbose "$IN"
${FFBUILD_CROSS_PREFIX}gcc $CFLAGS $STAGE_CFLAGS -Wa,--noexecstack -DIMPLIB_HIDDEN_SHIMS -c *.tramp.S *.init.c
${FFBUILD_CROSS_PREFIX}ar -rcs "$OUT" *.tramp.o *.init.o

View File

@ -0,0 +1,17 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i686)
set(CMAKE_SYSTEM_VERSION 4.18.20)
set(triple i686-ffbuild-linux-gnu)
set(CMAKE_C_COMPILER ${triple}-gcc)
set(CMAKE_CXX_COMPILER ${triple}-g++)
set(CMAKE_RANLIB ${triple}-gcc-ranlib)
set(CMAKE_AR ${triple}-gcc-ar)
set(CMAKE_SYSROOT /opt/ct-ng/${triple}/sysroot)
set(CMAKE_FIND_ROOT_PATH /opt/ct-ng /opt/ct-ng/${triple}/sysroot /opt/ffbuild)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux-install-shared.sh
source "$(dirname "$BASH_SOURCE")"/defaults-gpl-shared.sh

3
variants/linux32-gpl.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux-install-static.sh
source "$(dirname "$BASH_SOURCE")"/defaults-gpl.sh

View File

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux-install-shared.sh
source "$(dirname "$BASH_SOURCE")"/defaults-lgpl-shared.sh

3
variants/linux32-lgpl.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux-install-static.sh
source "$(dirname "$BASH_SOURCE")"/defaults-lgpl.sh

View File

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux32-gpl-shared.sh
FF_CONFIGURE="--enable-nonfree $FF_CONFIGURE"

View File

@ -0,0 +1,4 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/linux32-gpl.sh
FF_CONFIGURE="--enable-nonfree $FF_CONFIGURE"
LICENSE_FILE=""