Windows: MSVC provides fortran, fix msmpi handling (#49734)

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
John W. Parent 2025-03-31 04:53:07 -04:00 committed by GitHub
parent 72b14de89e
commit 75a3d179b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 31 deletions

View File

@ -20,3 +20,6 @@ packages:
cxx: [msvc] cxx: [msvc]
mpi: [msmpi] mpi: [msmpi]
gl: [wgl] gl: [wgl]
mpi:
require:
- one_of: [msmpi]

View File

@ -228,32 +228,29 @@ def setup_dependent_build_environment(self, env, dependent_spec):
env.prepend_path("SPACK_COMPILER_WRAPPER_PATH", item) env.prepend_path("SPACK_COMPILER_WRAPPER_PATH", item)
def setup_dependent_package(self, module, dependent_spec): def setup_dependent_package(self, module, dependent_spec):
bin_dir = self.bin_dir() def _spack_compiler_attribute(*, language: str) -> str:
compiler_pkg = dependent_spec[language].package
if sys.platform != "win32":
# On non-Windows we return the appropriate path to the compiler wrapper
return str(self.bin_dir() / compiler_pkg.compiler_wrapper_link_paths[language])
# On Windows we return the real compiler
if language == "c":
return compiler_pkg.cc
elif language == "cxx":
return compiler_pkg.cxx
elif language == "fortran":
return compiler_pkg.fortran
if dependent_spec.has_virtual_dependency("c"): if dependent_spec.has_virtual_dependency("c"):
compiler_pkg = dependent_spec["c"].package setattr(module, "spack_cc", _spack_compiler_attribute(language="c"))
setattr(
module, "spack_cc", str(bin_dir / compiler_pkg.compiler_wrapper_link_paths["c"])
)
if dependent_spec.has_virtual_dependency("cxx"): if dependent_spec.has_virtual_dependency("cxx"):
compiler_pkg = dependent_spec["cxx"].package setattr(module, "spack_cxx", _spack_compiler_attribute(language="cxx"))
setattr(
module, "spack_cxx", str(bin_dir / compiler_pkg.compiler_wrapper_link_paths["cxx"])
)
if dependent_spec.has_virtual_dependency("fortran"): if dependent_spec.has_virtual_dependency("fortran"):
compiler_pkg = dependent_spec["fortran"].package setattr(module, "spack_fc", _spack_compiler_attribute(language="fortran"))
setattr( setattr(module, "spack_f77", _spack_compiler_attribute(language="fortran"))
module,
"spack_fc",
str(bin_dir / compiler_pkg.compiler_wrapper_link_paths["fortran"]),
)
setattr(
module,
"spack_f77",
str(bin_dir / compiler_pkg.compiler_wrapper_link_paths["fortran"]),
)
@property @property
def disable_new_dtags(self) -> str: def disable_new_dtags(self) -> str:

View File

@ -23,8 +23,8 @@ class Msmpi(Package):
version("10.1.1", sha256="63c7da941fc4ffb05a0f97bd54a67968c71f63389a0d162d3182eabba1beab3d") version("10.1.1", sha256="63c7da941fc4ffb05a0f97bd54a67968c71f63389a0d162d3182eabba1beab3d")
version("10.0.0", sha256="cfb53cf53c3cf0d4935ab58be13f013a0f7ccb1189109a5b8eea0fcfdcaef8c1") version("10.0.0", sha256="cfb53cf53c3cf0d4935ab58be13f013a0f7ccb1189109a5b8eea0fcfdcaef8c1")
depends_on("cxx", type="build") # generated depends_on("cxx", type="build")
depends_on("fortran", type="build") # generated depends_on("fortran", type="build")
provides("mpi") provides("mpi")
@ -33,6 +33,7 @@ class Msmpi(Package):
patch("ifort_compat.patch") patch("ifort_compat.patch")
requires("platform=windows") requires("platform=windows")
requires("%msvc")
@classmethod @classmethod
def determine_version(cls, exe): def determine_version(cls, exe):
@ -48,11 +49,10 @@ def setup_dependent_package(self, module, dependent_spec):
# MSMPI does not vendor compiler wrappers, instead arguments should # MSMPI does not vendor compiler wrappers, instead arguments should
# be manually supplied to compiler by consuming package # be manually supplied to compiler by consuming package
# Note: This is not typical of MPI installations # Note: This is not typical of MPI installations
dependent_module = dependent_spec.package.module self.spec.mpicc = dependent_spec["c"].package.cc
self.spec.mpicc = dependent_module.spack_cc self.spec.mpicxx = dependent_spec["cxx"].package.cxx
self.spec.mpicxx = dependent_module.spack_cxx self.spec.mpifc = dependent_spec["fortran"].package.fortran
self.spec.mpifc = dependent_module.spack_fc self.spec.mpif77 = dependent_spec["fortran"].package.fortran
self.spec.mpif77 = dependent_module.spack_f77
class GenericBuilder(GenericBuilder): class GenericBuilder(GenericBuilder):

View File

@ -52,7 +52,7 @@ def install(self, spec, prefix):
# compiler wrappers # compiler wrappers
compiler_wrapper_link_paths = {"c": "", "cxx": "", "fortran": ""} compiler_wrapper_link_paths = {"c": "", "cxx": "", "fortran": ""}
provides("c", "cxx") provides("c", "cxx", "fortran")
requires("platform=windows", msg="MSVC is only supported on Windows") requires("platform=windows", msg="MSVC is only supported on Windows")
@classmethod @classmethod
@ -119,6 +119,9 @@ def setup_dependent_build_environment(self, env, dependent_spec):
env.set("CC", self.cc) env.set("CC", self.cc)
env.set("CXX", self.cxx) env.set("CXX", self.cxx)
if self.fortran:
env.set("FC", self.fortran)
env.set("F77", self.fortran)
def init_msvc(self): def init_msvc(self):
# To use the MSVC compilers, VCVARS must be invoked # To use the MSVC compilers, VCVARS must be invoked

View File

@ -116,10 +116,15 @@ def rename_downloaded_executable(self):
This name is not properly formated so that Windows understands it as an executable This name is not properly formated so that Windows understands it as an executable
We rename so as to allow Windows to run the WGL installer""" We rename so as to allow Windows to run the WGL installer"""
installer = glob.glob(os.path.join(self.stage.source_path, "linkid=**")) installer = glob.glob(os.path.join(self.stage.source_path, "linkid=**"))
if len(installer) > 1: fetch_size = len(installer)
if fetch_size > 1:
raise RuntimeError( raise RuntimeError(
"Fetch has failed, unable to determine installer path from:\n%s" "Fetch has failed, ambiguous behavior, fetch has pulled too much. "
% "\n".join(installer) "Unable to determine installer path from:\n%s" % "\n".join(installer)
)
elif fetch_size < 1:
raise RuntimeError(
"Fetch has failed, nothing was fetched from:\n%s" % "\n".join(installer)
) )
installer = installer[0] installer = installer[0]
os.rename(installer, os.path.join(self.stage.source_path, "wdksetup.exe")) os.rename(installer, os.path.join(self.stage.source_path, "wdksetup.exe"))