Skip to contentSkip to conversation

pulseaudio: Fix build with clang for non-x86 target

PATCH In review Khem Raj 2 participants 2 messages Dec 20, 2020 – Dec 21, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 pulseaudio: Fix build with clang for non-x86 target

Cc Tanu Kaskinen <[email protected]>
---
 .../0001-meson-Check-for-__get_cpuid.patch    | 82 +++++++++++++++++++
 .../pulseaudio/pulseaudio_14.0.bb             |  1 +
 2 files changed, 83 insertions(+)
 create mode 100644 meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch
meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch new file +82 -0
new file mode 100644
index 0000000000..c9d8abcbf2
@@ -0,0 +1,82 @@
+From 9d0dc8aedd08d77797f90fa6075a59613f18bf0d Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 20 Dec 2020 07:56:07 -0800
+Subject: [PATCH] meson: Check for __get_cpuid
+
+checking for presence of cpuid.h header alone is not sufficient in some case to use
+cpuid related functions. e.g. when using clang which is built for
+multiple targets will have cpuid.h header as part of compiler headers in
+distribution but one maybe compiling pulseaudion for non-x86 target. The
+current check in meson succeeds and then compile fails later because
+cpuid.h is x86-specific header. Therefore checking for symbol that is
+needed makes this robust, so even if header exist it will try to ensure
+the given symbol can be used
+
+Fixes
+src/pulsecore/core-util.c:113:
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/pulseaudio/14.0-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/cpuid.h:11:2: error: this header is for x86 only
+| #error this header is for x86 only
+|  ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+Cc: Tanu Kaskinen <[email protected]>
+---
+ meson.build               | 5 ++++-
+ src/pulsecore/core-util.c | 2 +-
+ src/pulsecore/cpu-x86.c   | 2 +-
+ 3 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 2589627..5f5127e 100644
+--- a/meson.build
++++ b/meson.build
+@@ -185,7 +185,6 @@ endif
+ check_headers = [
+   'arpa/inet.h',
+   'byteswap.h',
+-  'cpuid.h',
+   'dlfcn.h',
+   'execinfo.h',
+   'grp.h',
+@@ -243,6 +242,10 @@ if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
+   cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
+ endif
+ 
++if cc.has_header_symbol('cpuid.h', '__get_cpuid')
++  cdata.set('HAVE_GET_CPUID', 1)
++endif
++
+ # Functions
+ 
+ check_functions = [
+diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
+index 601b1d1..6f34e7c 100644
+--- a/src/pulsecore/core-util.c
++++ b/src/pulsecore/core-util.c
+@@ -109,7 +109,7 @@
+ #include <sys/personality.h>
+ #endif
+ 
+-#ifdef HAVE_CPUID_H
++#ifdef HAVE_GET_CPUID
+ #include <cpuid.h>
+ #endif
+ 
+diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
+index 4e59e14..86595d4 100644
+--- a/src/pulsecore/cpu-x86.c
++++ b/src/pulsecore/cpu-x86.c
+@@ -24,7 +24,7 @@
+ 
+ #include <stdint.h>
+ 
+-#ifdef HAVE_CPUID_H
++#ifdef HAVE_GET_CPUID
+ #include <cpuid.h>
+ #endif
+ 
+-- 
+2.29.2
+
meta/recipes-multimedia/pulseaudio/pulseaudio_14.0.bb +1 -0
index 63ef3a9c12..fccca1ba48 100644
@@ -4,6 +4,7 @@ SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/${BP}.tar.xz \
            file://0001-client-conf-Add-allow-autospawn-for-root.patch \
            file://0002-do-not-display-CLFAGS-to-improve-reproducibility-bui.patch \
            file://0001-build-sys-Add-an-option-for-enabling-disabling-Valgr.patch \
+           file://0001-meson-Check-for-__get_cpuid.patch \
            file://volatiles.04_pulse \
            "
 SRC_URI[md5sum] = "84a7776e63dd55c40db8fbd7c7e2e18e"
Signature · 1 line
2.29.2
#1 lore raw
Quoted 80 lines · Khem Raj
Cc Tanu Kaskinen <[email protected]>
---
 .../0001-meson-Check-for-__get_cpuid.patch    | 82 +++++++++++++++++++
 .../pulseaudio/pulseaudio_14.0.bb             |  1 +
 2 files changed, 83 insertions(+)
 create mode 100644 meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch
meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch new file +66 -0
new file mode 100644
index 0000000000..c9d8abcbf2
@@ -0,0 +1,82 @@
+From 9d0dc8aedd08d77797f90fa6075a59613f18bf0d Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 20 Dec 2020 07:56:07 -0800
+Subject: [PATCH] meson: Check for __get_cpuid
+
+checking for presence of cpuid.h header alone is not sufficient in some case to use
+cpuid related functions. e.g. when using clang which is built for
+multiple targets will have cpuid.h header as part of compiler headers in
+distribution but one maybe compiling pulseaudion for non-x86 target. The
+current check in meson succeeds and then compile fails later because
+cpuid.h is x86-specific header. Therefore checking for symbol that is
+needed makes this robust, so even if header exist it will try to ensure
+the given symbol can be used
+
+Fixes
+src/pulsecore/core-util.c:113:
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/pulseaudio/14.0-r0/recipe-sysroot-native/usr/lib/clang/11.0.1/include/cpuid.h:11:2: error: this header is for x86 only
+| #error this header is for x86 only
+|  ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+Cc: Tanu Kaskinen <[email protected]>
+---
+ meson.build               | 5 ++++-
+ src/pulsecore/core-util.c | 2 +-
+ src/pulsecore/cpu-x86.c   | 2 +-
+ 3 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 2589627..5f5127e 100644
+--- a/meson.build
++++ b/meson.build
+@@ -185,7 +185,6 @@ endif
+ check_headers = [
+   'arpa/inet.h',
+   'byteswap.h',
+-  'cpuid.h',
+   'dlfcn.h',
+   'execinfo.h',
+   'grp.h',
+@@ -243,6 +242,10 @@ if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
+   cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
+ endif
+ 
++if cc.has_header_symbol('cpuid.h', '__get_cpuid')
++  cdata.set('HAVE_GET_CPUID', 1)
++endif
++
+ # Functions
+ 
+ check_functions = [
+diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
+index 601b1d1..6f34e7c 100644
+--- a/src/pulsecore/core-util.c
++++ b/src/pulsecore/core-util.c
+@@ -109,7 +109,7 @@
+ #include <sys/personality.h>
+ #endif
+ 
+-#ifdef HAVE_CPUID_H
++#ifdef HAVE_GET_CPUID
+ #include <cpuid.h>
+ #endif
+ 

meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch line 76

Quoted 10 lines
meta/recipes-multimedia/pulseaudio/pulseaudio/0001-meson-Check-for-__get_cpuid.patch new file +10 -0
+diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
+index 4e59e14..86595d4 100644
+--- a/src/pulsecore/cpu-x86.c
++++ b/src/pulsecore/cpu-x86.c
+@@ -24,7 +24,7 @@
+ 
+ #include <stdint.h>
+ 
+-#ifdef HAVE_CPUID_H
++#ifdef HAVE_GET_CPUID

There are more instances of HAVE_CPUID_H in core-util.c and cpu-x86.c, they all need to be replaced with HAVE_GET_CPUID. Could you update the patch?

When upstreaming, I think this change needs to be ported to the Autotools build system too as long as it exists in PulseAudio, but I can take care of that.

Signature · 1 line
Tanu