Skip to content

Commit 09a167d

Browse files
committed
CMake: Disable -fassume-unique-vtables
Closes esa#579
1 parent d69220f commit 09a167d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ if(YACMA_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8")
148148
unset(_PAGMO_GCC_SUPPORTS_NO_OVERRIDE)
149149
endif()
150150

151+
if (PAGMO_ENABLE_IPO AND YACMA_COMPILER_IS_CLANGXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17)
152+
# workaround for https://github.com/llvm/llvm-project/issues/71196
153+
# tldr; The new -fassume-unique-vtables optimization breaks serialization with lto
154+
# xref https://releases.llvm.org/17.0.1/tools/clang/docs/ReleaseNotes.html#c-language-changes
155+
include(CheckCXXCompilerFlag)
156+
set(CMAKE_REQUIRED_QUIET TRUE)
157+
check_cxx_compiler_flag("-fno-assume-unique-vtables" _PAGMO_CLANG_SUPPORTS_ASSUME_UNIQUE_VTABLES)
158+
unset(CMAKE_REQUIRED_QUIET)
159+
if (_PAGMO_CLANG_SUPPORTS_ASSUME_UNIQUE_VTABLES)
160+
message(STATUS "The '-fno-assume-unique-vtables' flag is supported, enabling it.")
161+
list(APPEND PAGMO_CXX_FLAGS_DEBUG "-fno-assume-unique-vtables")
162+
list(APPEND PAGMO_CXX_FLAGS_RELEASE "-fno-assume-unique-vtables")
163+
endif ()
164+
unset (_PAGMO_CLANG_SUPPORTS_ASSUME_UNIQUE_VTABLES)
165+
endif ()
166+
151167
# TBB. Try to find it first in config mode (supported
152168
# since version 2021 after the oneTBB rename), and, if this
153169
# fails, fall back to our own FindTBB.cmake. This is of course

0 commit comments

Comments
 (0)