From a3548821ffa2b14c35e7037993af2119d90b1e00 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 10 Jul 2026 03:19:15 -0600 Subject: [PATCH 1/6] llvm: add v22.1.6, v22.1.7, v22.1.8 (#5059) --- repos/spack_repo/builtin/packages/llvm/package.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repos/spack_repo/builtin/packages/llvm/package.py b/repos/spack_repo/builtin/packages/llvm/package.py index c46e0fb4684..8bc65c18d0c 100644 --- a/repos/spack_repo/builtin/packages/llvm/package.py +++ b/repos/spack_repo/builtin/packages/llvm/package.py @@ -55,6 +55,9 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage): # Note: remember to update `provides("libllvm")` according to major versions listed # Latest stable + version("22.1.8", sha256="ad18b70e287954c3d62bc7e0b86e7b7af2adf87bcfce21c15fe717f101d7aace") + version("22.1.7", sha256="da1578ea1faf2050e4b1923fce150b5656db1dbdeda71fe02498ac04f35b03d3") + version("22.1.6", sha256="ba534c6835a5b9c2162c806e269799fe41fca952a3c25baff1afcff23841ec2b") version("22.1.5", sha256="263e99bd0b590664a886b0332037ff060e108f4e7b0310b7c8277208858f867d") version("22.1.4", sha256="e813bf8da34ec2b7c108c4067937380fa7d5a04a13f4fe13555dbe388482d69f") version("22.1.3", sha256="7e144bd6da8177757434cc0dfd1476122f143413df379c6d6cf03843512b5a9e") From ad304ec461c6c3c5ec183abd4078ba8018454d51 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sat, 12 Sep 2026 02:33:51 -0600 Subject: [PATCH 2/6] llvm: add v23.1.0 (#6260) * llvm: add v23.1.0 * llvm: add v23.1.1 --- repos/spack_repo/builtin/packages/llvm/package.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repos/spack_repo/builtin/packages/llvm/package.py b/repos/spack_repo/builtin/packages/llvm/package.py index 8bc65c18d0c..5bbbf47050b 100644 --- a/repos/spack_repo/builtin/packages/llvm/package.py +++ b/repos/spack_repo/builtin/packages/llvm/package.py @@ -55,6 +55,10 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage): # Note: remember to update `provides("libllvm")` according to major versions listed # Latest stable + version("23.1.1", sha256="851b3d701a4fbdd9f69536d4acda578469e810ca7056687d6556443f5fd39557") + version("23.1.0", sha256="d8657b2a7291e518407bf13c4b41c85ef2cded2d4354097a2f451644dfc817b0") + + # Previous stable series releases version("22.1.8", sha256="ad18b70e287954c3d62bc7e0b86e7b7af2adf87bcfce21c15fe717f101d7aace") version("22.1.7", sha256="da1578ea1faf2050e4b1923fce150b5656db1dbdeda71fe02498ac04f35b03d3") version("22.1.6", sha256="ba534c6835a5b9c2162c806e269799fe41fca952a3c25baff1afcff23841ec2b") @@ -65,7 +69,6 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage): version("22.1.1", sha256="c48878550911a8a8993a749e6118446082656768e62b26456ac7d39c4422b409") version("22.1.0", sha256="933765a1c2cd518d95a9033a92d88d7109a79aefa4609247c31f28b8bc8dd96e") - # Previous stable series releases version("21.1.8", sha256="7ba3f2a8d8fda88be18a31d011e8195d3b7f87f9fa92b20c94cba2d7f65b0e3f") version("21.1.7", sha256="9ee167cdf8f6b5221d6b02dbe9a664cf8c6fee70fab071aaa4a3889c7c265258") version("21.1.6", sha256="2380973eb435b48bd70881939da3629069009a851c81676dfb211a1b068d72a6") @@ -275,6 +278,7 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage): variant("utils", default=False, description="Install utility binaries (FileCheck, etc.)") + provides("libllvm@23", when="@23") provides("libllvm@22", when="@22") provides("libllvm@21", when="@21") provides("libllvm@20", when="@20") From 0e2a14ed1d41d956455e793857b71ea2613d0e3b Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 24 Sep 2026 15:28:08 -0400 Subject: [PATCH 3/6] More updates for macos.gmao --- .../builtin/packages/fms/llvmflang.patch | 26 ++++++++++++++ .../builtin/packages/fms/package.py | 4 +++ .../builtin/packages/hdf5/package.py | 34 +++++++++++++++++++ .../builtin/packages/openmpi/package.py | 18 ++++++++-- .../builtin/packages/parallelio/package.py | 9 +++++ .../builtin/packages/pfunit/package.py | 12 +++++++ 6 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 repos/spack_repo/builtin/packages/fms/llvmflang.patch diff --git a/repos/spack_repo/builtin/packages/fms/llvmflang.patch b/repos/spack_repo/builtin/packages/fms/llvmflang.patch new file mode 100644 index 00000000000..44ca3a74c43 --- /dev/null +++ b/repos/spack_repo/builtin/packages/fms/llvmflang.patch @@ -0,0 +1,26 @@ +--- a/cmake/fms_compiler_flags.cmake ++++ b/cmake/fms_compiler_flags.cmake +@@ -7,6 +7,8 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + include(compiler_flags_Intel_Fortran) + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + include(compiler_flags_IntelLLVM_Fortran) ++elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang") ++ include(compiler_flags_LLVMFlang_Fortran) + else() + message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") + endif() +--- /dev/null ++++ b/cmake/compiler_flags_LLVMFlang_Fortran.cmake +@@ -0,0 +1,11 @@ ++# Precision-based Fortran compiler flags ++set(r8_flags "-fdefault-real-8 -fdefault-double-8") ++set(r4_flags "-fdefault-real-4") ++ ++# LLVM Flang ++set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") ++set(CMAKE_Fortran_FLAGS_RELEASE "-O2") ++set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g") ++set(CMAKE_Fortran_LINK_FLAGS "") ++ ++# UFS flags are not known for LLVM Flang. diff --git a/repos/spack_repo/builtin/packages/fms/package.py b/repos/spack_repo/builtin/packages/fms/package.py index 2fae0fa805c..d12fa30d394 100644 --- a/repos/spack_repo/builtin/packages/fms/package.py +++ b/repos/spack_repo/builtin/packages/fms/package.py @@ -101,6 +101,10 @@ class Fms(CMakePackage): when="@2023.03", ) + # Add LLVM Flang precision flags. Based on the GEOS Baselibs patch: + # https://github.com/GEOS-ESM/ESMA-Baselibs/blob/main/patches/FMS/llvm.patch + patch("llvmflang.patch", when="@2026.01.01 %fortran=clang") + variant( "portable_kinds", description="Use iso_c_binding variable kinds", diff --git a/repos/spack_repo/builtin/packages/hdf5/package.py b/repos/spack_repo/builtin/packages/hdf5/package.py index 14671e18b77..d09390e715a 100644 --- a/repos/spack_repo/builtin/packages/hdf5/package.py +++ b/repos/spack_repo/builtin/packages/hdf5/package.py @@ -554,6 +554,20 @@ def is_enabled(text): def setup_build_environment(self, env: EnvironmentModifications) -> None: env.set("SZIP_INSTALL", self.spec["szip"].prefix) + @run_before("cmake") + def fix_darwin_flang_link_flags(self): + if not self.spec.satisfies("@2.0.0: platform=darwin %fortran=clang"): + return + + # HDF5 uses CMake's C linker flag variables for version flags on all + # targets. Forward them explicitly so Flang passes them to ld. + filter_file( + 'LINK_FLAGS "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}${PACKAGE_CURRENT} ${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}${PACKAGE_COMPATIBILITY}"', + 'LINK_FLAGS "-Wl,-current_version -Wl,${PACKAGE_CURRENT} -Wl,-compatibility_version -Wl,${PACKAGE_COMPATIBILITY}"', + "config/HDF5Macros.cmake", + string=True, + ) + def cmake_args(self): spec = self.spec @@ -646,6 +660,26 @@ def cmake_args(self): # NAG cannot pass Spack's padded build rpath through its linker. args.append(self.define("CMAKE_SKIP_RPATH", True)) + if spec.satisfies("@2.0.0: platform=darwin %fortran=clang"): + # CMake's generic Darwin rule sends -install_name directly to the + # driver, but LLVM Flang requires Darwin linker flags via + # -Xlinker. CMake emits this flag and its value separately. + args.append( + self.define( + "CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG", + "-Xlinker -install_name -Xlinker ", + ) + ) + # HDF5's nested Fortran project loses the OpenMPI module directory + # discovered by FindMPI, so its generated modules cannot resolve + # mpi_f08.mod while building the high-level Fortran library. + args.append( + self.define( + "MPI_Fortran_INCLUDE_DIRS", + f"{spec['mpi'].prefix.include};{spec['mpi'].prefix.lib}", + ) + ) + return args @run_after("install") diff --git a/repos/spack_repo/builtin/packages/openmpi/package.py b/repos/spack_repo/builtin/packages/openmpi/package.py index aee2c389337..246b64a4d63 100644 --- a/repos/spack_repo/builtin/packages/openmpi/package.py +++ b/repos/spack_repo/builtin/packages/openmpi/package.py @@ -999,10 +999,24 @@ def libs(self): return find_libraries(libraries, root=self.prefix, shared=True, recursive=True) def setup_build_environment(self, env: EnvironmentModifications) -> None: - # We need to unset MACOSX_DEPLOYMENT_TARGET on macOS if building with NAG Fortran - if self.spec.satisfies("platform=darwin") and self.spec.satisfies("%fortran=nag"): + # Match OpenMPI's Darwin configuration when using Flang or NAG. + # It avoids a shared-library path that these compilers do not support + # for the older Fortran bindings. + if self.spec.satisfies("platform=darwin") and ( + self.spec.satisfies("%fortran=nag") or self.spec.satisfies("%fortran=clang") + ): env.unset("MACOSX_DEPLOYMENT_TARGET") + @run_after("configure") + def fix_darwin_flang_libtool(self): + if not self.spec.satisfies("platform=darwin %fortran=clang"): + return + + # Libtool recognizes a direct `flang` command but not Spack's absolute + # compiler-wrapper path. Consequently it passes Darwin linker flags + # directly to Flang instead of through -Wl,. + filter_file(r"flang\*", r"*/flang|flang*", "libtool") + def setup_run_environment(self, env: EnvironmentModifications) -> None: # Because MPI is both a runtime and a compiler, we have to setup the # compiler components as part of the run environment. diff --git a/repos/spack_repo/builtin/packages/parallelio/package.py b/repos/spack_repo/builtin/packages/parallelio/package.py index 4d0ffd0d0d9..a0c78894e53 100644 --- a/repos/spack_repo/builtin/packages/parallelio/package.py +++ b/repos/spack_repo/builtin/packages/parallelio/package.py @@ -108,6 +108,15 @@ def cmake_args(self): if spec.satisfies("%nag"): # NAG cannot pass Spack's padded build rpath through its linker. args.append(define("CMAKE_SKIP_RPATH", True)) + if spec.satisfies("platform=darwin %fortran=clang"): + # CMake's generic Darwin rule sends -install_name directly to the + # compiler driver, but LLVM Flang requires linker flags via -Xlinker. + args.append( + define( + "CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG", + "-Xlinker -install_name -Xlinker ", + ) + ) if spec.satisfies("+ncint"): args.extend([define("PIO_ENABLE_NETCDF_INTEGRATION", True)]) if spec.satisfies("+pnetcdf"): diff --git a/repos/spack_repo/builtin/packages/pfunit/package.py b/repos/spack_repo/builtin/packages/pfunit/package.py index aab7ef38fbd..b6397614ef4 100644 --- a/repos/spack_repo/builtin/packages/pfunit/package.py +++ b/repos/spack_repo/builtin/packages/pfunit/package.py @@ -137,6 +137,18 @@ def patch(self): for file in glob.glob("*/CMakeLists.txt"): filter_file(r".*/mod($|[^\w].*)", "", file) + @run_before("cmake") + def fix_darwin_llvmflang_ranlib(self): + if self.spec.satisfies("platform=darwin %fortran=clang"): + # pFUnit's macOS override passes a GNU ranlib-only option that + # LLVM ranlib rejects. CMake's default archive rule is valid. + filter_file( + "if (APPLE)", + 'if (APPLE AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")', + "CMakeLists.txt", + string=True, + ) + def url_for_version(self, version): url_base = "https://github.com/Goddard-Fortran-Ecosystem/pFUnit" # Version 4.2.3+ has a v... From fc9b3f0c98162371af51e630c24a187cb3cbea34 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 24 Sep 2026 15:29:20 -0400 Subject: [PATCH 4/6] More updates for macos.gmao --- repos/spack_repo/builtin/packages/py_scipy/package.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/repos/spack_repo/builtin/packages/py_scipy/package.py b/repos/spack_repo/builtin/packages/py_scipy/package.py index 85594fda918..27cbb106406 100644 --- a/repos/spack_repo/builtin/packages/py_scipy/package.py +++ b/repos/spack_repo/builtin/packages/py_scipy/package.py @@ -221,6 +221,13 @@ def setup_build_environment(self, env: EnvironmentModifications) -> None: # https://github.com/scipy/scipy/issues/9080 env.set("F90", spack_fc) + if self.spec.satisfies("platform=darwin %fortran=clang"): + # Meson forwards Python's macOS extension-module linker flag to + # Flang. It must be passed through the compiler driver's linker + # wrapper rather than directly to the driver. + env.remove_flags("LDSHARED", "-bundle") + env.append_flags("LDSHARED", "-Wl,-bundle") + # https://github.com/scipy/scipy/issues/14935 # Newer pythran versions 0.12+ work with newer Intel compilers only for py-scipy. # Tested to work: intel@2022.0.1; tested to not work: 19.1.1.217; in between unknown From 0cfcdba4311d8955a51813fbcd7aef6710733bcb Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 28 Sep 2026 15:54:43 -0400 Subject: [PATCH 5/6] Spread fixes to NAG, revert scipy --- repos/spack_repo/builtin/packages/hdf5/package.py | 15 +++++++++++---- .../builtin/packages/py_scipy/package.py | 7 ------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/repos/spack_repo/builtin/packages/hdf5/package.py b/repos/spack_repo/builtin/packages/hdf5/package.py index d09390e715a..a1cbf75f7f0 100644 --- a/repos/spack_repo/builtin/packages/hdf5/package.py +++ b/repos/spack_repo/builtin/packages/hdf5/package.py @@ -555,12 +555,14 @@ def setup_build_environment(self, env: EnvironmentModifications) -> None: env.set("SZIP_INSTALL", self.spec["szip"].prefix) @run_before("cmake") - def fix_darwin_flang_link_flags(self): - if not self.spec.satisfies("@2.0.0: platform=darwin %fortran=clang"): + def fix_darwin_fortran_link_flags(self): + if not self.spec.satisfies("@2.0.0: platform=darwin") or not ( + self.spec.satisfies("%fortran=clang") or self.spec.satisfies("%fortran=nag") + ): return # HDF5 uses CMake's C linker flag variables for version flags on all - # targets. Forward them explicitly so Flang passes them to ld. + # targets. Forward them explicitly so Flang and NAG pass them to ld. filter_file( 'LINK_FLAGS "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}${PACKAGE_CURRENT} ${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}${PACKAGE_COMPATIBILITY}"', 'LINK_FLAGS "-Wl,-current_version -Wl,${PACKAGE_CURRENT} -Wl,-compatibility_version -Wl,${PACKAGE_COMPATIBILITY}"', @@ -670,9 +672,14 @@ def cmake_args(self): "-Xlinker -install_name -Xlinker ", ) ) + + if spec.satisfies("@2.0.0: platform=darwin +mpi +fortran") and ( + spec.satisfies("%fortran=clang") or spec.satisfies("%fortran=nag") + ): # HDF5's nested Fortran project loses the OpenMPI module directory # discovered by FindMPI, so its generated modules cannot resolve - # mpi_f08.mod while building the high-level Fortran library. + # mpi_f08.mod (Flang) or mpi.mod (NAG) while building the high-level + # Fortran library. args.append( self.define( "MPI_Fortran_INCLUDE_DIRS", diff --git a/repos/spack_repo/builtin/packages/py_scipy/package.py b/repos/spack_repo/builtin/packages/py_scipy/package.py index 27cbb106406..85594fda918 100644 --- a/repos/spack_repo/builtin/packages/py_scipy/package.py +++ b/repos/spack_repo/builtin/packages/py_scipy/package.py @@ -221,13 +221,6 @@ def setup_build_environment(self, env: EnvironmentModifications) -> None: # https://github.com/scipy/scipy/issues/9080 env.set("F90", spack_fc) - if self.spec.satisfies("platform=darwin %fortran=clang"): - # Meson forwards Python's macOS extension-module linker flag to - # Flang. It must be passed through the compiler driver's linker - # wrapper rather than directly to the driver. - env.remove_flags("LDSHARED", "-bundle") - env.append_flags("LDSHARED", "-Wl,-bundle") - # https://github.com/scipy/scipy/issues/14935 # Newer pythran versions 0.12+ work with newer Intel compilers only for py-scipy. # Tested to work: intel@2022.0.1; tested to not work: 19.1.1.217; in between unknown From e3897f0b64aef2770fe335cad52b9d05964c6bf1 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 29 Sep 2026 08:01:31 -0400 Subject: [PATCH 6/6] llvm: add v23.1.2 --- repos/spack_repo/builtin/packages/llvm/package.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repos/spack_repo/builtin/packages/llvm/package.py b/repos/spack_repo/builtin/packages/llvm/package.py index 5bbbf47050b..d6d3677f3b7 100644 --- a/repos/spack_repo/builtin/packages/llvm/package.py +++ b/repos/spack_repo/builtin/packages/llvm/package.py @@ -55,6 +55,7 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage): # Note: remember to update `provides("libllvm")` according to major versions listed # Latest stable + version("23.1.2", sha256="75788d759e6987a910975b902f554dc77c08b076b945b2cebde54116d8e831ca") version("23.1.1", sha256="851b3d701a4fbdd9f69536d4acda578469e810ca7056687d6556443f5fd39557") version("23.1.0", sha256="d8657b2a7291e518407bf13c4b41c85ef2cded2d4354097a2f451644dfc817b0")