[Debian-med-packaging] Bug#861754: libpll: FTBFS on non-x86: x86intrin.h: No such file or directory

James Cowgill jcowgill at debian.org
Tue May 16 11:28:15 UTC 2017


Control: tags -1 patch

Hi,

On 16/05/17 09:50, Andreas Tille wrote:
> Hi Aaron,
> 
> On Mon, May 15, 2017 at 10:01:53AM -0400, Aaron M. Ucko wrote:
>>
>> Alas, non-x86 builds are still failing, with the immediate cause of
>> failure being either an uncompilable cpuid call
> 
> Hmmm, I'm a bit clueless about this.
> 
>> or (in the case of
>> powerpc[spe] and ppc64[el]) the use of x86-specific compiler flags for
>> certain files.  Please limit all of the above to x86 architectures.
> 
> I think I could realise this but I'm afraid after having done so the
> cpuid issue will remain also for these - so seeking for help here fist.

Possibly the attached patch will work?

This:
- only tries to detect x86 features on x86
- detects altivec properly (although it's not used anywhere?)
- uses GCC's __builtin_cpu_supports which is nicer than cpuid
- compiles with --disable-* on all arches except x86
- enables arch specific code on x86 (there is proper runtime detection now)
- uses debhelper 10 to avoid manual autogen
- includes architecture.mk which is required before using DEB_HOST_*

james
-------------- next part --------------
diff -Nru libpll-0.3.0/debian/compat libpll-0.3.0/debian/compat
--- libpll-0.3.0/debian/compat	2017-05-15 08:19:35.000000000 +0100
+++ libpll-0.3.0/debian/compat	2017-05-16 11:45:26.000000000 +0100
@@ -1 +1 @@
-9
+10
diff -Nru libpll-0.3.0/debian/patches/hardware-detect.patch libpll-0.3.0/debian/patches/hardware-detect.patch
--- libpll-0.3.0/debian/patches/hardware-detect.patch	1970-01-01 01:00:00.000000000 +0100
+++ libpll-0.3.0/debian/patches/hardware-detect.patch	2017-05-16 11:45:11.000000000 +0100
@@ -0,0 +1,61 @@
+--- a/src/hardware.c
++++ b/src/hardware.c
+@@ -21,45 +21,23 @@
+ 
+ #include "pll.h"
+ 
+-#ifndef __PPC__
+-#define cpuid(f1, f2, a, b, c, d)                                \
+-  __asm__ __volatile__ ("cpuid"                                  \
+-                        : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+-                        : "a" (f1), "c" (f2));
+-#endif
+-
+ static void cpu_features_detect()
+ {
+-  unsigned int a,b,c,d;
+-
+   memset(pll_hardware,0,sizeof(pll_hardware_t));
+ 
+-#ifdef __PPC__
+-  pll_hardware->altivec_present = 1;
+-#else
+-
+-  cpuid(0,0,a,b,c,d);
+-  unsigned int maxlevel = a & 0xff;
+-
+-  if (maxlevel >= 1)
+-  {
+-    cpuid(1,0,a,b,c,d);
+-    pll_hardware->mmx_present    = (d >> 23) & 1;
+-    pll_hardware->sse_present    = (d >> 25) & 1;
+-    pll_hardware->sse2_present   = (d >> 26) & 1;
+-    pll_hardware->sse3_present   = (c >>  0) & 1;
+-    pll_hardware->ssse3_present  = (c >>  9) & 1;
+-    pll_hardware->sse41_present  = (c >> 19) & 1;
+-    pll_hardware->sse42_present  = (c >> 20) & 1;
+-    pll_hardware->popcnt_present = (c >> 23) & 1;
+-    pll_hardware->avx_present    = (c >> 28) & 1;
+-
+-    if (maxlevel >= 7)
+-    {
+-      cpuid(7,0,a,b,c,d);
+-      pll_hardware->avx2_present = (b >> 5) & 1;
+-    }
+-  }
++#if defined(__PPC__)
++  pll_hardware->altivec_present = __builtin_cpu_supports("altivec");
++#elif defined(__x86_64__) || defined(__i386__)
++  pll_hardware->mmx_present     = __builtin_cpu_supports("mmx");
++  pll_hardware->sse_present     = __builtin_cpu_supports("sse");
++  pll_hardware->sse2_present    = __builtin_cpu_supports("sse2");
++  pll_hardware->sse3_present    = __builtin_cpu_supports("sse3");
++  pll_hardware->ssse3_present   = __builtin_cpu_supports("ssse3");
++  pll_hardware->sse41_present   = __builtin_cpu_supports("sse4.1");
++  pll_hardware->sse42_present   = __builtin_cpu_supports("sse4.2");
++  pll_hardware->popcnt_present  = __builtin_cpu_supports("popcnt");
++  pll_hardware->avx_present     = __builtin_cpu_supports("avx");
++  pll_hardware->avx2_present    = __builtin_cpu_supports("avx2");
+ #endif
+ }
+ 
diff -Nru libpll-0.3.0/debian/patches/series libpll-0.3.0/debian/patches/series
--- libpll-0.3.0/debian/patches/series	2017-05-15 08:19:35.000000000 +0100
+++ libpll-0.3.0/debian/patches/series	2017-05-16 11:45:20.000000000 +0100
@@ -1 +1,2 @@
 have_x86intrin_h.patch
+hardware-detect.patch
diff -Nru libpll-0.3.0/debian/rules libpll-0.3.0/debian/rules
--- libpll-0.3.0/debian/rules	2017-05-15 08:19:35.000000000 +0100
+++ libpll-0.3.0/debian/rules	2017-05-16 11:45:26.000000000 +0100
@@ -2,19 +2,18 @@
 
 # DH_VERBOSE := 1
 
+include /usr/share/dpkg/architecture.mk
+
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 %:
 	dh $@
 
 override_dh_auto_configure:
-	./autogen.sh
-ifeq ($(DEB_BUILD_ARCH),i386)
-	./autogen.sh --disable-avx --disable-sse
-	dh_auto_configure -- --disable-avx --disable-sse
+ifneq ($(filter $(DEB_HOST_ARCH_CPU), amd64 i386),)
+	dh_auto_configure
 else
-	./autogen.sh --disable-avx
-	dh_auto_configure -- --disable-avx
+	dh_auto_configure -- --disable-sse --disable-avx --disable-avx2
 endif
 
 override_dh_install:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/debian-med-packaging/attachments/20170516/dde79252/attachment-0001.sig>


More information about the Debian-med-packaging mailing list