[SERVER-31936] Compile Error in planner_access.cpp Created: 13/Nov/17  Updated: 27/Nov/17  Resolved: 27/Nov/17

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

Type: Bug Priority: Major - P3
Reporter: Robert Simmons Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-28425 Fix mistyped QueryPlannerAccess invar... Closed
Operating System: ALL
Steps To Reproduce:

Using vagrant, spin up one instance of ubuntu/artful64
Install build-essential and scons
Run scons mongod mongo

Participants:

 Description   

I am unable to compile mongo 3.4.10 from source. There is an error:

Compiling build/opt/mongo/db/query/planner_access.o                             
In file included from src/mongo/platform/compiler.h:151:0,                      
                 from src/mongo/util/invariant.h:30,                            
                 from src/mongo/base/string_data.h:41,                          
                 from build/opt/mongo/base/error_codes.h:32,                    
                 from src/mongo/base/status.h:34,                               
                 from src/mongo/db/query/canonical_query.h:32,                  
                 from src/mongo/db/query/planner_access.h:31,                   
                 from src/mongo/db/query/planner_access.cpp:33:                 
src/mongo/db/query/planner_access.cpp: In static member function 'static mongo::QuerySolutionNode* mongo::QueryPlannerAccess::buildIndexedDataAccess(const mongo::CanonicalQuery&, mongo::MatchExpression*, bool, const std::vector<mongo::IndexEntry>&, const mongo::QueryPlannerParams&)':
src/mongo/util/invariant.h:51:41: error: enum constant in boolean context [-Werror=int-in-bool-context]
         if (MONGO_unlikely(!(_Expression))) {                           \      
                                         ^
src/mongo/platform/compiler_gcc.h:77:80: note: in definition of macro 'MONGO_unlikely'
  MONGO_unlikely(x) static_cast<bool>(__builtin_expect(static_cast<bool>(x), 0))
                                                                         ^
src/mongo/util/invariant.h:56:19: note: in expansion of macro 'MONGO_invariant' 
 #define invariant MONGO_invariant
                   ^~~~~~~~~~~~~~~
src/mongo/db/query/planner_access.cpp:1218:13: note: in expansion of macro 'invariant'
             invariant(MatchExpression::ELEM_MATCH_OBJECT);                     
             ^~~~~~~~~
cc1plus: all warnings being treated as errors                                   
scons: *** [build/opt/mongo/db/query/planner_access.o] Error 1                  
scons: building terminated because of errors.                                   
build/opt/mongo/db/query/planner_access.o failed: Error 1



 Comments   
Comment by David Storch [ 27/Nov/17 ]

The incorrect invariant() that's failing to compile on the newer version of gcc was fixed under SERVER-28425. The fix was part of the 3.5.5 development release, and will be included in the upcoming general availability release of MongoDB 3.6. I'm closing this ticket as a duplicate.

Comment by Mark Agarunov [ 14/Nov/17 ]

Hello utkonos,

Thank you for the report. I've managed to reproduce this behavior so I've set this ticket's fixVersion to 'Needs Triage' to be planned against our currently scheduled work. This error appears to be due to a warning on an invariant. As a workaround, please try building MongoDB with the --disable-warnings-as-errors flag. I can confirm from my testing that adding this flag will allow MongoDB to build successfully on Ubuntu 17.10 with gcc 7.2.

Thanks,
Mark

Comment by Robert Simmons [ 13/Nov/17 ]

You may need the GCC version:

$ apt-cache policy gcc
gcc:
Installed: 4:7.2.0-1ubuntu1
Candidate: 4:7.2.0-1ubuntu1
Version table:

Also, the command that I used to start the compile process was "scons mongod mongo"

Generated at Thu Feb 08 04:28:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.