[SERVER-22092] Scons cannot build server on osx with gcc Created: 07/Jan/16  Updated: 15/Mar/16  Resolved: 08/Jan/16

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

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: OS X
Participants:

 Description   

I have installed various versions of gcc (4.8.4, 4.9, 5.0, 5.1...) and I can no longer use them to build with. I get an error about libstdc++ being too old.

$ alias scons-gcc48 = scons-base CC=gcc-4.8 CXX=g++-4.8
$ scons-gcc48 --config force
scons: Reading SConscript files ...
scons version: 2.4.1
python version: 2 7 10 'final' 0
Checking whether the C++ compiler works... yes
Checking whether the C compiler works... yes
Checking if C++ compiler "g++-4.8" is GCC... yes
Checking if C compiler "gcc-4.8" is GCC... yes
Detected a x86_64 processor
Checking if target OS osx is supported by the toolchain yes
Checking if C compiler is GCC 4.8.2 or newer...yes
Checking if C++ compiler is GCC 4.8.2 or newer...yes
Checking if C compiler supports -Wno-unused-local-typedefs... yes
Checking if C compiler supports -Wno-unused-function... yes
Checking if C compiler supports -Wno-unused-private-field... no
Checking if C compiler supports -Wno-deprecated-declarations... yes
sChecking if C compiler supports -Wno-tautological-constant-out-of-range-compare... no
Checking if C compiler supports -Wno-unused-const-variable... no
cChecking if C compiler supports -Wno-unused-but-set-variable... yes
Checking if C compiler supports -Wno-missing-braces... yes
Checking if C compiler supports -Wno-inconsistent-missing-override... no
Checking if C compiler supports -Wno-potentially-evaluated-expression... no
Checking if C++ compiler supports -Wpessimizing-move... no
Checking if C++ compiler supports -Wredundant-move... no
Checking if we are using libstdc++... yes
Checking if C++ compiler supports -std=c++11... yes
Checking if C compiler supports -std=c99... yes
Checking for C++11... yes
Checking for memset_s... no
Checking for C function strnlen()... no
Checking for libstdc++ 4.8.2 or better... no
When using libstdc++, MongoDB requires libstdc++ 4.8.2 or newer
See /Users/scotthernandez/git/mongo/build/scons/config.log for details

config.log tail:

...
scons: Configure: Checking for C function strnlen()... 
build/scons/sconf_temp/conftest_25.c <-
  |
  |
  |#include <assert.h>
  |
  |#ifdef __cplusplus
  |extern "C"
  |#endif
  |char strnlen();
  |
  |int main() {
  |#if defined (__stub_strnlen) || defined (__stub___strnlen)
  |  fail fail fail
  |#else
  |  strnlen();
  |#endif
  |
  |  return 0;
  |}
  |
Compiling build/scons/sconf_temp/conftest_25.o
build/scons/sconf_temp/conftest_25.c:3:20: fatal error: assert.h: No such file or directory
 #include <assert.h>
                    ^
compilation terminated.
scons: Configure: no
 
 
file /Users/scotthernandez/git/mongo/SConstruct,line 1876:
	Configure(confdir = build/scons/sconf_temp)
scons: Configure: Checking for libstdc++ 4.8.2 or better... 
build/scons/sconf_temp/conftest_26.cpp <-
  |
  |#define _GLIBCXX_PROFILE
  |#include <unordered_map>
  |#if !defined(_GLIBCXX_PROFILE_UNORDERED)
  |#error libstdc++ older than 4.8.2
  |#endif
  |
Compiling build/scons/sconf_temp/conftest_26.o
In file included from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/bits/postypes.h:40:0,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/bits/char_traits.h:40,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/string:40,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/stdexcept:39,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/array:38,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/tuple:39,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/unordered_map:41,
                 from build/scons/sconf_temp/conftest_26.cpp:3:
/usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cwchar:44:19: fatal error: wchar.h: No such file or directory
 #include <wchar.h>
                   ^
compilation terminated.
scons: Configure: no



 Comments   
Comment by Scott Hernandez (Inactive) [ 08/Jan/16 ]

After rebuilding/reinstalling via homebrew this problem went away.

Comment by Scott Hernandez (Inactive) [ 07/Jan/16 ]

After investigating a bit more my local g++-4.8/9 compiler has the same issue with this simple program:

#include <iostream>
 
int main() {
	std::string h("hello");
	std::cout << h;
	return 0;
}

$ g++-4.9 test.cpp
In file included from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/bits/postypes.h:40:0,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/iosfwd:40,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/ios:38,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/ostream:38,
                 from /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/iostream:39,
                 from test.cpp:1:
/usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cwchar:44:19: fatal error: wchar.h: No such file or directory
 #include <wchar.h>
                   ^
compilation terminated.

But the g++5 compiler seems fine. This seems like a homebrew issue, maybe related to an OS system update.

I am reinstalling, by rebuilding, 4.8/4.9 to see if that helps.

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