Source: discount Version: 2.2.7-2.1 Tags: patch User: debian-cr...@lists.debian.org Usertags: ftcbfs
discount fails to build from source for multiple reasons. The immediate failure is a bit of a red herring. What we see is a failure due to -Werror=implicit-int. The real cause for this is that configure.sh passes compiler flags via CC and dh_auto_build does not recognize the build system as a configure-based one and hence overrides CC discarding the -Wno-implicit-int set up by configure.sh. I think the real solution here is passing compiler flags via CFLAGS rather than CC. >From here, things get messy. I noticed that configure.sh has no clue about the right CC and it was only getting as far due to overriding the detected CC for the make invocation. Clearly, it would be better to export CC and have configure.sh pick that up. Once doing so, the Makefile would stop being interpolated and instead become a verbatim copy of the template. What? Turns out, the template is interpolated using a sed script and that sed script is generated using a tool config.sed, which is a tiny C program compiled with the configured compiler. When that compiler becomes a cross compiler, config.sed cannot be run. Rather, the error is ignored (which is a Debian policy violation and serious bug) and the generated sed script would end up being empty. The prorgam is simple enough such that it can be written in plain shell with little effort, so we can side step the whole problem here. Last but not least, mktags fails to run. It is a build tool and not installed into the package. Unfortunately, the build system has no clue at all about build architecture and host architecture in any way. We can work around this by overriding the compiler (that is now detected by configure.sh) to become the build architecture one for just building mktags and then build the rest of the package with the host architecture compiler. With all of this, it actually starts working. Please allow me to suggest getting rid of this build system and using the CMake one instead that is also included in the source. With luck, using CMake would make cross building (among other things) just work at little effort. Helmut
diff --minimal -Nru discount-2.2.7/debian/changelog discount-2.2.7/debian/changelog --- discount-2.2.7/debian/changelog 2024-11-13 16:32:17.000000000 +0100 +++ discount-2.2.7/debian/changelog 2024-11-22 10:18:53.000000000 +0100 @@ -1,3 +1,14 @@ +discount (2.2.7-2.2) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fix FTCBFS: (Closes: #-1) + + cross.patch: Do not pass compiler flags via CC. + + cross.patch: Implement config.sed as a script rather than a host tool. + + Pass CC to configure.sh. + + Build mktags for the build architecture. + + -- Helmut Grohne <hel...@subdivi.de> Fri, 22 Nov 2024 10:18:53 +0100 + discount (2.2.7-2.1) unstable; urgency=medium * Non-maintainer upload. diff --minimal -Nru discount-2.2.7/debian/patches/cross.patch discount-2.2.7/debian/patches/cross.patch --- discount-2.2.7/debian/patches/cross.patch 1970-01-01 01:00:00.000000000 +0100 +++ discount-2.2.7/debian/patches/cross.patch 2024-11-22 10:18:53.000000000 +0100 @@ -0,0 +1,71 @@ +--- discount-2.2.7.orig/configure.inc ++++ discount-2.2.7/configure.inc +@@ -1742,41 +1742,20 @@ + + echo "generating config.sed" + +- AC_PROG_CC +- +-cat > ngc$$.c << \EOF +-#include <stdio.h> +- +-int +-main(argc, argv) +-int argc; +-char **argv; +-{ +- char *p; +- +- if (argc != 3) +- return 1; +- +- printf("s;@%s@;", argv[1]); +- +- for (p=argv[2]; *p; ++p) { +- if ( *p == ';' ) +- putchar('\\'); +- putchar(*p); +- } +- +- puts(";g"); +- return 0; +-} ++ cat >config.sed << \EOF ++#!/bin/sh ++test "$#" = 2 || exit 1 ++printf 's;@%s@;' "$1" ++V="$2" ++while test "${V#*;}" != "$V"; do ++ printf '%s\;' "${V%%;*}" ++ V="${V#*;}" ++done ++printf '%s;g\n' "$V" ++exit 0 + EOF +- +- if $AC_CC -o config.sed ngc$$.c; then +- rm -f ngc$$.c +- __config_files="$__config_files config.sed" +- else +- rm -f ngc$$.c +- AC_FAIL "Cannot generate config.sed helper program" +- fi ++ chmod +x config.sed ++ __config_files="$__config_files config.sed" + } + + # +--- discount-2.2.7.orig/configure.sh ++++ discount-2.2.7/configure.sh +@@ -104,9 +104,9 @@ + AC_DEFINE 'if(x)' 'if( (x) != 0 )' + + if [ "$IS_CLANG" ]; then +- AC_CC="$AC_CC -Wno-implicit-int" ++ AC_CFLAGS="$AC_CFLAGS -Wno-implicit-int" + elif [ "$IS_GCC" ]; then +- AC_CC="$AC_CC -Wno-return-type -Wno-implicit-int" ++ AC_CFLAGS="$AC_CFLAGS -Wno-return-type -Wno-implicit-int" + fi ;; + esac + fi diff --minimal -Nru discount-2.2.7/debian/patches/series discount-2.2.7/debian/patches/series --- discount-2.2.7/debian/patches/series 2024-11-13 16:19:18.000000000 +0100 +++ discount-2.2.7/debian/patches/series 2024-11-22 10:18:53.000000000 +0100 @@ -2,3 +2,4 @@ 0002-Honor-system-s-LDFLAGS-in-librarian.sh.patch 03_fix-typo.patch 0004-fix-build-with-gcc14.patch +cross.patch diff --minimal -Nru discount-2.2.7/debian/rules discount-2.2.7/debian/rules --- discount-2.2.7/debian/rules 2021-09-03 19:37:06.000000000 +0200 +++ discount-2.2.7/debian/rules 2024-11-22 10:18:53.000000000 +0100 @@ -1,6 +1,10 @@ #!/usr/bin/make -f #export DH_VERBOSE=1 +include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildtools.mk +export CC + %: dh $@ --no-parallel @@ -16,5 +20,10 @@ --github-checkbox \ --debian-glitch +ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) +execute_before_dh_auto_build: + dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_build --reload-all-buildenv-variables -- 'CC=$(CC_FOR_BUILD)' mktags +endif + override_dh_auto_install: dh_install