Source: pari
Version: 2.13.0-2
Severity: wishlist
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

PARI fails to cross build due to using 'cc' as the C compiler:
http://crossqa.debian.net/src/pari
With the attached patch, PARI successfully builds and the cross tests (by way
of QEMU user mode emulation) pass as well building for arm64. This also adds
support for the standard nocheck DEB_BUILD_OPTION.

What the origin Makefile syntax does is that, if CC is unset by the user
and is Make's implicit default, then it gets overridden with the appropriate
cross-compiler. This is the recommended solution [1] and has the bonus of
letting users override the compiler at build time should they please.

[1] https://wiki.debian.org/CrossBuildPackagingGuidelines

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing'), (2, 'unstable'), (1, 'testing-debug'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.9.0-5-amd64 (SMP w/2 CPU threads)
Kernel taint flags: TAINT_USER, TAINT_WARN, TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
--- rules.orig	2020-10-22 11:41:11.000000000 -0400
+++ rules	2021-01-07 11:25:07.713665303 -0500
@@ -2,6 +2,7 @@
 # Sample debian/rules that uses debhelper.
 # GNU copyright 1997 to 1999 by Joey Hess.
 # Adapted for the PARI Debian package by Bill Allombert 2001-2011
+# SPDX-FileContributor: 2021 John Scott <jsc...@posteo.net>
 
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
@@ -44,6 +45,11 @@
 CFLAGS_LTO = $(CFLAGS) -flto
 endif
 
+include /usr/share/dpkg/architecture.mk
+ifeq ($(origin CC),default)
+CC = $(DEB_HOST_GNU_TYPE)-gcc
+endif
+
 libpkg = libpari-gmp-tls7
 libtriplet = usr/lib/$(DEB_HOST_MULTIARCH)
 inctriplet = usr/include/$(DEB_HOST_MULTIARCH)
@@ -53,31 +59,31 @@
 config: config-stamp
 config-stamp:
 	dh_testdir
-	CC=cc CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
+	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
 	  ./Configure --mt=pthread\
             --prefix=/usr --host=$(PARI_CPU)-$(PARI_SYSTEM) \
             --libdir=/$(libtriplet) --sysdatadir=/$(libtriplet)/pari \
             --includedir=/$(inctriplet) \
             --builddir=obj-dyn --graphic=X11 --with-gmp 
-	CC=cc CFLAGS="$(CFLAGS_NOMAP)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
+	CC="$(CC)" CFLAGS="$(CFLAGS_NOMAP)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
 	  ./Configure --mt=pthread\
             --prefix=/usr --host=$(PARI_CPU)-$(PARI_SYSTEM) \
             --libdir=/$(libtriplet) --sysdatadir=/$(libtriplet)/pari \
             --includedir=/$(inctriplet) \
             --builddir=obj-cfg --graphic=X11 --with-gmp 
-	CC=cc CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
+	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
 	  ./Configure --mt=pthread \
             --prefix=/usr --host=$(PARI_CPU)-$(PARI_SYSTEM) \
             --libdir=/$(libtriplet) --sysdatadir=/$(libtriplet)/pari \
             --includedir=/$(inctriplet) \
             --builddir=obj-sta --graphic=X11 --with-gmp
-	CC=cc CFLAGS="$(CFLAGS_LTO)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
+	CC="$(CC)" CFLAGS="$(CFLAGS_LTO)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
 	  ./Configure --mt=pthread \
             --prefix=/usr --host=$(PARI_CPU)-$(PARI_SYSTEM) \
             --libdir=/$(libtriplet) --sysdatadir=/$(libtriplet)/pari \
             --includedir=/$(inctriplet) \
             --builddir=obj-lto --graphic=X11 --with-gmp
-	CC=cc CFLAGS="$(CFLAGS_DBG)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
+	CC="$(CC)" CFLAGS="$(CFLAGS_DBG)" LDFLAGS="$(LDFLAGS)" DLLDFLAGS="$(LDFLAGS)" \
 	  ./Configure --mt=pthread \
             --prefix=/usr --host=$(PARI_CPU)-$(PARI_SYSTEM) \
             --libdir=/$(libtriplet) --sysdatadir=/$(libtriplet)/pari \
@@ -90,7 +96,7 @@
 	$(MAKE) -C obj-dyn lib-dyn #"LIBS=-lc -lm -lgmp"
 	$(MAKE) -C obj-sta lib-sta DLCFLAGS=
 	$(MAKE) -C obj-lto gp-sta RUNPTH=
-ifeq (,$(findstring notest,$(DEB_BUILD_OPTIONS)))
+ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
 	$(MAKE) -C obj-dyn gp-dyn
 	$(MAKE) dobench -C obj-dyn
 	$(MAKE) dobench -C obj-sta

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to