使用CMake使用LLVM LLD发射单个IR位代码文件 [英] Emitting a single IR bitcode File with LLVM LLD using CMake

查看:74
本文介绍了使用CMake使用LLVM LLD发射单个IR位代码文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 16.04 x86_64和LLVM 5.0,并希望使用CMake将项目编译为单个LLVM IR位码文件.我知道有一种方法可以将GOLD链接器与LLVM插件一起使用,并添加CMake链接器标志" -fuse-ld = gold -Wl,-plugin-opt = emit-llvm ",CXX标志" -flto ".

I'm using Ubuntu 16.04 x86_64 and LLVM 5.0 and would like to compile a project to a single LLVM IR bitcode file using CMake. I know there is a way to do this using the GOLD Linker with the LLVM Plugin and add the CMake linker flags "-fuse-ld=gold -Wl,-plugin-opt=emit-llvm" and the CXX flag "-flto".

但是当我尝试使用LLVM LLD链接器和分别为< -fuse-ld = lld -Wl,-plugin-opt = emit-llvm 编译项目时,flto 标志,链接器正在生成本机可执行文件,没有LLVM IR文件.我正在寻找其他LLD选项来发出LLVM IR文件,但一无所获.

But when I try to compile the project with the LLVM LLD linker and the "-fuse-ld=lld -Wl,-plugin-opt=emit-llvm" respectively "-flto" Flag, the linker is generating a native executable and no LLVM IR file. I was searching for other LLD options to emit a LLVM IR file but found nothing.

是否有使用LLD生成单个LLVM IR文件的方法(或选项)?

Is there a way (or option) to generate a single LLVM IR file using LLD?

推荐答案

您可以使用 -save-temps 选项.

clang -flto -fuse-ld=lld -Wl,-save-temps a.o b.o -o myprogram

这将在其他文件中生成 myprogramXYZ.precodegen.bc .然后,您可以使用 llvm-dis 以可读的IR格式获取它.

This will generate myprogramXYZ.precodegen.bc among other files. You can then use llvm-dis to get it in readable IR format.

这篇关于使用CMake使用LLVM LLD发射单个IR位代码文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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