Repository: spack/spack

Issue:
openmpi and cxx 
What is the reasoning for turning on the cxx wrappers always when openmpi has turned them off by default?  This should be off by default... and enabled via a variant?

From the openmpi/package.py:
        if spec.satisfies('@2.0:'):
            # for Open-MPI 2.0:, C++ bindings are disabled by default.
            config_args.extend(['--enable-mpi-cxx'])





### Spack version

```console
$ spack --version
0.14.0-206-e916a9424
```



Discussion:
> This should be off by default

I think a lot of Spack users use MPI for C++ libraries, so it makes sense for the default to be on.

> and enabled via a variant?

We can certainly add a variant for this if you want. Are you experiencing any problems with the C++ build?

@hppritcha may have some opinions on this.
I might be... I'm currently having some issues with boost+openmpi+intel19
and havent quite figured out what was going on.  I was just reading and saw
that openmpi had disabled the cxx extensions by default and thought it was
quite odd that spack was setting them on by default.

On Thu, Mar 12, 2020 at 2:59 PM Adam J. Stewart <notifications@github.com>
wrote:

> This should be off by default
>
> I think a lot of Spack users use MPI for C++ libraries, so it makes sense
> for the default to be on.
>
> and enabled via a variant?
>
> We can certainly add a variant for this if you want. Are you experiencing
> any problems with the C++ build?
>
> @hppritcha <https://github.com/hppritcha> may have some opinions on this.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/spack/spack/issues/15465#issuecomment-598415630>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADXXLJ6EI3JX2EEBVUCBQ7TRHFELFANCNFSM4LGQQAOA>
> .
>

> I think a lot of Spack users use MPI for C++ libraries, so it makes sense for the default to be on.

Don't most major packages use the C bindings, I thought c++ bindings had been deprecated a long time ago

>We can certainly add a variant for this if you want. Are you experiencing any problems with the C++ build?

I think by default the openmpi c++ bindings throw a bunch of warnings on newer gcc's and it is hard to use isystem in mpi wrappers for the mpi headers

Edit: here is an issue where it is noted that c++ bindings were deprecated

https://github.com/open-mpi/ompi/issues/3173


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -77,7 +77,7 @@ class Openmpi(AutotoolsPackage):
 
     maintainers = ['hppritcha']
 
-    version('develop', branch='master')
+    version('master', branch='master')
 
     # Current
     version('4.0.3', sha256='1402feced8c3847b3ab8252165b90f7d1fa28c23b6b2ca4632b6e4971267fd03')  # libmpi.so.40.20.3
@@ -237,7 +237,8 @@ class Openmpi(AutotoolsPackage):
             description='Enable MPI_THREAD_MULTIPLE support')
     variant('cuda', default=False, description='Enable CUDA support')
     variant('pmi', default=False, description='Enable PMI support')
-    variant('cxx_exceptions', default=True, description='Enable C++ Exception support')
+    variant('cxx', default=False, description='Enable C++ MPI bindings')
+    variant('cxx_exceptions', default=False, description='Enable C++ Exception support')
     # Adding support to build a debug version of OpenMPI that activates
     # Memchecker, as described here:
     #
@@ -299,6 +300,10 @@ class Openmpi(AutotoolsPackage):
     conflicts('schedulers=loadleveler', when='@3.0.0:',
               msg='The loadleveler scheduler is not supported with '
               'openmpi(>=3.0.0).')
+    conflicts('+cxx', when='@5:',
+              msg='C++ MPI bindings are removed in 5.0.X release')
+    conflicts('+cxx_exceptions', when='@5:',
+              msg='C++ exceptions are removed in 5.0.X release')
 
     filter_compiler_wrappers('openmpi/*-wrapper-data*', relative_root='share')
     conflicts('fabrics=libfabric', when='@:1.8')  # libfabric support was added in 1.10.0
@@ -431,10 +436,6 @@ def configure_args(self):
             config_args.append('--enable-static')
             config_args.extend(self.with_or_without('pmi'))
 
-        if spec.satisfies('@2.0:'):
-            # for Open-MPI 2.0:, C++ bindings are disabled by default.
-            config_args.extend(['--enable-mpi-cxx'])
-
         if spec.satisfies('@3.0.0:', strict=True):
             config_args.append('--with-zlib={0}'.format(spec['zlib'].prefix))
 
@@ -532,10 +533,17 @@ def configure_args(self):
             else:
                 config_args.append('--without-cuda')
 
-        if '+cxx_exceptions' in spec:
-            config_args.append('--enable-cxx-exceptions')
-        else:
-            config_args.append('--disable-cxx-exceptions')
+        if spec.satisfies('@:4'):
+            if '+cxx' in spec:
+                config_args.append('--enable-mpi-cxx')
+            else:
+                config_args.append('--disable-mpi-cxx')
+
+            if '+cxx_exceptions' in spec:
+                config_args.append('--enable-cxx-exceptions')
+            else:
+                config_args.append('--disable-cxx-exceptions')
+
         return config_args
 
     @run_after('install')


Test patch: