Reorder cintw includes so linked libcint cint.h wins (transitional)#94
Draft
joshkamm wants to merge 1 commit into
Draft
Reorder cintw includes so linked libcint cint.h wins (transitional)#94joshkamm wants to merge 1 commit into
joshkamm wants to merge 1 commit into
Conversation
The vendored include/cint.h is libcint 4.4.0's header with build-time toggles (I8, CACHE_SIZE_I8) frozen in via #cmakedefine. When cintw is built against a different libcint -- pixi's, or the manual 5.3.0 at LIBCINT_PATH -- the vendored header was winning the search order and hiding the real headers, risking a silent ABI mismatch on FINT width or struct slot offsets. Move LIBCINT_PATH/include and PREFIX/include ahead of SlaterGPU/include in cintw's PRIVATE include path so the linked libcint's own cint.h is the one the wrapper sees. This is a transitional fix scoped to the cintw target. A follow-up can remove the vendored copy entirely once SlaterGPU's target_include_dirs also carry the libcint header path (and the DO_GTO=OFF case is sorted).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
In a DM yesterday, Paul flagged that
include/cint.hin this repo is a vendored copy of libcint 4.4.0's header, and that it can disagree with whatever libcint we actually link against -- pixi's, or his patched manual build atLIBCINT_PATH. His suggested direction: "include cint.h from the linked libcint directory" instead.The risk is concrete because libcint's own
cint.his generated fromcint.h.inby its CMake with#cmakedefine I8,#cmakedefine CACHE_SIZE_I8, etc. Two libcint builds at the same version tag can ship genuinely different headers depending on flags. If the vendored copy disagrees with the linked.soonsizeof(FINT),BAS_SLOTS/ATM_SLOTS, orenv[]offsets, integrals come out silently wrong -- no link error, no crash.The vendored header (
include/cint.h:7) hard-codesCINT_VERSION 4.4.0and was last touched in Nov 2024; we have meanwhile been linking against libcint 5.3.0 (manual) and pixi-provided libcint.Related: #82 / memory note
libcint_pixi_runtime_conflict-- pixi can also silently shadow Paul's patched libcint at runtime. Same disease (header vs.somismatch), opposite end of the link.What this PR does
Smallest possible step toward Paul's goal, scoped to the wrapper that actually calls libcint at runtime:
target_include_directories(cintw PRIVATE ...)insrc/libcintw/CMakeLists.txtso${LIBCINT_PATH}/includeand$ENV{PREFIX}/includecome before${CMAKE_SOURCE_DIR}/include.#include <cint.h>fromcint_funcs.hresolves to the linked libcint's own header inside thecintwtranslation units.include/cint.hin place for now -- see below.Why not just delete
include/cint.houtright?That's the right end state, but it's not a one-line change:
include/cintwrapper.h:9andinclude/cintprep.h:11unconditionally doextern \"C\" { #include \"cint_funcs.h\" }, which transitively pulls in<cint.h>.src/integrals/integrals_aux.cpp, which builds into theSlaterGPUtarget -- whosetarget_include_directoriesinsrc/integrals/CMakeLists.txt:46-49does not carryLIBCINT_PATH/includeorPREFIX/include. It compiles today only because the vendored header sits in${CMAKE_SOURCE_DIR}/include.DO_GTO=OFF, libcint is not linked at all, and the vendored header is what lets these C++ class signatures parse without a libcint dependency.So a clean removal needs: (a) libcint include paths plumbed into the
SlaterGPUtarget too, (b) a decision on theDO_GTO=OFFcase -- either require a libcint header to be reachable even when not linked, or guard theextern \"C\"includes behind#ifdef. Worth talking through before doing.Test plan
pixi run cmake --buildsucceeds andcintwpicks up pixi'scint.h(verify via verbose include trace).LIBCINT_PATH=... cmake ...succeeds and the libcint 5.3.0 header wins.cintw(oneint2e_sphcall) returns the same numbers as before this change.Discussion points for our next meeting
include/cint.h?DO_GTO=OFF, would you rather (a) still require a libcint header in the include path (cheap, but adds a non-link dependency), or (b)#ifdef DO_GTO-guard theextern \"C\"block incintwrapper.h/cintprep.h?cintw's include dirs becomePUBLICso that downstream consumers (viaSlaterGPU::cintwinSlaterGPUConfig.cmake.in) also see the linked libcint headers consistently?