[Debian-astro-maintainers] Bug#1149849: libsharp: skip -DMULTIARCH when -march= flag is set (fixes FTBFS on amd64v3)
Viktor Pashaiev
w.paszajew at gmail.com
Sat Oct 3 18:50:54 BST 2026
Package: src:libsharp
Version: 1.0.0-2
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu stonking ubuntu-patch
Dear Maintainer,
In libsharp, building on amd64 with a specific microarchitecture level
(such as -march=x86-64-v3, used by Ubuntu's amd64v3 port or custom builds)
fails to build from source:
libsharp/sharp_core.c:50:2: error: #error MULTIARCH specified but platform-specific flags detected
50 | #error MULTIARCH specified but platform-specific flags detected
| ^~~~~
Root cause:
In debian/rules, CFLAGS += -DMULTIARCH is added whenever DEB_HOST_ARCH_CPU
is amd64. This enables libsharp's runtime CPU dispatch mechanism, which builds
multiple implementations (generic, AVX, AVX2, FMA, AVX-512) and dispatches
at runtime.
However, in sharp_core.c (lines 48-52):
#ifdef MULTIARCH
#if (defined(__AVX512F__) || defined(__FMA4__) || defined(__FMA__) || \
defined(__AVX2__) || defined(__AVX__))
#error MULTIARCH specified but platform-specific flags detected
#endif
When building with -march=x86-64-v3, __AVX__, __AVX2__, and __FMA__ are
defined globally for all compilation units. libsharp explicitly forbids combining
MULTIARCH with platform-specific vector flags, as runtime dispatch to generic
routines is neither supported nor meaningful when the baseline ISA already
guarantees these instructions.
Fix:
In debian/rules, only append -DMULTIARCH if no -march= option is present in
CFLAGS. On standard amd64 builds, -DMULTIARCH is still enabled as before.
When -march= is set, libsharp compiles cleanly for the selected target ISA.
This issue is also tracked in Ubuntu at:
https://bugs.launchpad.net/ubuntu/+source/libsharp/+bug/2169085
The patch below resolves the failure:
--- a/debian/rules
+++ b/debian/rules
@@ -30,9 +30,14 @@
# Note that the libsharp source refers to this feature using the
# preprocessor macro MULTIARCH, but it has nothing to do with the
# Debian concept of multiarch.
+# Not when the baseline already targets a specific ISA level (e.g. Ubuntu's
+# amd64v3 builds with -march=x86-64-v3): libsharp refuses to combine
+# MULTIARCH with AVX/AVX2/FMA flags, and the dispatch would be pointless.
ifeq ($(DEB_HOST_ARCH_CPU),amd64)
+ifeq (,$(filter -march=%,$(CFLAGS)))
CFLAGS += -DMULTIARCH
endif
+endif
%:
dh $@
More information about the Debian-astro-maintainers
mailing list