[SERVER-55395] 4.0.23 does not build with gcc 10 Created: 22/Mar/21  Updated: 29/Oct/23  Resolved: 01/Apr/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.0.23
Fix Version/s: 4.4.11, 4.0.24, 4.2.14, 4.9.0-rc1, 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Oleg Pudeyev (Inactive) Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
is duplicated by SERVER-54384 stdx/thread.h needs to include <cstdlib> Closed
Related
is related to SERVER-55663 Document upper bounds on supported co... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.9, v4.4, v4.2, v4.0
Sprint: Service Arch 2021-04-05
Participants:

 Description   

When I build the server 4.0.23 with gcc 10, I get the following error:

Compiling build/opt/mongo/util/clock_source.o
In file included from src/mongo/util/clock_source.cpp:33:
src/mongo/stdx/thread.h: In member function 'void mongo::stdx::support::SigAltStackController::_install() const':
src/mongo/stdx/thread.h:82:13: error: 'abort' was not declared in this scope
   82 |             abort();
      |             ^~~~~
src/mongo/stdx/thread.h: In member function 'void mongo::stdx::support::SigAltStackController::_uninstall() const':
src/mongo/stdx/thread.h:90:13: error: 'abort' was not declared in this scope
   90 |             abort();
      |             ^~~~~
scons: *** [build/opt/mongo/util/clock_source.o] Error 1

Tail of build transcript:

Compiling build/opt/mongo/db/logical_clock.o
Compiling build/opt/third_party/gperftools-2.5/src/maybe_threads.o
Compiling build/opt/mongo/db/repl/always_allow_non_local_writes.o
Compiling build/opt/third_party/s2/s2regionunion.o
Compiling build/opt/third_party/icu4c-57.1/source/i18n/numsys.o
Compiling build/opt/third_party/icu4c-57.1/source/common/uniset_closure.o
Compiling build/opt/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid32_nearbyintd.o
Compiling build/opt/third_party/zlib-1.2.11/inftrees.o
Compiling build/opt/third_party/gperftools-2.5/src/internal_logging.o
src/third_party/gperftools-2.5/src/internal_logging.cc: In function 'void tcmalloc::WriteMessage(const char*, int)':
src/third_party/gperftools-2.5/src/internal_logging.cc:58:8: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   write(STDERR_FILENO, msg, length);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling build/opt/third_party/mozjs-45/platform/x86_64/linux/build/Unified_cpp_js_src25.o
Compiling build/opt/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid32_ldexp.o
Compiling build/opt/third_party/icu4c-57.1/source/common/uchar.o
Compiling build/opt/third_party/icu4c-57.1/source/common/ucnv_cnv.o
Compiling build/opt/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid128_tgamma.o
Compiling build/opt/mongo/util/itoa.o
Compiling build/opt/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid64_to_uint8.o
Compiling build/opt/mongo/util/net/sock.o
In member function 'js::TemporaryTypeSet* js::jit::IonBuilder::computeHeapType(const js::TemporaryTypeSet*, jsid)':
cc1plus: warning: function may return address of local variable [-Wreturn-local-addr]
In file included from src/third_party/mozjs-45/platform/x86_64/linux/build/Unified_cpp_js_src12.cpp:47:
src/third_party/mozjs-45/extract/js/src/jit/IonBuilder.cpp:9259:22: note: declared here
 9259 |     TemporaryTypeSet empty;
      |                      ^~~~~
Compiling build/opt/third_party/mozjs-45/platform/x86_64/linux/build/Unified_cpp_js_src19.o
Compiling build/opt/third_party/mozjs-45/platform/x86_64/linux/build/Unified_cpp_js_src26.o
Compiling build/opt/mongo/util/clock_source.o
In file included from src/mongo/util/clock_source.cpp:33:
src/mongo/stdx/thread.h: In member function 'void mongo::stdx::support::SigAltStackController::_install() const':
src/mongo/stdx/thread.h:82:13: error: 'abort' was not declared in this scope
   82 |             abort();
      |             ^~~~~
src/mongo/stdx/thread.h: In member function 'void mongo::stdx::support::SigAltStackController::_uninstall() const':
src/mongo/stdx/thread.h:90:13: error: 'abort' was not declared in this scope
   90 |             abort();
      |             ^~~~~
scons: *** [build/opt/mongo/util/clock_source.o] Error 1
scons: building terminated because of errors.
build/opt/mongo/util/clock_source.o failed: Error 1

 
(.2) serene% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6) 

The abort() call appears to have been added in 4.0.21. I successfully built 4.0.19 previously.



 Comments   
Comment by Githook User [ 21/Oct/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-55395 stdx/thread.h needs cstdlib

(cherry picked from commit 47f28ebf7feb4c37e9bdf07d0356d389c75ad5f3)
Branch: v4.4
https://github.com/mongodb/mongo/commit/e9a9c9f342381cbe332bb1c46ecfbd15924c7150

Comment by Githook User [ 01/Apr/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-55395 stdx/thread.h needs cstdlib
Branch: v4.0
https://github.com/mongodb/mongo/commit/09544c3bb1fe2fc8450c474913e2b8a1c515df46

Comment by Githook User [ 31/Mar/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-55395 stdx/thread.h needs cstdlib
Branch: master
https://github.com/mongodb/mongo/commit/47f28ebf7feb4c37e9bdf07d0356d389c75ad5f3

Comment by Githook User [ 31/Mar/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-55395 stdx/thread.h needs cstdlib
Branch: v4.9
https://github.com/mongodb/mongo/commit/3ce3f09f0378fc7f24131b1d14e4f0ffb0d63a98

Comment by Githook User [ 31/Mar/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-55395 stdx/thread.h needs cstdlib
Branch: v4.2
https://github.com/mongodb/mongo/commit/236851ab2a1221e76dc8662e7ab4ba80ae0e7116

Comment by Oleg Pudeyev (Inactive) [ 31/Mar/21 ]

Testing now, thank you billy.donahue.

Comment by Oleg Pudeyev (Inactive) [ 31/Mar/21 ]

acm I am happy to test a patch but, given the server's build time, I'd rather not attempt to develop said patch.

Comment by Billy Donahue [ 31/Mar/21 ]

CR https://mongodbcr.appspot.com/778010001/

Comment by Billy Donahue [ 31/Mar/21 ]

Yes I can do it.

Comment by Andrew Morrow (Inactive) [ 29/Mar/21 ]

oleg.pudeyev - Which minor version of GCC 5 we are require isn't particularly germane to whether or not it builds with GCC 10 and is, as you pointed out, already documented, so I just didn't specify. As far as GCC 10 support goes, if the fix is trivial, sure we can make it. Send a PR. But it is an explicit non-goal of the server development process to require that the product build with all versions of the major compilers. We build with the documented one. Newer compilers may work, they may not. The older the branch, the less likely we are to adapt it for newer compilers. You can always use the mongodbtoolchain to build if you have a system compiler that isn't suitable.

Comment by Oleg Pudeyev (Inactive) [ 29/Mar/21 ]

I can test a patch on my system if needed.

gcc 10 is the default system compiler on devuan testing, 4.2/4.4 build without errors.

Note that https://github.com/mongodb/mongo/blob/r4.0.23/docs/building.md specifies "GCC 5.4.0 or newer", this seems to be different from "only GCC 5.x is supported".

Comment by Andrew Morrow (Inactive) [ 29/Mar/21 ]

This is almost certainly due to the backport of SERVER-15902 to v4.0, as that change was the one that introduced the abort call. However, we in general don't officially support building v4.0 with anything other than the v2 GCC version, which is GCC 5 IIRC. We attempt to deal with novel warnings in compilers newer than that via --disable-warnings-as-errors, but that is insufficient in this instance since the diagnostic is at the error level. Presumably, the fix for this is as simple as including <cstdlib> to the headers in thread.h. oleg.pudeyev, if you would like to try that out, and if you find it fixes the issue on v4.0, we could probably move forward with that fix.

Have you tested v4.2, v4.4 with GCC 10?

CC billy.donahue.

Generated at Thu Feb 08 05:36:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.