0008-Allow-forcing-of-endianness-for-cross-compilation.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From 4bd8fe780ff2064f2d4e9c905d8a98dd0f9b6191 Mon Sep 17 00:00:00 2001
  2. From: Nevo Hed <nhed+buildroot@starry.com>
  3. Date: Mon, 30 Aug 2021 13:28:13 -0400
  4. Subject: [PATCH] Allow forcing of endianness for cross-compilation
  5. Upstream-status: Invalid (upstream doesn't support cross-compilation)
  6. See https://trac.nginx.org/nginx/ticket/2240
  7. Signed-off-by: Nevo Hed <nhed+buildroot@starry.com>
  8. ---
  9. auto/endianness | 61 ++++++++++++++++++++++++++++++++-----------------
  10. auto/options | 6 +++++
  11. 2 files changed, 46 insertions(+), 21 deletions(-)
  12. diff --git a/auto/endianness b/auto/endianness
  13. index 1b552b6b..4b2a3cd7 100644
  14. --- a/auto/endianness
  15. +++ b/auto/endianness
  16. @@ -26,25 +26,44 @@ int main(void) {
  17. END
  18. -ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
  19. - -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
  20. -
  21. -eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
  22. -
  23. -if [ -x $NGX_AUTOTEST ]; then
  24. - if $NGX_AUTOTEST >/dev/null 2>&1; then
  25. - echo " little endian"
  26. +case "${NGX_FORCE_ENDIANNESS}" in
  27. + little)
  28. + echo " little endian (forced)"
  29. have=NGX_HAVE_LITTLE_ENDIAN . auto/have
  30. - else
  31. - echo " big endian"
  32. - fi
  33. -
  34. - rm -rf $NGX_AUTOTEST*
  35. -
  36. -else
  37. - rm -rf $NGX_AUTOTEST*
  38. -
  39. - echo
  40. - echo "$0: error: cannot detect system byte ordering"
  41. - exit 1
  42. -fi
  43. + ;;
  44. +
  45. + big)
  46. + echo " big endian (forced)"
  47. + ;;
  48. +
  49. + "")
  50. + ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
  51. + -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
  52. +
  53. + eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
  54. +
  55. + if [ -x $NGX_AUTOTEST ]; then
  56. + if $NGX_AUTOTEST >/dev/null 2>&1; then
  57. + echo " little endian"
  58. + have=NGX_HAVE_LITTLE_ENDIAN . auto/have
  59. + else
  60. + echo " big endian"
  61. + fi
  62. +
  63. + rm -rf $NGX_AUTOTEST*
  64. +
  65. + else
  66. + rm -rf $NGX_AUTOTEST*
  67. +
  68. + echo
  69. + echo "$0: error: cannot detect system byte ordering"
  70. + exit 1
  71. + fi
  72. + ;;
  73. +
  74. + *)
  75. + echo
  76. + echo "$0: error: invalid \"--force-endianness=${NGX_FORCE_ENDIANNESS}\""
  77. + exit 1
  78. + ;;
  79. +esac
  80. diff --git a/auto/options b/auto/options
  81. index 80be906e..85a06456 100644
  82. --- a/auto/options
  83. +++ b/auto/options
  84. @@ -17,6 +17,8 @@ NGX_USER=
  85. NGX_GROUP=
  86. NGX_BUILD=
  87. +NGX_FORCE_ENDIANNESS=
  88. +
  89. CC=${CC:-cc}
  90. CPP=
  91. NGX_OBJS=objs
  92. @@ -196,6 +198,8 @@ do
  93. --user=*) NGX_USER="$value" ;;
  94. --group=*) NGX_GROUP="$value" ;;
  95. + --force-endianness=*) NGX_FORCE_ENDIANNESS="$value" ;;
  96. +
  97. --crossbuild=*) NGX_PLATFORM="$value" ;;
  98. --build=*) NGX_BUILD="$value" ;;
  99. @@ -432,6 +436,8 @@ cat << END
  100. --build=NAME set build name
  101. --builddir=DIR set build directory
  102. + --force-endianness=<big>|<little> force endianness
  103. +
  104. --with-select_module enable select module
  105. --without-select_module disable select module
  106. --with-poll_module enable poll module
  107. --
  108. 2.31.1