ABI key of the pops core: stable string identifying the (compiler, C++ standard, header tree signature) combination a unit was compiled with.
More...
ABI key of the pops core: stable string identifying the (compiler, C++ standard, header tree signature) combination a unit was compiled with.
MOTIVATION ("production" DSL path). A .so loader generated by the DSL (cf. dsl.emit_cpp_native_loader) inlines the pops::add_compiled_model header template and calls out-of-line methods of pops::System DEFINED in the already-loaded _pops module. The loader and the module MUST share the same ABI (same headers, same compiler, same standard); otherwise the memory layout of objects crossing the boundary (System, GridContext, BlockClosures...) diverges -> SILENT undefined behavior. We make the incompatibility EXPLICIT: the loader exposes pops_native_abi_key() (key frozen at ITS compilation) and the System compares it against ITS own abi_key() at load time (add_native_block); a mismatch raises a clear error instead of UB.
Key construction (parallel to adc_cases/common/native.py::_abi_key):
- VERSION: compiler identity + version (g++/clang++/Apple clang...);
- cplusplus: effective C++ standard (thus -std= and the compiler mode);
- POPS_HEADER_SIG: signature of the core header tree, INJECTED by the build (CMake on the module side, -D flag on the loader side); its value changes if a header changes, so the key changes and the incompatibility is detected. Absent (old build / manual build) -> literal token "unknown": the key stays stable and comparable, it then captures only compiler + standard (graceful degradation, never silent UB since both sides see the same "unknown" if built the same).
- kokkos=0|1: POPS_HAS_KOKKOS of the unit. This macro CHANGES the layout of types crossing the boundary (allocator.hpp: Fab backing malloc vs Kokkos::SharedSpace pool; types.hpp: POPS_HD): a serial loader on a Kokkos module (or the reverse) was previously ACCEPTED by the key -> mute serial fallback in one direction, UB in the other. The divergence is now rejected explicitly; parity is restored via POPS_KOKKOS_ROOT (cf. dsl._native_kokkos_flags) or a serial module.
- stdlib=...: C++ standard library linked (libc++ _LIBCPP_VERSION / libstdc++ __GLIBCXX). Two toolchains may share VERSION AND __cplusplus but link stdlibs with INCOMPATIBLE ABIs (std::string/std::function cross the loader boundary). Detects the clang -stdlib=libc++ vs libstdc++ mix (conda/system mix). The macros are visible here because <string> is included.