[compiler-rt] r344126 - [sanitizers] [windows] Use a linker directive pragma for psapi
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 10 02:03:58 PDT 2018
Author: mstorsjo
Date: Wed Oct 10 02:03:58 2018
New Revision: 344126
URL: http://llvm.org/viewvc/llvm-project?rev=344126&view=rev
Log:
[sanitizers] [windows] Use a linker directive pragma for psapi
This allows users of static libraries (such as ubsan) to link without
knowing about this transitive dependency, if using the psapi functions
that require linking to a separate psapi library. Since Windows 7,
these functions (EnumProcessModules, GetModuleInformation,
GetProcessMemoryInfo) are remapped to K32- prefixed ones, available in
kernel32.dll.
Differential Revision: https://reviews.llvm.org/D53012
Modified:
compiler-rt/trunk/lib/asan/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=344126&r1=344125&r2=344126&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Wed Oct 10 02:03:58 2018
@@ -100,7 +100,6 @@ append_list_if(COMPILER_RT_HAS_LIBM m AS
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.
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=344126&r1=344125&r2=344126&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Wed Oct 10 02:03:58 2018
@@ -29,6 +29,10 @@
#include "sanitizer_placement_new.h"
#include "sanitizer_win_defs.h"
+#if defined(PSAPI_VERSION) && PSAPI_VERSION == 1
+#pragma comment(lib, "psapi")
+#endif
+
// A macro to tell the compiler that this part of the code cannot be reached,
// if the compiler supports this feature. Since we're using this in
// code that is called when terminating the process, the expansion of the
More information about the llvm-commits
mailing list