zoukankan      html  css  js  c++  java
  • Linux上成功编译CoreCLR源代码

    >>Build日期:2015-2-5下午(编译失败)。

    开始Linux发行版用的是CentOS 6.5,操作步骤:

    1)配置git: git config --global http.sslverify false 

    2)签出github上的CoreCLR代码库: git clone https://github.com/dotnet/coreclr.git 

    3)安装cmake: yum install cmake 

    4)安装clang: yum install clang 

    5)运行build命令: sh build.sh 

    6)build结果——失败!错误信息如下:

    Commencing CoreCLR Repo build
    Checking pre-requisites...
    Commencing build of native components for amd64/debug
    Invoking cmake with arguments: /data/git/coreclr DEBUG
    Detected Linux x86_64
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/git/coreclr/binaries/CMake
    Executing make
    [  0%] Building CXX object src/pal/src/CMakeFiles/CoreClrPal.dir/exception/seh.cpp.o
    In file included from /data/git/coreclr/src/pal/src/exception/seh.cpp:22:
    In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/typeinfo:34:
    In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:148:
    /usr/bin/../lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception_ptr.h:143:13: error: unknown type
          name 'type_info'
          const type_info*
                ^
    1 error generated.
    make[2]: *** [src/pal/src/CMakeFiles/CoreClrPal.dir/exception/seh.cpp.o] Error 1
    make[1]: *** [src/pal/src/CMakeFiles/CoreClrPal.dir/all] Error 2
    make: *** [all] Error 2
    Failed to build coreclr components.

    【更新】

    >>Build日期:2015-2-5晚上(编译成功)。

    后来,将遇到的这个问题在github coreclr issue #77中提交了一下,很快有人回复编译器只能用clang 3.5。

    看了一下CentOS安装的最新版clang是clang 3.4.2,看来是这个问题引起的。

    要到LLVM官网上一看,预编译好的clang 3.5有Ubuntu的版本,但没有CentOS的。

    于是,干脆将操作系统换成Ubuntu。在Ubuntu上用apt-get install clang安装,也是clang 3.4,只有手动安装clang 3.5。

    手动安装参考的是园子里的这篇博文:在 Linux 下使用 clang 3.0 + llvm 3.0 + libc++

    在Ubuntu中编译CoreCLR的实际操作步骤如下:

    1)安装cmake: apt-get install cmake 

    2)下载预编译好的clang 3.5: wget http://llvm.org/releases/3.5.0/clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz 

    3)解压下载好的clang 3.5压缩包: tar xvf clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz 

    4)进入解压后的文件夹: cd clang+llvm-3.5.0-x86_64-linux-gnu 

    5)复制其中的文件至/usr: cp -R * /usr 

    6)编译CoreCLR: sh build.sh 

    7)等待编译结果:

    Commencing CoreCLR Repo build
    build.sh: 101: build.sh: Bad substitution
    build.sh: 161: [: false: unexpected operator
    Checking pre-requisites...
    Commencing build of native components for amd64/debug
    Invoking cmake with arguments: /data/git/coreclr DEBUG
    Detected Linux x86_64
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/git/coreclr/binaries/CMake
    Executing make
    [  0%] Building CXX object src/pal/src/CMakeFiles/CoreClrPal.dir/exception/seh.cpp.o
    ...

    结果。。。编译成功了!

    [100%] Built target mscordaccore
    Install the project...
    -- Install configuration: "DEBUG"
    -- Installing: /data/git/coreclr/binaries/Product/amd64/debug/./corerun
    -- Installing: /data/git/coreclr/binaries/Product/amd64/debug/./libmscordaccore.so
    -- Installing: /data/git/coreclr/binaries/Product/amd64/debug/./libcoreclr.so
    Repo successfully built.
    Product binaries are available at /data/git/coreclr/binaries/Product/amd64/debug

    耶!大功告成!

    /data/git/coreclr/binaries/Product/amd64/debug# ls
    corerun  libcoreclr.so  libmscordaccore.so

    【补充】

    GitHub上已经有了专门的参考资料:Building and Running CoreCLR on Linux

  • 相关阅读:
    Unique Binary Search Trees——LeetCode
    Binary Tree Inorder Traversal ——LeetCode
    Maximum Product Subarray——LeetCode
    Remove Linked List Elements——LeetCode
    Maximum Subarray——LeetCode
    Validate Binary Search Tree——LeetCode
    Swap Nodes in Pairs——LeetCode
    Find Minimum in Rotated Sorted Array——LeetCode
    Linked List Cycle——LeetCode
    VR AR MR
  • 原文地址:https://www.cnblogs.com/dudu/p/build-coreclr-on-linux.html
Copyright © 2011-2022 走看看