Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmake/modules/CheckCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
27 changes: 27 additions & 0 deletions cmake/modules/check_libcpp_vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <cstddef>
#include <vector>

#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<const std::vector<char> *>(vec)->size();
}

int main()
{
std::vector<int> v(1);
const auto size = GetTypeErasedSize(reinterpret_cast<const void *>(&v));
if (size == sizeof(int)) {
return 0;
} else if (size == 1) {
return 1; // New ABI
} else {
return 2; // Unexpected
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <cling/Interpreter/RuntimeOptions.h>
#include "cling/Interpreter/Visibility.h"
#include <cstddef>
#include <new>

namespace cling {
Expand Down
1 change: 1 addition & 0 deletions main/src/rmain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "RConfigure.h"

#include <cstdio>
#include <cstdlib>
#ifdef _MSC_VER
#include <process.h>
#define execv _execv
Expand Down
2 changes: 2 additions & 0 deletions tree/treeplayer/src/TTreeFormulaManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "TError.h"
#include "TLeafElement.h"

#include <cmath>


/** \class TTreeFormulaManager
Used to coordinate one or more TTreeFormula objects.
Expand Down
Loading