在Linux CentOS上编译CoreCLR
經(jīng)過幾天的努力,終于解決了在CentOS上編譯CoreCLR的問題。最終發(fā)現(xiàn)問題是CMAKE_C_FLAGS的設(shè)置引起的。
只要在“src/pal/tools/clang-compiler-override.txt”中刪除“SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11")?”,在“src/pal/tests/CMakeLists.txt”中添加“SET (CMAKE_C_FLAGS "-Wall -std=c11")”,就能編譯了。(更新:后來(lái)找到一個(gè)更好的解決方法:只需要將-std=c11改為-std=gnu11)?
下面分享一下在CentOS上編譯CoreCLR的操作步驟。
所用的CentOS版本7.0。
1)下載llvm的源代碼
wget http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz mv llvm-3.5.0.src llvm2)下載clang的源代碼
cd llvm/tools wget http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xz tar xf cfe-3.5.0.src.tar.xz mv cfe-3.5.0.src clang2+)下載lldb的源代碼及安裝相關(guān)組件
wget http://llvm.org/releases/3.5.0/lldb-3.5.0.src.tar.xz tar -xf lldb-3.5.0.src.tar.xz mv lldb-3.5.0.src lldb yum install swig python-devel libedit-devel3)下載compiler-rt的源代碼
cd ../projects wget http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xz tar xf compiler-rt-3.5.0.src.tar.xz mv compiler-rt-3.5.0.src compiler-rt4)下載libcxxabi的源代碼
wget http://llvm.org/releases/3.5.0/libcxxabi-3.5.0.src.tar.xz tar -xf libcxxabi-3.5.0.src.tar.xz mv libcxxabi-3.5.0.src.tar.xz libcxxabi5)下載libcxx的源代碼
wget http://llvm.org/releases/3.5.0/libcxx-3.5.0.src.tar.xz tar xf libcxx-3.5.0.src.tar.xz mv libcxx-3.5.0.src libcxx6)配置編譯選項(xiàng)
cd .. ./configure --enable-optimized CC=gcc CXX=g++7)編譯llvm
make -j28)安裝編譯好的llvm
make install(如果只安裝lldb,只需進(jìn)入llvm/tools/lldb中運(yùn)行make install)
9)簽出CoreClr的源代碼進(jìn)行編譯
git clone https://github.com/dotnet/coreclr.git cd coreclr ./build.sh10)安裝libunwind
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz tar -xf libunwind-1.1.tar.gz cd libunwind-1.1 ./configure make make install如果不安裝libunwind會(huì)出現(xiàn)下面的錯(cuò)誤:
/data/git/coreclr/src/pal/src/exception/seh-unwind.cpp:32:10: fatal error: 'libunwind.h' file not found10)解決"Native context type is not known"編譯錯(cuò)誤
編譯過程中出現(xiàn)如下的錯(cuò)誤:
-- Check size of siginfo_t -- Check size of siginfo_t - failed -- Check size of ucontext_t -- Check size of ucontext_t - failed ... [ 0%] Building CXX object src/palrt/CMakeFiles/palrt.dir/bstr.cpp.o In file included from /data/git/coreclr/src/pal/src/arch/i386/context.cpp:25: /data/git/coreclr/src/pal/src/include/pal/context.h:40:2: error: Native context type is not known on this platform!修改?src/pal/tools/clang-compiler-override.txt?文件,去掉?SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11")?可以解決這個(gè)問題。
(更新:后來(lái)找到一個(gè)更好的解決方法:只需要將-std=c11改為-std=gnu11)
10)解決"use of undeclared identifier"編譯錯(cuò)誤
繼續(xù)編譯過程中出現(xiàn)如下的錯(cuò)誤:
/data/git/coreclr/src/pal/tests/palsuite/c_runtime/wprintf/test2/test2.c: 31:15: error: use of undeclaredidentifier 'u'DoStrTest(u"foo %s", u"bar", u"foo bar");在?src/pal/tests/CMakeLists.txt?中添加?SET (CMAKE_C_FLAGS "-Wall -std=c11")?可以解決這個(gè)問題。
(更新:后來(lái)找到一個(gè)更好的解決方法:只需要將-std=c11改為-std=gnu11)
11)大功告成
Repo successfully built. Product binaries are available at /data/git/coreclr/binaries/Product/amd64/debug總結(jié)
以上是生活随笔為你收集整理的在Linux CentOS上编译CoreCLR的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: rsync命令大全
- 下一篇: 为什么Nginx性能比Apache高
