fix(windows): set CFLAGS +sse4.1 +ssse3 so audiopus_sys builds under clang-cl
Some checks failed
Mirror to GitHub / mirror (push) Failing after 39s
Build Release Binaries / build-amd64 (push) Has been cancelled

libopus ships per-file SSE4.1 / SSSE3 C sources (opus/silk/x86/NSQ_del_dec_sse4_1.c
etc.) that assume the compiler picks up `-msse4.1` / `-mssse3` as per-file
CMake COMPILE_FLAGS. With clang-cl those bare -m flags are silently dropped,
so _mm_cvtepi16_epi32 + friends fail compile with 'always_inline function
requires target feature sse4.1, but would be inlined into a function that
is compiled without support for sse4.1'.

Workaround: set CFLAGS_x86_64_pc_windows_msvc + CXXFLAGS_x86_64_pc_windows_msvc
to `/clang:-msse4.1 /clang:-mssse3 /clang:-msse3 /clang:-msse2` before running
cargo xwin build. Every x86_64 Windows CPU shipped since 2008 has these
instruction sets so globally enabling them on this target is safe.

Also bump the tail -30 on cargo xwin output to tail -50 so the actual
compiler errors (not just the cmake wrapper panic) make it into the
ntfy / remote log file next time.
This commit is contained in:
Siavash Sameni
2026-04-10 12:40:38 +04:00
parent 7949266e11
commit 990b6f1ee0

View File

@@ -172,6 +172,23 @@ docker run --rm \
wzp-windows-builder \
bash -c '
set -euo pipefail
# libopus (audiopus_sys) ships per-file SSE4.1 / SSSE3 C sources under
# opus/silk/x86/ that assume the compiler sets `-msse4.1` / `-mssse3`
# as per-file CMake COMPILE_FLAGS. With clang-cl those bare -m flags
# are silently ignored (clang-cl expects /clang:-msse4.1), so the
# intrinsics functions in those files fail to compile with:
# "error: always_inline function _mm_cvtepi16_epi32 requires target
# feature sse4.1, but would be inlined into a function that is
# compiled without support for sse4.1"
#
# Workaround: set global CFLAGS for the Windows target so every C file
# in libopus (and any other cc-rs crate) compiles with SSE4.1/SSSE3
# enabled. All x86_64 Windows CPUs shipped since 2008 support these,
# so the global enablement is safe for the target platform.
export CFLAGS_x86_64_pc_windows_msvc="/clang:-msse4.1 /clang:-mssse3 /clang:-msse3 /clang:-msse2"
export CXXFLAGS_x86_64_pc_windows_msvc="/clang:-msse4.1 /clang:-mssse3 /clang:-msse3 /clang:-msse2"
cd /build/source/desktop
echo ">>> npm install"
@@ -182,7 +199,7 @@ npm run build 2>&1 | tail -5
echo ">>> cargo xwin build --release --target x86_64-pc-windows-msvc --bin wzp-desktop"
cd src-tauri
cargo xwin build --release --target x86_64-pc-windows-msvc --bin wzp-desktop 2>&1 | tail -30
cargo xwin build --release --target x86_64-pc-windows-msvc --bin wzp-desktop 2>&1 | tail -50
echo ""
echo ">>> Build artifacts:"