在EnableABIBreakingChecks上编译失败 [英] Compilation failing on EnableABIBreakingChecks

查看:542
本文介绍了在EnableABIBreakingChecks上编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了LLVM v8.0.0(在RHEL 7.4上).我正在通过 LLVM万花筒教程来学习如何使用该系统,但是遇到问题链接.

I recently installed LLVM v8.0.0 (on RHEL 7.4). I am going through the LLVM Kaleidoscope tutorial to learn how to use the system, but am running into an issue linking.

每个教程(第二章结束) ,我运行:

Per the tutorial (end of chapter 2), I run:

clang++ -g -O3 kld.cpp `llvm-config --cxxflags` -o kld

它可以编译,但是链接器失败:

It compiles, but the linker fails on:

/tmp/kld-f7264f.o:(.data+0x0): undefined reference to `llvm::EnableABIBreakingChecks'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

我怀疑这可能是llvm-config的问题,所以我也尝试使用--ldflags--system-libs标志,但是没有运气.

I suspected this may have been an issue with llvm-config, so I also tried using the --ldflags and --system-libs flags, but no luck.

llvm-config --cxxflags提供(经过重新格式化以提高可读性)

llvm-config --cxxflags gives (reformatted for readability)

-I~/project/llvm-src/include -I~/project/llvm-build/include 
-fPIC -fvisibility-inlines-hidden
-std=c++11
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-g 
-fno-exceptions -fno-rtti
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

~/...只是我的主目录的路径(出于隐私目的进行了编辑;实际输出是完整路径).我正在使用一个共享系统,该系统要求我在本地安装新软件.

Where ~/... is just the path to my home directory (edited for privacy; the actual output is a fullpath). I am working on a shared system that requires I install new software locally.

教程代码从不明确引用ABI,因此我认为这一定是某种编译器标志问题.在非二进制文件中grep表示缺少的符号,在include/llvm/Config/abi-breaking.h中给出extern声明,在lib/Support/Error.cpp中给出真实的声明:

The tutorial code never references ABI explicitly, so I assume this must be some kind of compiler-flags issue. greping for the missing symbol in non-binary files gives an extern declaration in include/llvm/Config/abi-breaking.h and the real declaration in lib/Support/Error.cpp:

#if LLVM_ENABLE_ABI_BREAKING_CHECKS
int EnableABIBreakingChecks;
#else
int DisableABIBreakingChecks;
#endif

我以为我会尝试使用-DLLVM_ENABLE_ABI_BREAKING_CHECKS重新编译.那也可以.

I thought I would try re-compiling, then, with -DLLVM_ENABLE_ABI_BREAKING_CHECKS. That also does that work.

我不太清楚ABI中断检查最初是做什么的,这可能超出了我的C ++舒适度水平.但是,如果我不需要引用的功能,该如何使该错误静音?或修复它,如果我愿意的话?

I'm not really clear what the ABI breaking checks are doing in the first place, and this may be way over my C++ comfort level. But how can I silence this error, if I don't need the referenced functionality; or fix it, if i do?

谢谢.

推荐答案

基于llvm irc频道中的讨论.

Based on the discussion in llvm irc channel.

尝试使用以下命令进行编译:clang ++ -O3 -c $(llvm-config --cxxflags)source_file.cpp -o obj_code.

Try the following command to compile : clang++ -O3 -c $(llvm-config --cxxflags) source_file.cpp -o obj_code.

然后尝试使用以下命令链接:clang ++ obj_code $(llvm-config --ldflags --libs)-lpthread.

Then try linking with this command : clang++ obj_code $(llvm-config --ldflags --libs) -lpthread.

我认为万花筒部分没有提到链接部分.上面的解决方案对我有用.

I think linking part doesn't mentioned in the kaleidoscope section. The above solution worked for me.

这篇关于在EnableABIBreakingChecks上编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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