Skip to content

Commit b81024c

Browse files
committed
build: adjust the flags addition for the standard library
The standard library cannot be built with MSVC's compiler. However, if it is built with the toolchain which uses MSVC, it would fail to add this flag. With recent VS2022 toolsets, this is a problem as we would fail to be able to use the `offsetof` macro. Unconditionally apply the definition when building the standard library.
1 parent d526dcf commit b81024c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ function(_add_target_variant_c_compile_flags)
215215
list(APPEND result "-DLLVM_ON_WIN32")
216216
list(APPEND result "-D_CRT_SECURE_NO_WARNINGS")
217217
list(APPEND result "-D_CRT_NONSTDC_NO_WARNINGS")
218-
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
219-
list(APPEND result "-D_CRT_USE_BUILTIN_OFFSETOF")
220-
endif()
218+
list(APPEND result "-D_CRT_USE_BUILTIN_OFFSETOF")
221219
# TODO(compnerd) permit building for different families
222220
list(APPEND result "-D_CRT_USE_WINAPI_FAMILY_DESKTOP_APP")
223221
if("${CFLAGS_ARCH}" MATCHES arm)

0 commit comments

Comments
 (0)