Commit 9066387b68 for ffmpeg

commit 9066387b6898b09c55249fb7f9774aa7dadf656f
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Mon Oct 26 16:10:03 2026 +0100

    configure: build only the AltiVec and VSX files with their flags

    The PPC SIMD code is selected at runtime, but configure added
    -maltivec -mabi=altivec and -mvsx to CFLAGS, so GCC could emit AltiVec
    and VSX instructions in any function. It does, so a default PPC32 build
    crashes on CPUs without AltiVec. Collect the flags in ALTIVECFLAGS and
    VSXFLAGS and add them only to the ALTIVEC-OBJS and VSX-OBJS objects and
    to the header check of util_altivec.h. VSX is only enabled on
    little-endian, where the AltiVec code loads and stores with VSX, so
    there the AltiVec files get the VSX flags, as they did through CFLAGS.

    Signed-off-by: Kacper Michajłow <kasper93@gmail.com>

diff --git a/configure b/configure
index f70591050c..2fb600fbea 100755
--- a/configure
+++ b/configure
@@ -6679,29 +6679,31 @@ elif enabled ppc; then
     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'

     if enabled altivec; then
-        check_allcflags -maltivec -mabi=altivec
+        test_cflags -maltivec -mabi=altivec && append ALTIVECFLAGS -maltivec -mabi=altivec

         # check if our compiler supports Motorola AltiVec C API
         check_cc altivec altivec.h "vector signed int v1 = (vector signed int) { 0 };
                                     vector signed int v2 = (vector signed int) { 1 };
-                                    v1 = vec_add(v1, v2);"
+                                    v1 = vec_add(v1, v2);" $ALTIVECFLAGS

         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
     fi

     if enabled vsx; then
-        check_allcflags -mvsx
+        append VSXFLAGS $ALTIVECFLAGS
+        test_cflags $VSXFLAGS -mvsx && append VSXFLAGS -mvsx
         check_cc vsx altivec.h "int v[4] = { 0 };
-                                vector signed int v1 = vec_vsx_ld(0, v);"
+                                vector signed int v1 = vec_vsx_ld(0, v);" $VSXFLAGS
+        enabled vsx && ALTIVECFLAGS=$VSXFLAGS
     fi

     if enabled power8; then
-        check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
+        check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)" $ALTIVECFLAGS
     fi

     if enabled altivec; then
         check_cc vec_xl altivec.h "const unsigned char *y1i = { 0 };
-                                   vector unsigned char y0 = vec_xl(0, y1i);"
+                                   vector unsigned char y0 = vec_xl(0, y1i);" $ALTIVECFLAGS
     fi

 elif enabled riscv; then
@@ -8546,6 +8548,8 @@ MSAFLAGS=$MSAFLAGS
 MMIFLAGS=$MMIFLAGS
 LSXFLAGS=$LSXFLAGS
 LASXFLAGS=$LASXFLAGS
+ALTIVECFLAGS=$ALTIVECFLAGS
+VSXFLAGS=$VSXFLAGS
 BUILDSUF=$build_suffix
 PROGSSUF=$progs_suffix
 FULLNAME=$FULLNAME
diff --git a/ffbuild/arch.mak b/ffbuild/arch.mak
index 13e1eb33bc..6e03836b7d 100644
--- a/ffbuild/arch.mak
+++ b/ffbuild/arch.mak
@@ -19,6 +19,9 @@ OBJS-$(HAVE_LASX)      += $(LASX-OBJS)       $(LASX-OBJS-yes)
 OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
 OBJS-$(HAVE_VSX)     += $(VSX-OBJS) $(VSX-OBJS-yes)

+$(sort $(addprefix $(SUBDIR),$(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes))): CFLAGS += $(ALTIVECFLAGS)
+$(sort $(addprefix $(SUBDIR),$(VSX-OBJS) $(VSX-OBJS-yes))): CFLAGS += $(VSXFLAGS)
+
 OBJS-$(HAVE_RV)      += $(RV-OBJS)      $(RV-OBJS-yes)
 OBJS-$(HAVE_RVV)     += $(RVV-OBJS)     $(RVV-OBJS-yes)
 OBJS-$(HAVE_RV_ZVBB) += $(RVVB-OBJS)    $(RVVB-OBJS-yes)
diff --git a/libavutil/ppc/Makefile b/libavutil/ppc/Makefile
index a0febf8d52..603cd44d98 100644
--- a/libavutil/ppc/Makefile
+++ b/libavutil/ppc/Makefile
@@ -4,3 +4,5 @@ OBJS += ppc/cpu.o                                                       \
 ALTIVEC-OBJS += ppc/float_dsp_altivec.o                                 \

 VSX-OBJS     += ppc/float_dsp_vsx.o                                     \
+
+$(SUBDIR)ppc/util_altivec.h.o: CFLAGS += $(ALTIVECFLAGS)