Bug 1525 - Linker error with mpi on Mac 10.8
Linker error with mpi on Mac 10.8
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: mpi
ns-3-dev
Mac Intel Mac OS
: P5 blocker
Assigned To: Brian Swenson
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-06 16:22 EST by Peter Barnes
Modified: 2012-12-07 10:20 EST (History)
5 users (show)

See Also:


Attachments
diff (both wscripts have to be patched) (1.27 KB, patch)
2012-11-19 19:02 EST, Peter Barnes
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barnes 2012-11-06 16:22:23 EST
--enable-mpi won't build, linker error, log below

(non-ns3) MPI example programs build and run just fine.

$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-134.9
configured to support archs: armv6 armv7 armv7s i386 x86_64
LTO support using: LLVM version 3.1svn, from Apple Clang 4.1 (build 421.11.66)

$ ompi_info | head 
                 Package: Open MPI fink-bld@pdb Distribution
                Open MPI: 1.6.2
   Open MPI SVN revision: r27344
   Open MPI release date: Sep 18, 2012



NOCOLOR=1 ./waf --keep -v doxygen
Waf: Entering directory `/Users/barnes26/Code/netsim/ns3/repos/docs/build'
[1665/1878] cxxshlib: build/src/mpi/model/distributed-simulator-impl.cc.1.o build/src/mpi/model/mpi-interface.cc.1.o build/src/mpi/model/mpi-receiver.cc.1.o -> build/libns3-dev-mpi-debug.dylib
13:21:03 runner ['/usr/bin/g++', '-dynamiclib', '-Wl,-rpath=/sw/lib/openmpi', 'src/mpi/model/distributed-simulator-impl.cc.1.o', 'src/mpi/model/mpi-interface.cc.1.o', 'src/mpi/model/mpi-receiver.cc.1.o', '-o', '/Users/barnes26/Code/netsim/ns3/repos/docs/build/libns3-dev-mpi-debug.dylib', '-L.', '-L.', '-L/sw/lib', '-L/sw/lib/openmpi', '-lns3-dev-network-debug', '-lns3-dev-core-debug', '-lgsl', '-lgslcblas', '-lm', '-lmpi_cxx', '-lmpi', '-lm']
ld: unknown option: -rpath=/sw/lib/openmpi
collect2: ld returned 1 exit status
Waf: Leaving directory `/Users/barnes26/Code/netsim/ns3/repos/docs/build'
Build failed
 -> task in 'ns3-mpi' failed (exit status 1): 
	{task 4418566160: cxxshlib distributed-simulator-impl.cc.1.o,mpi-interface.cc.1.o,mpi-receiver.cc.1.o -> libns3-dev-mpi-debug.dylib}
['/usr/bin/g++', '-dynamiclib', '-Wl,-rpath=/sw/lib/openmpi', 'src/mpi/model/distributed-simulator-impl.cc.1.o', 'src/mpi/model/mpi-interface.cc.1.o', 'src/mpi/model/mpi-receiver.cc.1.o', '-o', '/Users/barnes26/Code/netsim/ns3/repos/docs/build/libns3-dev-mpi-debug.dylib', '-L.', '-L.', '-L/sw/lib', '-L/sw/lib/openmpi', '-lns3-dev-network-debug', '-lns3-dev-core-debug', '-lgsl', '-lgslcblas', '-lm', '-lmpi_cxx', '-lmpi', '-lm']

Compilation exited abnormally with code 1 at Tue Nov  6 13:21:04
Comment 1 Tom Henderson 2012-11-09 09:39:18 EST
Possibly relevant to a fix:
https://blogs.oracle.com/dipol/entry/dynamic_libraries_rpath_and_mac
Comment 2 Brian Swenson 2012-11-15 10:24:02 EST
I'll take a look at this once I finish updating my mac to 10.8
Comment 3 Tommaso Pecorella 2012-11-15 15:05:25 EST
Works for me.

Test environment: MacOS 10.8.2 + "mpich2" package installed using macports.


20:43:10:~/Development/workspace/ns-3-dev pecos$ ./waf configure --enable-mpi --enable-tests --enable-examples
Setting top to                           : /Users/pecos/Development/workspace/ns-3-dev 
Setting out to                           : /Users/pecos/Development/workspace/ns-3-dev/build 
Checking for 'gcc' (c compiler)          : /usr/bin/gcc 
Checking for 'g++' (c++ compiler)        : /usr/bin/g++ 
Checking for program pkg-config          : /opt/local/bin/pkg-config 
Checking for program python              : /usr/bin/python 
Checking for python version              : (2, 7, 2, 'final', 0) 
Checking for library python2.7 in LIBDIR : yes 
Checking for program python2.7-config,python-config-2.7,python2.7m-config : /opt/local/bin/python2.7-config 
Checking for header Python.h                                              : yes 
Checking for compilation flag -fvisibility=hidden... support              : ok 
Checking for compilation flag -Wno-array-bounds... support                : not found 
Checking for pybindgen location                                           : not found 
Python module pybindgen                                                   : not found 
pybindgen missing => no python bindings
Checking for click location                                               : not found 
Checking for pkg-config flags for GTK_CONFIG_STORE                        : ok 
Checking for pkg-config flags for LIBXML2                                 : ok 
Checking for type uint128_t                                               : not found 
Checking for type __uint128_t                                             : yes 
Checking high precision time implementation                               : 128-bit integer 
Checking for header stdint.h                                              : yes 
Checking for header inttypes.h                                            : yes 
Checking for header sys/inttypes.h                                        : not found 
Checking for header sys/types.h                                           : yes 
Checking for header sys/stat.h                                            : yes 
Checking for header dirent.h                                              : yes 
Checking for header stdlib.h                                              : yes 
Checking for header signal.h                                              : yes 
Checking for header pthread.h                                             : yes 
Checking for header stdint.h                                              : yes 
Checking for header inttypes.h                                            : yes 
Checking for header sys/inttypes.h                                        : not found 
Checking for library rt                                                   : not found 
Checking for header netpacket/packet.h                                    : not found 
Checking for NSC location                                                 : not found 
Checking for 'mpic++'                                                     : not found 
Checking for 'mpic++'                                                     : yes 
Checking boost includes                                                   : 1_52 
Checking boost libs                                                       : ok 
Checking for OpenFlow location                                            : not found 
Checking for library sqlite3                                              : yes 
Checking for header linux/if_tun.h                                        : not found 
Checking for program sudo                                                 : /usr/bin/sudo 
Checking for program valgrind                                             : /opt/local/bin/valgrind 
Checking for pkg-config flags for GSL                                     : ok 
Checking for compilation flag -Wno-error=deprecated-d... support          : ok 
Checking for compilation flag -Wno-error=deprecated-d... support          : ok 
Checking for compilation flag -fstrict-aliasing... support                : ok 
Checking for compilation flag -fstrict-aliasing... support                : ok 
Checking for compilation flag -Wstrict-aliasing... support                : ok 
Checking for compilation flag -Wstrict-aliasing... support                : ok 
Checking for program doxygen                                              : /opt/local/bin/doxygen 
---- Summary of optional NS-3 features:
Python Bindings               : not enabled (PyBindGen missing)
NS-3 Click Integration        : not enabled (nsclick not enabled (see option --with-nsclick))
GtkConfigStore                : enabled
XmlIo                         : enabled
Threading Primitives          : enabled
Real Time Simulator           : not enabled (librt is not available)
Emulated Net Device           : not enabled (<netpacket/packet.h> include not detected)
Network Simulation Cradle     : not enabled (NSC not found (see option --with-nsc))
MPI Support                   : enabled
NS-3 OpenFlow Integration     : not enabled (OpenFlow not enabled (see option --with-openflow))
SQlite stats data output      : enabled
Tap Bridge                    : not enabled (<linux/if_tun.h> include not detected)
PyViz visualizer              : not enabled (Python Bindings are needed but not enabled)
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
Build tests                   : enabled
Build examples                : enabled
GNU Scientific Library (GSL)  : enabled
'configure' finished successfully (3.204s)
20:44:01:~/Development/workspace/ns-3-dev pecos$ ./waf
[...]
works.


20:46:51:~/Development/workspace/ns-3-dev pecos$ ./test.py 
[...]

236 of 246 tests passed (236 passed, 10 skipped, 0 failed, 0 crashed, 0 valgrind errors)

T.
Comment 4 Brian Swenson 2012-11-16 13:11:27 EST
Yeah it works for me too.  OSX 10.8.2

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-134.9
configured to support archs: i386 x86_64
LTO support using: LLVM version 3.1

$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 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.

$ ompi_info | head
   Package: Open MPI macports Distribution
                Open MPI: 1.6.3
   Open MPI SVN revision: r27472
   Open MPI release date: Oct 24, 2012
                Open RTE: 1.6.3
   Open RTE SVN revision: r27472
   Open RTE release date: Oct 24, 2012
                    OPAL: 1.6.3
       OPAL SVN revision: r27472
       OPAL release date: Oct 24, 2012

$ ./waf --enable-mpi --enable-examples configure
[…]
[1590/1590] cxxprogram: build/scratch/scratch-simulator.cc.1.o -> build/scratch/scratch-simulator
Waf: Leaving directory `/Users/brian/Documents/Code/Work/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (2m54.399s)

Modules built:
antenna                   aodv                      applications             
bridge                    buildings                 config-store             
core                      csma                      csma-layout              
dsdv                      dsr                       energy                   
flow-monitor              internet                  lte                      
mesh                      mobility                  mpi                      
netanim (no Python)       network                   nix-vector-routing       
olsr                      point-to-point            point-to-point-layout    
propagation               spectrum                  stats                    
test (no Python)          tools                     topology-read            
uan                       virtual-net-device        wifi                     
wimax                    

Modules not built:
click                     emu                       openflow                 
tap-bridge                visualizer

$ mpirun -np 2 ./waf --run simple-distributed
Waf: Entering directory `/Users/brian/Documents/Code/Work/ns-3-allinone/ns-3-dev/build'
Waf: Entering directory `/Users/brian/Documents/Code/Work/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/Users/brian/Documents/Code/Work/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (2.445s)
Waf: Leaving directory `/Users/brian/Documents/Code/Work/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (2.456s)
At time 1.02264s packet sink received 512 bytes from 10.1.1.1 port 49153 total Rx 512 bytes
At time 1.0235s packet sink received 512 bytes from 10.1.2.1 port 49153 total Rx 512 bytes
At time 1.02437s packet sink received 512 bytes from 10.1.3.1 port 49153 total Rx 512 bytes
At time 1.02524s packet sink received 512 bytes from 10.1.4.1 port 49153 total Rx 512 bytes
Comment 5 Peter Barnes 2012-11-16 14:16:54 EST
Well, the only difference I can see is OpenMPI 1.6.3 (works for Brian), and 1.6.2 (doesn't work for me).  Let me try that and report back.
Comment 6 Peter Barnes 2012-11-19 16:52:05 EST
Tried openmpi-1.6.3 from fink, no joy.

Tried the command line by hand, reproduces linker error.

Playing with the command reveals that these work:

-Wl,-rpath -Wl,/sw/lib/openmpi
-Wl,-rpath,/sw/lib/openmpi

This (produced by waf) doesn't:
-Wl,-rpath=/sw/lib/openmpi

This thread seems to reach the same solution for a similar issue:
https://github.com/tsuna/boost.m4/issues/19

Suggested patch coming...
Comment 7 Peter Barnes 2012-11-19 19:02:26 EST
Created attachment 1471 [details]
diff (both wscripts have to be patched)
Comment 8 Brian Swenson 2012-12-02 12:31:02 EST
Patch testing

My mac, which worked previously and still works with new patch.
Tested on Ubuntu 12.04 64 -works
Tested on Fedora 17 64 -works
Tested on Fedora 17 32 -works
Comment 9 Brian Swenson 2012-12-07 10:20:12 EST
changeset:   9173:513f8ec65729