Hello friends working on LLVM, I am a beginner to LLVM. I tried to get C code from LLVM bitcode using 'llc -march=c'. But it seems to me that it doesn't work if the source program is a C++ program. Am I right? I have attatched the source program and the result of compiling the C code of it with GCC4.3.3. By the way, has LLVM's C code backend been tested on benchmarks like spec? Sorry if I missed the answers on websites. Best regards, Liang Peng -------------- next part -------------- A non-text attachment was scrubbed... Name: test.cc Type: text/x-c++src Size: 157 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091208/c97861e2/attachment.cc> -------------- next part -------------- $gcc testcc.cbe.c testcc.cbe.c:323: warning: conflicting types for built-in function ‘malloc’ testcc.cbe.c: In function ‘main’: testcc.cbe.c:356: warning: return type of ‘main’ is not ‘int’ /tmp/ccDcoA7R.o: In function `main': testcc.cbe.c:(.text+0x33): undefined reference to `std::cout' testcc.cbe.c:(.text+0x38): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)' testcc.cbe.c:(.text+0x42): undefined reference to `std::cout' testcc.cbe.c:(.text+0x47): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' /tmp/ccDcoA7R.o: In function `global constructors keyed to main': testcc.cbe.c:(.text+0x6a): undefined reference to `std::ios_base::Init::Init()' /tmp/ccDcoA7R.o: In function `__tcf_0': testcc.cbe.c:(.text+0x9e): undefined reference to `std::ios_base::Init::~Init()' collect2: ld returned 1 exit status
Hello> 'llc -march=c'. But it seems to me that it doesn't work if the source > program is a C++ program. Am I right?No. You haven't linked libstdc++ in your case. So, you either have to provide -lstdc++ or link via g++. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
lpeng <pengliang at ict.ac.cn> writes:> Hello friends working on LLVM, > I am a beginner to LLVM. I tried to get C code from LLVM bitcode using > 'llc -march=c'. But it seems to me that it doesn't work if the source > program is a C++ program. Am I right?If you use functions from some library on your C++ code (the C++ Standard Library, for example) calls to those functions are still present on the generated C code. This means that you must provide the referenced library on your compile command. On your case, either compile with gcc testcc.cbe.c -lstdc++ or with g++ testcc.cbe.c (g++ automatically adds the C++ standard library) [snip] -- Óscar
Hi, You need to link against the c++ standard library. gcc test.cbe.c -lstdc++ works for me :) Cornelius Am 08.12.2009 10:00, schrieb lpeng:> Hello friends working on LLVM, > I am a beginner to LLVM. I tried to get C code from LLVM bitcode using > 'llc -march=c'. But it seems to me that it doesn't work if the source > program is a C++ program. Am I right? I have attatched the source > program and the result of compiling the C code of it with GCC4.3.3. > By the way, has LLVM's C code backend been tested on benchmarks like > spec? Sorry if I missed the answers on websites. > > Best regards, > Liang Peng > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Apparently Analagous Threads
- errors Interix 3.5 / xapian-core-1.2.21 / Eric Lindblad
- question / errors Interix 3.5 / xapian-core-1.2.21 / Eric Lindblad
- [LLVMdev] AsmWriter.cpp:255: error: ambiguous overload for `std::basic_ostream<char,...
- [LLVMdev] AsmWriter.cpp:255: error: ambiguous overload for `std::basic_ostream<char,...
- [LLVMdev] AsmWriter.cpp:255: error: ambiguous overload for `std::basic_ostream<char,...