From 4ed963dda1d1b66c1be9e3b168613b24c72e32f4 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 5 Oct 2022 10:30:09 -0700 Subject: [PATCH] OpenBLAS 0.3.21: w/o Fortran (#32398) There is a new OpenBLAS release out that can be compiled w/o a Fortran compiler. macOS XCode developers, rejoice. Maybe at some point Spack becomes a package manager that can be used without using another package manager (to get gfortran) :tada: phist: add conflict on reference netlib-lapack due to API change in lapack.h Co-authored-by: Harmen Stoppels --- .../builtin/packages/openblas/package.py | 33 ++++++++++++------- .../repos/builtin/packages/phist/package.py | 8 +++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py index b8a0d16d5a..bfb6d3e7d5 100644 --- a/var/spack/repos/builtin/packages/openblas/package.py +++ b/var/spack/repos/builtin/packages/openblas/package.py @@ -20,6 +20,7 @@ class Openblas(MakefilePackage): libraries = ["libopenblas"] version("develop", branch="develop") + version("0.3.21", sha256="f36ba3d7a60e7c8bcc54cd9aaa9b1223dd42eaf02c811791c37e8ca707c241ca") version("0.3.20", sha256="8495c9affc536253648e942908e88e097f2ec7753ede55aca52e5dead3029e3c") version("0.3.19", sha256="947f51bfe50c2a0749304fbe373e00e7637600b0a47b78a51382aeb30ca08562") version("0.3.18", sha256="1632c1e8cca62d8bed064b37747e331a1796fc46f688626337362bf0d16aeadb") @@ -48,6 +49,13 @@ class Openblas(MakefilePackage): version("0.2.16", sha256="766f350d0a4be614812d535cead8c816fc3ad3b9afcd93167ea5e4df9d61869b") version("0.2.15", sha256="73c40ace5978282224e5e122a41c8388c5a19e65a6f2329c2b7c0b61bacc9044") + variant( + "fortran", + default="True", + when="@0.3.21:", + description="w/o a Fortran compiler, OpenBLAS will build an f2c-converted LAPACK", + ) + variant("ilp64", default=False, description="Force 64-bit Fortran native integers") variant("pic", default=True, description="Build position independent code") variant("shared", default=True, description="Build shared libraries") @@ -208,7 +216,10 @@ def check_compilers(self): # As of 06/2016 there is no mechanism to specify that packages which # depends on Blas/Lapack need C or/and Fortran symbols. For now # require both. - if self.compiler.fc is None: + # As of 08/2022 (0.3.21), we can build purely with a C compiler using + # a f2c translated LAPACK version + # https://github.com/xianyi/OpenBLAS/releases/tag/v0.3.21 + if self.compiler.fc is None and "~fortran" not in self.spec: raise InstallError("OpenBLAS requires both C and Fortran compilers!") @staticmethod @@ -313,10 +324,9 @@ def make_defs(self): # When mixing compilers make sure that # $SPACK_ROOT/lib/spack/env/ have symlinks with reasonable # names and hack them inside lib/spack/spack/compilers/.py - make_defs = [ - "CC={0}".format(spack_cc), - "FC={0}".format(spack_fc), - ] + make_defs = ["CC={0}".format(spack_cc)] + if "~fortran" not in self.spec: + make_defs += ["FC={0}".format(spack_fc)] # force OpenBLAS to use externally defined parallel build if self.spec.version < Version("0.3"): @@ -327,14 +337,15 @@ def make_defs(self): # Add target and architecture flags make_defs += self._microarch_target_args() + # Fortran-free compilation + if "~fortran" in self.spec: + make_defs += ["NOFORTRAN=1"] + if "~shared" in self.spec: if "+pic" in self.spec: - make_defs.extend( - [ - "CFLAGS={0}".format(self.compiler.cc_pic_flag), - "FFLAGS={0}".format(self.compiler.f77_pic_flag), - ] - ) + make_defs.append("CFLAGS={0}".format(self.compiler.cc_pic_flag)) + if "~fortran" not in self.spec: + make_defs.append("FFLAGS={0}".format(self.compiler.f77_pic_flag)) make_defs += ["NO_SHARED=1"] # fix missing _dggsvd_ and _sggsvd_ if self.spec.satisfies("@0.2.16"): diff --git a/var/spack/repos/builtin/packages/phist/package.py b/var/spack/repos/builtin/packages/phist/package.py index d5c420468b..b158851834 100644 --- a/var/spack/repos/builtin/packages/phist/package.py +++ b/var/spack/repos/builtin/packages/phist/package.py @@ -189,6 +189,14 @@ class Phist(CMakePackage): # and actual argument at (2) (scalar and rank-1) conflicts("%gcc@10:", when="@:1.9.0") + # reference lapack 3.9.1 (included in openblas 0.3.21) changed their lapack.h API + # to include trailing string lengths arguments in functions that have + # single-character strings as args. phist should be using the relevant + # LAPACK_function(...) macro's instead. + # https://bitbucket.org/essex/phist/issues/245/does-not-compile-with-reference-lapack-391 + conflicts("^openblas@0.3.21:") + conflicts("^netlib-lapack@3.9.1:") + # the phist repo came with it's own FindMPI.cmake before, which may cause some other # MPI installation to be used than the one spack wants. def patch(self):