summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Herbener <32968781+srherbener@users.noreply.github.com>2024-11-11 18:55:28 -0700
committerGitHub <noreply@github.com>2024-11-11 17:55:28 -0800
commit3fed7086180966329a5cee2e3f9c73cf34c5a532 (patch)
treed89b1e4ec21245ed703a2387966cdb2782d16d52
parent0614ded2ef418fa9b2a90fb8c9db4dbc905dcdc2 (diff)
downloadspack-3fed7086180966329a5cee2e3f9c73cf34c5a532.tar.gz
spack-3fed7086180966329a5cee2e3f9c73cf34c5a532.tar.bz2
spack-3fed7086180966329a5cee2e3f9c73cf34c5a532.tar.xz
spack-3fed7086180966329a5cee2e3f9c73cf34c5a532.zip
openmpi: add two_level_namespace variant for MacOS (#47202)
* Add two_level_namespace variant (default is disabled) for MacOS to enable building executables and libraries with two level namespace enabled. * Addressed reviewer comments. * Moved two_level_namespace variant ahead of the patch that uses that variant to get concretize to work properly. * Removed extra print statements
-rw-r--r--var/spack/repos/builtin/packages/openmpi/package.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py
index c82e58cfba..4251569072 100644
--- a/var/spack/repos/builtin/packages/openmpi/package.py
+++ b/var/spack/repos/builtin/packages/openmpi/package.py
@@ -575,6 +575,24 @@ class Openmpi(AutotoolsPackage, CudaPackage):
variant("openshmem", default=False, description="Enable building OpenSHMEM")
variant("debug", default=False, description="Make debug build", when="build_system=autotools")
+ variant(
+ "two_level_namespace",
+ default=False,
+ description="""Build shared libraries and programs
+built with the mpicc/mpifort/etc. compiler wrappers
+with '-Wl,-commons,use_dylibs' and without
+'-Wl,-flat_namespace'.""",
+ )
+
+ # Patch to allow two-level namespace on a MacOS platform when building
+ # openmpi. Unfortuntately, the openmpi configure command has flat namespace
+ # hardwired in. In spack, this only works for openmpi up to versions 4,
+ # because for versions 5+ autoreconf is triggered (see below) and this
+ # patch needs to be applied (again) AFTER autoreconf ran.
+ @when("+two_level_namespace platform=darwin")
+ def patch(self):
+ filter_file(r"-flat_namespace", "-commons,use_dylibs", "configure")
+
provides("mpi@:2.0", when="@:1.2")
provides("mpi@:2.1", when="@1.3:1.7.2")
provides("mpi@:2.2", when="@1.7.3:1.7.4")
@@ -997,11 +1015,15 @@ class Openmpi(AutotoolsPackage, CudaPackage):
def autoreconf(self, spec, prefix):
perl = which("perl")
perl("autogen.pl")
+ if spec.satisfies("+two_level_namespace platform=darwin"):
+ filter_file(r"-flat_namespace", "-commons,use_dylibs", "configure")
@when("@5.0.0:5.0.1")
def autoreconf(self, spec, prefix):
perl = which("perl")
perl("autogen.pl", "--force")
+ if spec.satisfies("+two_level_namespace platform=darwin"):
+ filter_file(r"-flat_namespace", "-commons,use_dylibs", "configure")
def configure_args(self):
spec = self.spec