Skip to content

Commit 17b0a47

Browse files
committed
fix windows
1 parent 2e0c911 commit 17b0a47

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

.github/workflows/build-ffmpeg.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ jobs:
9292
path: ${{ github.workspace }}/out/ffmpeg-${{ matrix.target }}.gz
9393
if-no-files-found: error
9494

95+
# Publishes all platform binaries + checksums.sha256 to a single GitHub Release at the
96+
# pinned tag (scripts/ffmpeg/release.mjs). This release is the stable, discoverable
97+
# location that `@livekit/agents` downloads from at install time — the per-job
98+
# upload-artifact steps above are just transport into this job. `needs: build` gates this
99+
# on ALL platforms succeeding, so a release is never partial. Runs on push (branch tests)
100+
# and workflow_dispatch alike; re-running updates the existing release in place.
95101
release:
96102
needs: [config, build]
97-
# TEMP(dz/build-ffmpeg): only publish on manual dispatch, so the push test runs above
98-
# validate the builds without creating a release. Remove this `if:` before merging.
99-
if: github.event_name == 'workflow_dispatch'
100103
runs-on: ubuntu-latest
101104
steps:
102105
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0

scripts/ffmpeg/build-ffmpeg.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,22 @@ if command -v nproc >/dev/null 2>&1; then JOBS="$(nproc)"; else JOBS="$(sysctl -
4444
# --- per-target toolchain configuration ---------------------------------------------------
4545
CROSS_FLAGS=() # extra ffmpeg ./configure flags
4646
OPUS_HOST_FLAGS=() # extra libopus ./configure flags
47+
OPUS_CFLAGS="" # extra CFLAGS for the opus build ("" = use opus defaults)
48+
FF_EXTRA_CFLAGS="" # appended to ffmpeg --extra-cflags
4749
BIN_NAME="ffmpeg"
4850
case "$TARGET" in
4951
win32-x64)
5052
CROSS_PREFIX="x86_64-w64-mingw32-"
5153
CROSS_FLAGS=(--arch=x86_64 --target-os=mingw32 "--cross-prefix=${CROSS_PREFIX}" --pkg-config=pkg-config)
52-
# --disable-hardening: opus enables -fstack-protector-strong by default, which on mingw
53-
# references __stack_chk_* from libssp that opus.pc doesn't advertise. FFmpeg's static
54-
# link test for opus would then fail to link and report "opus not found using pkg-config".
5554
OPUS_HOST_FLAGS=(--host=x86_64-w64-mingw32 --disable-hardening)
55+
# Debian/Ubuntu patch their mingw-w64 gcc to default -fstack-protector-strong and
56+
# _FORTIFY_SOURCE=2. Those inject __stack_chk_*/__memcpy_chk references (normally
57+
# satisfied by libssp) into libopus.a and the ffmpeg objects, breaking the static link
58+
# — FFmpeg's opus link test then fails with the misleading "opus not found using
59+
# pkg-config". Turn both off for the cross build (opus's --disable-hardening alone does
60+
# not counter the compiler default). Harmless on toolchains that don't default them on.
61+
OPUS_CFLAGS="-O2 -fno-stack-protector -D_FORTIFY_SOURCE=0"
62+
FF_EXTRA_CFLAGS="-fno-stack-protector -D_FORTIFY_SOURCE=0"
5663
BIN_NAME="ffmpeg.exe"
5764
;;
5865
darwin-arm64|darwin-x64|linux-x64|linux-arm64)
@@ -67,9 +74,11 @@ cd "$WORK"
6774
echo "::group::build libopus $OPUS_VERSION"
6875
curl -fsSL -o opus.tar.gz "https://downloads.xiph.org/releases/opus/opus-${OPUS_VERSION}.tar.gz"
6976
tar xf opus.tar.gz && cd "opus-${OPUS_VERSION}"
77+
if [ -n "$OPUS_CFLAGS" ]; then export CFLAGS="$OPUS_CFLAGS"; fi
7078
./configure --prefix="$PREFIX" --disable-shared --enable-static --disable-doc \
7179
--disable-extra-programs ${OPUS_HOST_FLAGS[@]+"${OPUS_HOST_FLAGS[@]}"}
7280
make -j"$JOBS" && make install
81+
unset CFLAGS # don't leak opus CFLAGS into the ffmpeg build (it uses --extra-cflags)
7382
cd "$WORK"
7483
echo "::endgroup::"
7584

@@ -82,7 +91,7 @@ trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::group::ffbuild/config.log
8291
./configure \
8392
--prefix="$PREFIX" \
8493
--pkg-config-flags="--static" \
85-
--extra-cflags="-I$PREFIX/include" \
94+
--extra-cflags="-I$PREFIX/include $FF_EXTRA_CFLAGS" \
8695
--extra-ldflags="-L$PREFIX/lib" \
8796
--enable-static --disable-shared \
8897
--disable-gpl --disable-nonfree \

0 commit comments

Comments
 (0)