Visual Studio 2017编译LLVM7.0

1、编译环境

Win7 64位

Visual studio 2017 15.6

Windows Kits 10.0.14393.0

 

2、源码

http://releases.llvm.org/download.html#7.0.0

2.1 llvm

llvm-7.0.0.src.tar.xz

解压至llvm

2.2 Clang

cfe-7.0.0.src.tar.xz

解压重新命名为:clang

放入:llvm/tools

2.3 clang-extra

clang-tools-extra-7.0.0.src.tar.xz

解压重新命名为:extra

放入:llvm/tools/clang/tools

2.4 LLD linker

lld-7.0.0.src.tar.xz

解压重新命名为:lld

放入:llvm/tools

2.5 Polly Loop Optimizer

lld-7.0.0.src.tar.xz

解压重新命名为:polly

放入:llvm/tools

2.6 Compiler-RT

compiler-rt-7.0.0.src.tar.xz

解压重新命名为:compiler-rt

放入:llvm/projects

2.7 Libomp

openmp-7.0.0.src.tar.xz

解压重新命名为:openmp

放入:llvm/projects

2.8 libcxx and libcxxabi

libcxx-7.0.0.src.tar.xz

libcxxabi-7.0.0.src.tar.xz

解压重新命名为:libcxx 、libcxxabi

放入:llvm/projects

2.9 Test Suite Source Code

test-suite-7.0.0.src.tar.xz

解压重新命名为:test-suite

放入:llvm/projects

 

3、编译准备

3.1 安装CMake

cmake-3.12.3-win32-x86.zip

最低版本要求:3.4.3

3.2 安装python

添加PATH

3.3 安装perl

strawberry-perl-5.28.0.1-32bit.msi

添加PATH

3.4 生成sln

用CMake生成sln

 

4、编译

打开LLVM.sln,建议先查看5修正错误,选择ALL_BUILD生成即可。

 

5、调试错误解决

5.1 clang_rt.asan-dynamic-i386

Windows下,Compiler-RT Libraries\RTAsan.i386\asan_malloc_win.cc

中无MemalignFromLocalPool()函数,添加一个空的。

void* MemalignFromLocalPool(uptr alignment, uptr size) {

return NULL;

}

解决问题。当然空函数对程序的影响未知。

5.2 clangDaemon

Clang libraries\clangDaemon\CodeComplete.h

 

将文件编码另存为:

解决问题。

5.3 OMP

后期生成事件语句错误:

setlocal

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E make_directory E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/common.50/include

if %errorlevel% neq 0 goto :cmEnd

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E copy omp.h E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/common.50/include

if %errorlevel% neq 0 goto :cmEnd

:cmEnd

endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone

:cmErrorLevel

exit /b %1

:cmDone

if %errorlevel% neq 0 goto :VCEnd

setlocal

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E make_directory E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/win_32.50/lib

if %errorlevel% neq 0 goto :cmEnd

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E copy E:/LLVM/dist/bin/libomp.dll E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/win_32.50/lib

if %errorlevel% neq 0 goto :cmEnd

:cmEnd

endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone

:cmErrorLevel

exit /b %1

:cmDone

if %errorlevel% neq 0 goto :VCEnd

将标红部分修改为:

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E copy E:/LLVM/dist/bin/$(ConfigurationName)/libomp.dll

5.4 ompip

A、包含库路径错误

由于项目文件中:libomp.dll.lib路径有误。

删除相应的文件,按如下目录添加,或修改

dist\projects\openmp\runtime\src\ompimp.vcxpro文件中:

<Object Include="E:\LLVM\dist\lib\Debug\libomp.dll.lib" />

B、后期生成事件语句错误

setlocal

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E make_directory E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/win_32.50/lib

if %errorlevel% neq 0 goto :cmEnd

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E copy E:/LLVM/dist/lib/libomp.lib E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/win_32.50/lib

if %errorlevel% neq 0 goto :cmEnd

:cmEnd

endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone

:cmErrorLevel

exit /b %1

:cmDone

if %errorlevel% neq 0 goto :VCEnd

将标红部分修改为:

E:\LLVM\cmake-3.12.3-win32-x86\cmake-3.12.3-win32-x86\bin\cmake.exe -E copy E:/LLVM/dist/lib/$(ConfigurationName)/libomp.lib E:/LLVM/llvm-7.0.0.src/projects/openmp/runtime/exports/win_32.50/lib

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值