From 3fed7086180966329a5cee2e3f9c73cf34c5a532 Mon Sep 17 00:00:00 2001 From: Stephen Herbener <32968781+srherbener@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:55:28 -0700 Subject: 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 --- .../repos/builtin/packages/openmpi/package.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'var') 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 -- cgit v1.2.3-70-g09d2