Source: gcl27 Version: 2.7.1-8 Tags: patch User: [email protected] Usertags: ftcbfs
gcl27 fails to cross build from source for two main reasons. One reason is that debian/rules forces a bare C compiler onto configure that would otherwise choose a cross compiler. This is due to the MCC=gcc assignment. Deferring the choice to dpkg's buildtools.mk is the usual way to choose a compiler. The other reason is use of AC_RUN_IFELSE. The configure.ac uses it in lots of places and each of those makes cross compilation fail as host code cannot be run. A significant chunk of those checks do not actually need to run code. For instance, sizeof can be determined via compilation bisection as is implemented in AC_CHECK_SIZEOF. The attached patch converts a significant chunk of those checks and ideally it would be forwarded upstream as it benefits other distributions such as Yocto. For the remaining checks, AC_CACHE_CHECK probably is the way to go. The attached patch significantly improves the situation without making gcl27 cross buildable yet. Please close the bug report anyway when addressing significant aspects of what is being reported here. Helmut
diff -Nru gcl27-2.7.1/debian/changelog gcl27-2.7.1/debian/changelog --- gcl27-2.7.1/debian/changelog 2025-09-21 20:06:45.000000000 +0200 +++ gcl27-2.7.1/debian/changelog 2025-12-28 19:26:27.000000000 +0100 @@ -1,3 +1,12 @@ +gcl27 (2.7.1-8.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Improve cross building. (Closes: #-1) + + Pass a triplet-prefixed CC to configure. + + cross.patch: Convert quite some AC_RUN_IFELSE checks. + + -- Helmut Grohne <[email protected]> Sun, 28 Dec 2025 19:26:27 +0100 + gcl27 (2.7.1-8) unstable; urgency=medium * Bug fix: "FTBFS: /tmp/gazonk_6005_0.c:21:63: error: implicit diff -Nru gcl27-2.7.1/debian/patches/cross.patch gcl27-2.7.1/debian/patches/cross.patch --- gcl27-2.7.1/debian/patches/cross.patch 1970-01-01 01:00:00.000000000 +0100 +++ gcl27-2.7.1/debian/patches/cross.patch 2025-12-28 19:26:27.000000000 +0100 @@ -0,0 +1,135 @@ +--- gcl27-2.7.1.orig/configure.ac ++++ gcl27-2.7.1/configure.ac +@@ -577,22 +577,11 @@ + + AC_CHECK_HEADERS( + [setjmp.h], +- [AC_MSG_CHECKING([sizeof jmp_buf]) +- AC_RUN_IFELSE( +- [AC_LANG_PROGRAM( +- [[ ++ [AC_CHECK_SIZEOF([jmp_buf],,[ + #include <stdio.h> + #include <setjmp.h> +- ]], +- [[ +- FILE *fp=fopen("conftest1","w"); +- fprintf(fp,"%lu\n",sizeof(jmp_buf)); +- fclose(fp); +- ]])], +- [sizeof_jmp_buf=`cat conftest1` +- AC_MSG_RESULT($sizeof_jmp_buf) +- AC_DEFINE_UNQUOTED(SIZEOF_JMP_BUF,$sizeof_jmp_buf,[sizeof jmp_buf])], +- [AC_MSG_RESULT([no])])]) ++ ]) ++ AC_DEFINE_UNQUOTED(SIZEOF_JMP_BUF,$ac_cv_sizeof_jmp_buf,[sizeof jmp_buf])]) + + # sysconf + AC_CHECK_HEADERS( +@@ -620,7 +609,7 @@ + AC_CHECK_HEADERS([gmp.h], + [AC_CHECK_LIB([gmp],[__gmpz_init], + [AC_MSG_CHECKING([for external gmp version]) +- AC_RUN_IFELSE( ++ AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include <gmp.h> +@@ -629,7 +618,7 @@ + #if __GNU_MP_VERSION > 3 + return 0; + #else +- return -1; ++ #error GMP version to low + #endif + ]])], + [AC_MSG_RESULT([good]) +@@ -660,18 +649,11 @@ + AC_MSG_RESULT("no") + fi + +-AC_MSG_CHECKING([for size of gmp limbs]) +-AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ++AC_CHECK_SIZEOF([mp_limb_t],,[[ + #include <stdio.h> + #include "$MP_INCLUDE" +- ]], +- [[ +- FILE *fp=fopen("conftest1","w"); +- fprintf(fp,"%u",sizeof(mp_limb_t)); +- fclose(fp); +- ]])],[mpsize=`cat conftest1`],[AC_MSG_ERROR([Cannot determine mpsize])]) +-AC_DEFINE_UNQUOTED(MP_LIMB_BYTES,$mpsize,[sizeof mp_limb in gmp library]) +-AC_MSG_RESULT($mpsize) ++]]) ++AC_DEFINE_UNQUOTED(MP_LIMB_BYTES,$ac_cv_sizeof_mp_limb_t,[sizeof mp_limb in gmp library]) + + AC_MSG_CHECKING([_SHORT_LIMB]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +@@ -991,7 +973,7 @@ + AC_DEFINE_UNQUOTED(OBJ_ALIGN,$obj_align,[can use C extension for object alignment]) + + AC_MSG_CHECKING([for C extension noreturn function attribute]) +-AC_RUN_IFELSE( ++AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]], + [[ + extern int v() __attribute__ ((noreturn)); +@@ -1000,10 +982,7 @@ + AC_MSG_RESULT($no_return) + AC_DEFINE_UNQUOTED(NO_RETURN,$no_return,[can use C extension for functions that do not return]) + +-AC_MSG_CHECKING([sizeof struct contblock]) +- +-AC_RUN_IFELSE( +- [AC_LANG_PROGRAM( ++AC_CHECK_SIZEOF([struct contblock],, + [[ + #include <stdio.h> + #include <stdlib.h> +@@ -1015,18 +994,9 @@ + #include "$srcdir/h/type.h" + #include "$srcdir/h/lu.h" + #include "$srcdir/h/object.h" +- ]], +- [[ +- FILE *f=fopen("conftest1","w"); +- fprintf(f,"%u",sizeof(struct contblock)); +- fclose(f); +- ]])], +- [sizeof_contblock=`cat conftest1`], +- [AC_MSG_ERROR([Cannot find sizeof struct contblock])], +- [AC_MSG_ERROR([Cannot find sizeof struct contblock])]) ++ ]]) + +-AC_MSG_RESULT($sizeof_contblock) +-AC_DEFINE_UNQUOTED(SIZEOF_CONTBLOCK,$sizeof_contblock,[sizeof linked list for contiguous pages]) ++AC_DEFINE_UNQUOTED(SIZEOF_CONTBLOCK,$ac_cv_sizeof_struct_contblock,[sizeof linked list for contiguous pages]) + + AC_MSG_CHECKING(CSTACK_DIRECTION) + AC_RUN_IFELSE( +@@ -1433,18 +1403,12 @@ + fi + fi + +-AC_MSG_CHECKING([sizeof long long int]) +-AC_RUN_IFELSE( +- [AC_LANG_PROGRAM( +- [[ +- #include <stdio.h> +- ]], +- [[ +- if (sizeof(long long int) == 2*sizeof(long)) return 0; +- return 1; +- ]])], +- [AC_DEFINE(HAVE_LONG_LONG,1,[long long is available]) AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no)]) ++AC_CHECK_SIZEOF([long]) ++AC_CHECK_SIZEOF([long long int]) ++twice_long=`expr 2 '*' $ac_cv_sizeof_long` ++if test "$twice_long" = "$ac_cv_sizeof_long_long_int"; then ++ AC_DEFINE(HAVE_LONG_LONG,1,[long long is available]) ++fi + + AC_SUBST(HAVE_LONG_LONG) + diff -Nru gcl27-2.7.1/debian/patches/series gcl27-2.7.1/debian/patches/series --- gcl27-2.7.1/debian/patches/series 2025-09-21 20:06:45.000000000 +0200 +++ gcl27-2.7.1/debian/patches/series 2025-12-28 19:26:27.000000000 +0100 @@ -4,3 +4,4 @@ Version_2_7_2pre5 Version_2_7_2pre6 Version_2_7_2pre7 +cross.patch diff -Nru gcl27-2.7.1/debian/rules gcl27-2.7.1/debian/rules --- gcl27-2.7.1/debian/rules 2025-05-30 01:11:18.000000000 +0200 +++ gcl27-2.7.1/debian/rules 2025-12-28 19:26:25.000000000 +0100 @@ -15,6 +15,9 @@ # This has to be exported to make some magic below work. export DH_OPTIONS +include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildtools.mk + ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS=$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) endif @@ -24,21 +27,17 @@ export GCL_MULTIPROCESS_MEMORY_POOL endif -# This is the debhelper compatability version to use. -ARCHT:=$(shell dpkg-architecture -qDEB_HOST_ARCH) - -MCC?=gcc -# ifeq ($(ARCHT),alpha) -# MCC:=gcc-4.6 +# ifeq ($(DEB_HOST_ARCH),alpha) +# CC:=$(DEB_HOST_GNU_TYPE)-gcc-4.6 # endif CFLAGS_APPEND?= -#ifeq ($(ARCHT),ppc64) +#ifeq ($(DEB_HOST_ARCH),ppc64) #CFLAGS_APPEND:=$(CFLAGS_APPEND) -O1 #endif DEBUG?= -#ifeq ($(ARCHT),hppa) +#ifeq ($(DEB_HOST_ARCH),hppa) #DEBUG=--enable-debug #endif @@ -64,8 +63,8 @@ dh_autoreconf eval `dpkg-buildflags --export=sh` && \ - CC=$(MCC) CFLAGS="$$CFLAGS $(CFLAGS_APPEND)" ./configure \ - --host=$$(dpkg-architecture -qDEB_HOST_GNU_TYPE) \ + CC='$(CC)' CFLAGS="$$CFLAGS $(CFLAGS_APPEND)" ./configure \ + --host=$(DEB_HOST_GNU_TYPE) \ $(DEBUG) \ --prefix=/usr

