From e830ddaa8a94d75ecab0a6e7c50e8adc053e1910 Mon Sep 17 00:00:00 2001 From: Stephen Herbener Date: Fri, 30 Aug 2024 09:10:12 -0600 Subject: [PATCH 1/5] Changes to get Mac Sonoma 14.6.1 with Command Line Tools 15.3 working. --- .../packages/fms/enable-shared-libs.patch | 64 +++++++++++++++++++ .../repos/builtin/packages/fms/package.py | 12 ++++ .../builtin/packages/py-netcdf4/package.py | 2 +- .../packages/py-ruamel-yaml-clib/package.py | 2 +- 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 var/spack/repos/builtin/packages/fms/enable-shared-libs.patch diff --git a/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch b/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch new file mode 100644 index 00000000000000..9ca2c98f81ab87 --- /dev/null +++ b/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch @@ -0,0 +1,64 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2ca5c652..5082a98e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -52,14 +52,16 @@ endif() + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + + # Build options +-option(OPENMP "Build FMS with OpenMP support" OFF) +-option(32BIT "Build 32-bit (r4) FMS library" ON) +-option(64BIT "Build 64-bit (r8) FMS library" OFF) +-option(FPIC "Build with position independent code" OFF) ++option(OPENMP "Build FMS with OpenMP support" OFF) ++option(32BIT "Build 32-bit (r4) FMS library" ON) ++option(64BIT "Build 64-bit (r8) FMS library" OFF) ++option(FPIC "Build with position independent code" OFF) ++option(SHARED_LIBS "Build shared/dynamic libraries" OFF) + + # Options for compiler definitions + option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON) + option(ENABLE_QUAD_PRECISION "Enable compiler definition -DENABLE_QUAD_PRECISION" ON) ++option(PORTABLE_KINDS "Enable compiler definition -DPORTABLE_KINDS" OFF) + option(GFS_PHYS "Enable compiler definition -DGFS_PHYS" OFF) + option(LARGEFILE "Enable compiler definition -Duse_LARGEFILE" OFF) + option(WITH_YAML "Enable compiler definition -Duse_yaml" OFF) +@@ -266,6 +268,10 @@ if(ENABLE_QUAD_PRECISION) + list(APPEND fms_defs ENABLE_QUAD_PRECISION) + endif() + ++if(PORTABLE_KINDS) ++ list(APPEND fms_defs PORTABLE_KINDS) ++endif() ++ + if(LARGEFILE) + list(APPEND fms_defs use_LARGEFILE) + endif() +@@ -360,8 +366,15 @@ foreach(kind ${kinds}) + endif() + + # FMS (C + Fortran) +- add_library(${libTgt} STATIC $ +- $) ++ if (SHARED_LIBS) ++ message(STATUS "Shared library target: ${libTgt}") ++ add_library(${libTgt} SHARED $ ++ $) ++ else () ++ message(STATUS "Static library target: ${libTgt}") ++ add_library(${libTgt} STATIC $ ++ $) ++ endif () + + target_include_directories(${libTgt} PUBLIC + $ +@@ -397,7 +410,8 @@ foreach(kind ${kinds}) + target_compile_definitions(${libTgt} PRIVATE "${fms_defs}") + target_compile_definitions(${libTgt} PRIVATE "${${kind}_defs}") + +- target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_Fortran ++ target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_C ++ NetCDF::NetCDF_Fortran + MPI::MPI_Fortran) + + if(OpenMP_Fortran_FOUND) diff --git a/var/spack/repos/builtin/packages/fms/package.py b/var/spack/repos/builtin/packages/fms/package.py index 0bcf22034cf8d2..8441d2f3f93102 100644 --- a/var/spack/repos/builtin/packages/fms/package.py +++ b/var/spack/repos/builtin/packages/fms/package.py @@ -62,6 +62,17 @@ class Fms(CMakePackage): when="@2023.03", ) + # macos needs shared libraries for version 2024.02 + # What the following patch is providing is available in version 2024.03 + # and newer so it is only needed to 2024.02 + variant( + "sharedlibs", + description="Build shared libraries", + default=True, + when="@2024.02: %apple-clang@15:" + ) + patch("enable-shared-libs.patch", when="@2024.02 %apple-clang@15: +sharedlibs") + variant( "precision", values=("32", "64"), @@ -119,6 +130,7 @@ def cmake_args(self): self.define_from_variant("GFS_PHYS"), self.define_from_variant("OPENMP"), self.define_from_variant("ENABLE_QUAD_PRECISION", "quad_precision"), + self.define_from_variant("SHARED_LIBS", "sharedlibs"), self.define_from_variant("WITH_YAML", "yaml"), self.define_from_variant("CONSTANTS"), self.define_from_variant("LARGEFILE", "large_file"), diff --git a/var/spack/repos/builtin/packages/py-netcdf4/package.py b/var/spack/repos/builtin/packages/py-netcdf4/package.py index e0bf493749e4c0..3316e69692d7d5 100644 --- a/var/spack/repos/builtin/packages/py-netcdf4/package.py +++ b/var/spack/repos/builtin/packages/py-netcdf4/package.py @@ -50,7 +50,7 @@ class PyNetcdf4(PythonPackage): def flag_handler(self, name, flags): if name == "cflags": - if self.spec.satisfies("%oneapi"): + if self.spec.satisfies("%oneapi") or self.spec.satisfies("%apple-clang@15:"): flags.append("-Wno-error=int-conversion") return flags, None, None diff --git a/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py b/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py index bd9d97f49bd23b..2ae9ad5f568522 100644 --- a/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py +++ b/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py @@ -27,6 +27,6 @@ class PyRuamelYamlClib(PythonPackage): def flag_handler(self, name, flags): if name == "cflags": - if self.spec.satisfies("%oneapi"): + if self.spec.satisfies("%oneapi") or self.spec.satisfies(" %apple-clang@15:"): flags.append("-Wno-error=incompatible-function-pointer-types") return (flags, None, None) From 276956ad8c629318075a50f06b1daae3dd17972a Mon Sep 17 00:00:00 2001 From: Stephen Herbener <32968781+srherbener@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:24:08 -0600 Subject: [PATCH 2/5] Fixed style error --- var/spack/repos/builtin/packages/fms/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/fms/package.py b/var/spack/repos/builtin/packages/fms/package.py index 8441d2f3f93102..7719f2887bfd64 100644 --- a/var/spack/repos/builtin/packages/fms/package.py +++ b/var/spack/repos/builtin/packages/fms/package.py @@ -69,7 +69,7 @@ class Fms(CMakePackage): "sharedlibs", description="Build shared libraries", default=True, - when="@2024.02: %apple-clang@15:" + when="@2024.02: %apple-clang@15:", ) patch("enable-shared-libs.patch", when="@2024.02 %apple-clang@15: +sharedlibs") From b0654766f0150074a1873c025c6524087b59cfbb Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Tue, 3 Sep 2024 16:59:53 -0600 Subject: [PATCH 3/5] Redo sharedlibs patch for fms@2024.02+ --- var/spack/repos/builtin/packages/fms/package.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/var/spack/repos/builtin/packages/fms/package.py b/var/spack/repos/builtin/packages/fms/package.py index 7719f2887bfd64..6abaa976386e71 100644 --- a/var/spack/repos/builtin/packages/fms/package.py +++ b/var/spack/repos/builtin/packages/fms/package.py @@ -62,16 +62,15 @@ class Fms(CMakePackage): when="@2023.03", ) - # macos needs shared libraries for version 2024.02 + variant("shared", description="Build shared libraries", when="@2024.02:", default=False) # What the following patch is providing is available in version 2024.03 # and newer so it is only needed to 2024.02 - variant( - "sharedlibs", - description="Build shared libraries", - default=True, - when="@2024.02: %apple-clang@15:", + #patch("enable-shared-libs.patch", when="@2024.02") # +shared") + patch( + "https://github.com/NOAA-GFDL/fms/pull/1559.patch?full_index=1", + sha256="2b12a6c35f357c3dddcfa5282576e56ab0e8e6c1ad1dab92a2c85ce3dfb815d4", + when="@2024.02", ) - patch("enable-shared-libs.patch", when="@2024.02 %apple-clang@15: +sharedlibs") variant( "precision", @@ -130,7 +129,7 @@ def cmake_args(self): self.define_from_variant("GFS_PHYS"), self.define_from_variant("OPENMP"), self.define_from_variant("ENABLE_QUAD_PRECISION", "quad_precision"), - self.define_from_variant("SHARED_LIBS", "sharedlibs"), + self.define_from_variant("SHARED_LIBS", "shared"), self.define_from_variant("WITH_YAML", "yaml"), self.define_from_variant("CONSTANTS"), self.define_from_variant("LARGEFILE", "large_file"), From 579a4740660de4790d95b96c36b8577198fa40ac Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Tue, 3 Sep 2024 20:48:10 -0600 Subject: [PATCH 4/5] Fix formatting error in var/spack/repos/builtin/packages/fms/package.py --- var/spack/repos/builtin/packages/fms/package.py | 1 - 1 file changed, 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/fms/package.py b/var/spack/repos/builtin/packages/fms/package.py index 6abaa976386e71..f94fb771b05de6 100644 --- a/var/spack/repos/builtin/packages/fms/package.py +++ b/var/spack/repos/builtin/packages/fms/package.py @@ -65,7 +65,6 @@ class Fms(CMakePackage): variant("shared", description="Build shared libraries", when="@2024.02:", default=False) # What the following patch is providing is available in version 2024.03 # and newer so it is only needed to 2024.02 - #patch("enable-shared-libs.patch", when="@2024.02") # +shared") patch( "https://github.com/NOAA-GFDL/fms/pull/1559.patch?full_index=1", sha256="2b12a6c35f357c3dddcfa5282576e56ab0e8e6c1ad1dab92a2c85ce3dfb815d4", From 18084523b061686a920841c5766df86847fa2a45 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Tue, 3 Sep 2024 20:59:55 -0600 Subject: [PATCH 5/5] Remove unused var/spack/repos/builtin/packages/fms/enable-shared-libs.patch --- .../packages/fms/enable-shared-libs.patch | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 var/spack/repos/builtin/packages/fms/enable-shared-libs.patch diff --git a/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch b/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch deleted file mode 100644 index 9ca2c98f81ab87..00000000000000 --- a/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2ca5c652..5082a98e 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -52,14 +52,16 @@ endif() - list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - - # Build options --option(OPENMP "Build FMS with OpenMP support" OFF) --option(32BIT "Build 32-bit (r4) FMS library" ON) --option(64BIT "Build 64-bit (r8) FMS library" OFF) --option(FPIC "Build with position independent code" OFF) -+option(OPENMP "Build FMS with OpenMP support" OFF) -+option(32BIT "Build 32-bit (r4) FMS library" ON) -+option(64BIT "Build 64-bit (r8) FMS library" OFF) -+option(FPIC "Build with position independent code" OFF) -+option(SHARED_LIBS "Build shared/dynamic libraries" OFF) - - # Options for compiler definitions - option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON) - option(ENABLE_QUAD_PRECISION "Enable compiler definition -DENABLE_QUAD_PRECISION" ON) -+option(PORTABLE_KINDS "Enable compiler definition -DPORTABLE_KINDS" OFF) - option(GFS_PHYS "Enable compiler definition -DGFS_PHYS" OFF) - option(LARGEFILE "Enable compiler definition -Duse_LARGEFILE" OFF) - option(WITH_YAML "Enable compiler definition -Duse_yaml" OFF) -@@ -266,6 +268,10 @@ if(ENABLE_QUAD_PRECISION) - list(APPEND fms_defs ENABLE_QUAD_PRECISION) - endif() - -+if(PORTABLE_KINDS) -+ list(APPEND fms_defs PORTABLE_KINDS) -+endif() -+ - if(LARGEFILE) - list(APPEND fms_defs use_LARGEFILE) - endif() -@@ -360,8 +366,15 @@ foreach(kind ${kinds}) - endif() - - # FMS (C + Fortran) -- add_library(${libTgt} STATIC $ -- $) -+ if (SHARED_LIBS) -+ message(STATUS "Shared library target: ${libTgt}") -+ add_library(${libTgt} SHARED $ -+ $) -+ else () -+ message(STATUS "Static library target: ${libTgt}") -+ add_library(${libTgt} STATIC $ -+ $) -+ endif () - - target_include_directories(${libTgt} PUBLIC - $ -@@ -397,7 +410,8 @@ foreach(kind ${kinds}) - target_compile_definitions(${libTgt} PRIVATE "${fms_defs}") - target_compile_definitions(${libTgt} PRIVATE "${${kind}_defs}") - -- target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_Fortran -+ target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_C -+ NetCDF::NetCDF_Fortran - MPI::MPI_Fortran) - - if(OpenMP_Fortran_FOUND)