【发布时间】:2014-07-26 20:13:17
【问题描述】:
注意:
这项工作的目标是在非 c++11 编译器中使用一些 c++11 功能
以下步骤已完成,
-
生成llvm位码,
clang++ -emit-llvm -c test.cc -o test.o -
将llvm位码转换为c++代码,
llc-3.4 test.o -o test.cpp -march=cpp -
使用 GNU g++ 编译 llvm 生成的 c++ 代码时出现以下错误
arunprasadr@geekvm:~/works/myex/llvm$ g++ test.cpp test.cpp:3:23:致命错误:llvm/Pass.h:没有这样的文件或目录 编译终止。
我什至尝试添加 llvm-dev 包含路径,但仍然失败,
arunprasadr@geekvm:~/works/myex/llvm$ g++ test.cpp -I/usr/include/llvm-3.4 -I /usr/include/llvm-c-3.4
In file included from /usr/include/llvm-3.4/llvm/Support/type_traits.h:20:0,
from /usr/include/llvm-3.4/llvm/ADT/StringRef.h:13,
from /usr/include/llvm-3.4/llvm/PassRegistry.h:20,
from /usr/include/llvm-3.4/llvm/PassSupport.h:26,
from /usr/include/llvm-3.4/llvm/Pass.h:366,
from test.cpp:3:
/usr/include/llvm-3.4/llvm/Support/DataTypes.h:48:3: error: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
/usr/include/llvm-3.4/llvm/Support/DataTypes.h:52:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
In file included from /usr/include/llvm-3.4/llvm/ADT/SmallVector.h:19:0,
from /usr/include/llvm-3.4/llvm/PassAnalysisSupport.h:22,
from /usr/include/llvm-3.4/llvm/Pass.h:367,
from test.cpp:3:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isInt(int64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:33: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:33: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:264:65: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isUInt(uint64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:290:36: error: there are no arguments to ‘UINT64_C’ that depend on a template parameter, so a declaration of ‘UINT64_C’ must be available [-fpermissive]
/usr/include/llvm-3.4/llvm/Support/MathExtras.h: In function ‘bool llvm::isIntN(unsigned int, int64_t)’:
/usr/include/llvm-3.4/llvm/Support/MathExtras.h:322:33: error: ‘INT64_C’ was not declared in this scope
【问题讨论】:
-
cpp后端生成一个 C++ 代码,它将构建您的 LLVM IR 模块。显然,您想要一些不同的东西 - 就像旧的 C 后端所做的那样,但它早就从 LLVM 中删除了,而且它从来没有真正运作良好。 -
谢谢@SK-logic,听到这我有点失望。是否有任何其他替代方案可以从 LLVM IR 生成 C 代码?
标签: llvm llvm-clang llvm-gcc