|
| 1 | +ARG GH_REPO=ghcr.io/fwgs/ffmpeg-builds |
| 2 | +FROM $GH_REPO/base:latest |
| 3 | + |
| 4 | +RUN --mount=src=ct-ng-config,dst=/.config \ |
| 5 | + git clone --filter=blob:none https://github.com/crosstool-ng/crosstool-ng.git /ct-ng && cd /ct-ng && \ |
| 6 | + ./bootstrap && \ |
| 7 | + ./configure --enable-local && \ |
| 8 | + make -j$(nproc) && \ |
| 9 | + cp /.config .config && \ |
| 10 | + ./ct-ng build && \ |
| 11 | + cd / && \ |
| 12 | + rm -rf ct-ng |
| 13 | + |
| 14 | +# Prepare "cross" environment to heavily favour static builds |
| 15 | +RUN \ |
| 16 | + find /opt/ct-ng -type l \ |
| 17 | + -and -name '*.so' \ |
| 18 | + -and -not -ipath '*plugin*' \ |
| 19 | + -and -not -name 'libdl.*' \ |
| 20 | + -and -not -name 'libc.*' \ |
| 21 | + -and -not -name 'libm.*' \ |
| 22 | + -and -not -name 'libmvec.*' \ |
| 23 | + -and -not -name 'librt.*' \ |
| 24 | + -and -not -name 'libpthread.*' \ |
| 25 | + -delete && \ |
| 26 | + find /opt/ct-ng \ |
| 27 | + -name 'libdl.a' \ |
| 28 | + -or -name 'libc.a' \ |
| 29 | + -or -name 'libm.a' \ |
| 30 | + -or -name 'libmvec.a' \ |
| 31 | + -or -name 'librt.a' \ |
| 32 | + -or -name 'libpthread.a' \ |
| 33 | + -delete && \ |
| 34 | + mkdir /opt/ffbuild |
| 35 | + |
| 36 | +ENV FFBUILD_TOOLCHAIN=i686-ffbuild-linux-gnu \ |
| 37 | + FFBUILD_RUST_TARGET="i686-unknown-linux-gnu" |
| 38 | + |
| 39 | +#RUN \ |
| 40 | +# rustup default nightly && \ |
| 41 | +# echo "[unstable]\ntarget-applies-to-host = true\nhost-config = true\n" > "$CARGO_HOME"/config.toml && \ |
| 42 | +# echo "[target.$FFBUILD_RUST_TARGET]\nlinker = \"${FFBUILD_TOOLCHAIN}-gcc\"\nar = \"${FFBUILD_TOOLCHAIN}-gcc-ar\"\n" >> "$CARGO_HOME"/config.toml && \ |
| 43 | +# echo "[target.host]\nlinker = \"gcc\"\nar = \"ar\"\n" >> "$CARGO_HOME"/config.toml |
| 44 | + |
| 45 | +ADD toolchain.cmake /toolchain.cmake |
| 46 | +ADD cross.meson /cross.meson |
| 47 | + |
| 48 | +ADD gen-implib.sh /usr/bin/gen-implib |
| 49 | +RUN git clone --filter=blob:none --depth=1 https://github.com/yugr/Implib.so /opt/implib |
| 50 | + |
| 51 | +ENV PATH="/opt/ct-ng/bin:${PATH}" \ |
| 52 | + FFBUILD_TARGET_FLAGS="--pkg-config=pkg-config --cross-prefix=${FFBUILD_TOOLCHAIN}- --arch=i686 --target-os=linux" \ |
| 53 | + FFBUILD_CROSS_PREFIX="${FFBUILD_TOOLCHAIN}-" \ |
| 54 | + FFBUILD_PREFIX=/opt/ffbuild \ |
| 55 | + FFBUILD_CMAKE_TOOLCHAIN=/toolchain.cmake \ |
| 56 | + PKG_CONFIG=pkg-config \ |
| 57 | + PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig:/opt/ffbuild/share/pkgconfig \ |
| 58 | + CC="${FFBUILD_TOOLCHAIN}-gcc" \ |
| 59 | + CXX="${FFBUILD_TOOLCHAIN}-g++" \ |
| 60 | + LD="${FFBUILD_TOOLCHAIN}-ld" \ |
| 61 | + AR="${FFBUILD_TOOLCHAIN}-gcc-ar" \ |
| 62 | + RANLIB="${FFBUILD_TOOLCHAIN}-gcc-ranlib" \ |
| 63 | + NM="${FFBUILD_TOOLCHAIN}-gcc-nm" \ |
| 64 | + CFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \ |
| 65 | + CXXFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \ |
| 66 | + LDFLAGS="-static-libgcc -static-libstdc++ -L/opt/ffbuild/lib -O2 -pipe -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro,-z,now -pthread -lm" \ |
| 67 | + STAGE_CFLAGS="-fvisibility=hidden -fno-semantic-interposition" \ |
| 68 | + STAGE_CXXFLAGS="-fvisibility=hidden -fno-semantic-interposition" |
0 commit comments