[PATCH] D96120: [scudo] Port scudo sanitizer to Windows

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 5 13:38:43 PST 2021


mstorsjo added a comment.

As is, this breaks compilation for mingw. With the three modifications I suggest here, it no longer breaks compilation for me - I have no idea if it actually works in mingw configurations though, but not breaking compilation is at least the first step.



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_win.cpp:28
+#define SystemFunction036 NTAPI SystemFunction036
+#include <NTSecAPI.h>
+#undef SystemFunction036
----------------
The includes need to be all-lowercase for mingw. (The windows SDK isn't self-consistent so it can't be used as-is on case sensitive filesystems, thus the all-lowercase convention of mingw headers is the only one that works for case sentisitivity for now.)


================
Comment at: compiler-rt/lib/scudo/CMakeLists.txt:18
 append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer
                SCUDO_CFLAGS)
 
----------------
This needs an extra `append_list_if(MINGW "${MINGW_LIBRARIES}" SCUDO_MINIMAL_DYNAMIC_LIBS)` here (similar to a line in compiler-rt/lib/asan/CMakeLists.txt) to fix building in mingw configurations. (That's needed because these libs are built with `-nodefaultlibs`, which omits a few essential libs.)


================
Comment at: compiler-rt/lib/scudo/scudo_new_delete.cpp:30
+#ifdef _WIN64
+COMMENT_EXPORT("??2 at YAPEAX_K@Z")                    // operator new
+COMMENT_EXPORT("??2 at YAPEAX_KAEBUnothrow_t@std@@@Z") // operator new nothrow
----------------
These don't work in this form for mingw targets (which use the itanium c++ abi).

By changing `#if SANTIZER_WINDOWS` into `#if SANITIZER_WINDOWS && !defined(__MINGW32__)`, I fixed the linker errors at least.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96120/new/

https://reviews.llvm.org/D96120



More information about the cfe-commits mailing list