[PATCH] D11085: compiler-rt: add support for mingw-w64 in builtins

Reid Kleckner rnk at google.com
Fri Jul 17 09:23:31 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL242539: compiler-rt: add support for mingw-w64 in builtins (authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D11085?vs=29593&id=30011#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11085

Files:
  compiler-rt/trunk/CMakeLists.txt
  compiler-rt/trunk/lib/builtins/CMakeLists.txt
  compiler-rt/trunk/lib/builtins/enable_execute_stack.c

Index: compiler-rt/trunk/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -164,7 +164,7 @@
 # We support running instrumented tests when we're not cross compiling
 # and target a UNIX-like system or Windows.
 # We can run tests on Android even when we are cross-compiling.
-if(("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND (UNIX OR MSVC)) OR ANDROID
+if(("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND (UNIX OR WIN32)) OR ANDROID
    OR COMPILER_RT_EMULATOR)
   option(COMPILER_RT_CAN_EXECUTE_TESTS "Can we execute instrumented tests" ON)
 else()
Index: compiler-rt/trunk/lib/builtins/CMakeLists.txt
===================================================================
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt
@@ -154,6 +154,12 @@
   x86_64/floatundixf.S
   ${GENERIC_SOURCES})
 
+if(WIN32)
+  set(x86_64_SOURCES
+      ${x86_64_SOURCES}
+      x86_64/chkstk.S)
+endif()
+
 set(i386_SOURCES
   i386/ashldi3.S
   i386/ashrdi3.S
@@ -171,6 +177,12 @@
   i386/umoddi3.S
   ${GENERIC_SOURCES})
 
+if(WIN32)
+  set(i386_SOURCES
+      ${i386_SOURCES}
+      i386/chkstk.S)
+endif()
+
 set(i686_SOURCES
   ${i386_SOURCES})
 
@@ -260,7 +272,7 @@
 
 add_custom_target(builtins)
 
-if (NOT WIN32)
+if (NOT WIN32 OR MINGW)
   foreach (arch x86_64 i386 i686 arm)
     if (CAN_TARGET_${arch})
       # Filter out generic versions of routines that are re-implemented in
Index: compiler-rt/trunk/lib/builtins/enable_execute_stack.c
===================================================================
--- compiler-rt/trunk/lib/builtins/enable_execute_stack.c
+++ compiler-rt/trunk/lib/builtins/enable_execute_stack.c
@@ -10,17 +10,24 @@
 
 #include "int_lib.h"
 
+#ifndef _WIN32
 #include <sys/mman.h>
+#endif
 
 /* #include "config.h"
  * FIXME: CMake - include when cmake system is ready.
  * Remove #define HAVE_SYSCONF 1 line.
  */
 #define HAVE_SYSCONF 1
 
+#ifdef _WIN32
+#include <windef.h>
+#include <winbase.h>
+#else
 #ifndef __APPLE__
 #include <unistd.h>
 #endif /* __APPLE__ */
+#endif /* _WIN32 */
 
 #if __LP64__
 	#define TRAMPOLINE_SIZE 48
@@ -40,6 +47,12 @@
 __enable_execute_stack(void* addr)
 {
 
+#if _WIN32
+	MEMORY_BASIC_INFORMATION mbi;
+	if (!VirtualQuery (addr, &mbi, sizeof(mbi)))
+		return; /* We should probably assert here because there is no return value */
+	VirtualProtect (mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect);
+#else
 #if __APPLE__
 	/* On Darwin, pagesize is always 4096 bytes */
 	const uintptr_t pageSize = 4096;
@@ -55,4 +68,5 @@
 	unsigned char* endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask);
 	size_t length = endPage - startPage;
 	(void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC);
+#endif
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11085.30011.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150717/82aaef78/attachment.bin>


More information about the cfe-commits mailing list