我可以使用 LLVM(低级虚拟机)为哪些平台编译二进制文件?
我对使用 LLVM 的 Clang 编译器感兴趣。 LLVM 声称是跨平台的,但尚不清楚可以针对哪些平台。我对此做了很多谷歌搜索,但似乎没有太多关于 LLVM 支持的平台的信息。我唯一发现的是 "this" 这有点令人困惑。我不确定这是否意味着我可以使用 LLVM 为这些平台编译二进制文件,或者它是否只在这些平台(或两者)上运行。对 LLVM/Clang 编译器有更多了解的人能否告诉我可以使用 Clang 或任何其他 LLVM 前端来定位哪些平台?我想要具体信息(例如“它支持 Windows 32 位、Windows 64 位、Linux 32 位、Linux 64 位等)。谢谢!
编辑:
好吧,我想我只是对 LLVM 到底是什么感到困惑。来自我刚刚发现 LLVM 只是一个字节码解释器,因为 LLVM 二进制文件比可执行二进制文件慢多少? “此处” 我找到了它支持的架构,但没有说明它支持哪些操作系统。在所有操作系统上,如果我避免平台相关的代码,我会寻找更多更详细地解释 LLVM 的文章(如果我能找到的话)。
I am interested in using the LLVM's Clang compiler. LLVM claims to be cross-platform however it is not clear which platforms can be targeted. I have done quite a lot of Googling on this but there doesn't seem to be much information about LLVM's supported platforms. The only thing I did find was "this" which is kinda confusing. I am not sure if it means I can compile binaries for those platforms using LLVM or if it just runs on those platforms (or both). Could someone who knows more about the LLVM/Clang compiler tell me which platforms I can target using Clang or any other LLVM front ends? I want specific information (like "It supports Windows 32bit, Windows 64bit, Linux 32bit, Linux 64bit, etc). Thanks!
EDIT:
Ok, I think I am just confused about what LLVM really is. From what I just figured out LLVM is simply a byte-code interpreter. Since LLVM is interpreted how much slower is LLVM binaries compared to executable binaries? So if performance is important LLVM is not the right choice? "Here" I found the architectures it supports but it did not say what operating systems it supports. Does it run on all operating systems if I avoid platform dependent code? I will look for more articles that explain LLVM in more detail if I can find any.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 llvm 安装类型
,您将看到类似于
转到 github.com 并搜索 mbed_samples 以查看 llvm 和 clang 用于 ARM 交叉编译的内容。在blinker03或04周围的某个地方是它的用武之地。LLVM对于任何平台都以相同的方式工作,llc步骤是你选择目标的地方,编译合并、优化等都是与平台无关的(例如你可以使用-m32)选择 int 大小)然后 llc 让您进入依赖于平台的汇编器。
With llvm installed type
and you will see something like
Go to github.com and search for mbed_samples to see llvm and clang being used to cross compile for ARM. Somewhere around blinker03 or 04 is where it comes in. LLVM works the same way for any platform, the llc step is where you choose your target, the compiling merging, optimizing, etc are all platform independent (well you might use -m32 for example to choose the int size) then llc gets you to platform dependent assembler.
LLVM 在目标机方面有很多可能的应用。
There are many possible applications of LLVM in terms of target machine.
根据clang手册,clang可以针对X86,Arm,部分支持PPC, SPARC 和 MSP430。
不过,Clang 也可以生成 LLVM 字节码。 LLVM 可以在更多平台上运行。
因此,如果您想要本机机器代码,那么这个列表非常小。如果您想要 LLVM 字节码,您有更广泛的平台选择。
According to the clang manual clang can target X86, Arm with partial support for PPC, SPARC and MSP430.
Clang can also generate LLVM bytecode though. LLVM can run on quite a few more platforms.
So if you want native machine code then the list is pretty small. If you want LLVM bytecode you have a broader choice of platforms.
我只是在这里回答编辑的问题(提出一个新问题可能更合适)。
这是 LLVM 的一个很好的架构概述。 此页面还包含大量有关 LLVM 各个方面的文档。
简而言之,LLVM 是传统编译器的优化器和后端。它在字节码上运行,字节码本质上是代码的中间表示,用于优化和生成最终的二进制文件。 LLVM 前端是独立的,并使用自己的内部 AST 来最终生成字节码。
当您想要生成最终的二进制文件时,LLVM 实际上非常灵活。您可以立即执行此操作,也可以延迟执行直到程序安装完成。我相信您甚至可以在执行期间使用其 JIT 生成最终的二进制文件(对此不能 100% 确定)。像这样延迟的主要优点是它可以应用特定于其执行环境的优化。
I'm only answering the edit's question here (it would probably be more appropriate to make a new question).
This is a good architectural overview of LLVM. This page also contains a ton of documentations on all aspects of LLVM.
The short version is that LLVM is the optimizer and backend of a traditionnal compiler. It operates on a bytecode which is essentially it's intermediate representation of the code and is used to optimize and generate the final binary. The LLVM frontends are independent and uses there own internal ASTs to eventually generate bytecode.
LLVM is actually pretty flexible when it comes to when you want to generate the final binary. You can either do it right away or delay it until the program is being installed. I believe you can even use its JIT to generate the final binary during execution (not 100% sure of this). The main advantage of delaying like this is that it can apply optimizations that are specific to the environment it is executing on.