Dockerfile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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=aarch64-ffbuild-linux-gnu \
  34. FFBUILD_RUST_TARGET="aarch64-unknown-linux-gnu"
  35. RUN \
  36. rustup target add "$FFBUILD_RUST_TARGET" && \
  37. echo "[target.$FFBUILD_RUST_TARGET]\nlinker = \"${FFBUILD_TOOLCHAIN}-gcc\"\nar = \"${FFBUILD_TOOLCHAIN}-gcc-ar\"\n" > "$CARGO_HOME"/config.toml
  38. ADD toolchain.cmake /toolchain.cmake
  39. ADD cross.meson /cross.meson
  40. ADD gen-implib.sh /usr/bin/gen-implib
  41. RUN git clone --filter=blob:none --depth=1 https://github.com/yugr/Implib.so /opt/implib
  42. ENV PATH="/opt/ct-ng/bin:${PATH}" \
  43. FFBUILD_TARGET_FLAGS="--pkg-config=pkg-config --cross-prefix=${FFBUILD_TOOLCHAIN}- --arch=aarch64 --target-os=linux" \
  44. FFBUILD_CROSS_PREFIX="${FFBUILD_TOOLCHAIN}-" \
  45. FFBUILD_PREFIX=/opt/ffbuild \
  46. FFBUILD_CMAKE_TOOLCHAIN=/toolchain.cmake \
  47. PKG_CONFIG=pkg-config \
  48. PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig:/opt/ffbuild/share/pkgconfig \
  49. CC="${FFBUILD_TOOLCHAIN}-gcc" \
  50. CXX="${FFBUILD_TOOLCHAIN}-g++" \
  51. LD="${FFBUILD_TOOLCHAIN}-ld" \
  52. AR="${FFBUILD_TOOLCHAIN}-gcc-ar" \
  53. RANLIB="${FFBUILD_TOOLCHAIN}-gcc-ranlib" \
  54. NM="${FFBUILD_TOOLCHAIN}-gcc-nm" \
  55. CFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \
  56. CXXFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -fPIC -DPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -pthread" \
  57. LDFLAGS="-static-libgcc -static-libstdc++ -L/opt/ffbuild/lib -O2 -pipe -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro,-z,now -pthread -lm" \
  58. STAGE_CFLAGS="-fvisibility=hidden -fno-semantic-interposition" \
  59. STAGE_CXXFLAGS="-fvisibility=hidden -fno-semantic-interposition"