From 9a1ba8272c03183ed24c505c9909715dcb2499c0 Mon Sep 17 00:00:00 2001 From: Fei Lin Date: Thu, 3 Sep 2026 00:08:27 -0400 Subject: [PATCH 1/2] Silence compiler warnings when building from source with clang/libc++ Building from source on macOS (AppleClang, libc++, Python 3.14) produced several recurring warnings. This cleans them all up without touching the bundled Boost sources: - Define BOOST_NO_AUTO_PTR with an empty value to match Boost's own definition in boost/config/stdlib/libcpp.hpp (identical redefinitions are legal and silent; -DBOOST_NO_AUTO_PTR expands to 1 and warned on every TU with -Wmacro-redefined). - Define BOOST_ALLOW_DEPRECATED_HEADERS and BOOST_BIND_GLOBAL_PLACEHOLDERS, Boost's official opt-outs for the deprecation pragma (we already set BOOST_TIMER_ENABLE_DEPRECATED) and the global bind placeholders pragma. - Suppress -Wdeprecated-declarations for the bundled boost_python target only: Boost.Python <= 1.87 calls _PyUnicode_AsString, deprecated since Python 3.14 (it is an alias of PyUnicode_AsUTF8, so behavior is fine). - Suppress -Winvalid-noreturn (clang only) for the bundled boost target: Boost.MPI's environment::abort() is noreturn but the compiler cannot know MPI_Abort does not return. - Suppress -Wconstant-conversion (clang only) for rngfactory.C: the legacy lagged_fibonacci607 generator uses a 48-bit word with a 32-bit result type, so max() truncates by design; kept for stream compatibility with old simulations. - Add virtual destructors to alps::mcbase (abstract, destroyed through base references by Boost.Python's converters) and alps::EigenvectorMeasurements (virtual save/load); fixes -Wdelete-abstract-non-virtual-dtor / -Wdelete-non-abstract-non-virtual-dtor and closes genuine UB if instances are ever deleted via a base pointer. No object layout change since both classes already had vtables. With these changes a full build (including examples and tests) completes with zero warnings on AppleClang 17 / macOS SDK 26.2 / Python 3.14. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01DaRLRTayS75a9Yk1iLvNu9 --- CMakeLists.txt | 2 +- src/alps/CMakeLists.txt | 7 +++++++ src/alps/mcbase.hpp | 1 + src/alps/scheduler/measurement_operators.h | 3 ++- src/boost/CMakeLists.txt | 7 +++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90985ca22..0cb22678b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version COMMAND head -n1 OUTPUT_VARIABLE ALPS_COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Compiler version: ${ALPS_COMPILER_VERSION}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -DBOOST_NO_AUTO_PTR -DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF -DBOOST_TIMER_ENABLE_DEPRECATED") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -DBOOST_NO_AUTO_PTR= -DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF -DBOOST_TIMER_ENABLE_DEPRECATED -DBOOST_ALLOW_DEPRECATED_HEADERS -DBOOST_BIND_GLOBAL_PLACEHOLDERS") # set convenient warning flags for clang diff --git a/src/alps/CMakeLists.txt b/src/alps/CMakeLists.txt index 9c495dc88..91bfbba14 100644 --- a/src/alps/CMakeLists.txt +++ b/src/alps/CMakeLists.txt @@ -117,6 +117,13 @@ endif() add_library(alps ${ALPS_SOURCES}) +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # The legacy "lagged_fibonacci607" generator uses a 48-bit word with a 32-bit + # result type, so max() truncates by design; keep it for stream compatibility. + set_source_files_properties(random/rngfactory.C PROPERTIES + COMPILE_OPTIONS "-Wno-constant-conversion") +endif() + find_package(HDF5) if (Boost_FOUND) # link to ${Boost_LIBRARIES} when precompiled Boost libraries found diff --git a/src/alps/mcbase.hpp b/src/alps/mcbase.hpp index 81c001533..6579d4497 100644 --- a/src/alps/mcbase.hpp +++ b/src/alps/mcbase.hpp @@ -46,6 +46,7 @@ namespace alps { #endif mcbase(parameters_type const & parms, std::size_t seed_offset = 0); + virtual ~mcbase() {} virtual void update() = 0; virtual void measure() = 0; diff --git a/src/alps/scheduler/measurement_operators.h b/src/alps/scheduler/measurement_operators.h index 90f107aac..8d2bca2d1 100644 --- a/src/alps/scheduler/measurement_operators.h +++ b/src/alps/scheduler/measurement_operators.h @@ -82,7 +82,8 @@ class EigenvectorMeasurements template EigenvectorMeasurements(LatticeModel const&); - + virtual ~EigenvectorMeasurements() {} + void write_xml_one_vector(oxstream& out, const boost::filesystem::path&, std::size_t j) const; XMLTag handle_tag(std::istream& infile, const XMLTag& intag); diff --git a/src/boost/CMakeLists.txt b/src/boost/CMakeLists.txt index 30274bb1a..292737619 100644 --- a/src/boost/CMakeLists.txt +++ b/src/boost/CMakeLists.txt @@ -307,9 +307,16 @@ endif (BUILD_BOOST_MPI AND BUILD_BOOST_PYTHON AND Boost_ROOT_DIR) if (NOT Boost_FOUND) add_library(${ALPS_BOOST_LIBRARY_NAME} ${BOOST_SOURCES}) target_link_libraries(${ALPS_BOOST_LIBRARY_NAME} ${BOOST_LINK_LIBS}) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Boost.MPI's environment::abort() is declared noreturn but relies on + # MPI_Abort not returning, which the compiler cannot verify + target_compile_options(${ALPS_BOOST_LIBRARY_NAME} PRIVATE -Wno-invalid-noreturn) + endif() if(BUILD_BOOST_PYTHON) add_library(${ALPS_BOOST_PYTHON_LIBRARY_NAME} ${BOOST_PYTHON_SOURCES}) target_link_libraries(${ALPS_BOOST_PYTHON_LIBRARY_NAME} ${BOOST_PYTHON_LINK_LIBS}) + # Boost.Python <= 1.87 uses _PyUnicode_AsString, deprecated since Python 3.14 + target_compile_options(${ALPS_BOOST_PYTHON_LIBRARY_NAME} PRIVATE -Wno-deprecated-declarations) endif() # Boost.Test if(BUILD_BOOST_TEST) From d7b6f07409d0e5155c6633121d0010b649152779 Mon Sep 17 00:00:00 2001 From: Fei Lin Date: Thu, 3 Sep 2026 23:16:42 -0400 Subject: [PATCH 2/2] Suppress readdir_r deprecation warning in bundled Boost.Filesystem Per review: recent macOS SDKs (and glibc) deprecate readdir_r, which Boost.Filesystem's directory.cpp still uses, leaving one -Wdeprecated-declarations warning on the bundled boost target. Scope the suppression to that target, next to the existing -Wno-invalid-noreturn. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01DaRLRTayS75a9Yk1iLvNu9 --- src/boost/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/boost/CMakeLists.txt b/src/boost/CMakeLists.txt index 292737619..491067f9e 100644 --- a/src/boost/CMakeLists.txt +++ b/src/boost/CMakeLists.txt @@ -307,6 +307,9 @@ endif (BUILD_BOOST_MPI AND BUILD_BOOST_PYTHON AND Boost_ROOT_DIR) if (NOT Boost_FOUND) add_library(${ALPS_BOOST_LIBRARY_NAME} ${BOOST_SOURCES}) target_link_libraries(${ALPS_BOOST_LIBRARY_NAME} ${BOOST_LINK_LIBS}) + # Boost.Filesystem's directory.cpp uses readdir_r, deprecated by recent + # macOS SDKs and glibc + target_compile_options(${ALPS_BOOST_LIBRARY_NAME} PRIVATE -Wno-deprecated-declarations) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Boost.MPI's environment::abort() is declared noreturn but relies on # MPI_Abort not returning, which the compiler cannot verify