错误信息提示如下:
[ 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
[ 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修改成这样:
/* ===-- 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);
}
补丁: http://clang-developers.42468.n3.nabble.com/file/n4033828/enable_execute_stack.c.patch
继续make,ok 过了。哈哈,狂喜中。编译还有问题可以找我,evilbinary_root 小E rootntsd@gmail.com