From cc3708fda5efff0f93c852678c19321c20839387 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 24 Jul 2025 10:20:44 -0400 Subject: [PATCH] build(GridFire): building on gcc and clang resolved some issues preventing GridFire from building on both gcc and clang. Also resolved all warnings on both compilers. --- build-config/eigen/meson.build | 2 +- meson.build | 16 ++++++++++++++-- src/include/gridfire/reaction/reaclib.h | 2 +- src/include/gridfire/reaction/reaction.h | 2 +- src/lib/engine/engine_graph.cpp | 2 +- src/lib/engine/views/engine_adaptive.cpp | 4 ++-- src/lib/engine/views/engine_defined.cpp | 4 ++-- src/lib/engine/views/engine_multiscale.cpp | 14 ++++++-------- .../partition/composite/partition_composite.cpp | 2 +- src/lib/solver/solver.cpp | 4 ++-- subprojects/fourdst.wrap | 2 +- 11 files changed, 32 insertions(+), 22 deletions(-) diff --git a/build-config/eigen/meson.build b/build-config/eigen/meson.build index ce160f25..5c5a0a1c 100644 --- a/build-config/eigen/meson.build +++ b/build-config/eigen/meson.build @@ -2,4 +2,4 @@ eigen_dep = dependency( 'eigen3', version : '>=3.3', fallback : ['eigen', 'eigen_dep'] -) \ No newline at end of file +).as_system() \ No newline at end of file diff --git a/meson.build b/meson.build index df170309..462b0b11 100644 --- a/meson.build +++ b/meson.build @@ -22,8 +22,20 @@ project('GridFire', 'cpp', version: '0.0.1a', default_options: ['cpp_std=c++23'] # Add default visibility for all C++ targets add_project_arguments('-fvisibility=default', language: 'cpp') -# We disable these because of CppAD -add_project_arguments('-Wno-bitwise-instead-of-logical', language: 'cpp') + +message('Found CXX compiler: ' + meson.get_compiler('cpp').get_id()) + +if meson.get_compiler('cpp').get_id() == 'clang' + # We disable these because of CppAD + message('disabling bitwise-instead-of-logical warnings for clang') + add_project_arguments('-Wno-bitwise-instead-of-logical', language: 'cpp') +endif + +if meson.get_compiler('cpp').get_id() == 'gcc' + # We disable these because of boost notes about abi changes from C++10 -> C++17 make the build too noisey + message('disabling psabi warnings for gcc') + add_project_arguments('-Wno-psabi', language: 'cpp') +endif # For Eigen add_project_arguments('-Wno-deprecated-declarations', language: 'cpp') diff --git a/src/include/gridfire/reaction/reaclib.h b/src/include/gridfire/reaction/reaclib.h index 7258a709..dfdbf948 100644 --- a/src/include/gridfire/reaction/reaclib.h +++ b/src/include/gridfire/reaction/reaclib.h @@ -4,7 +4,7 @@ namespace gridfire::reaclib { - static bool s_initialized = false; + [[maybe_unused]] static bool s_initialized = false; /** * @brief Provides global access to the fully initialized REACLIB reaction set. diff --git a/src/include/gridfire/reaction/reaction.h b/src/include/gridfire/reaction/reaction.h index f964e9e4..00328882 100644 --- a/src/include/gridfire/reaction/reaction.h +++ b/src/include/gridfire/reaction/reaction.h @@ -536,7 +536,7 @@ namespace gridfire::reaction { /// friend std::ostream& operator<<(std::ostream& os, const TemplatedReactionSet& r) { os << "(ReactionSet: ["; - int counter = 0; + size_t counter = 0; for (const auto& reaction : r.m_reactions) { os << reaction; if (counter < r.m_reactions.size() - 2) { diff --git a/src/lib/engine/engine_graph.cpp b/src/lib/engine/engine_graph.cpp index 6f97e11b..f4754487 100644 --- a/src/lib/engine/engine_graph.cpp +++ b/src/lib/engine/engine_graph.cpp @@ -860,7 +860,7 @@ namespace gridfire { // Dynamic cast to REACLIBReaction to access specific properties csvFile << reaction.id() << ";"; // Reactants - int count = 0; + size_t count = 0; for (const auto& reactant : reaction.reactants()) { csvFile << reactant.name(); if (++count < reaction.reactants().size()) { diff --git a/src/lib/engine/views/engine_adaptive.cpp b/src/lib/engine/views/engine_adaptive.cpp index c3afb0e1..d9596418 100644 --- a/src/lib/engine/views/engine_adaptive.cpp +++ b/src/lib/engine/views/engine_adaptive.cpp @@ -339,7 +339,7 @@ namespace gridfire { } size_t AdaptiveEngineView::mapCulledToFullSpeciesIndex(size_t culledSpeciesIndex) const { - if (culledSpeciesIndex < 0 || culledSpeciesIndex >= static_cast(m_speciesIndexMap.size())) { + if (culledSpeciesIndex < 0 || culledSpeciesIndex >= m_speciesIndexMap.size()) { LOG_ERROR(m_logger, "Culled index {} is out of bounds for species index map of size {}.", culledSpeciesIndex, m_speciesIndexMap.size()); m_logger->flush_log(); throw std::out_of_range("Culled index " + std::to_string(culledSpeciesIndex) + " is out of bounds for species index map of size " + std::to_string(m_speciesIndexMap.size()) + "."); @@ -348,7 +348,7 @@ namespace gridfire { } size_t AdaptiveEngineView::mapCulledToFullReactionIndex(size_t culledReactionIndex) const { - if (culledReactionIndex < 0 || culledReactionIndex >= static_cast(m_reactionIndexMap.size())) { + if (culledReactionIndex < 0 || culledReactionIndex >= m_reactionIndexMap.size()) { LOG_ERROR(m_logger, "Culled index {} is out of bounds for reaction index map of size {}.", culledReactionIndex, m_reactionIndexMap.size()); m_logger->flush_log(); throw std::out_of_range("Culled index " + std::to_string(culledReactionIndex) + " is out of bounds for reaction index map of size " + std::to_string(m_reactionIndexMap.size()) + "."); diff --git a/src/lib/engine/views/engine_defined.cpp b/src/lib/engine/views/engine_defined.cpp index c00e7fa7..657fd331 100644 --- a/src/lib/engine/views/engine_defined.cpp +++ b/src/lib/engine/views/engine_defined.cpp @@ -293,7 +293,7 @@ namespace gridfire { } size_t DefinedEngineView::mapViewToFullSpeciesIndex(size_t culledSpeciesIndex) const { - if (culledSpeciesIndex < 0 || culledSpeciesIndex >= static_cast(m_speciesIndexMap.size())) { + if (culledSpeciesIndex < 0 || culledSpeciesIndex >= m_speciesIndexMap.size()) { LOG_ERROR(m_logger, "Defined index {} is out of bounds for species index map of size {}.", culledSpeciesIndex, m_speciesIndexMap.size()); m_logger->flush_log(); throw std::out_of_range("Defined index " + std::to_string(culledSpeciesIndex) + " is out of bounds for species index map of size " + std::to_string(m_speciesIndexMap.size()) + "."); @@ -302,7 +302,7 @@ namespace gridfire { } size_t DefinedEngineView::mapViewToFullReactionIndex(size_t culledReactionIndex) const { - if (culledReactionIndex < 0 || culledReactionIndex >= static_cast(m_reactionIndexMap.size())) { + if (culledReactionIndex < 0 || culledReactionIndex >= m_reactionIndexMap.size()) { LOG_ERROR(m_logger, "Defined index {} is out of bounds for reaction index map of size {}.", culledReactionIndex, m_reactionIndexMap.size()); m_logger->flush_log(); throw std::out_of_range("Defined index " + std::to_string(culledReactionIndex) + " is out of bounds for reaction index map of size " + std::to_string(m_reactionIndexMap.size()) + "."); diff --git a/src/lib/engine/views/engine_multiscale.cpp b/src/lib/engine/views/engine_multiscale.cpp index 8440b610..837e51d1 100644 --- a/src/lib/engine/views/engine_multiscale.cpp +++ b/src/lib/engine/views/engine_multiscale.cpp @@ -1,15 +1,13 @@ #include "gridfire/engine/views/engine_multiscale.h" #include "gridfire/exceptions/error_engine.h" -#include - -#include "fourdst/logging/logging.h" - #include #include #include #include +#include + #include #include @@ -531,7 +529,7 @@ namespace gridfire { m_algebraic_species.size(), [&]() -> std::string { std::stringstream ss; - int count = 0; + size_t count = 0; for (const auto& species : m_algebraic_species) { ss << species.name(); if (m_algebraic_species.size() > 1 && count < m_algebraic_species.size() - 1) { @@ -1256,7 +1254,7 @@ namespace gridfire { } else { msg << "nuclei "; // TODO: Refactor nice list printing into utility function somewhere - int counter = 0; + size_t counter = 0; for (const auto& seed_idx : seed_indices) { msg << m_baseEngine.getNetworkSpecies()[seed_idx].name(); if (counter < seed_indices.size() - 2) { @@ -1309,7 +1307,7 @@ namespace gridfire { size_t slowest_pool_index = 0; // Default to the first pool if no valid pool is found double slowest_mean_timescale = std::numeric_limits::min(); - int count = 0; + size_t count = 0; for (const auto& pool : pools) { double mean_timescale = 0.0; for (const auto& species_idx : pool) { @@ -1321,7 +1319,7 @@ namespace gridfire { LOG_CRITICAL(m_logger, "Encountered infinite mean timescale for pool {} with species: {}", count, [&]() -> std::string { std::stringstream ss; - int iCount = 0; + size_t iCount = 0; for (const auto& idx : pool) { ss << all_species[idx].name() << ": " << all_timescales.at(all_species[idx]); if (iCount < pool.size() - 1) { diff --git a/src/lib/partition/composite/partition_composite.cpp b/src/lib/partition/composite/partition_composite.cpp index 9f02b267..a271d227 100644 --- a/src/lib/partition/composite/partition_composite.cpp +++ b/src/lib/partition/composite/partition_composite.cpp @@ -76,7 +76,7 @@ namespace gridfire::partition { std::string CompositePartitionFunction::type() const { std::stringstream ss; ss << "CompositePartitionFunction("; - int count = 0; + size_t count = 0; for (const auto& partitionFunction : m_partitionFunctions) { ss << partitionFunction->type(); if (count < m_partitionFunctions.size() - 1) { diff --git a/src/lib/solver/solver.cpp b/src/lib/solver/solver.cpp index 57df8e22..6b499988 100644 --- a/src/lib/solver/solver.cpp +++ b/src/lib/solver/solver.cpp @@ -221,8 +221,8 @@ namespace gridfire::solver { size_t numSpecies = m_engine.getNetworkSpecies().size(); J.resize(numSpecies+1, numSpecies+1); J.clear(); - for (int i = 0; i < numSpecies; ++i) { - for (int j = 0; j < numSpecies; ++j) { + for (size_t i = 0; i < numSpecies; ++i) { + for (size_t j = 0; j < numSpecies; ++j) { J(i, j) = m_engine.getJacobianMatrixEntry(i, j); } } diff --git a/subprojects/fourdst.wrap b/subprojects/fourdst.wrap index 328f8539..4f1827e9 100644 --- a/subprojects/fourdst.wrap +++ b/subprojects/fourdst.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://github.com/4D-STAR/fourdst -revision = v0.5.1 +revision = v0.5.2 depth = 1