This commit is contained in:
Nikita Taranov 2024-11-27 19:07:57 +08:00 committed by GitHub
commit dbc9bc0649
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -356,6 +356,23 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-vtable-pointers")
if (NOT (SANITIZE OR SANITIZE_COVERAGE OR WITH_COVERAGE)
AND (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO"))
# Applied only for Release builds because we've seen memory exceptions with sanitizer builds.
#
# The point is to increase the chances of a code explicitly marked as supposed
# to be inlined by the programmer to be actually inlined without increasing the
# global threshold for inlining. It also makes sense to note that even
# `always_inline` is still just a hint from clang's perspective. It works for
# `inline` keyword and `always_inline` attribute, but e.g. class methods that
# are implicitly `inline` are not considered as having an inline hint.
#
# The choice of the threshold is rather intuitive. Searching across the github
# shows different choices from few thousands to million.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mllvm -inlinehint-threshold=1234")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm -inlinehint-threshold=1234")
endif()
# We cannot afford to use LTO when compiling unit tests, and it's not enough
# to only supply -fno-lto at the final linking stage. So we disable it
# completely.