c++ - LLVM tutorial 3.6 linker error when trying to compile output from chapter 8 -


i working through llvm tutorial: http://llvm.org/releases/3.6.0/docs/tutorial/index.html

the code chapter 8 compiles fine , emits ir unable compile emitted ir. code listing copy , pasted reduce chances have typo in code somewhere. thing have modified build command since llvm-config defaults older version. build command:

clang++ -g -o3 toy.cpp `llvm-config-3.6 --cxxflags --ldflags --system-libs --libs core mcjit native` -o toy 

to run (i removed & original command since seems throw error):

./toy < programs/basic.ks | clang-3.6 -x ir - 

the output listed below:

; 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\002\00kaleidoscope compiler\000\00\000\00\001", !3, !4, !4, !5, !4, !4} ; [ dw_tag_compile_unit ] [./fib.ks] [dw_lang_c] !3 = !{!"fib.ks", !"."} !4 = !{} !5 = !{!6, !11} !6 = !{!"0x2e\00printd\00printd\00\001\000\001\000\000\00256\000\001", !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\00\000\000\000\000\000\000", 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\00double\000\0064\0064\000\000\004", null, null} ; [ dw_tag_base_type ] [double] [line 0, size 64, align 64, offset 0, enc dw_ate_float] !11 = !{!"0x2e\00main\00main\00\002\000\001\000\000\00256\000\002", !3, !7, !12, null, double ()* @main, null, null, !4} ; [ dw_tag_subprogram ] [line 2] [def] [main] !12 = !{!"0x15\00\000\000\000\000\000\000", 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 module target triple x86_64-apple-macosx10.10.0 1 warning generated. undefined symbols architecture x86_64:   "_main", referenced from:      implicit entry/start main executable ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

the example code prints out ir using dump() method, prints stderr. should redirect stderr stdout before piping, this:

./toy < programs/basic.ks 2>&1 | clang-3.6 -x ir - 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -