You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are running into problems with JEDI-UFS where we get the "usual" double-free corruption because code gets linked against ESMF shared and ESMF static due to all the complicated dependencies for JEDI-UFS.
I can work around this by modifying findESMF.cmake like this, following precedence from the cmake default findHDF5.cmake:
--- /Users/heinzell/prod/spack-stack-1.7.0/envs/unified-env/install/apple-clang/13.1.6/jedi-cmake-1.4.0-mskpdnp/share/jedicmake/Modules/FindESMF.cmake.original 2024-04-09 09:26:09.000000000 -0600
+++ /Users/heinzell/prod/spack-stack-1.7.0/envs/unified-env/install/apple-clang/13.1.6/jedi-cmake-1.4.0-mskpdnp/share/jedicmake/Modules/FindESMF.cmake 2024-04-09 15:02:00.000000000 -0600
@@ -90,19 +90,12 @@
endforeach()
set(ESMF_F90COMPILEPATHS ${tmp})
- # Look for static library, if not found try dynamic library
- find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR})
- if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
- unset(esmf_lib)
- message(STATUS "Static ESMF library not found, searching for dynamic library instead")
- find_library(esmf_lib NAMES esmf_fullylinked libesmf.so PATHS ${ESMF_LIBSDIR})
- if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
- unset(esmf_lib)
- message(STATUS "Neither the dynamic nor the static ESMF library was found")
- else()
- set(_library_type SHARED)
- endif()
+ # Look for static library by default unless user specifies ESMF_USE_SHARED_LIBRARIES
+ if(ESMF_USE_SHARED_LIBRARIES)
+ find_library(esmf_lib NAMES esmf_fullylinked${CMAKE_SHARED_LIBRARY_SUFFIX} libesmf${CMAKE_SHARED_LIBRARY_SUFFIX} PATHS ${ESMF_LIBSDIR})
+ set(_library_type SHARED)
else()
+ find_library(esmf_lib NAMES libesmf${CMAKE_STATIC_LIBRARY_SUFFIX} PATHS ${ESMF_LIBSDIR})
set(_library_type STATIC)
endif()
The default for ESMF will still be to look for a static ESMF library, but it will fail if it doesn't find it (i.e. it will not automatically fall back to look for the shared library). When the user sets ESMF_USE_SHARED_LIBRARIES in CMakeLists.txt, then the same is true for the shared library.
Would that be an ok modification? Should we also propose this for the ESMF repo?
What is the prospect of getting rid of findESMF.py here and always use the one that comes with ESMF?
The text was updated successfully, but these errors were encountered:
Actually, looking at ESMF's own findESMF.cmake, they already have something like this, just with shared being the default (which makes sense, since this is more common nowadays). See attached screenshot for a diff ouf our (develop) findESMF.cmake an the esmf-8.6.0 findESMF.cmake.
It think we should get rid of findESMF.cmake in CMakeModules and make sure the spack package is configured correctly to point cmake to the version provided by ESMF itself.
climbfuji
changed the title
Provide switch to choose between ESMF static and shared?
Provide switch to choose between ESMF static and shared? No, better to use ESMF's own findESMF.cmake?
Apr 9, 2024
We are running into problems with JEDI-UFS where we get the "usual" double-free corruption because code gets linked against ESMF shared and ESMF static due to all the complicated dependencies for JEDI-UFS.
I can work around this by modifying
findESMF.cmake
like this, following precedence from the cmake defaultfindHDF5.cmake
:The default for ESMF will still be to look for a static ESMF library, but it will fail if it doesn't find it (i.e. it will not automatically fall back to look for the shared library). When the user sets
ESMF_USE_SHARED_LIBRARIES
inCMakeLists.txt
, then the same is true for the shared library.Would that be an ok modification? Should we also propose this for the ESMF repo?
What is the prospect of getting rid of
findESMF.py
here and always use the one that comes with ESMF?The text was updated successfully, but these errors were encountered: