Skip to content

Commit f51b0d5

Browse files
committed
[compiler-rt] suppress LNK4221 warning when creating static libraries
Summary: We put empty object files in archives, which causes MSVC's linker to complain about these objects not defining any previously undefined symbols. Since we do it on purpose, this only creates noise during the build process. This patch causes us to suppress the warnings. Reviewers: rnk, samsonov Subscribers: dberris, mgorny Differential Revision: https://reviews.llvm.org/D28262 llvm-svn: 291011
1 parent 63687e4 commit f51b0d5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
225225
# Warnings to turn off for all libraries, not just sanitizers.
226226
append_string_if(COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
227227

228+
if (CMAKE_LINKER MATCHES "link.exe$")
229+
# Silence MSVC linker warnings caused by empty object files. The
230+
# sanitizer libraries intentionally use ifdefs that result in empty
231+
# files, rather than skipping these files in the build system.
232+
# Ideally, we would pass this flag only for the libraries that need
233+
# it, but CMake doesn't seem to have a way to set linker flags for
234+
# individual static libraries, so we enable the suppression flag for
235+
# the whole compiler-rt project.
236+
append("/IGNORE:4221" CMAKE_STATIC_LINKER_FLAGS)
237+
endif()
238+
228239
add_subdirectory(include)
229240

230241
set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)

0 commit comments

Comments
 (0)