[Pkg-nginx-maintainers] Bug#912284: nginx FTCBFS: multiple reasons

Helmut Grohne helmut at subdivi.de
Sun Dec 11 18:06:55 GMT 2022


Hi,

On Mon, Oct 29, 2018 at 09:34:00PM +0100, Helmut Grohne wrote:
> The attached patch fixes all of the issues above. After applying it,
> nginx fails finding accept4, struct in6_pktinfo and NGX_SYS_NERR.
> Likely, some checks are still broken. Still I think that the patch is an
> incremental step in the right direction. Please consider applying it and
> close this bug when doing so.

I've updated the patch to actually make nginx fully cross buildable.

Helmut
-------------- next part --------------
diff --minimal -Nru nginx-1.22.1/debian/changelog nginx-1.22.1/debian/changelog
--- nginx-1.22.1/debian/changelog	2022-12-08 14:15:15.000000000 +0100
+++ nginx-1.22.1/debian/changelog	2022-12-11 12:05:06.000000000 +0100
@@ -1,3 +1,19 @@
+nginx (1.22.1-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #912284)
+    + cross.patch: Accept a compiler without running binaries.
+    + Pass a C compiler to configure.
+    + cross.patch: Implement auto/cc/name without running.
+    + Pass --crossbuild to configure.
+    + cross.patch: When passing --crossbuild, set NGX_CROSSBUILD.
+    + cross.patch: When NGX_CROSSBUILD, assume that gcc does atomics.
+    + cross.patch: When NGX_CROSSBUILD, only build the MAP_ANON test.
+    + B-D: perl-xs-dev.
+    + debian/rules: Fix build vs host confusion.
+
+ -- Helmut Grohne <helmut at subdivi.de>  Sun, 11 Dec 2022 12:05:06 +0100
+
 nginx (1.22.1-4) unstable; urgency=medium
 
   * d/t/*-module-deps: updated, added curl timeout 300 seconds and
diff --minimal -Nru nginx-1.22.1/debian/control nginx-1.22.1/debian/control
--- nginx-1.22.1/debian/control	2022-12-08 14:15:15.000000000 +0100
+++ nginx-1.22.1/debian/control	2022-12-11 12:05:06.000000000 +0100
@@ -12,9 +12,9 @@
                libmhash-dev,
                libpam0g-dev,
                libpcre3-dev,
-               libperl-dev,
                libssl-dev,
                libxslt1-dev,
+               perl-xs-dev,
                po-debconf,
                quilt,
                zlib1g-dev
diff --minimal -Nru nginx-1.22.1/debian/patches/cross.patch nginx-1.22.1/debian/patches/cross.patch
--- nginx-1.22.1/debian/patches/cross.patch	1970-01-01 01:00:00.000000000 +0100
+++ nginx-1.22.1/debian/patches/cross.patch	2022-12-11 12:05:06.000000000 +0100
@@ -0,0 +1,146 @@
+--- nginx-1.22.1.orig/auto/cc/name
++++ nginx-1.22.1/auto/cc/name
+@@ -7,7 +7,7 @@
+ 
+     ngx_feature="C compiler"
+     ngx_feature_name=
+-    ngx_feature_run=yes
++    ngx_feature_run=no
+     ngx_feature_incs=
+     ngx_feature_path=
+     ngx_feature_libs=
+--- nginx-1.22.1.orig/auto/types/sizeof
++++ nginx-1.22.1/auto/types/sizeof
+@@ -26,7 +26,7 @@
+ $NGX_INCLUDE_AUTO_CONFIG_H
+ 
+ int main(void) {
+-    printf("%d", (int) sizeof($ngx_type));
++    char canary[1 - 2 * (sizeof($ngx_type) != 8)];
+     return 0;
+ }
+ 
+@@ -38,20 +38,55 @@
+ 
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+ 
++if [ -x $NGX_AUTOTEST ]; then
++    ngx_size_is_8=yes
++else
++    ngx_size_is_8=no
++fi
++
++rm -rf $NGX_AUTOTEST*
++
++cat << END > $NGX_AUTOTEST.c
++
++#include <sys/types.h>
++#include <sys/time.h>
++$NGX_INCLUDE_UNISTD_H
++#include <signal.h>
++#include <stdio.h>
++#include <sys/resource.h>
++$NGX_INCLUDE_INTTYPES_H
++$NGX_INCLUDE_AUTO_CONFIG_H
++
++int main(void) {
++    char canary[1 - 2 * (sizeof($ngx_type) != 4)];
++    return 0;
++}
++
++END
++
++
++ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
++          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
++
++eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+ 
+ if [ -x $NGX_AUTOTEST ]; then
+-    ngx_size=`$NGX_AUTOTEST`
+-    echo " $ngx_size bytes"
++    ngx_size_is_4=yes
++else
++    ngx_size_is_4=no
+ fi
+ 
++rm -rf $NGX_AUTOTEST*
+ 
+-case $ngx_size in
+-    4)
++case $ngx_size_is_8:$ngx_size_is_4 in
++    no:yes)
++	ngx_size=4
+         ngx_max_value=2147483647
+         ngx_max_len='(sizeof("-2147483648") - 1)'
+     ;;
+ 
+-    8)
++    yes:no)
++	ngx_size=8
+         ngx_max_value=9223372036854775807LL
+         ngx_max_len='(sizeof("-9223372036854775808") - 1)'
+     ;;
+@@ -66,11 +101,7 @@
+         echo $ngx_test       >> $NGX_AUTOCONF_ERR
+         echo "----------"    >> $NGX_AUTOCONF_ERR
+ 
+-        rm -rf $NGX_AUTOTEST*
+-
+         exit 1
+ esac
+ 
+-
+-rm -rf $NGX_AUTOTEST*
+-
++echo " $ngx_size bytes"
+--- nginx-1.22.1.orig/auto/cc/conf
++++ nginx-1.22.1/auto/cc/conf
+@@ -180,6 +180,9 @@
+ 
+     if [ "$NGX_CC_NAME" = "sunc" ]; then
+         echo "checking for gcc builtin atomic operations ... disabled"
++    elif [ "$NGX_CC_NAME" = gcc ] && [ "$NGX_CROSSBUILD" = YES ]; then
++	echo "checking for gcc builtin atomic operations ... assumed available during cross build with gcc"
++        have=NGX_HAVE_GCC_ATOMIC . auto/have
+     else
+         ngx_feature="gcc builtin atomic operations"
+         ngx_feature_name=NGX_HAVE_GCC_ATOMIC
+--- nginx-1.22.1.orig/auto/options
++++ nginx-1.22.1/auto/options
+@@ -34,6 +34,7 @@
+ NGX_TEST_BUILD_SOLARIS_SENDFILEV=NO
+ 
+ NGX_PLATFORM=
++NGX_CROSSBUILD=NO
+ NGX_WINE=
+ 
+ EVENT_FOUND=NO
+@@ -197,7 +198,10 @@
+         --user=*)                        NGX_USER="$value"          ;;
+         --group=*)                       NGX_GROUP="$value"         ;;
+ 
+-        --crossbuild=*)                  NGX_PLATFORM="$value"      ;;
++        --crossbuild=*)
++            NGX_PLATFORM="$value"
++            NGX_CROSSBUILD=YES
++        ;;
+ 
+         --build=*)                       NGX_BUILD="$value"         ;;
+         --builddir=*)                    NGX_OBJS="$value"          ;;
+--- nginx-1.22.1.orig/auto/unix
++++ nginx-1.22.1/auto/unix
+@@ -805,7 +805,12 @@
+ 
+ ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
+ ngx_feature_name="NGX_HAVE_MAP_ANON"
+-ngx_feature_run=yes
++if [ "$NGX_CROSSBUILD" = YES ]; then
++    # Assume that mmap works if it is defined and the macros work.
++    ngx_feature_run=no
++else
++    ngx_feature_run=yes
++fi
+ ngx_feature_incs="#include <sys/mman.h>"
+ ngx_feature_path=
+ ngx_feature_libs=
diff --minimal -Nru nginx-1.22.1/debian/patches/series nginx-1.22.1/debian/patches/series
--- nginx-1.22.1/debian/patches/series	2022-12-08 14:15:15.000000000 +0100
+++ nginx-1.22.1/debian/patches/series	2022-12-11 12:05:06.000000000 +0100
@@ -2,3 +2,4 @@
 nginx-fix-pidfile.patch
 nginx-ssl_cert_cb_yield.patch
 bug-1024605.patch
+cross.patch
diff --minimal -Nru nginx-1.22.1/debian/rules nginx-1.22.1/debian/rules
--- nginx-1.22.1/debian/rules	2022-12-08 14:15:15.000000000 +0100
+++ nginx-1.22.1/debian/rules	2022-12-11 12:05:06.000000000 +0100
@@ -2,6 +2,8 @@
 export DH_VERBOSE=1
 
 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+include /usr/share/dpkg/architecture.mk
+include /usr/share/dpkg/buildtools.mk
 debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) -fPIC $(shell dpkg-buildflags --get CPPFLAGS)
 debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS) -fPIC
 
@@ -30,11 +32,14 @@
 BASEDIR = $(CURDIR)
 $(foreach flavour,$(FLAVOURS) src ,$(eval BUILDDIR_$(flavour) = $(CURDIR)/debian/build-$(flavour)))
 
-DEB_BUILD_ARCH ?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
-ifeq ($(DEB_BUILD_ARCH),sparc)
+ifeq ($(DEB_HOST_ARCH),sparc)
 	debian_cflags += -m32 -mcpu=ultrasparc
 endif
 
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+export PERL5LIB=/usr/lib/$(DEB_HOST_MULTIARCH)/perl/cross-config-$(shell perl -MConfig -e 'print $$Config{version}')
+endif
+
 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
 	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
 	MAKEFLAGS += -j$(NUMJOBS)
@@ -70,10 +75,23 @@
 			--with-threads
 
 common_configure_flags := \
+			--with-cc="$(CC)" \
 			--with-cc-opt="$(debian_cflags)" \
 			--with-ld-opt="$(debian_ldflags)" \
 			$(basic_configure_flags)
 
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+ ifeq ($(DEB_HOST_ARCH_OS),linux)
+	common_configure_flags += --crossbuild=Linux::
+ endif
+ ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
+	common_configure_flags += --crossbuild=FreeBSD::
+ endif
+ ifeq ($(DEB_HOST_ARCH_OS),hurd)
+	common_configure_flags += --crossbuild=GNU::
+ endif
+endif
+
 light_configure_flags := \
 			$(common_configure_flags) \
 			--with-http_gzip_static_module \


More information about the Pkg-nginx-maintainers mailing list