Skip to content

Commit bf00d8d

Browse files
committed
Runtimes: treat linker warnings as errors
We were previously silently emitting incorrect code for the standard libraries and the warnings were being swallowed by the build system. This was brought to light by the new build system. The code generation issues have been addressed. In order to prevent a backslide, we would ideally use `/WX:4217 /WX:4286`. Unfortunately, `clang-cl` does not support this, so compromise and use `/WX` which treats all linker warnings as errors.
1 parent 5770d59 commit bf00d8d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ add_compile_options(
144144
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
145145
$<$<COMPILE_LANGUAGE:CXX>:-funwind-tables>)
146146

147+
# LNK4049: symbol 'symbol' defined in 'filename.obj' is imported
148+
# LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj'
149+
# LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function'
150+
#
151+
# We cannot selectively filter the linker warnings as we do not use the MSVC
152+
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
153+
# a compromise, treat all linker warnings as errors.
154+
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
155+
147156
add_compile_options(
148157
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
149158
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-runtime-compatibility-version none>"

0 commit comments

Comments
 (0)