From 6a5b509558aac269b529a3fd8db2fcebf60dd01d Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 29 Sep 2025 22:34:32 +0200 Subject: [PATCH] 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. --- pkgs/development/libraries/ffmpeg/generic.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index bc51ce177bc5..d1c657eabf4e 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -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"