mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
build: check and add -fsized-deallocation
We use C++17 for the Swift compiler and IRGen uses the sized deallocation for releasing memory it creates with over-allocation. That triggers ASAN warnings due to the mismatched `operator new`/`operator delete`.
This commit is contained in:
@@ -834,6 +834,19 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=c++98-compat-extra-semi>)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
include(CheckCXXCompilerFlag)
|
||||
# Check for '-fsized-deallocation', which we need in IRGen. Clang presumably
|
||||
# adds this flag as a requirement for C++14+ to avoid a potential source
|
||||
# compatibility issue with C++11 where the 2-parameter `operator delete` was
|
||||
# used for placement deletion.
|
||||
check_cxx_compiler_flag("-fsized-deallocation"
|
||||
CXX_SUPPORTS_FSIZED_DEALLOCATION)
|
||||
if(CXX_SUPPORTS_FSIZED_DEALLOCATION)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fsized-deallocation>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(SWIFT_BUILD_SWIFT_SYNTAX
|
||||
"Enable building swift syntax"
|
||||
FALSE)
|
||||
|
||||
Reference in New Issue
Block a user