Dockerfile 2.9 KB

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