All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit branch/2021.05.x] package/nginx: override endianness
@ 2021-09-10  9:51 Peter Korsgaard
  0 siblings, 0 replies; only message in thread
From: Peter Korsgaard @ 2021-09-10  9:51 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=ae40953bc4966601d0114a784fd294b3360ae240
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2021.05.x

Though several cross-compilation patches exist in buildroot's nginx
package dir they do not seem to address endianness.

The test program generated by the configure script compiles but fails
to run (as it is built for another architecture) but the script does
not distinguish between the failure to run the program and an
indication of certain endianness.  As such the fallback of big-endian
is used.  This setting then causes http2 headers (anything not in the
static dictionary) to come out as undecipherable trash on 64bit
targets (see ngx_http_v2_huff_encode_buf()).

This commit includes a patch to the configure script to allow a
`--force-endianness=big|little` flag as well as setting that flag in
buildroot's package makefile.

Signed-off-by: Nevo Hed <nhed+buildroot@starry.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit e205b5ec1819d44f95c1886c5004be0eeabf56b3)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 ...rcing-of-endianness-for-cross-compilation.patch | 118 +++++++++++++++++++++
 package/nginx/nginx.mk                             |   1 +
 2 files changed, 119 insertions(+)

diff --git a/package/nginx/0010-Allow-forcing-of-endianness-for-cross-compilation.patch b/package/nginx/0010-Allow-forcing-of-endianness-for-cross-compilation.patch
new file mode 100644
index 0000000000..3810412b52
--- /dev/null
+++ b/package/nginx/0010-Allow-forcing-of-endianness-for-cross-compilation.patch
@@ -0,0 +1,118 @@
+From 4bd8fe780ff2064f2d4e9c905d8a98dd0f9b6191 Mon Sep 17 00:00:00 2001
+From: Nevo Hed <nhed+buildroot@starry.com>
+Date: Mon, 30 Aug 2021 13:28:13 -0400
+Subject: [PATCH] Allow forcing of endianness for cross-compilation
+
+Upstream-status: Invalid (upstream doesn't support cross-compilation)
+See https://trac.nginx.org/nginx/ticket/2240
+
+Signed-off-by: Nevo Hed <nhed+buildroot@starry.com>
+---
+ auto/endianness | 61 ++++++++++++++++++++++++++++++++-----------------
+ auto/options    |  6 +++++
+ 2 files changed, 46 insertions(+), 21 deletions(-)
+
+diff --git a/auto/endianness b/auto/endianness
+index 1b552b6b..4b2a3cd7 100644
+--- a/auto/endianness
++++ b/auto/endianness
+@@ -26,25 +26,44 @@ int main(void) {
+ 
+ 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
+-    if $NGX_AUTOTEST >/dev/null 2>&1; then
+-        echo " little endian"
++case "${NGX_FORCE_ENDIANNESS}" in
++    little)
++        echo " little endian (forced)"
+         have=NGX_HAVE_LITTLE_ENDIAN . auto/have
+-    else
+-        echo " big endian"
+-    fi
+-
+-    rm -rf $NGX_AUTOTEST*
+-
+-else
+-    rm -rf $NGX_AUTOTEST*
+-
+-    echo
+-    echo "$0: error: cannot detect system byte ordering"
+-    exit 1
+-fi
++    ;;
++
++    big)
++        echo " big endian (forced)"
++    ;;
++
++    "")
++        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
++            if $NGX_AUTOTEST >/dev/null 2>&1; then
++                echo " little endian"
++                have=NGX_HAVE_LITTLE_ENDIAN . auto/have
++            else
++                echo " big endian"
++            fi
++
++            rm -rf $NGX_AUTOTEST*
++
++        else
++            rm -rf $NGX_AUTOTEST*
++
++            echo
++            echo "$0: error: cannot detect system byte ordering"
++            exit 1
++        fi
++    ;;
++
++    *)
++        echo
++        echo "$0: error: invalid \"--force-endianness=${NGX_FORCE_ENDIANNESS}\""
++        exit 1
++    ;;
++esac
+diff --git a/auto/options b/auto/options
+index 80be906e..85a06456 100644
+--- a/auto/options
++++ b/auto/options
+@@ -17,6 +17,8 @@ NGX_USER=
+ NGX_GROUP=
+ NGX_BUILD=
+ 
++NGX_FORCE_ENDIANNESS=
++
+ CC=${CC:-cc}
+ CPP=
+ NGX_OBJS=objs
+@@ -196,6 +198,8 @@ do
+         --user=*)                        NGX_USER="$value"          ;;
+         --group=*)                       NGX_GROUP="$value"         ;;
+ 
++        --force-endianness=*)            NGX_FORCE_ENDIANNESS="$value" ;;
++
+         --crossbuild=*)                  NGX_PLATFORM="$value"      ;;
+ 
+         --build=*)                       NGX_BUILD="$value"         ;;
+@@ -432,6 +436,8 @@ cat << END
+   --build=NAME                       set build name
+   --builddir=DIR                     set build directory
+ 
++  --force-endianness=<big>|<little>  force endianness
++
+   --with-select_module               enable select module
+   --without-select_module            disable select module
+   --with-poll_module                 enable poll module
+-- 
+2.31.1
+
diff --git a/package/nginx/nginx.mk b/package/nginx/nginx.mk
index e93e802fd3..6e3883e136 100644
--- a/package/nginx/nginx.mk
+++ b/package/nginx/nginx.mk
@@ -52,6 +52,7 @@ NGINX_CONF_ENV += \
 
 # prefix: nginx root configuration location
 NGINX_CONF_OPTS += \
+	--force-endianness=$(call qstrip,$(call LOWERCASE,$(BR2_ENDIAN))) \
 	--prefix=/usr \
 	--conf-path=/etc/nginx/nginx.conf \
 	--sbin-path=/usr/sbin/nginx \
_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-10  9:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  9:51 [Buildroot] [git commit branch/2021.05.x] package/nginx: override endianness Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.