[PATCH] D51885: [CMake] [MinGW] Build address sanitizer for MinGW
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 10 12:35:57 PDT 2018
mstorsjo created this revision.
mstorsjo added reviewers: rnk, timurrrr.
Herald added subscribers: Sanitizers, mgorny, kubamracek.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D51885
Files:
CMakeLists.txt
cmake/config-ix.cmake
lib/asan/CMakeLists.txt
Index: lib/asan/CMakeLists.txt
===================================================================
--- lib/asan/CMakeLists.txt
+++ lib/asan/CMakeLists.txt
@@ -91,6 +91,8 @@
append_list_if(COMPILER_RT_HAS_LIBM m ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBLOG log ASAN_DYNAMIC_LIBS)
+append_list_if(MINGW "${MINGW_LIBRARIES}" ASAN_DYNAMIC_LIBS)
+append_list_if(MINGW psapi ASAN_DYNAMIC_LIBS)
# Compile ASan sources into an object library.
@@ -215,7 +217,7 @@
endif()
set(ASAN_DYNAMIC_WEAK_INTERCEPTION)
- if (MSVC)
+ if (WIN32)
add_compiler_rt_object_libraries(AsanWeakInterception
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${arch}
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -37,6 +37,19 @@
elseif (COMPILER_RT_HAS_GCC_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
endif ()
+ if (MINGW)
+ # Mingw64 requires quite a few "C" runtime libraries in order for basic
+ # programs to link successfully with -nodefaultlibs.
+ if (COMPILER_RT_USE_BUILTINS_LIBRARY)
+ set(MINGW_RUNTIME ${COMPILER_RT_BUILTINS_LIBRARY})
+ else ()
+ set(MINGW_RUNTIME gcc_s gcc)
+ endif()
+ set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32
+ shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
+ moldname mingwex msvcrt)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
+ endif()
endif ()
# CodeGen options.
@@ -501,7 +514,7 @@
if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
(OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD|OpenBSD|Fuchsia|SunOS" OR
- (OS_NAME MATCHES "Windows" AND (NOT MINGW AND NOT CYGWIN))))
+ (OS_NAME MATCHES "Windows" AND NOT CYGWIN)))
set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)
else()
set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -310,6 +310,8 @@
append_list_if(COMPILER_RT_HAS_WD4722_FLAG /wd4722 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
+append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS)
+
# Set common link flags.
append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51885.164728.patch
Type: text/x-patch
Size: 2528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180910/7914b89e/attachment.bin>
More information about the llvm-commits
mailing list