4

I'm trying to build mongodb from sources and getting a number of errors.

Here's the pastebin of the whole output: http://pastebin.com/pyZLTkz4

The first error is

endian.h does not define __BYTE_ORDER nor BYTE_ORDER. Cannot determine endianness.

And all other errors are like

error: template with C linkage
error: template specialization with C linkage

My configuration is:

  1. Debian 8 64 bit
  2. scons version: 2.3.1
  3. python version: 2 7 9
  4. gcc version: gcc (Debian 4.9.2-10) 4.9.2

Installed dependencies with

sudo apt-get build-dep mongodb

I have tried to build it under CentOS 7 and had the same result.

Kara
  • 6,115
  • 16
  • 50
  • 57
Konstantin Bodnia
  • 1,372
  • 3
  • 20
  • 43

3 Answers3

1

This is happening while building the embedded SpiderMonkey engine ("mozjs" - Mozilla JavaScript, version 38).

As you're using a VERBOSE=1 build in SCONS, you're seeing that an include directory is added via the -I switch to compile with -Ibuild/opt/third_party/mozjs-38/extract/mfbt. Because of the very aggressive behavior of -I, this means any include files in that directory will pre-empt any system include files of the same name.

(For why -I acts this way, see "Why do projects use the -I include switch given the dangers?". I'll add for Google crawlers that builds circa 2018 use SpiderMonkey 45, so the directory is -Ibuild/opt/third_party/mozjs-45/extract/mfbt)

So what's happening is that the mfbt/Endian.h file (which brings in a bunch of high-level C++ definitions) is overriding your system's low-level /usr/include/endian.h file, which is wreaking havoc when anyone tries to #include <endian.h> to get the system definitions.

The question you likely have is why is it only happening to you...and a few others.

I'm going to guess the reason is probably the same as in my case, which led me to this question: your MongoDB source files are on a filesystem that is retrieving them case-insensitively. So perhaps you are running a Debian Linux VM but have your files on a Windows host.

Most people building on Linux are using fully case-sensitive filesystems, that wouldn't have an Endian.h considered as a candidate to override their system's endian.h. So their builds succeed.


If you are running a version of Windows 10 since the April 2018 update, and have the Windows Subsystem for Linux enabled, then you can set specific Windows directories to be case-sensitive, e.g.

fsutil.exe file SetCaseSensitiveInfo C:\Projects\mongo\src\third_party\mozjs-45\extract\mfbt enable

Unfortunately, it's something you have to set up on each individual folder...you can't do it for entire subtrees. :-(

0

About first error

The sys/param.h header normally defines the symbols __BYTE_ORDER, __BIG_ENDIAN, __LITTLE_ENDIAN, and __PDP_ENDIAN. You can test endianness by doing something like:

The sys/param.h header normally defines the symbols __BYTE_ORDER, __BIG_ENDIAN, __LITTLE_ENDIAN, and __PDP_ENDIAN. You can test endianness by doing something like:

   #include <sys/param.h>

   #ifdef __BYTE_ORDER
   # if __BYTE_ORDER == __LITTLE_ENDIAN
   #  define I_AM_LITTLE_ENDIAN
   # else
   #  if __BYTE_ORDER == __BIG_ENDIAN
   #   define I_AM_BIG_ENDIAN
   #  else
       Error: unknown byte order!
   #  endif
   # endif
   #endif /* __BYTE_ORDER */

If __BYTE_ORDER is not defined, you may want to test for the existance of BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN. Linux defines these as synonym of the versions with underscores, apparantly in attempt to be compatible with BSD Unix.

If that is not defined, you might try things like:

   #if defined (i386) || defined (__i386__) || defined (_M_IX86) || \
        defined (vax) || defined (__alpha)
   # define I_AM_LITTLE_ENDIAN
   #endif

Read more

0

A couple of options:

A. You're missing the glibc development headers.

Try installing libc6-dev (debian) or glibc-headers (redhat)

B. You have a non-standard endian.h floating around on your include path

You could try running:

g++ -M -Wnon-virtual-dtor -Woverloaded-virtual -std=c++11 -Wno-non-virtual-dtor -fno-omit-frame-pointer -fPIC -fno-strict-aliasing -ggdb -pthread -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp -include js-confdefs.h -Wno-invalid-offsetof -DAB_CD -DIMPL_MFBT -DJS_USE_CUSTOM_ALLOCATOR -DNO_NSPR_10_SUPPORT -DSTATIC_JS_API=1 -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -DPCRE_STATIC -DBOOST_THREAD_VERSION=4 -DBOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -DBOOST_THREAD_HAS_NO_EINTR_BUG -Isrc -Ibuild/opt -Isrc -Ibuild/opt/third_party/mozjs-38/extract/js/src -Isrc/third_party/mozjs-38/extract/js/src -Ibuild/opt/third_party/mozjs-38/extract/mfbt -Isrc/third_party/mozjs-38/extract/mfbt -Ibuild/opt/third_party/mozjs-38/extract/intl/icu/source/common -Isrc/third_party/mozjs-38/extract/intl/icu/source/common -Ibuild/opt/third_party/mozjs-38/include -Isrc/third_party/mozjs-38/include -Ibuild/opt/third_party/mozjs-38/mongo_sources -Isrc/third_party/mozjs-38/mongo_sources -Ibuild/opt/third_party/mozjs-38/platform/x86_64/linux/build -Isrc/third_party/mozjs-38/platform/x86_64/linux/build -Ibuild/opt/third_party/mozjs-38/platform/x86_64/linux/include -Isrc/third_party/mozjs-38/platform/x86_64/linux/include -Isrc/third_party/zlib-1.2.8 src/third_party/mozjs-38/extract/js/src/builtin/RegExp.cpp | grep endian.h

That's the first compile failure from your pastbin with '-M' substituted for the -o, which should let us see which file you're actually including as endian.h.

hanumantmk
  • 641
  • 4
  • 12
  • A. I have all headers installed. And I tried to build it on both systems: Debian and CentOS (may be I should try Ubuntu, but I believe it's gonna have same result). B. Running this gets me same error. That I have same error: src/third_party/mozjs-38/extract/js/src/jscpucfg.h:71:4: error: #error "endian.h does not define __BYTE_ORDER nor BYTE_ORDER. Cannot determine endianness." – Konstantin Bodnia Aug 05 '15 at 08:38