Eli Friedman schrieb:> On Wed, Sep 17, 2008 at 1:31 PM, Michael Reichenbach > <michael_reichenbach at freenet.de> wrote: >> question about: >> http://llvm.org/docs/FAQ.html#translatec++ >> "With llvm-gcc3, this will generate program and program.bc." >> >> Is this llvm-gcc3 only out of date of is it really only llvm-gcc3? > > Those instructions are out of date; the current version of llvm-gcc > doesn't generate bitcode files unless you explicitly ask it to > generate them. The correct procedure with a current LLVM and llvm-gcc > is something like the following: > > llvm-g++ a.cpp -c -emit-llvm > llvm-g++ b.cpp -c -emit-llvm > llvm-link a.bc b.bc -o program.bc > llc -march=c program.bc -o program.c > gcc program.c > > -EliThanks for fast response! Currently I am trying what you told me. No matter if I try " llvm-g++ a.cpp -c -emit-llvm " with "LLVM-GCC 4.2 Front End Binaries for Mingw32/x86" on Windows XP or if I am trying it on Ubuntu... Only the a.o file will be created without any error messages. The .bc file will not be created, do you know why? Regards, -mr
On Sep 17, 2008, at 2:36 PMPDT, Michael Reichenbach wrote:> > No matter if I try " > llvm-g++ a.cpp -c -emit-llvm > " with "LLVM-GCC 4.2 Front End Binaries for Mingw32/x86" on Windows XP > or if I am trying it on Ubuntu... > > Only the a.o file will be created without any error messages. The .bc > file will not be created, do you know why?-emit-llvm doesn't change the default name for the -c output. The .o file should be llvm binary IR; if you want it named .bc, use -o a.bc If you're starting out, probably -S -emit-llvm is more useful, you can read that format.
Dale Johannesen schrieb:> On Sep 17, 2008, at 2:36 PMPDT, Michael Reichenbach wrote: >> No matter if I try " >> llvm-g++ a.cpp -c -emit-llvm >> " with "LLVM-GCC 4.2 Front End Binaries for Mingw32/x86" on Windows XP >> or if I am trying it on Ubuntu... >> >> Only the a.o file will be created without any error messages. The .bc >> file will not be created, do you know why? > > -emit-llvm doesn't change the default name for the -c output. > The .o file should be llvm binary IR; if you want it named .bc, use -o > a.bc > If you're starting out, probably -S -emit-llvm is more useful, you can > read that format.Ok, I understand so far. I have a partially working example now. llvm-g++ a.cpp -c -emit-llvm llvm-g++ b.cpp -c -emit-llvm llvm-link a.o b.o -o program.bc llc -march=c program.bc -o program.c gcc program.c program.c will contain some non-human generated code. But it doesn't compile with gcc. There is an error, gcc complaints about undefined reference to std::cout and such (the code was just a very small example with cout). It hasn't be converted into "C only" code, can you tell me why? Regards, -mr