【问题标题】:Why does clang/llvm on windows require Visual Studio's Link.exe?为什么 windows 上的 clang/llvm 需要 Visual Studio 的 Link.exe?
【发布时间】:2012-12-28 02:49:07
【问题描述】:

根据LLVM's Getting Started (Windows) site

... Clang 可用于发出位码、直接发出目标文件甚至使用 Visual Studio 的 link.exe 链接的可执行文件。

为什么需要在 Windows 上使用 Link.exe?而且,就此而言,Mac/Linux 上使用什么?再往下说:

Compile the program to object code using the LLC code generator:
    C:\..> llc -filetype=obj hello.bc
Link to binary using Microsoft link:
    C:\..> link hello.obj -defaultlib:libcmt

为什么 LLC 不能执行最后一步? LLI 似乎工作正常,所以我假设它在某种程度上与 link.exe 互操作 - 为什么 LLC 不能?

【问题讨论】:

    标签: windows linker llvm clang llc


    【解决方案1】:

    因为没有人为 LLVM 编写过链接器。

    有一个项目可以这样做(难以置信地称为lld),但它还没有准备好。

    更多详情请见http://lld.llvm.org

    在 mac 上,人们使用 Apple 的链接器,ld

    在 Linux 上,大多数人使用 gnu 链接器,通常(也)命名为 ld

    【讨论】:

    • 我猜这意味着 LLVM 不做 LTO?
    • @Mehrdad:LLVM 在 IR 级别执行 LTO。但即使一个可执行文件是从单个 .s 文件生成的,它仍然必须被链接。
    • @Mehrdad,gold 和 Mac ld 都可以使用 LLVM 插件进行 LTO。
    • 目前windows上支持lld
    【解决方案2】:

    试试 MinGW-W64 的 ld。我一直将它与 llvm 的 clang 一起使用,而不是我最初用于构建 clang 的 VS 工具。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-17
      • 2014-03-28
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      相关资源
      最近更新 更多