LLVM 教程 3.6 尝试编译第 8 章输出时的链接器错误
LLVM tutorial 3.6 linker error when trying to compile output from chapter 8
我正在学习 llvm 教程:http://llvm.org/releases/3.6.0/docs/tutorial/index.html
第 8 章中的代码编译得很好并发出 IR,但我无法编译发出的 IR。 代码清单被复制并粘贴,以减少我在某处的代码中出现拼写错误的可能性。 我唯一修改的是构建命令,因为 llvm-config 默认为旧版本。构建命令:
clang++ -g -O3 toy.cpp `llvm-config-3.6 --cxxflags --ldflags --system-libs --libs core mcjit native` -o toy
运行它(我从原始命令中删除了 &,因为这似乎抛出了一个错误):
./toy < programs/basic.ks | clang-3.6 -x ir -
输出如下所示:
; ModuleID = 'my cool jit'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
declare double @printd(double)
define double @main() {
entry:
%calltmp = call double @printd(double 4.200000e+01), !dbg !14
ret double %calltmp, !dbg !14
}
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Debug Info Version", i32 2}
!1 = !{i32 2, !"Dwarf Version", i32 2}
!2 = !{!"0x11 02 0Kaleidoscope Compiler 00 0 00 0 01", !3, !4, !4, !5, !4, !4} ; [ DW_TAG_compile_unit ] [./fib.ks] [DW_LANG_C]
!3 = !{!"fib.ks", !"."}
!4 = !{}
!5 = !{!6, !11}
!6 = !{!"0x2e 0printd 0printd 0 01 00 01 00 00 0256 00 01", !3, !7, !8, null, double (double)* @printd, null, null, !4} ; [ DW_TAG_subprogram ] [line 1] [def] [printd]
!7 = !{!"0x29", !3} ; [ DW_TAG_file_type ] [./fib.ks]
!8 = !{!"0x15 0 00 00 00 00 00 00", null, null, null, !9, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!9 = !{!10, !10}
!10 = !{!"0x24 0double 00 064 064 00 00 04", null, null} ; [ DW_TAG_base_type ] [double] [line 0, size 64, align 64, offset 0, enc DW_ATE_float]
!11 = !{!"0x2e 0main 0main 0 02 00 01 00 00 0256 00 02", !3, !7, !12, null, double ()* @main, null, null, !4} ; [ DW_TAG_subprogram ] [line 2] [def] [main]
!12 = !{!"0x15 0 00 00 00 00 00 00", null, null, null, !13, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!13 = !{!10}
!14 = !MDLocation(line: 2, column: 8, scope: !11)
warning: overriding the module target triple with x86_64-apple-macosx10.10.0
1 warning generated.
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
示例代码使用 dump()
方法打印出 IR,该方法打印到 stderr。您应该在管道之前将 stderr 重定向到 stdout,如下所示:
./toy < programs/basic.ks 2>&1 | clang-3.6 -x ir -
相关文章:
- Qt creator 4.11,在应用程序输出面板中创建一个链接
- 在静态库中使用输出迭代器时出现链接器错误
- 我的动态链接队列在同一输出流中调用时不正确地输出三个返回函数
- 将多个效果与 libSox 链接并读取输出数据的正确方法
- 将.init_array部分包含在链接器脚本中会产生不可用的输出
- 将我的主输出库与测试可执行文件链接时出现问题
- 当我从可用选择中选择基础链接时,为什么要获得怪异的输出
- 如何以C++格式输出已保存.html文件中<a href>标签中的所有链接?
- 聚输出错误 - 链接列表
- 做循环静态链接的LIB会导致更大的输出尺寸
- 我写了一个函数来删除循环链接列表中的第 1 个节点,但输出显示无限次"55 44 33 22 11 99",那么我该如何解决呢?
- C 链接列表仅输出其他每个元素
- LLVM 教程 3.6 尝试编译第 8 章输出时的链接器错误
- 将C++程序输出与 Python 脚本链接
- 在 c++ 中链接多个对象文件,但没有输出
- 将命令行实用程序的输出传递给编译器/链接器
- VS2010将项目输出库与依赖库链接(无项目)
- o流链接,输出顺序
- LDD输出静态链接在共享库上
- 无法输出链接列表的内容