在Ubuntu 16.04上构建LLVM 6 Trunk不能构建lld [英] LLVM 6 Trunk Build on Ubuntu 16.04 not building lld

查看:169
本文介绍了在Ubuntu 16.04上构建LLVM 6 Trunk不能构建lld的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu 16.04上构建LLVM 6.我也想要lld.但是无论我做什么,lld都不会构建/安装.

I am building LLVM 6 on Ubuntu 16.04. I want lld too. But no matter what I do, lld doesn't build/install.

遵循此处中的以下说明. 仍然在第一个和第二个中进行筛选:)

Followed the following instruction from here. Still sifting through first and second :)

  1. 阅读文档.

  1. Read the documentation.

阅读文档.

请记住,您两次被警告阅读文档.

Remember that you were warned twice about reading the documentation.

特别是,指定的相对路径很重要.

In particular, the relative paths specified are important.

结帐LLVM:

cd where-you-want-llvm-to-live
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm

  • 结帐C语:

  • Checkout Clang:

    cd where-you-want-llvm-to-live
    cd llvm/tools
    svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
    

  • 结帐额外的Clang工具[可选]:

  • Checkout Extra Clang Tools [Optional]:

    cd where-you-want-llvm-to-live
    cd llvm/tools/clang/tools
    svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
    

  • 结帐LLD链接器[可选]:

  • Checkout LLD linker [Optional]:

    cd where-you-want-llvm-to-live
    cd llvm/tools
    svn co http://llvm.org/svn/llvm-project/lld/trunk lld
    

  • 没有下载其他可选软件包.由于svn下载无法正常工作(svn: E000104: Error running context: Connection reset by peer),因此我为 LLVM C语 lld 从他们的github镜像中获取.从那时起,我就没有使用svn来重命名文件夹(例如,将clang-tools-extra-master更改为extra).

    Didn't download the other optional packages. Since svn download was not working properly (svn: E000104: Error running context: Connection reset by peer), I downloaded respective zip for LLVM, Clang, clang-extra and lld from their github mirrors. Since, I didn't use svn some renaming of the folders had to be done (for e.g. clang-tools-extra-master to just extra).

    cd进入llvm源文件夹的父文件夹后,执行以下操作

    Then execute the following, after cding into the parent folder of the llvm source folder,

    $ mkdir build; cd build
    $ cmake ../llvm
    $ make
    

    等待+8小时后,我得到了除lld之外的所有程序(clangllillc等).我希望它出现在文件夹build/bin中.

    After waiting for +8 hours, I get all the programs (clang, lli, llc etc.) except lld. I am expecting it to appear in the folder build/bin.

    我也尝试了选项cmake -DLLVM_ENABLE_PROJECTS=llvm/tools/lld ../llvm. (-DLLVM_ENABLE_PROJECTS=lld格式不起作用,我发现讨论有关同一ENABLE问题.)

    I have also tried the option cmake -DLLVM_ENABLE_PROJECTS=llvm/tools/lld ../llvm. (The form -DLLVM_ENABLE_PROJECTS=lld doesn't work and I found this place discussing about the same ENABLE issue.)

    我已经尝试了三遍,进行了一些调整.由于需要花费大量时间进行编译,因此我决定寻求您的帮助.

    I have already tried things with some tweaking three times. Since it takes so much time to compile, I decided to take your help.

    一个单独的问题:在构建时,链接阶段需要在我的笔记本电脑上使用12 GB RAM + 8.8 GB交换空间! LLVM构建是否真的需要大于20 GB的内存? (我已经关闭了所有其他前台应用程序,尤其是firefox)

    A separate issue: While building, linking phase takes 12 GB RAM + 8.8 GB swap space on my laptop!! Does LLVM building really require >20 GB of ram ? (I had closed all other foreground apps, especially firefox)

    请让我知道是否需要更多信息.

    Please let me know if any more information is needed.

    推荐答案

    首先,我认为LLVM_ENABLE_PROJECTS选项在使用平面"源目录布局时很有用.就您而言,如果您按照编写的方式执行了结帐,那么它就没什么用了.

    First of all, I think that the LLVM_ENABLE_PROJECTS option is useful if you use a "flat" source directory layout. In your case, if you performed the checkouts as you wrote, then it's not of much use.

    此外,@ PaulR关于使用ninja的内容是一个很好的建议.重新启动生成时它更快且非常有用,并且可以根据nproc并发生成尽可能多的单独的编译作业,而不必显式指定它.

    Moreover, what @PaulR wrote about using ninja is a very good suggestion. It's faster and very useful when restarting builds and it spawns as many separate compilation jobs concurrently as it can depending on the nproc without having to specify it explicitly.

    为加快构建速度并缩短链接时间,我还建议您使用BUILD_SHARED_LIBS选项启用启用共享库的构建.

    For faster build and shorter link times, I'd also suggest enabling a shared libs enabled build using the BUILD_SHARED_LIBS option.

    可以在此处,可以总结为:

    1. 使用clang构建clang(自举或第二阶段构建).
    2. 使用gold链接器代替ld,以缩短链接时间.
    3. 更喜欢生成共享库的版本.
    1. use clang to build clang (a bootstrapped or second-stage build).
    2. use the gold linker instead ld for faster linking times.
    3. prefer a build producing shared libraries.

    您现在可以跳过第1点(尽管您可以从系统软件包管理器中安装初始的llvm/clang)

    You can skip point 1 for now (although you could install an initial llvm/clang from the system package manager)

    最后,您可以使用LLVM_TARGETS_TO_BUILD选项将编译限制为当前所需的特定目标后端.

    Lastly, you could limit the compilation for the specific target backend you currently require using the LLVM_TARGETS_TO_BUILD option.

    我最近使用以下cmake配置构建了trunk(包括lld):

    I've built trunk recently (including lld) with this cmake configuration:

    CC=gcc CXX=g++ \
    cmake -G Ninja \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=On \
      -DBUILD_SHARED_LIBS=On \
    
      -DLLVM_ENABLE_ASSERTIONS=On \
      -DLLVM_TARGETS_TO_BUILD="X86" \
      -DLLVM_ENABLE_SPHINX=Off \
      -DLLVM_ENABLE_THREADS=On \
      -DLLVM_INSTALL_UTILS=On \
    
      -DCMAKE_BUILD_TYPE=Debug \
      [path-to-source-root-dir]
    

    如果需要构建libcxx,可以添加以下标志:

    You can add the following flags if you need to build libcxx:

    [...]
    -DLLVM_ENABLE_LIBCXX=On \
    -DLIBCXX_ENABLE_EXCEPTIONS=On \
    -DLIBCXX_ENABLE_RTTI=On \
    [...]
    

    对于使用另一个llvm/clanglibc++的自举构建,您可以将上述命令扩展为(在$PATH环境变量中具有clang):

    For a bootstrapped build using another llvm/clang and libc++ you can augment the above command as (having that clang in your $PATH environment variable):

    LLVM_TOOLCHAIN_LIB_DIR=$(llvm-config --libdir)
    
    LD_FLAGS=""
    LD_FLAGS="${LD_FLAGS} -Wl,-L ${LLVM_TOOLCHAIN_LIB_DIR}"
    LD_FLAGS="${LD_FLAGS} -Wl,-rpath-link ${LLVM_TOOLCHAIN_LIB_DIR}"
    LD_FLAGS="${LD_FLAGS} -lc++ -lc++abi"
    
    CXX_FLAGS=""
    CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -pthread"
    
    CC=clang CXX=clang++ \
    cmake -G Ninja \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=On \
      -DBUILD_SHARED_LIBS=On \
      -DLLVM_ENABLE_LIBCXX=On \
      -DLLVM_ENABLE_ASSERTIONS=On \
      -DLLVM_TARGETS_TO_BUILD="X86" \
      -DLLVM_ENABLE_SPHINX=Off \
      -DLLVM_ENABLE_THREADS=On \
      -DLLVM_INSTALL_UTILS=On \
      -DLIBCXX_ENABLE_EXCEPTIONS=On \
      -DLIBCXX_ENABLE_RTTI=On \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
      -DCMAKE_SHARED_LINKER_FLAGS="${LD_FLAGS}" \
      -DCMAKE_MODULE_LINKER_FLAGS="${LD_FLAGS}" \
      -DCMAKE_EXE_LINKER_FLAGS="${LD_FLAGS}" \
      -DCMAKE_POLICY_DEFAULT_CMP0056=NEW \
      -DCMAKE_POLICY_DEFAULT_CMP0058=NEW \
      [path-to-source-root-dir]
    

    此外,可以找到另一个感兴趣的相关SO问题

    Moreover, another relevant SO question of interest can be found here.

    正如您所写,阅读文档,再次尝试并阅读文档是解决问题的方法.

    As you wrote, reading the documentation, experimenting and reading the documentation again is the way to go.

    这篇关于在Ubuntu 16.04上构建LLVM 6 Trunk不能构建lld的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆