From 75a88b97207e31ec8695e619f5392ccbcc6af3ab Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Fri, 28 Nov 2025 11:56:41 -0500 Subject: [PATCH] fix(unity): GridFire supports unity builds GridFire can now support unity builds. This is useful for python bindings. The main limitation is that openssl (a dependency of libplugin) does not support unity builds. Therefore when building in a unity build libplugin must be disabled. This is done with the -Dunity-safe=ture flag at setup time --- Doxyfile | 2 +- build-config/fourdst/meson.build | 19 ++++++++++++++++--- meson.build | 2 +- meson_options.txt | 1 + pyproject.toml | 2 +- src/meson.build | 5 ++++- src/python/gridfire/__init__.py | 2 +- subprojects/fourdst.wrap | 2 +- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Doxyfile b/Doxyfile index 89e00480..4be53f7c 100644 --- a/Doxyfile +++ b/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = GridFire # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v0.7.3_rc2 +PROJECT_NUMBER = v0.7.4_rc2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewers a diff --git a/build-config/fourdst/meson.build b/build-config/fourdst/meson.build index 124ecdcf..04a160c2 100644 --- a/build-config/fourdst/meson.build +++ b/build-config/fourdst/meson.build @@ -1,9 +1,17 @@ # bring in all of the fourdst utility repositories +fourdst_build_lib_all = true +if get_option('unity-safe') + fourdst_build_lib_all=false +endif + fourdst_sp = subproject('fourdst', default_options: ['build-tests=' + get_option('build-tests').to_string(), - 'build-python=' + get_option('build-python').to_string() + 'build-python=' + get_option('build-python').to_string(), + 'build-lib-all=' + fourdst_build_lib_all.to_string(), + 'pkg-config=' + get_option('pkg-config').to_string(), + 'build-lib-log=true' ] ) @@ -11,10 +19,15 @@ composition_dep = fourdst_sp.get_variable('composition_dep') log_dep = fourdst_sp.get_variable('log_dep') const_dep = fourdst_sp.get_variable('const_dep') config_dep = fourdst_sp.get_variable('config_dep') -plugin_dep = fourdst_sp.get_variable('plugin_dep') +if not get_option('unity-safe') + plugin_dep = fourdst_sp.get_variable('plugin_dep') +endif libcomposition = fourdst_sp.get_variable('libcomposition') libconst = fourdst_sp.get_variable('libconst') libconfig = fourdst_sp.get_variable('libconfig') liblogging = fourdst_sp.get_variable('liblogging') -libplugin = fourdst_sp.get_variable('libplugin') \ No newline at end of file + +if not get_option('unity-safe') + libplugin = fourdst_sp.get_variable('libplugin') +endif \ No newline at end of file diff --git a/meson.build b/meson.build index 7dd5d4cc..5097959f 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # *********************************************************************** # -project('GridFire', ['c', 'cpp', 'fortran'], version: 'v0.7.3_rc2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') +project('GridFire', ['c', 'cpp', 'fortran'], version: 'v0.7.4_rc2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') # Add default visibility for all C++ targets add_project_arguments('-fvisibility=default', language: 'cpp') diff --git a/meson_options.txt b/meson_options.txt index 63a752d5..ec80a866 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,3 +4,4 @@ option('build-python', type: 'boolean', value: false, description: 'build the py option('build-tests', type: 'boolean', value: true, description: 'build the test suite') option('build-fortran', type: 'boolean', value: false, description: 'build fortran module support') option('unsafe-fortran', type: 'boolean', value: false, description: 'Allow untested fortran compilers (compilers other than gfortran)') +option('unity-safe', type: 'boolean', value: false, description: 'Enable safe unity builds for better compatibility across different compilers and platforms') diff --git a/pyproject.toml b/pyproject.toml index 6a7a6a2e..bedbcdc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "mesonpy" [project] name = "gridfire" # Choose your Python package name -version = "0.7.3_rc2" # Your project's version +version = "0.7.4_rc2" # Your project's version description = "Python interface to the GridFire nuclear network code" readme = "README.md" license = { file = "LICENSE.txt" } # Reference your license file [cite: 2] diff --git a/src/meson.build b/src/meson.build index 84495c35..a34ad24c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -38,11 +38,14 @@ gridfire_build_dependencies = [ log_dep, xxhash_dep, eigen_dep, - plugin_dep, sundials_dep, json_dep, ] +if not get_option('unity-safe') + gridfire_build_dependencies += [plugin_dep] +endif + # Define the libnetwork library so it can be linked against by other parts of the build system libgridfire = library('gridfire', gridfire_sources, diff --git a/src/python/gridfire/__init__.py b/src/python/gridfire/__init__.py index 709419c1..65d6e5e5 100644 --- a/src/python/gridfire/__init__.py +++ b/src/python/gridfire/__init__.py @@ -16,5 +16,5 @@ sys.modules['gridfire.io'] = io __all__ = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'policy'] -__version__ = "v0.7.3_rc2" +__version__ = "v0.7.4_rc2" diff --git a/subprojects/fourdst.wrap b/subprojects/fourdst.wrap index e718833b..140d8639 100644 --- a/subprojects/fourdst.wrap +++ b/subprojects/fourdst.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://github.com/4D-STAR/fourdst -revision = v0.9.10 +revision = v0.9.11 depth = 1