Your untested debian/rules tweak worked on the first try :)

Tested in stonking container with -march=x86-64-v3 and baseline amd64:

- With -march=x86-64-v3: -DMULTIARCH skipped, compiles cleanly, runtest.sh 
passes.
- Baseline amd64: -DMULTIARCH enabled, builds all vector targets, runtest.sh 
passes.

Forwarded to Debian BTS:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149849

Attached debdiff for stonking (1.0.0-2ubuntu1).


** Description changed:

+ [ Impact ]
+ libsharp FTBFS on amd64v3:
+ 
+   libsharp/sharp_core.c:50:2: error: #error MULTIARCH specified but 
platform-specific flags detected
+      50 | #error MULTIARCH specified but platform-specific flags detected
+         |  ^~~~~
+ 
+ On amd64, debian/rules sets CFLAGS += -DMULTIARCH. When building for
+ amd64v3, compiler flags include -march=x86-64-v3, defining __AVX__,
+ __AVX2__, and __FMA__. Combining MULTIARCH with -march=x86-64-v3
+ triggers an #error in sharp_core.c:50.
+ 
+ [ Fix ]
+ Only set CFLAGS += -DMULTIARCH in debian/rules if no -march= flag is present 
in CFLAGS.
+ 
+ [ Test Plan ]
+ 1. Baseline amd64:
+    dpkg-buildpackage -b -uc -us
+    Check that -DMULTIARCH is set and testsuite passes.
+ 2. amd64v3:
+    DEB_CFLAGS_MAINT_APPEND="-march=x86-64-v3" dpkg-buildpackage -b -uc -us
+    Check that -DMULTIARCH is omitted, build succeeds, and testsuite passes.
+ 
+ [ Where problems could occur ]
+ Only affects builds where -march= is explicitly set in CFLAGS. Baseline amd64 
builds remain unchanged.
+ 
+ [ Other Info ]
+ - Debian BTS: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149849
+ - Devel series: stonking
+ - PPA: ppa:steelf/ppa
+ 
+ --- [ Original Report ]
  libsharp 1.0.0-2build1 fails to build from source on amd64v3:
  https://launchpad.net/ubuntu/+source/libsharp/1.0.0-2build1/+build/31519162
  Build log: 
https://launchpad.net/ubuntu/+source/libsharp/1.0.0-2build1/+build/31519162/+files/buildlog_ubuntu-resolute-amd64v3.libsharp_1.0.0-2build1_BUILDING.txt.gz
  
    libsharp/sharp_core.c:50:2: error: #error MULTIARCH specified but
  platform-specific flags detected
  
  Cause: on amd64, debian/rules adds -DMULTIARCH, which makes libsharp
  build generic plus AVX/AVX2/FMA code paths and select one at runtime
  (unrelated to Debian multiarch). The check is DEB_HOST_ARCH_CPU ==
  amd64, which is also true for amd64v3 builds. There, the default
  compiler flags include -march=x86-64-v3, which defines
  __AVX__/__AVX2__/__FMA__ for all code, and libsharp refuses that
  combination with an explicit #error (sharp_core.c:48-51). Runtime
  selection is pointless on amd64v3 anyway, since the baseline already has
  AVX2 and FMA.
  
  The failed build is from resolute; stonking only has 1.0.0-2build1
  copied from resolute's release pocket, so there is no amd64v3 build of
  libsharp in stonking.
  
  Fix: only add -DMULTIARCH when no -march= flag is set (patch attached in
  a comment). Checked the resulting CFLAGS: with the normal amd64 flags
  -DMULTIARCH is still added (amd64 unchanged); with -march=x86-64-v3
  (added via dpkg-buildflags) it is not. A full package build has not been
  done.
  
  The change is harmless in Debian and could be forwarded there to avoid
  carrying an Ubuntu delta.

** Changed in: libsharp (Ubuntu)
       Status: New => Confirmed

** Tags added: amd64v3 patch stonking

** Bug watch added: Debian Bug tracker #1149849
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149849

** Patch added: "libsharp 1.0.0-2ubuntu1 debdiff for stonking"
   
https://bugs.launchpad.net/ubuntu/+source/libsharp/+bug/2169085/+attachment/6005337/+files/libsharp_1.0.0-2ubuntu1.debdiff

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169085

Title:
  libsharp FTBFS on amd64v3: -DMULTIARCH combined with -march=x86-64-v3
  hits #error

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libsharp/+bug/2169085/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to