ffmpeg: Fix CPU-related settings on POWER

The defaults with the `generic` CPU target are somewhere between the ppc64 and ppc64le baseline.
More specific CPU targets don't have perfect settings either.

Just try to configure together a set of baseline-compatible settings.
This commit is contained in:
OPNA2608
2025-09-29 22:34:32 +02:00
parent 722ba864ad
commit 6a5b509558
@@ -795,6 +795,25 @@ stdenv.mkDerivation (
(enableFeature withExtraWarnings "extra-warnings")
(enableFeature withStripping "stripping")
]
++ optionals (stdenv.hostPlatform.isPower) [
# FFmpeg expects us to pass `--cpu=` to pick a specific feature set to compile for. If unset, it defaults to `generic`.
# For POWER, the default doesn't produce baseline-compliant settings. Passing a baseline-like CPU as a target doesn't
# produce entirely correct settings either - POWER4 leaves AltiVec enabled, but that's only guaranteed with POWER6.
# Just configure together everything on our own.
# Easy: Only ppc64le's baseline is recent enough to guarantee all of these.
(enableFeature (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian) "altivec")
(enableFeature (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian) "vsx")
(enableFeature (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian) "power8")
(enableFeature (stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian) "ldbrx")
# Instructions that are highly specific to that series of 32-bit embedded CPUs. Never try to enable them.
(enableFeature false "ppc4xx")
# I *think* enabling this on 64-bit POWER is correct? Struggling to find much info on when/where this was introduced.
# Definitely present on the Apple G5, and likely Freescale e5500/e6500 as well.
(enableFeature (stdenv.hostPlatform.isPower64) "dcbzl")
]
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"