Skip to content

deps.ffmpeg: Fix libvpx Windows x64 build with NASM 3.02 - #5

Merged
zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/libvpx-nasm3-rdata
Oct 20, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/libvpx-nasm3-rdata

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix the Windows x64 FFmpeg build (libvpx 1.14.1) with NASM 3.02 by applying libvpx's own upstream fix as a Windows patch: deps.ffmpeg/patches/libvpx/0003-use-rdata-section-on-windows.patch, wired into 30-libvpx.ps1 through a new Patch step (same Safe-Patch pattern as the other Windows scripts). NASM is not pinned.

The patch is libvpx commit 8b3ce4cfa488 "x86_abi_support.asm: use .rdata for win32/win64" by James Zern (credited as co-author), shipped in libvpx 1.17.0. It is 4 lines: SECTION_RODATA becomes section .rdata on win32/win64 instead of section .rodata. The patch can be dropped when libvpx is updated to 1.17.0 or later.

Motivation and Context

What fails. "Build FFmpeg for Windows (x64)" has failed in every run here since the first one on master (37731278276, 2026-10-08), every nightly since (latest: 39002391991), and the PR runs of #1, #2 and #3:

x64\Debug\vpxrc\vp8_common_x86_dequantize_mmx_asm.obj : fatal error LNK1136: invalid or corrupt file
x64\Debug\vpx\vpx_dsp_x86_add_noise_sse2_asm.obj : fatal error LNK1136: invalid or corrupt file

The arm64 job shows as cancelled in those runs (fail-fast after x64). Its one standalone failure (38682381576) was a transient git clone of vorbis; arm64 libvpx uses armasm64, not NASM.

Root cause.

  • Every failing run installs MSYS2 nasm-3.02-1. obsproject/obs-deps has the same failure: its last green nightly (36673288925, 2026-09-30) installed nasm-2.16.03-1; from 2026-10-02 on, every nightly installs nasm-3.02-1 and fails with the same LNK1136 (the 2026-10-01 run failed earlier on an unrelated libpng download hash).
  • Only Debug objects fail. libvpx's Visual Studio project assembles Debug with nasm -Xvc -gcv8 -f win64 (CodeView debug info), Release without -gcv8.
  • libvpx 1.14.1 puts its constant tables in section .rodata, which on win64 NASM creates as an executable code section. NASM 3.02's CodeView writer then hits a NULL line table for that section and crashes (saa_rewind(s=0x0) from write_linenumber_table, output/codeview.c:570), leaving a 0-byte .obj, which is what LNK1136 reports. The regression is NASM commit dee2d13f2 ("Proper handling of several code sections in Codeview debug information"), bisected in netwide-assembler/nasm#267; the NASM fix (netwide-assembler/nasm#292) is still open. libvpx's tracker entry is webm bug 540261859.

Why this fix and not a NASM pin. The libvpx change is the upstream fix for the actual problem (read-only data in an executable section on Windows; with .rdata the tables are also no longer mapped executable). It works with every NASM version, does not depend on MSYS2 keeping an old package around, and goes away by itself with the next libvpx update. Bumping libvpx to 1.17.0 instead would be three minor versions at once (new ABI) mixed into a CI fix; that stays a separate, one-library update.

This unblocks #1 (libsrt 1.5.7), #2 (FFmpeg 8.1.3) and #3 (Mbed TLS 3.6.7), which all fail on this job.

How Has This Been Tested?

RED. The CI runs linked above (master and upstream, nasm 3.02).

Local, outside Windows (NASM 2.16.03 and 3.02 built from the nasm.us release tarballs; libvpx v1.14.1 configured for x86_64-win64-vs17; the 45 x86 .asm sources under vp8/, vp9/, vpx_dsp/ assembled with the same flags as the vcxproj, -Xvc [-gcv8] -f win64):

libvpx 1.14.1 nasm 2.16.03 -gcv8 nasm 3.02 -gcv8 nasm 3.02, no -gcv8
unpatched assembles 15 of 45 files segfault, 0-byte .obj (incl. dequantize_mmx.asm, add_noise_sse2.asm) assembles
patched assembles all 45 assemble assembles

(The 46th .asm file, vpx_dsp/x86/bitdepth_conversion_sse2.asm, is macros only and is not assembled on its own by the build.)

Object checks with llvm-readobj (dequantize_mmx and add_noise_sse2, the two files in the CI error): nasm 2.16.03 unpatched puts the tables in .rodata flagged CNT_CODE | MEM_EXECUTE; nasm 3.02 patched puts them in .rdata flagged INITIALIZED_DATA | MEM_READ. The .text bytes are identical to the nasm 2.16.03 objects that link today, and the .rdata bytes equal the old .rodata bytes. All 45 patched objects from nasm 3.02 -gcv8 parse cleanly with llvm-readobj --codeview. Not checked here: linking with the MSVC linker (no Windows machine available), which is what this PR's CI does.

The patch applies to the v1.14.1 sources with patch -p1 --binary (as Safe-Patch runs it) and no fuzz, and the reverse dry-run fails on unpatched sources, so Safe-Patch applies it once.

GREEN. This PR's CI: the Windows x64 and arm64 FFmpeg jobs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

🤖 Generated with Claude Code

The Windows x64 FFmpeg job has failed in every run since MSYS2
replaced nasm 2.16.03 with nasm 3.02 (here since the first run on
master, https://github.com/obs-rust/obs-deps/actions/runs/37731278276,
latest nightly:
https://github.com/obs-rust/obs-deps/actions/runs/39002391991):

  x64\Debug\vpxrc\vp8_common_x86_dequantize_mmx_asm.obj :
    fatal error LNK1136: invalid or corrupt file

libvpx's Visual Studio project assembles its Debug configuration with
"nasm -Xvc -gcv8 -f win64". libvpx 1.14.1 puts its constant tables in
"section .rodata" on win64, which NASM treats as an executable code
section there. NASM 3.02's CodeView writer then dereferences a NULL
line table for that section while writing the debug info and crashes,
leaving a 0-byte object that the MSVC linker rejects. Assembling the
15 affected libvpx 1.14.1 files with -gcv8 -f win64 segfaults with
nasm 3.02 and works with nasm 2.16.03.

libvpx fixed this in 1.17.0 (commit 8b3ce4cfa488, "x86_abi_support.asm:
use .rdata for win32/win64"; libvpx bug 540261859): read-only data goes
to .rdata on win32/win64, which also stops it being mapped executable.
The NASM side is netwide-assembler/nasm#267, with an open fix in
netwide-assembler/nasm#292.

Apply that libvpx commit as a patch on Windows instead of pinning
NASM back to 2.16.03. With the patch, every libvpx 1.14.1 x86 asm
source the build assembles also assembles with nasm 3.02 -gcv8 -f
win64. The patch can be dropped when libvpx is updated to 1.17.0 or
later.

Co-Authored-By: James Zern <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants