错误信息提示如下:
[ 0%] Built target compiler-rt-headers
[ 0%] Building C object projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/enable_execute_stack.c.obj
D:\llvm-3.3.src\projects\compiler-rt\lib\enable_execute_stack.c:13:22: fatal error: sys/mman.h: No such file or director
y
compilation terminated.
mingw32-make.exe[2]: *** [projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/enable_execute_stack.c.obj] Error 1
mingw32-make.exe[1]: *** [projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
发现mingw include路径下没有sys/mman.h
然后去下载个,这个过程找了好久。妹的,最后贴出下载地址:https://code.google.com/p/mman-win32/ 下载下来自己编译一下,或者用现成的http://sourceforge.net/projects/gtk-mingw/files/mman-win32/
然后编译发现又出错了,信息如下:
[ 0%] Built target compiler-rt-headers
[ 0%] Building C object projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/enable_execute_stack.c.obj
D:\llvm-3.3.src\projects\compiler-rt\lib\enable_execute_stack.c: In function '__enable_execute_stack':
D:\llvm-3.3.src\projects\compiler-rt\lib\enable_execute_stack.c:48:9: warning: implicit declaration of function 'sysconf
' [-Wimplicit-function-declaration]
D:\llvm-3.3.src\projects\compiler-rt\lib\enable_execute_stack.c:48:44: error: '_SC_PAGESIZE' undeclared (first use in th
is function)
D:\llvm-3.3.src\projects\compiler-rt\lib\enable_execute_stack.c:48:44: note: each undeclared identifier is reported only
once for each function it appears in
mingw32-make.exe[2]: *** [projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/enable_execute_stack.c.obj] Error 1
mingw32-make.exe[1]: *** [projects/compiler-rt/lib/CMakeFiles/clang_rt.i386.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
知道是什么错误了,得修改代码,
最后enable_execute_stack.c修改成这样:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* ===-- enable_execute_stack.c - Implement __enable_execute_stack ---------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== */ #include "int_lib.h" #include <sys mman.h=""> /* #include "config.h" * FIXME: CMake - include when cmake system is ready. * Remove #define HAVE_SYSCONF 1 line. */ #define HAVE_SYSCONF 1 #ifndef __APPLE__ #include <unistd.h> #endif /* __APPLE__ */ #if __LP64__ #define TRAMPOLINE_SIZE 48 #else #define TRAMPOLINE_SIZE 40 #endif #if defined WIN32 || defined _WIN32 #include <windows.h> #endif /* * The compiler generates calls to __enable_execute_stack() when creating * trampoline functions on the stack for use with nested functions. * It is expected to mark the page(s) containing the address * and the next 48 bytes as executable. Since the stack is normally rw- * that means changing the protection on those page(s) to rwx. */ void __enable_execute_stack( void * addr) { #if __APPLE__ /* On Darwin, pagesize is always 4096 bytes */ const uintptr_t pageSize = 4096; #elif defined WIN32 || defined _WIN32 const SYSTEM_INFO si; GetSystemInfo (&si); const uintptr_t pageSize = si.dwPageSize; #elif !defined(HAVE_SYSCONF) #error "HAVE_SYSCONF not defined! See enable_execute_stack.c" #else const uintptr_t pageSize = sysconf(_SC_PAGESIZE); #endif /* __APPLE__ */ const uintptr_t pageAlignMask = ~(pageSize-1); uintptr_t p = ( uintptr_t )addr; unsigned char * startPage = (unsigned char *)(p & pageAlignMask); 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); } </windows.h></unistd.h></sys> |