From e916ccf0892407602ca1436bd50ad48684215d4f Mon Sep 17 00:00:00 2001 From: Jakob Blomer Date: Thu, 5 Nov 2026 14:00:18 +0100 Subject: [PATCH 1/2] add missing includes Found by compiling with clang/libc++ on Linux. --- interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h | 1 + main/src/rmain.cxx | 1 + tree/treeplayer/src/TTreeFormulaManager.cxx | 2 ++ 3 files changed, 4 insertions(+) diff --git a/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h b/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h index c6f0f2eab0972..72b39090b9658 100644 --- a/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h +++ b/interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h @@ -25,6 +25,7 @@ #include #include "cling/Interpreter/Visibility.h" +#include #include namespace cling { diff --git a/main/src/rmain.cxx b/main/src/rmain.cxx index 3e0e0fe5c2dea..f5c108c772232 100644 --- a/main/src/rmain.cxx +++ b/main/src/rmain.cxx @@ -21,6 +21,7 @@ #include "RConfigure.h" #include +#include #ifdef _MSC_VER #include #define execv _execv diff --git a/tree/treeplayer/src/TTreeFormulaManager.cxx b/tree/treeplayer/src/TTreeFormulaManager.cxx index 8ef1fad85302d..55cd9d400a0ca 100644 --- a/tree/treeplayer/src/TTreeFormulaManager.cxx +++ b/tree/treeplayer/src/TTreeFormulaManager.cxx @@ -15,6 +15,8 @@ #include "TError.h" #include "TLeafElement.h" +#include + /** \class TTreeFormulaManager Used to coordinate one or more TTreeFormula objects. From c9e90353c61b19e56ff4acdcc54fd720c71d299e Mon Sep 17 00:00:00 2001 From: Jakob Blomer Date: Thu, 5 Nov 2026 13:57:47 +0100 Subject: [PATCH 2/2] [cmake] check std::vector layout The std::vector layout, currently, uses three pointers (begin, end, end of capacity). This is used by the ROOT I/O to work with vectors of anything by treating any vector as a vector. The approach breaks, however, with the std::vector layout in the libc++ unstable ABI that implements vector with one pointer and two integers. --- cmake/modules/CheckCompiler.cmake | 18 ++++++++++++++++++ cmake/modules/check_libcpp_vector.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 cmake/modules/check_libcpp_vector.cpp diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake index bab91fd76e5f3..524ce7bbc8bb7 100644 --- a/cmake/modules/CheckCompiler.cmake +++ b/cmake/modules/CheckCompiler.cmake @@ -261,3 +261,21 @@ endif() if(gnuinstall) set(R__HAVE_CONFIG 1) endif() + + +#---Check if the std::vector implementation is using three pointers or one pointer and two integers +message(STATUS "Checking std::vector layout") +try_run(RUN_CHECK_LIBCPP_VECTOR_RESULT COMPILE_CHECK_LIBCPP_VECTOR_RESULT + ${CMAKE_BINARY_DIR} + SOURCES "${CMAKE_SOURCE_DIR}/cmake/modules/check_libcpp_vector.cpp" + COMPILE_OUTPUT_VARIABLE COMPILE_CHECK_LIBCPP_VECTOR_OUTPUT) + +if(NOT COMPILE_CHECK_LIBCPP_VECTOR_RESULT) + message(FATAL_ERROR "Failed to compile vector layout check, " + "likely an issue with the compiler installation: ${COMPILE_CHECK_LIBCPP_VECTOR_OUTPUT}") +endif() + +if(NOT RUN_CHECK_LIBCPP_VECTOR_RESULT EQUAL 0) + message(FATAL_ERROR "Size based std::vector layout is unsupported; " + "run result='${RUN_CHECK_LIBCPP_VECTOR_RESULT}' (1 = size based, 2 = unexpected).") +endif() diff --git a/cmake/modules/check_libcpp_vector.cpp b/cmake/modules/check_libcpp_vector.cpp new file mode 100644 index 0000000000000..7d123aa2cbbc6 --- /dev/null +++ b/cmake/modules/check_libcpp_vector.cpp @@ -0,0 +1,27 @@ +#include +#include + +#if defined(_MSC_VER) + #define NOINLINE __declspec(noinline) +#else + #define NOINLINE __attribute__((noinline)) +#endif + +// Don't inline to prevent the optimizer from interfering with the test +NOINLINE static std::size_t GetTypeErasedSize(const void *vec) +{ + return reinterpret_cast *>(vec)->size(); +} + +int main() +{ + std::vector v(1); + const auto size = GetTypeErasedSize(reinterpret_cast(&v)); + if (size == sizeof(int)) { + return 0; + } else if (size == 1) { + return 1; // New ABI + } else { + return 2; // Unexpected + } +}