Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTBFS/Regression in nghttp2 1.61.0 => 1.62.0 with gcc 11 #2194

Open
moonlitbugs opened this issue May 13, 2024 · 9 comments
Open

FTBFS/Regression in nghttp2 1.61.0 => 1.62.0 with gcc 11 #2194

moonlitbugs opened this issue May 13, 2024 · 9 comments

Comments

@moonlitbugs
Copy link

Compiling nghttp2 1.62.0 fails on stable Linux distros that use gcc 11 as their compiler, such as the stable Slackware 15.0 which uses gcc 11.2.0. Compiling against gcc-13 works fine. The previous versions of nghttp2, 1.61.0 and below, are not affected.

Example:

# make V=1
make  all-recursive
make[3]: Entering directory 'nghttp2-1.62.0/src'
depbase=`echo util.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -std=gnu++20 -DHAVE_CONFIG_H -I. -I..  -DPKGDATADIR='"/usr/share/nghttp2"' -DPKGLIBDIR='"/usr/lib64/nghttp2"' -I../lib/includes -I../lib/includes -I../lib -I../third-party -I../third-party/llhttp/include -I/usr/include/libxml2 -DHAVE_CONFIG_H    -g -O2 -fPIC -march=opteron -MT util.o -MD -MP -MF $depbase.Tpo -c -o util.o util.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from util.h:57,
                 from util.cc:25:
template.h: In constructor ‘constexpr nghttp2::ImmutableString::ImmutableString(const string&)’:
template.h:233:19: error: call to non-‘constexpr’ function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
  233 |       : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
      |             ~~~~~~^~
In file included from /usr/include/c++/11.2.0/string:55,
                 from util.h:42,
                 from util.cc:25:
/usr/include/c++/11.2.0/bits/basic_string.h:919:7: note: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ declared here
  919 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~

As a possible workaround, I tried switching between std=c++20 and std=gnu++20 and std=c++17, optionally with HAVE_CXX20=0, but all of those failed with more errors.

@xl32
Copy link

xl32 commented May 13, 2024

GCC 12 (latest version available for EL7) also fails with the same error. GCC 13 is ok.

g++ -std=gnu++20 -DHAVE_CONFIG_H -I. -I..  -DPKGDATADIR='"/usr/share/nghttp2"' -DPKGLIBDIR='"/usr/lib64/nghttp2"' -I../lib/includes -I../lib/includes -I../lib -I../third-party -I../third-party/llhttp/include -I/usr/include/libxml2 -DHAVE_CONFIG_H      -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -c -o libnghttpx_a-shrpx_config.o `test -f 'shrpx_config.cc' || echo './'`shrpx_config.cc
In file included from util.h:57,
                 from http2.h:40,
                 from http2.cc:25:
template.h: In constructor 'constexpr nghttp2::ImmutableString::ImmutableString(const std::string&)':
template.h:233:19: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  233 |       : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
      |             ~~~~~~^~
In file included from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/basic_string.h:51,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/string:53,
                 from http2.h:32:
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In function 'constexpr bool nghttp2::operator==(const ImmutableString&, const std::string&)':
template.h:325:32: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  325 |   return lhs.size() == rhs.size() &&
      |                        ~~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In constructor 'constexpr nghttp2::StringRef::StringRef(const std::string&)':
template.h:363:59: error: call to non-'constexpr' function 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  363 |   constexpr StringRef(const std::string &s) : base(s.c_str()), len(s.size()) {}
      |                                                    ~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:2206:7: note: 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' declared here
 2206 |       c_str() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
In file included from util.h:57,
                 from app_helper.cc:57:
template.h: In constructor 'constexpr nghttp2::ImmutableString::ImmutableString(const std::string&)':
template.h:233:19: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  233 |       : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
      |             ~~~~~~^~
In file included from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/basic_string.h:51,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/string:53,
                 from app_helper.cc:49:
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In function 'constexpr bool nghttp2::operator==(const ImmutableString&, const std::string&)':
template.h:325:32: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  325 |   return lhs.size() == rhs.size() &&
      |                        ~~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In constructor 'constexpr nghttp2::StringRef::StringRef(const std::string&)':
template.h:363:59: error: call to non-'constexpr' function 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  363 |   constexpr StringRef(const std::string &s) : base(s.c_str()), len(s.size()) {}
      |                                                    ~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:2206:7: note: 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' declared here
 2206 |       c_str() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
In file included from util.h:57,
                 from util.cc:25:
template.h: In constructor 'constexpr nghttp2::ImmutableString::ImmutableString(const std::string&)':
template.h:233:19: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  233 |       : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
      |             ~~~~~~^~
In file included from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/basic_string.h:51,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/string:53,
                 from util.h:42:
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In function 'constexpr bool nghttp2::operator==(const ImmutableString&, const std::string&)':
template.h:325:32: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  325 |   return lhs.size() == rhs.size() &&
      |                        ~~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In constructor 'constexpr nghttp2::StringRef::StringRef(const std::string&)':
template.h:363:59: error: call to non-'constexpr' function 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  363 |   constexpr StringRef(const std::string &s) : base(s.c_str()), len(s.size()) {}
      |                                                    ~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:2206:7: note: 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' declared here
 2206 |       c_str() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
make[3]: *** [Makefile:1477: libnghttpx_a-app_helper.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:1463: libnghttpx_a-http2.o] Error 1
In file included from shrpx_log_config.h:34,
                 from shrpx_log.h:36,
                 from shrpx_config.h:54,
                 from shrpx_config.cc:25:
template.h: In constructor 'constexpr nghttp2::ImmutableString::ImmutableString(const std::string&)':
template.h:233:19: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  233 |       : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
      |             ~~~~~~^~
In file included from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/basic_string.h:51,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/string:53,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/locale_classes.h:40,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/ios_base.h:41,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/ios:42,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/ostream:38,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:41,
                 from /opt/rh/devtoolset-12/root/usr/include/c++/12/memory:76,
                 from shrpx_config.h:44:
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In function 'constexpr bool nghttp2::operator==(const ImmutableString&, const std::string&)':
template.h:325:32: error: call to non-'constexpr' function 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  325 |   return lhs.size() == rhs.size() &&
      |                        ~~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:913:7: note: 'std::basic_string<_CharT, _Traits, _Alloc>::size_type std::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' declared here
  913 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
template.h: In constructor 'constexpr nghttp2::StringRef::StringRef(const std::string&)':
template.h:363:59: error: call to non-'constexpr' function 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  363 |   constexpr StringRef(const std::string &s) : base(s.c_str()), len(s.size()) {}
      |                                                    ~~~~~~~^~
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/cow_string.h:2206:7: note: 'const _CharT* std::basic_string<_CharT, _Traits, _Alloc>::c_str() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' declared here
 2206 |       c_str() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
make[3]: *** [Makefile:1449: libnghttpx_a-util.o] Error 1
make[3]: *** [Makefile:1505: libnghttpx_a-shrpx_config.o] Error 1
make[3]: Leaving directory '/home/builder/rpmbuild/BUILD/nghttp2-1.62.0/src'
make[2]: *** [Makefile:2353: all-recursive] Error 1
make[2]: Leaving directory '/home/builder/rpmbuild/BUILD/nghttp2-1.62.0/src'
make[1]: *** [Makefile:559: all-recursive] Error 1
make[1]: Leaving directory '/home/builder/rpmbuild/BUILD/nghttp2-1.62.0'
make: *** [Makefile:467: all] Error 2

@tatsuhiro-t
Copy link
Member

gcc-11 probably does not work anymore due to C++20 requirement. gcc-12 works on our GithHub Actions workflow.

@moonlitbugs
Copy link
Author

According to the config.log, gcc-11 was tested and found to comply with c++20 features when either of -std=c++20 or -std=gnu++20 were specified. Here's a snippet of the output:

configure:20266: checking whether g++ supports C++20 features with -std=gnu++20
configure:21093: g++ -std=gnu++20 -c   conftest.cpp >&5
conftest.cpp:140:36: warning: 'volatile'-qualified parameter is deprecated [-Wvolatile]
configure:21093: $? = 0
configure:21103: result: yes

According to the report from @xl32, and despite the Github Actions cited above, gcc-12 also fails, and with the same error messages.

While this may be gcc's bug, the fact that it affects gcc-12 in RHEL7 (and likely many other similar GNU/Linux distros) suggests this FTBFS will be a problem of more widespread interest. If any further updates to nghttp2 contain fixes for 0-day security vulnerabilities and the like, those distributions will want to roll out patches ASAP; and they will have only gcc-11 or gcc-12 available for the compile.

Is it the intention of the nghttp2 developers to roll out nghttp2-1.61.1 and -1.61.2, etc etc., for the foreseeable future, for those distributions which are locked into gcc-11 or gcc-12? Should this c++20 requirement be backed out and moved to nghttp2-2.x as it is not present in nghttp2-1.61? Or add appropriate #ifdef feature-check blocks to avoid the FTBFS?

@tatsuhiro-t
Copy link
Member

Even though gcc says it supports -std=c++20, the actual implementation status of C++ features varies across versions. Also the linux distribution vendors package compilers with their own patches, so it is kind a hard to check the minimum version of gcc.

We only support the latest version of nghttp2. It is very hard to support distributions that do have no effort to bring newer compilers to backport to LTS or older releases. Adding ifdef just complicates the source code and we just tired and lose interest in this project, and will eventually abandon its development, that is not what we want.

@cmeister2
Copy link

Saw this in curl also. curl/curl#13650

@BrianInglis
Copy link

Ditto Cygwin g++ 11.4.
While g++ 12 and 13 are in test, there are issues with some other GCC components, so are not considered stable enough for promotion.
Other distros with many users and even more packages need to be able to be recompiled with newer compiler versions, including backports and LTS releases, extending the testing required, and even longer lead times to promotion.
Distros with latest compilers and packages are those with fewer users and packages and variants; some I've never heard of! ;^>
You should check which g++ version supports the features you need, check that and fail during configure, rather than fail during make.

carlocab added a commit to Homebrew/brew that referenced this issue May 28, 2024
Needed for Homebrew/homebrew-core#171634 due to nghttp2/nghttp2#2194.

I've avoided adding an allowlist for now because I really don't want to
see this list grow.
carlocab added a commit to Homebrew/brew that referenced this issue May 29, 2024
richardlau added a commit to richardlau/build that referenced this issue Jun 5, 2024
Use gcc 12 to compile h2load as latest nghttp2 does not compile
with gcc 11.

Refs: nghttp2/nghttp2#2194
richardlau added a commit to nodejs/build that referenced this issue Jun 7, 2024
Use gcc 12 to compile h2load as latest nghttp2 does not compile
with gcc 11.

Refs: nghttp2/nghttp2#2194
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jun 18, 2024
@moonlitbugs
Copy link
Author

The "solution" I used to make nghttp2 1.62 work is, well, not ideal:

  • I put together a distribution build script for gcc-14 and built packages for it.
  • Replace the packages for gcc-11 with gcc-14
  • Manually delete libgcc_s.so.1 !!!
  • Compile nghttp2, which now links statically against libgcc_s.a
  • Revert the packages for gcc-14 with the original gcc-11 ones.
    N.B.: nghttp2 will not load due to missing features in gcc-11's libgcc_s.so, necessitating a static link.
  • Recompile anything else under gcc-11 that needs to link with the new libnghttp2, if necessary.

While this is a nice SysAdmin tabletop exercise, it does not lend itself well to a distribution's automation, which may see several non-conflicting packages being updated/compiled in parallel. Replacing gcc from underneath another build process while that build process is actively compiling source files is not what I had wished to accompany my morning coffee. 😄

To be fair, the reverse issue of building packages under gcc-14 that were engineered for earlier standards has been even more "fun" than this one. And this is, in turn, so much nicer than yet another ABI change in libpoppler; but I digress. 😉

@tatsuhiro-t
Copy link
Member

I hope that slackware updates its compilers so that this kind of issues go away.
libnghttp2 itself is plain C, which can be compiled with any modern compilers. C++ part is tricky like this, so you can pass CC=gcc-11 CXX=g++-14 and build nghttp2, which workarounds the non-ideal part of build issue?

@github-actions github-actions bot removed the Stale label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants