diff --git a/CMakeLists.txt b/CMakeLists.txt index e76ce7d0f9f92..47505ee0b8261 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -834,6 +834,19 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang) add_compile_options($<$:-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($<$:-fsized-deallocation>) + endif() +endif() + option(SWIFT_BUILD_SWIFT_SYNTAX "Enable building swift syntax" FALSE) diff --git a/lib/IRGen/CMakeLists.txt b/lib/IRGen/CMakeLists.txt index 2782386daed71..e1fc4379b0dfd 100644 --- a/lib/IRGen/CMakeLists.txt +++ b/lib/IRGen/CMakeLists.txt @@ -76,8 +76,6 @@ add_swift_host_library(swiftIRGen STATIC transformutils irprinter ) -target_compile_options(swiftIRGen PRIVATE - $<$,$>:-fsized-deallocation>) target_link_libraries(swiftIRGen INTERFACE clangCodeGen clangAST)