Fix Windows build compatibility (MSVC cl.exe and clang-cl)#201
Open
lorisercole wants to merge 9 commits intowavefunction91:masterfrom
Open
Fix Windows build compatibility (MSVC cl.exe and clang-cl)#201lorisercole wants to merge 9 commits intowavefunction91:masterfrom
lorisercole wants to merge 9 commits intowavefunction91:masterfrom
Conversation
GauXC was only buildable with GCC, Clang, and clang-cl. This commit fixes all compilation and linking issues when building with MSVC's native `cl.exe` compiler. ## Compiler compatibility fixes - `__PRETTY_FUNCTION__` → `__FUNCSIG__` (`exceptions.hpp`): MSVC does not support `__PRETTY_FUNCTION__`; use `__FUNCSIG__` under `_MSC_VER` guard. - `__builtin_popcount` → `std::popcount` (`exx_screening.cxx`): MSVC does not provide GCC builtins; use C++20 `<bit>` header instead. - C99 `[restrict]` array params → `*__restrict` pointers (14 rys files): MSVC does not support the C99 array parameter syntax. The `*__restrict` pointer form is portable across GCC, Clang, and MSVC. - `__attribute__((always_inline))` → `FORCE_INLINE` macro (`rys_integral.c`): Maps to `__forceinline` on MSVC and `__attribute__((always_inline))` on GCC/Clang. Also replaces the GNU statement-expression `MIN` macro with a simple ternary. - C99 VLAs → `_malloca`/`_freea` (`rys_rw.c`, `rys_xrw.c`): MSVC does not support VLAs. Uses `_malloca`/`_freea` (stack with heap fallback) under `_MSC_VER` guards. - `__attribute__((__aligned__(64)))` → `alignas(64)` (20 `integral_*.cxx` files): Portable C++11 alignment specifier, works on GCC, Clang, and MSVC. - `__restrict__` → `__restrict` (`integral_1_0.cxx`): `__restrict__` is GCC/Clang-only; `__restrict` is portable across all three compilers. - Missing `#include <string>` (`reduction_driver.hpp`): MSVC does not provide `<string>` transitively through other headers. - Non-const `operator==` (`molecule.hpp`): Made `Molecule::operator==` `const` to fix C++20 ambiguity with synthesized reverse candidates on MSVC. ## Static HDF5 linking fixes (`src/external/CMakeLists.txt`) - HighFive incorrectly propagates `H5_BUILT_AS_DYNAMIC_LIB`: CMake's `FindHDF5` module sets this define on Windows when `HDF5_USE_STATIC_LIBRARIES` is unset, regardless of whether the library is actually static. HighFive then propagates it via its `libdeps` INTERFACE target. The fix patches `libdeps` after `FetchContent` to replace `H5_BUILT_AS_DYNAMIC_LIB` with `H5_BUILT_AS_STATIC_LIB`. - HDF5 transitive static dependencies: When linking HDF5 statically on Windows, its dependencies (zlib, szip/aec, shlwapi) must be linked explicitly as they are not auto-resolved.
warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup.
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.
__PRETTY_FUNCTION__→__FUNCSIG__under_MSC_VERguard__builtin_popcount→ C++20std::popcount(MSVC has no GCC builtins)[restrict]array params →*__restrictpointers in 14 rys files__attribute__((always_inline))→FORCE_INLINEmacro (__forceinlineon MSVC)_malloca/_freeainrys_rw.candrys_xrw.c__attribute__((__aligned__(64)))→alignas(64)in 20integral_*.cxxfiles__restrict__→__restrictinintegral_1_0.cxx#include <string>inreduction_driver.hppMolecule::operator==const for C++20 compatibilitylibdepsto useH5_BUILT_AS_STATIC_LIBand link transitive deps (zlib, szip/aec, shlwapi)#include <stdlib.h>ingau2grid_helper.c(implicitexit()declaration)strdupwith_strdupacross 7 exception headers-Wno-covered-switch-default,-Wno-documentation, etc.)/wd4100,/wd4101,/wd4242,/wd5219)Requires:
cmake/gauxc-dep-versions.cmake: change IntegratorXX & ExchCXX git ref back to upstream commit once their PRs are merged