Skip to content

Commit 949216d

Browse files
committed
build: disable static RTTI on Windows if possible
Newer SDKs have the ability to disable the static RTTI usage as well as the dynamic. We had to enable the use of static RTTI previously for the use of `std::function`. Disable the static RTTI if possible.
1 parent 6c42bcc commit 949216d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,18 @@ function(_add_variant_c_compile_flags)
257257
list(APPEND result "-D_ENABLE_ATOMIC_ALIGNMENT_FIX")
258258

259259
# msvcprt's std::function requires RTTI, but we do not want RTTI data.
260-
# Emulate /GR-
260+
# Emulate /GR-.
261+
# TODO(compnerd) when moving up to VS 2017 15.3 and newer, we can disable
262+
# RTTI again
261263
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
262264
list(APPEND result -frtti)
263265
list(APPEND result -Xclang;-fno-rtti-data)
264266
endif()
267+
268+
# NOTE: VS 2017 15.3 introduced this to disable the static components of
269+
# RTTI as well. This requires a newer SDK though and we do not have
270+
# guarantees on the SDK version currently.
271+
list(APPEND result "-D_HAS_STATIC_RTTI=0")
265272
endif()
266273

267274
if(CFLAGS_ENABLE_ASSERTIONS)

0 commit comments

Comments
 (0)