Welcome to Centmin Mod Community
Become a Member

Upgrade Nginx NGINX v1.21.6 fails to recompile

Discussion in 'Install & Upgrades or Pre-Install Questions' started by happyhacking, May 11, 2022.

  1. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
    After doing some tests today i discovered that the routine to rebuild nginx on centmin menu "4). Nginx Upgrade / Downgrade" fails after the latest updates, my last succesful upgrade build was the march 17 when "update Nginx OpenSSL 1.1.1n in 123.09beta01" was commited to centminmod_123.09beta01.b802, then i did a new rebuild try the may 5th because "Nginx OpenSSL 1.1.1o update in 123.09beta01" commited to centminmod_123.09beta01.b813, but today i found that the rebuild failed to upgrade nginx and luckly for me the script avoided to overwrite the working build from march 17.


    So, looking at the logs which i'll attach here: March 17 and May 5th
    After searching in the logs it appears there is a problem with brotli make routine:
    Code:
    BROTLI_CFLAG= -Wno-deprecated-declarations
    download ngx_brotli module
    Cloning into 'ngx_brotli'...
    Submodule 'deps/brotli' (https://github.com/google/brotli.git) registered for path 'deps/brotli'
    Cloning into 'deps/brotli'...
    Submodule path 'deps/brotli': checked out 'f4153a09f87cbb9c826d8fc12c74642bb2d879ea'
    
    real    0m4.121s
    user    0m2.268s
    sys    0m1.899s
    CMake Error at CMakeLists.txt:11 (cmake_policy):
      Policy "CMP0048" is not known to this version of CMake.
    
    
    -- The C compiler identification is GNU 10.2.1
    -- Check for working C compiler: /usr/local/bin/ccache
    -- Check for working C compiler: /usr/local/bin/ccache -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Build type is 'Debug'
    -- Performing Test BROTLI_EMSCRIPTEN
    -- Performing Test BROTLI_EMSCRIPTEN - Failed
    -- Compiler is not EMSCRIPTEN
    -- Looking for log2
    -- Looking for log2 - not found
    -- Looking for log2
    -- Looking for log2 - found
    -- Configuring incomplete, errors occurred!
    ###########################################################################
          |                ;
    In file included from ../ngx_brotli/deps/brotli/c/enc/hash.h:21,
                     from ../ngx_brotli/deps/brotli/c/enc/encoder_dict.c:19:
    ../ngx_brotli/deps/brotli/c/enc/fast_log.h:35:16: error: expected ‘;’ before ‘extern’
       35 | BROTLI_INTERNAL extern const double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE];
          |                ^~~~~~~
          |                ;
    In file included from ../ngx_brotli/deps/brotli/c/enc/hash.h:25,
                     from ../ngx_brotli/deps/brotli/c/enc/encoder_dict.c:19:
    ../ngx_brotli/deps/brotli/c/enc/static_dict.h:31:16: error: expected ‘;’ before ‘int’
       31 | BROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches(
          |                ^
          |                ;
    cc1: note: unrecognized command-line option ‘-Wno-vla-parameter’ may have been intended to silence earlier diagnostics
    make[1]: *** [objs/addon/enc/encoder_dict.o] Error 1
    make[1]: Leaving directory `/svr-setup/nginx-1.21.6'
    make: *** [build] Error 2
    
    real    0m23.757s
    user    2m13.658s
    sys    0m43.074s
    
    Thu May  5 01:14:14 CDT 2022
    Error: 2, Nginx make failed
    
    And here is the CMakeError.log
    Code:
    Performing C SOURCE FILE Test BROTLI_EMSCRIPTEN failed with the following output:
    Change Dir: /svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp
    
    Run Build Command:/bin/gmake "cmTryCompileExec4170860762/fast"
    /bin/gmake -f CMakeFiles/cmTryCompileExec4170860762.dir/build.make CMakeFiles/cmTryCompileExec4170860762.dir/build
    gmake[1]: Entering directory `/svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp'
    /usr/bin/cmake -E cmake_progress_report /svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp/CMakeFiles 1
    Building C object CMakeFiles/cmTryCompileExec4170860762.dir/src.c.o
    /usr/local/bin/ccache  gcc  -DBROTLI_EMSCRIPTEN   -o CMakeFiles/cmTryCompileExec4170860762.dir/src.c.o   -c /svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp/src.c
    Linking C executable cmTryCompileExec4170860762
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec4170860762.dir/link.txt --verbose=1
    /usr/local/bin/ccache  gcc  -DBROTLI_EMSCRIPTEN    CMakeFiles/cmTryCompileExec4170860762.dir/src.c.o  -o cmTryCompileExec4170860762 -rdynamic
    /opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /lib/../lib64/crt1.o: in function `_start':
    (.text+0x20): undefined reference to `main'
    collect2: error: ld returned 1 exit status
    gmake[1]: Leaving directory `/svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp'
    gmake[1]: *** [cmTryCompileExec4170860762] Error 1
    gmake: *** [cmTryCompileExec4170860762/fast] Error 2
    
    Source file was:
    #if defined(__EMSCRIPTEN__)
       int main() {return 0;}
       #endif
    Determining if the function log2 exists failed with the following output:
    Change Dir: /svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp
    
    Run Build Command:/bin/gmake "cmTryCompileExec1176828493/fast"
    /bin/gmake -f CMakeFiles/cmTryCompileExec1176828493.dir/build.make CMakeFiles/cmTryCompileExec1176828493.dir/build
    gmake[1]: Entering directory `/svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp'
    /usr/bin/cmake -E cmake_progress_report /svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp/CMakeFiles 1
    Building C object CMakeFiles/cmTryCompileExec1176828493.dir/CheckFunctionExists.c.o
    /usr/local/bin/ccache  gcc  -DCHECK_FUNCTION_EXISTS=log2   -o CMakeFiles/cmTryCompileExec1176828493.dir/CheckFunctionExists.c.o   -c /usr/share/cmake/Modules/CheckFunctionExists.c
    <command-line>: warning: conflicting types for built-in function ‘log2’; expected ‘double(double)’ [-Wbuiltin-declaration-mismatch]
    /usr/share/cmake/Modules/CheckFunctionExists.c:3:6: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
        3 | char CHECK_FUNCTION_EXISTS();
          |      ^~~~~~~~~~~~~~~~~~~~~
    /usr/share/cmake/Modules/CheckFunctionExists.c:1:1: note: ‘log2’ is declared in header ‘<math.h>’
      +++ |+#include <math.h>
        1 | #ifdef CHECK_FUNCTION_EXISTS
    Linking C executable cmTryCompileExec1176828493
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1176828493.dir/link.txt --verbose=1
    /usr/local/bin/ccache  gcc  -DCHECK_FUNCTION_EXISTS=log2    CMakeFiles/cmTryCompileExec1176828493.dir/CheckFunctionExists.c.o  -o cmTryCompileExec1176828493 -rdynamic
    /opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: CMakeFiles/cmTryCompileExec1176828493.dir/CheckFunctionExists.c.o: in function `main':
    CheckFunctionExists.c:(.text+0x15): undefined reference to `log2'
    collect2: error: ld returned 1 exit status
    gmake[1]: *** [cmTryCompileExec1176828493] Error 1
    gmake[1]: Leaving directory `/svr-setup/ngx_brotli/deps/brotli/CMakeFiles/CMakeTmp'
    gmake: *** [cmTryCompileExec1176828493/fast] Error 2
    
    because of this bug at the moment i cannot update nginx
     

    Attached Files:

  2. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    Yeah I ran across this Brotli bug the other day didn't have time to look at it as it only happened on 1 specific server and not the rest of my servers. I just disabled Brotli on that specific server until I have time to investigate.

    It's probably a Brotli upstream code change/update causing issues. Thanks for the reminder to check it out :)
    By design failed Nginx compiles can't override working Nginx binaries as the upgrade process aborts before it has a chance to replace the Nginx binaries. So working Nginx version should remind intact :)
     
  3. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    This is on working server with ngx_brotli and Centmin Mod Nginx with latest ngx_brotli commit too Commits · google/ngx_brotli with hash 6e975bc
     
  4. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    Ah looked at your logs and see possible issue that ngx_brotli has with version of cmake used
    Code (Text):
    BROTLI_CFLAG= -Wno-deprecated-declarations
    download ngx_brotli module
    Cloning into 'ngx_brotli'...
    Submodule 'deps/brotli' (https://github.com/google/brotli.git) registered for path 'deps/brotli'
    Cloning into 'deps/brotli'...
    Submodule path 'deps/brotli': checked out 'f4153a09f87cbb9c826d8fc12c74642bb2d879ea'
    
    real    0m4.121s
    user    0m2.268s
    sys    0m1.899s
    CMake Error at CMakeLists.txt:11 (cmake_policy):
      Policy "CMP0048" is not known to this version of CMake.
    

    cmake CMP0048 policy info - so cmake 2.8 doesn't recognise this policy and hence the error. Only cmake 3.0+ recognises the policy.
    Code (Text):
    cmake --help-policy CMP0048
    CMP0048
    -------
    
    The ``project()`` command manages ``VERSION`` variables.
    
    CMake version 3.0 introduced the ``VERSION`` option of the ``project()``
    command to specify a project version as well as the name.  In order to keep
    ``PROJECT_VERSION`` and related variables consistent with variable
    ``PROJECT_NAME`` it is necessary to set the ``VERSION`` variables
    to the empty string when no ``VERSION`` is given to ``project()``.
    However, this can change behavior for existing projects that set ``VERSION``
    variables themselves since ``project()`` may now clear them.
    This policy controls the behavior for compatibility with such projects.
    
    The ``OLD`` behavior for this policy is to leave ``VERSION`` variables untouched.
    The ``NEW`` behavior for this policy is to set ``VERSION`` as documented by the
    ``project()`` command.
    
    This policy was introduced in CMake version 3.0.
    CMake version 3.20.2 warns when the policy is not set and uses
    ``OLD`` behavior.  Use the ``cmake_policy()`` command to set
    it to ``OLD`` or ``NEW`` explicitly.
    
    .. note::
      The ``OLD`` behavior of a policy is
      ``deprecated by definition``
      and may be removed in a future version of CMake.


    CentOS 7 defaults to cmake YUM package with 2.8.x and side install package cmake3 YUM for 3.x version. Probably ngx_brotli latest submodule update increased the cmake version requirements to cmake 3.x. Centmin Mod has a routine to workaround this used for BoringSSL crypto library optional alternative to OpenSSL 1.1.1 with Nginx to use cmake3 YUM package version and switches system defaults via alternatives command/settings so when cmake is called, cmake3 package is used. My working systems had at one time tested and installed this routine so have cmake3 override in place so probably why some of my servers worked.

    I'll have to update 124.00stable and 130.00beta01 with the cmake3 workaround for ngx_brotli installs sometime today :)
     
  5. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    Try updating to 124.00stable or 130.00beta01 https://community.centminmod.com/threads/centmin-mod-124-00stable-130-00beta01-releases.22673/ as both have updated routines for ngx_brotli now

    For my problematic server, on 124.00stable with this update, ngx_brotli works now

     
  6. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
    Thank you for considering this scenario i have been worried that this failure could be persistent until centmin fix, but this is not since it doesnt overwrites working nginx on failed build. But as a side comment/bug i have the NGINX_UPDATEMAINTENANCE='y' option to show the maintenance page on updates, but when the build failed, it failed to remove the maintenance page and i have to do it manually by doing command "sitestatus online"
     
  7. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
  8. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    Ah a bug to fix. Thanks for bringing it to my attention. I've updated both 124.00stable and 130.00beta01 with the fix for that too :) See https://community.centminmod.com/threads/update-nginx_updatemaintenance-in-124-00stable.22745/

    Great to hear :D
     
  9. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
    Thanks again, now it even works with GCC 11.2.1

    Code:
    nginx version: nginx/1.21.6 (130522-022417-centos7-kvm-88042fc-br-6e975bc)
    built by gcc 11.2.1 20210728 (Red Hat 11.2.1-1) (GCC) 
    built with OpenSSL 1.1.1o  3 May 2022
    TLS SNI support enabled
    configure arguments: --with-ld-opt='-Wl,-E -L/usr/local/zlib-cf/lib -L/usr/local/nginx-dep/lib -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/zlib-cf/lib:/usr/local/nginx-dep/lib -flto=8 -fuse-ld=gold' --with-cc-opt='-I/usr/local/zlib-cf/include -I/usr/local/nginx-dep/include -m64 -march=native -DTCP_FASTOPEN=23 -g -O3 -Wno-strict-aliasing -fstack-protector-strong -flto=8 -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-pointer-sign -Wimplicit-fallthrough=0 -Wno-missing-profile -Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-result -Wno-unused-result -Wno-vla-parameter -fcode-hoisting -Wno-cast-function-type -Wno-format-extra-args -Wno-vla-parameter -Wp,-D_FORTIFY_SOURCE=2 -Wno-deprecated-declarations' --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --build=130522-022417-centos7-kvm-88042fc-br-6e975bc --with-compat --without-pcre2 --with-http_stub_status_module --with-http_secure_link_module --with-libatomic --with-http_gzip_static_module --add-dynamic-module=../ngx_brotli --with-http_sub_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --with-stream --with-stream_ssl_module --with-http_realip_module --add-dynamic-module=../ngx-fancyindex-0.4.2 --add-module=../ngx_cache_purge-2.5.1 --add-dynamic-module=../ngx_devel_kit-0.3.0 --add-dynamic-module=../set-misc-nginx-module-0.32 --add-dynamic-module=../echo-nginx-module-0.62 --add-module=../redis2-nginx-module-0.15 --add-module=../ngx_http_redis-0.3.7 --add-module=../memc-nginx-module-0.19 --add-module=../srcache-nginx-module-0.32 --add-dynamic-module=../headers-more-nginx-module-0.33 --with-pcre-jit --with-zlib=../zlib-cloudflare-1.3.0 --with-http_ssl_module --with-http_v2_module --with-http_v2_hpack_enc --with-openssl=../openssl-1.1.1o --with-openssl-opt='enable-ec_nistp_64_gcc_128 enable-tls1_3 -fuse-ld=gold'
    
    BTW: did you know if Devtoolset-11 works with php too? (I dont want to try the compilation since PGO takes a while)
     
  10. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    Yes GCC 11 works with Nginx and PHP-FPM (and PGO).
     
  11. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
    thank you so much eva2000

    pd: i’ll report a last bug i found, every time you create a virtual host through centmin menu, the nginx conf template always adds the “reuseport” option but this parameter just can be used once ie. only one vhost conf template should have reuseport, then everytime you add a host the nginx wont start because of this repetitive parameter at conf template.
     
  12. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    hmm that shouldn't be happening as I have a check for that. Will have another look into that :)

    edit: tested this and haven't been able to reproduce the issue, only one reuseport directive is set for HTTPS nginx vhosts as the routine checks if an existing reuseport directive exists first.
     
    Last edited: May 13, 2022
  13. happyhacking

    happyhacking Premium Member Premium Member

    72
    12
    8
    Apr 23, 2021
    Ratings:
    +37
    Local Time:
    11:28 AM
    1.22.0
    MariadDB 10.4.25
    This happened to me again with latest centmin update patch, and i already have a reuseport vhost config
     
  14. eva2000

    eva2000 Administrator Staff Member

    48,902
    11,190
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,424
    Local Time:
    2:28 AM
    Nginx 1.21.x
    MariaDB 10.x
    hmm, might need the log recorded at time of Nginx vhost creation. It would be in /root/centminlogs with label *addvhost*. It will have sensitive private info so might want to private message me.

    You can find the file name by either using of the below commands which lists logs in date ascending order - newest files at the bottom.
    Code (Text):
    ls -lAhrt /root/centminlogs | grep -i addvhost

    or
    Code (Text):
    cminfo listlogs | grep -i addvhost