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
This commit is contained in:
Stephen Herbener 2024-11-11 18:55:28 -07:00 committed by GitHub
parent 0614ded2ef
commit 3fed708618
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 @@ def die_without_fortran(self):
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