I'm trying to link two modules together using the C++ API, one that's a sort of library module and one that's being generated from the source language. If I have something like this: OwningPtr<MemoryBuffer> owning_ptr; if (MemoryBuffer::getFile(StringRef("../hello.bc"), owning_ptr)) std::cout << "error opening file" << std::endl; Module* Lib = ParseBitcodeFile(owning_ptr.get(), context, &error); if (!Lib) std::cout << error << std::endl; When I run this (either on a bitcode file generated by llvm-gcc or by createBitcodeWriterPass()) I get an error telling me: "invalid bitcode signature". I'm not sure where this error's coming from. Any help would be appreciated. -- View this message in context: http://old.nabble.com/Invalid-bitcode-signature-tp33259763p33259763.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Feb 3, 2012, at 1:47 PM, Fraser Cormack wrote:> > I'm trying to link two modules together using the C++ API, one that's a sort > of library module and one that's being generated from the source language. > > If I have something like this: > > OwningPtr<MemoryBuffer> owning_ptr; > if (MemoryBuffer::getFile(StringRef("../hello.bc"), owning_ptr)) > std::cout << "error opening file" << std::endl; > > Module* Lib = ParseBitcodeFile(owning_ptr.get(), context, &error); > > if (!Lib) > std::cout << error << std::endl; > > When I run this (either on a bitcode file generated by llvm-gcc or by > createBitcodeWriterPass()) I get an error telling me: "invalid bitcode > signature". > > I'm not sure where this error's coming from. Any help would be appreciated. >The error is coming from the bit-code reader. Make sure that you generated the file with '-emit-llvm' (i.e., it's not an object file) and that it's the binary version of the bit-code file, not the text version. And, llvm-gcc? really? :-) -bw
Bill Wendling-3 wrote:> > The error is coming from the bit-code reader. Make sure that you generated > the file with '-emit-llvm' (i.e., it's not an object file) and that it's > the binary version of the bit-code file, not the text version. > > And, llvm-gcc? really? :-) > >Is there no way that the API can generate valid bitcode? And no, not really llvm-gcc, I'm not sure why I said that, haha :) -- View this message in context: http://old.nabble.com/Invalid-bitcode-signature-tp33259763p33262186.html Sent from the LLVM - Dev mailing list archive at Nabble.com.