[macppc] Unbreak audio/flac 1.3.3

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[macppc] Unbreak audio/flac 1.3.3

Charlene Wendling
Hi,

That newer version of flac makes use of getauxval(3) on powerpc, that
apparently we don't implement, so the builds fails while not finding
sys/auxv.h.

The below diff allows to build flac on macppc, where tests are passing
[1]. I've not bumped revision, the change impacts powerpc where it has
never been built.

Comments/feedback are welcome,

Charlène.


[0] http://man7.org/linux/man-pages/man3/getauxval.3.html
[1] https://bin.charlenew.xyz/flac.log


Index: patches/patch-src_libFLAC_cpu_c
===================================================================
RCS file: patches/patch-src_libFLAC_cpu_c
diff -N patches/patch-src_libFLAC_cpu_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_libFLAC_cpu_c 15 Aug 2019 09:43:18 -0000
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+Remove getauxval(3) code for ppc because we don't implement this
+
+Index: src/libFLAC/cpu.c
+--- src/libFLAC/cpu.c.orig
++++ src/libFLAC/cpu.c
+@@ -53,10 +53,6 @@
+ #define dfprintf(file, format, ...)
+ #endif
+
+-#if defined FLAC__CPU_PPC
+-#include <sys/auxv.h>
+-#endif
+-
+ #if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && (defined FLAC__HAS_NASM || FLAC__HAS_X86INTRIN) && !defined FLAC__NO_ASM
+
+ /* these are flags in EDX of CPUID AX=00000001 */
+@@ -236,24 +232,8 @@ x86_cpu_info (FLAC__CPUInfo *info)
+ static void
+ ppc_cpu_info (FLAC__CPUInfo *info)
+ {
+-#if defined FLAC__CPU_PPC
+-#ifndef PPC_FEATURE2_ARCH_3_00
+-#define PPC_FEATURE2_ARCH_3_00 0x00800000
+-#endif
+-
+-#ifndef PPC_FEATURE2_ARCH_2_07
+-#define PPC_FEATURE2_ARCH_2_07 0x80000000
+-#endif
+-
+- if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00) {
+- info->ppc.arch_3_00 = true;
+- } 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
+ }
+
+ void FLAC__cpu_info (FLAC__CPUInfo *info)

Reply | Threaded
Open this post in threaded view
|

Re: [macppc] Unbreak audio/flac 1.3.3

Jeremie Courreges-Anglas-2
On Thu, Aug 15 2019, Charlene Wendling <[hidden email]> wrote:
> Hi,
>
> That newer version of flac makes use of getauxval(3) on powerpc, that
> apparently we don't implement, so the builds fails while not finding
> sys/auxv.h.

Bleh, this implements just the right amount of autoconf tests so that it
*looks* portable.

To be truly portable tests for sys/auxv.h and getauxval should be added
and used properly.

> The below diff allows to build flac on macppc, where tests are passing
> [1]. I've not bumped revision, the change impacts powerpc where it has
> never been built.

Good enough for ports, ok jca@

If we want this fixed upstream, someone (tm) should write better tests.
naddy, cwen, are you interested, or shall I give it a try?

> Comments/feedback are welcome,
>
> Charlène.
>
>
> [0] http://man7.org/linux/man-pages/man3/getauxval.3.html
> [1] https://bin.charlenew.xyz/flac.log
>
>
> Index: patches/patch-src_libFLAC_cpu_c
> ===================================================================
> RCS file: patches/patch-src_libFLAC_cpu_c
> diff -N patches/patch-src_libFLAC_cpu_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_libFLAC_cpu_c 15 Aug 2019 09:43:18 -0000
> @@ -0,0 +1,43 @@
> +$OpenBSD$
> +
> +Remove getauxval(3) code for ppc because we don't implement this
> +
> +Index: src/libFLAC/cpu.c
> +--- src/libFLAC/cpu.c.orig
> ++++ src/libFLAC/cpu.c
> +@@ -53,10 +53,6 @@
> + #define dfprintf(file, format, ...)
> + #endif
> +
> +-#if defined FLAC__CPU_PPC
> +-#include <sys/auxv.h>
> +-#endif
> +-
> + #if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && (defined FLAC__HAS_NASM || FLAC__HAS_X86INTRIN) && !defined FLAC__NO_ASM
> +
> + /* these are flags in EDX of CPUID AX=00000001 */
> +@@ -236,24 +232,8 @@ x86_cpu_info (FLAC__CPUInfo *info)
> + static void
> + ppc_cpu_info (FLAC__CPUInfo *info)
> + {
> +-#if defined FLAC__CPU_PPC
> +-#ifndef PPC_FEATURE2_ARCH_3_00
> +-#define PPC_FEATURE2_ARCH_3_00 0x00800000
> +-#endif
> +-
> +-#ifndef PPC_FEATURE2_ARCH_2_07
> +-#define PPC_FEATURE2_ARCH_2_07 0x80000000
> +-#endif
> +-
> +- if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00) {
> +- info->ppc.arch_3_00 = true;
> +- } 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
> + }
> +
> + void FLAC__cpu_info (FLAC__CPUInfo *info)
>

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply | Threaded
Open this post in threaded view
|

Re: [macppc] Unbreak audio/flac 1.3.3

Christian Weisgerber
Jeremie Courreges-Anglas:

> > The below diff allows to build flac on macppc, where tests are passing
> > [1]. I've not bumped revision, the change impacts powerpc where it has
> > never been built.
>
> Good enough for ports, ok jca@

ok naddy@

> If we want this fixed upstream, someone (tm) should write better tests.

FreeBSD has the functionality, but the API is different:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239870

> naddy, cwen, are you interested, or shall I give it a try?

I'm interested but I don't have powerpc, so this would be rather
cumbersome for me...

--
Christian "naddy" Weisgerber                          [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [macppc] Unbreak audio/flac 1.3.3

Theo de Raadt-2
Christian Weisgerber <[hidden email]> wrote:

> Jeremie Courreges-Anglas:
>
> > > The below diff allows to build flac on macppc, where tests are passing
> > > [1]. I've not bumped revision, the change impacts powerpc where it has
> > > never been built.
> >
> > Good enough for ports, ok jca@
>
> ok naddy@
>
> > If we want this fixed upstream, someone (tm) should write better tests.
>
> FreeBSD has the functionality, but the API is different:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239870

In my opinion the entire "aux" approach is garbage.  Linux started it
and put a mixture of weak junk in their (including their tiny useless
random seed, which was a fantastic idea to defer doing something
proper for random numbers for a decade or two).  I prefer richer interfaces.

On other cpus we have sysctl's which expose the hardware's feature set.
This wasn't nicely generalized, because it is already cpu-specific.  I still
believe that is the right way to go, on systems which don't have an equivelant
for userland-permitted "cpuinfo" instructions.

And if there's one thing I really hate, it is SIGILL for discovery.