[SERVER-19746] 3.0.5 fails to build without c++11 Created: 04/Aug/15  Updated: 22/Sep/15  Resolved: 22/Sep/15

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 3.0.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Marek Skalický Assignee: Andrew Morrow (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File build.log    
Issue Links:
Duplicate
duplicates SERVER-19755 scons should require c++11 on 3.0 Closed
is duplicated by SERVER-20329 MongoDB 3.0.5 and newer not compiling... Closed
Operating System: ALL
Steps To Reproduce:

Try to build:

scons all -j4 --use-system-all --variant-dir=build.fc23 --nostrip --ssl --disable-warnings-as-errors --wiredtiger=on

with

$ gcc --version
gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sprint: Platform 9 (09/18/15), Platform A (10/09/15)
Participants:

 Description   

Mongodb 3.0.5 uses keyword "auto" from this commit.
And this keyword change meaning in c++11 standard. So compilation fails with this error:

src/mongo/shell/bench.cpp: In member function 'void mongo::BenchRunWorker::generateLoadOnConnection(mongo::DBClientBase*)':
src/mongo/shell/bench.cpp:379:17: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
                 auto& stats = shouldCollectStats() ? _stats : _statsBlackHole;
                 ^

See attached build.log



 Comments   
Comment by Ramon Fernandez Marina [ 22/Sep/15 ]

All, we're closing this ticket as a duplicate of SERVER-19755, which is already in flight. Please watch SERVER-19755 for updates and post any further information in that ticket.

Thanks,
Ramón.

Comment by Matthias Saou [ 22/Sep/15 ]

I see that SERVER-19755 might be better tracking this issue.

FWIW, I have been able to get the Fedora source rpm updated to 3.0.6 to build on EPEL7 by explicitly adding -std=c++11 to the CCFLAGS (both the %build and %install, otherwise scons tries to rebuild a second time).

This is where the spec may be found : http://pkgs.fedoraproject.org/cgit/mongodb.git/tree/mongodb.spec?id=293a130986c9b2aa3d4cecb73a7dc0f0616f757a (I updated the version and disabled the wiredtiger patch)

Note also that I have encountered another issue, related to boost, and I had to update to boost >= 1.57 because RHEL7 ships with boost 1.53. This is the issue : https://svn.boost.org/trac/boost/ticket/10038

Comment by Matthias Saou [ 11/Aug/15 ]

Note that I'm running into the exact same issue on Red Hat Enterprise Linux 7, which has gcc 4.8.3.

But it seems to be just a warning. I get errors after it. Once I add -Wno-c++0x-compat, it still fails and this is what I get :

[...]
g++ -o build/build.el7/mongo/shell/shell_utils_launcher.o -c -Wnon-virtual-dtor -Woverloaded-virtual -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -Wno-c++0x-compat -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -pipe -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp -D_SCONS -DMONGO_EXPOSE_MACROS -DPCRE_STATIC -DSUPPORT_UTF8 -DMONGO_OPTIMIZED_BUILD -DMONGO_BYTE_ORDER=1234 -D_FILE_OFFSET_BITS=64 -DMONGO_SSL -DMONGO_HAVE___THREAD -DMONGO_HAVE_GCC_ATOMIC_BUILTINS -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_VERSION=2 -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_POSIX_MONOTONIC_CLOCK -DMONGO_HAVE_EXECINFO_BACKTRACE -DMONGO_HAVE_FIPS_MODE_SET -Isrc/third_party/s2 -Ibuild/build.el7 -Isrc src/mongo/shell/shell_utils_launcher.cpp
src/mongo/shell/bench.cpp: In member function 'void mongo::BenchRunWorker::generateLoadOnConnection(mongo::DBClientBase*)':
src/mongo/shell/bench.cpp:379:23: error: ISO C++ forbids declaration of 'stats' with no type [-fpermissive]
                 auto& stats = shouldCollectStats() ? _stats : _statsBlackHole;
                       ^
src/mongo/shell/bench.cpp:379:63: error: invalid initialization of reference of type 'int&' from expression of type 'mongo::BenchRunStats'
                 auto& stats = shouldCollectStats() ? _stats : _statsBlackHole;
                                                               ^
src/mongo/shell/bench.cpp:429:61: error: request for member 'findOneCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.findOneCounter);
                                                             ^
src/mongo/shell/bench.cpp:439:39: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                 stats.errCount++;
                                       ^
src/mongo/shell/bench.cpp:453:61: error: request for member 'commandCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.commandCounter);
                                                             ^
src/mongo/shell/bench.cpp:461:35: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                             stats.errCount++;
                                   ^
src/mongo/shell/bench.cpp:468:39: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                 stats.errCount++;
                                       ^
src/mongo/shell/bench.cpp:493:61: error: request for member 'queryCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.queryCounter);
                                                             ^
src/mongo/shell/bench.cpp:498:61: error: request for member 'queryCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.queryCounter);
                                                             ^
src/mongo/shell/bench.cpp:515:39: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                 stats.errCount++;
                                       ^
src/mongo/shell/bench.cpp:534:61: error: request for member 'updateCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.updateCounter);
                                                             ^
src/mongo/shell/bench.cpp:568:43: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                     stats.errCount++;
                                           ^
src/mongo/shell/bench.cpp:586:61: error: request for member 'insertCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.insertCounter);
                                                             ^
src/mongo/shell/bench.cpp:615:43: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                     stats.errCount++;
                                           ^
src/mongo/shell/bench.cpp:635:61: error: request for member 'deleteCounter' in 'stats', which is of non-class type 'int'
                             BenchRunEventTrace _bret(&stats.deleteCounter);
                                                             ^
src/mongo/shell/bench.cpp:667:43: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                                     stats.errCount++;
                                           ^
src/mongo/shell/bench.cpp:697:31: error: request for member 'error' in 'stats', which is of non-class type 'int'
                         stats.error = true;
                               ^
src/mongo/shell/bench.cpp:701:27: error: request for member 'opCount' in 'stats', which is of non-class type 'int'
                     stats.opCount++;
                           ^
src/mongo/shell/bench.cpp:722:35: error: request for member 'trappedErrors' in 'stats', which is of non-class type 'int'
                             stats.trappedErrors.push_back( BSON( "error" << ex.what() << "op" << e << "count" << count ) );
                                   ^
src/mongo/shell/bench.cpp:728:27: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                     stats.errCount++;
                           ^
src/mongo/shell/bench.cpp:734:27: error: request for member 'errCount' in 'stats', which is of non-class type 'int'
                     stats.errCount++;
                           ^
src/mongo/shell/bench.cpp: In static member function 'static mongo::BSONObj mongo::BenchRunner::finish(mongo::BenchRunner*)':
src/mongo/shell/bench.cpp:914:15: error: 'appendPerSec' does not name a type
          auto appendPerSec = [&buf, runner](StringData name, double total) {
               ^
src/mongo/shell/bench.cpp:918:50: error: 'appendPerSec' was not declared in this scope
          appendPerSec("totalOps/s", stats.opCount);
                                                  ^
scons: *** [build/build.el7/mongo/shell/bench.o] Error 1
scons: building terminated because of errors.

Comment by Marek Skalický [ 04/Aug/15 ]

So it is not possible to compile v3.0 branch without c++11? Or this warning is only in gcc5?

Comment by Ramon Fernandez Marina [ 04/Aug/15 ]

Hi mskalick, this is expected: given the positive results of using C++11 on our development branch we decided to allow C++11 code in our v3.0 branch. Note also that we haven't adapted to gcc5 yet, so you may run into some other issues with the compiler you're using.

Generated at Thu Feb 08 03:51:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.