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>
This commit is contained in:
Kacper Michajłow committed 2026-11-02 07:24:04 +00:00
1 parent 29c5dba781
commit 9066387b68
3 files changed
+15 -6

No files matched your search

Vendored
+10 -6
View File
@@ -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
+3
View File
@@ -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)
+2
View File
@@ -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)