RE: [mongodb-dev] MongoDB 2.4.3 32 Bit on Solaris 10 i386

188 views
Skip to first unread message

Tad Marshall

unread,
May 22, 2013, 5:57:02 AM5/22/13
to mongo...@googlegroups.com

Hi Christophe,

 

Thanks for the report and the patch.

 

I have recently built all of MongoDB (scons all) on Solaris 11.1 and on OpenIndiana, and it did take a little futzing.

 

I only tried to build a 64-bit version, and I specified --64 on the scons command line to force this.  I have (so far) unresolved problems building a debug version, so I have only built a release version.

 

a) Can you elaborate on the problems caused by scons not recognizing i86pc?  For me, scons determined the platform to be "sunos5".  I used scons 2.1.0 and 2.3.0.

 

b)  Definitely a bug that pid_t is not used consistently as the type for a pid.  The line "int portForPid( int port ) const;" is clearly wrong, and refers to the pid as a port.

 

If pid_t is a typedef for long, shouldn't that make it 32-bits in 32-bit builds?  Agreed that it will be 64-bits in 64-bit builds.

 

c)  I didn't hit this issue with PF_LOCAL, but I don't have Solaris 10 to test against.

 

d)  I haven't tried gcc 4.7.3 but we'd like to be upwardly compatible with newer gcc versions if we can be.

 

For OpenIndiana, I had to use the OpenCSW build of gcc to get MongoDB to compile.  I didn't try very hard to find out why the older gcc from the OpenIndiana repo didn't work; the OpenCSW one did work for me.

 

I'll look at your patch and look into the libstc++ issues.  If you'd like us to incorporate your patch, could you file a Jira ticket describing what you've found, sign the contributor agreement at http://www.10gen.com/legal/contributor-agreement and issue a pull request against the Jira ticket you create?

 

Thanks!

 

Tad Marshall

t...@10gen.com

 


From: mongo...@googlegroups.com [mailto:mongo...@googlegroups.com] On Behalf Of chlu...@googlemail.com
Sent: Tuesday, May 21, 2013 2:45 PM
To: mongo...@googlegroups.com
Subject: [mongodb-dev] MongoDB 2.4.3 32 Bit on Solaris 10 i386

 

Hi,

I recently had to build MongoDB 2.4.3 on a Solaris 10 machine.Due to problems with unresolved symbols, we could not get the binaries available at [1] working.

More precisely, the machine description is:

$ uname -i -p -r -s
SunOS 5.10 i386 i86pc

I did not succeed in building MongoDB with the GCC 3.4.3 already available in the system, whence I locally built and installed GCC 4.7.3:

$ gcc-4.7.3/bin/gcc-4.7.3 -v
Using built-in specs.
COLLECT_GCC=gcc-4.7.3/bin/gcc-4.7.3
COLLECT_LTO_WRAPPER=/export/home/heliosdb/gcc-4.7.3/bin/../libexec/gcc/i386-pc-solaris2.10/4.7.3/lto-wrapper
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.7.3_src/configure --prefix=/home/heliosdb/gcc-4.7.3 --program-suffix=-4.7.3 --enable-threads --enable-languages=c,c++ --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld CONFIG_SHELL=/bin/ksh
Thread model: posix
gcc version 4.7.3 (GCC)

This is probably not an optimal GCC configuration for Solaris 10, but I only cared about getting it working at all. In particular, this GCC seems to default to 32 Bit builds - which was part of the reason why I had to patch the MongoDB sources before they would build. The attached patch file has all the details, but in summary:

a) The SConstruct file does not know the processor identifier "i86pc" returned by uname.

b) pid_t is a typedef for long (in 32 Bit builds, at least), and sizeof(long) > sizeof(int). Therefore the declaration

      int ProgramRegistry::portForPid(int port) const;

(sic!) in shell_utils_launcher.h disagrees with the definition 

      int ProgramRegistry::portForPid(pid_t pid) const { ... }

in shell_utils_launcher.cpp. In addition, the call

      BSONObjBuilder toLog;
      // ...
      toLog.append( "pid", getpid() );

in db.cpp becomes ambiguous. I solved the latter with a template specialization that chooses between int and long long depending on the size of the template argument type.

c) Solaris 10 has no definition PF_LOCAL, it seems. I mapped it to PF_UNIX instead.

d) g++ 4.7.3 balks on the calls to sqrt(x) in s2.cc where x is an integer literal.I therefore had to turn them into double literals.


With these changes, I could finally build and install a MongoDB executable that seems to work fine so far:
$~/scons-2.3.0/bin/scons --prefix=/home/heliosdb/mongodb-2.4.3 --cxx=/home/heliosdb/gcc-4.7.3/bin/g++-4.7.3 --static-libstdc++ all
$
~/scons-2.3.0/bin/scons --prefix=/home/heliosdb/mongodb-2.4.3 --cxx=/home/heliosdb/gcc-4.7.3/bin/g++-4.7.3 --static-libstdc++ install

(Even though I gave the option --static-libstdc++, the binary still dynamically links to libstdc++.so. I did not try to figure out the reason for this, though.) We use this build in a development environment only; it therefore does not bother us if it has a suboptimal performance or has any restrictions on the maximum collection size.


It's been about 8 years since I did any serious C++ programming and it is even longer since I had to mess with the build tool chain under Solaris. So someone more familiar with the code and / or with Solaris will likely come up with better fixes. Nevertheless, I'd like to share the patch so you see where I ran into portability issues.

Cheers,
Christoph

[1] http://www.mongodb.org/dr/fastdl.mongodb.org/sunos5/mongodb-sunos5-x86_64-2.4.3.tgz/download

--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-dev?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rogério Brito

unread,
May 22, 2013, 10:14:25 AM5/22/13
to mongo...@googlegroups.com
Hi there.

On Wed, May 22, 2013 at 6:57 AM, Tad Marshall <t...@tadmarshall.com> wrote:
> d) I haven't tried gcc 4.7.3 but we'd like to be upwardly compatible with
> newer gcc versions if we can be.

Just for the record, I am building mongodb (or, at least, version
2.4.[123]) for Debian with gcc 4.7 and that's the version that is
currently in Debian's unstable (soon in Debian's testing, after some
library transitions are performed).

Furthermore, we are going to have gcc 4.8 in the next release.


Regards,

--
Rogério Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 4096R/BCFCAAAA
http://rb.doesntexist.org/blog : Projects : https://github.com/rbrito/
DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br

chlu...@googlemail.com

unread,
May 28, 2013, 7:58:46 PM5/28/13
to mongo...@googlegroups.com, Tad Marshall
Hi Tad,

sorry for the late response. For some reason Google Groups has not sent updates of this thread to my mail account.

The built of GCC 4.7.3 I used defaults to 32 bit. I have not tried yet to force the build of MongoDB to 64 bit.

a) Scons recognized the platform as sunos5 just fine. The problem was the processor. Sconstruct looks at os.uname()[4] which happens to be "i86pc" on our machine. If you provide an option that forces either a 32 bit or a 64 bit build, then the determined value of processor is overwritten with "i386" and "x86_64", rspectively. But if you don't, then the value "i86pc" of processor causes the script to fail later on. If you want me to, then I can try to reproduce the error and tell you the exact line.

b) I am not sure what led me to think that long is 64 bit on this machine. I double-checked and, indeed, sizeof(int) == sizeof(long) == sizeof(pid_t) == 4.
That said, _ILP32 is defined whereas _LP64 and _I32LPx are not defined, whence pid_t is a typedef or long. So if the compiler has to choose between function overloads f(int) and f(long long), then a call f(expresion_of_type_pid_t) is ambiguous. It either needs an additional overload f(long) that's a better match or an explicit static cast.

d) In the meantime, our admins installed a built of GCC 4.8.0. (I assume it is also an OpenCSW built.) I can try to build MongoDB with this compiler as well, maybe even as a 64 bit build. However, I won't get around to this before next week.

Of course, I don't mind to create a ticket or sign the contribution agreement. However, my C++ is very rusty and I have no Scons experience at all. My path would therefore need to be carefully vetted.

Cheers,
Christoph

Andrew Morrow

unread,
May 29, 2013, 10:00:56 AM5/29/13
to mongo...@googlegroups.com
The error message for the second case (e.g. --32 or --64 specified, causing an overwrite of i86pc) would be helpful.

Thanks,
Andrew

chlu...@googlemail.com

unread,
May 29, 2013, 10:40:42 AM5/29/13
to mongo...@googlegroups.com
Hi,

the error manifests itself if I *don't* supply the options --32 or --64:

[heliosdb@heliosdev-02:~/tmp/mongodb-src-r2.4.3]$ ~/scons-2.3.0/bin/scons --prefix=/tmp/mongo --cxx=/home/heliosdb/gcc-4.7.3/bin/g++-4.7.3 all
scons: Reading SConscript files ...
scons version: 2.3.0
python version: 2 6 4 'final' 0
Checking whether the C++ compiler worksyes
Checking for C header file unistd.h... yes
Checking for C library rt... yes
Checking for C++ header file execinfo.h... no
Checking for C library pcap... no
Checking for C library wpcap... no
Checking for C library nsl... yes
AssertionError: Unsupported architecture: i86pc:
  File "/export/home/heliosdb/tmp/mongodb-src-r2.4.3/SConstruct", line 1136:
    env.SConscript('src/SConscript', variant_dir='$BUILD_DIR', duplicate=False)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 546:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 260:
    exec _file_ in call_stack[-1].globals
  File "/export/home/heliosdb/tmp/mongodb-src-r2.4.3/src/SConscript", line 10:
    module_sconscripts)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 609:
    return method(*args, **kw)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 546:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 260:
    exec _file_ in call_stack[-1].globals
  File "/export/home/heliosdb/tmp/mongodb-src-r2.4.3/src/third_party/SConscript", line 53:
    env.SConscript('v8/SConscript')
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 546:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/export/home/heliosdb/scons-2.3.0/lib/scons-2.3.0/SCons/Script/SConscript.py", line 260:
    exec _file_ in call_stack[-1].globals
  File "/export/home/heliosdb/tmp/mongodb-src-r2.4.3/src/third_party/v8/SConscript", line 344:
    options = get_options()
  File "/export/home/heliosdb/tmp/mongodb-src-r2.4.3/src/third_party/v8/SConscript", line 298:
    assert False, "Unsupported architecture: " + processor


Cheers,
Christoph
Reply all
Reply to author
Forward
0 new messages