Skip to content

Commit aecb5d0

Browse files
authored
Merge pull request swiftlang#15660 from compnerd/win-rtti
build: disable static RTTI on Windows if possible
2 parents e1ca63c + 949216d commit aecb5d0

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)