[flac-dev] 1.3.3: powerpc portability problems

Christian Weisgerber naddy at mips.inka.de
Sun Aug 18 20:06:42 UTC 2019


The PowerPC-related changes in FLAC 1.3.3 have caused some portability
problems.

libFLAC/cpu.c assumes that the <sys/auxv.h> header and the getauxval()
function are universally available on PowerPC platforms.  They are not.

On FreeBSD/powerpc, <sys/auxv.h> is available, but getauxval() is
not.  Equivalent functionality is provided by elf_aux_info().

On OpenBSD/powerpc, neither is available, nor any equivalent.

I have attached a patch by Jeremie Courreges-Anglas which adds
proper autoconf checks to detect <sys/auxv.h> and getauxval().  This
could be extended to cover elf_aux_info().

For FreeBSD/powerpc64, I have been told the compiler requires -mvsx
to enable the intrinsics used by libFLAC/lpc_intrin_vsx.c.  Apparently,
there is no sufficient autoconf check, so compilation will fail
unless -mvsx has been manually added.  It is, however, unclear
whether compiling with explicit -mvsx will cause the compiler to
emit code that does not run on earlier generations of POWER machines.

-- 
Christian "naddy" Weisgerber                          naddy at mips.inka.de
-------------- next part --------------
Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -69,7 +69,7 @@ AC_C_INLINE
 AC_C_VARARRAYS
 AC_C_TYPEOF
 
-AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h])
+AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h sys/auxv.h])
 
 XIPH_C_BSWAP32
 XIPH_C_BSWAP16
@@ -104,6 +104,8 @@ AC_CHECK_TYPES(socklen_t, [], [])
 dnl check for getopt in standard library
 dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
 AC_CHECK_FUNCS(getopt_long, [], [])
+
+AC_CHECK_FUNCS([getauxval])
 
 AC_CHECK_SIZEOF(void*,1)
 
Index: src/libFLAC/cpu.c
--- src/libFLAC/cpu.c.orig
+++ src/libFLAC/cpu.c
@@ -53,7 +53,7 @@
 #define dfprintf(file, format, ...)
 #endif
 
-#if defined FLAC__CPU_PPC
+#if defined(HAVE_SYS_AUXV_H)
 #include <sys/auxv.h>
 #endif
 
@@ -236,7 +236,10 @@ x86_cpu_info (FLAC__CPUInfo *info)
 static void
 ppc_cpu_info (FLAC__CPUInfo *info)
 {
-#if defined FLAC__CPU_PPC
+	info->ppc.arch_2_07 = false;
+	info->ppc.arch_3_00 = false;
+
+#if defined(FLAC__CPU_PPC) && defined(HAVE_GETAUXVAL)
 #ifndef PPC_FEATURE2_ARCH_3_00
 #define PPC_FEATURE2_ARCH_3_00		0x00800000
 #endif
@@ -250,9 +253,6 @@ ppc_cpu_info (FLAC__CPUInfo *info)
 	} else if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07) {
 		info->ppc.arch_2_07 = true;
 	}
-#else
-	info->ppc.arch_2_07 = false;
-	info->ppc.arch_3_00 = false;
 #endif
 }
 


More information about the flac-dev mailing list