OpenMPI strongly recommends using their wrapper compilers. Behind the scenes, their wrapper compiler mpiCC calls gcc (by default?) and adds the necessary flags for MPI code to compile. However, other compilers give more descriptive error messages than gcc (e.g. clang which is also GCC-compatible). So, I'd like to be able to use clang with Open MPI.
I tried:
1) finding an mpiCC option for specifying the compiler, but
mpiCC --help
just spits out the g++ help page.
2) using the --showme:compile option
mpiCC --showme:compile ./test-boost.cc -lboost_mpi -lboost_serialization -o test-boost
which, instead of calling gcc, prints the flags needed for compiling the MPI code. I can then use those with clang (since it's GCC-compatible). This should work, but I'm looking for an easier solution.
Open MPI FAQ says which environmental variables can be set to override the default choice of the compiler called by the wrapper.
http://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0
Depending on the version of OpenMPI you should set OMPI_CXX=clang++
or OMPI_MPICC=clang
. For OpenMPI v.1.1 and later use OMPI_CXX
and then call the wrapper compiler. The wrapper would call clang++ in turn.