[help] Kaleidoscope build fails after llvm-3.8

Hello ,

I have build llvm from release_38 branch ( only llvm and clang ) and install it. My DYLD_LIBRARY_PATH points to installation-directory/lib.

I am compiling example files for Kaleidoscope with following command :

clang++ -g toy.cpp -std=c++11 llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native -O3 -o toy

but it fails with following error:
Undefined symbols for architecture x86_64:
“llvm::CmpInst::CmpInst(llvm::Type*, llvm::Instruction::OtherOps, llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)”, referenced from:
llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >::CreateFCmp(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::MDNode*) in toy-1f302b.o
“llvm::DIBuilder::createFunction(llvm::DIScope*, llvm::StringRef, llvm::StringRef, llvm::DIFile*, unsigned int, llvm::DISubroutineType*, bool, bool, unsigned int, unsigned int, bool, llvm::MDTupleTypedArrayWrapperllvm::DITemplateParameter, llvm::DISubprogram*)”, referenced from:
(anonymous namespace)::FunctionAST::codegen() in toy-1f302b.o
“vtable for llvm::PHINode”, referenced from:
llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >::CreatePHI(llvm::Type*, unsigned int, llvm::Twine const&) in toy-1f302b.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)

With previous version 3.8.0svn it used to build successfully. Can someone help me what I am doing wrong ?

Sincerely,

Are you compiling the actual Kaleidoscope in the llvm 3.8 directory? Or a version from a different version of LLVM?

I should add that in my git version 393c3c6b687d0d92a24afe888bca6995f41f381a chapter8/toy.cpp compiles with the command you posted.

(Replying to llvm-dev as well - it is part of the normal mailing-list etiquette to reply-all, so that replies go to list as well as the individual - then others can see the replies and any follow up)

So, I tried the chapter8/toy.cpp from release_38, and it works on my setup [I didn’t rebuild the compiler, I used mine, built from sources with changes from February 5th.

I think you need to do some clang++ -v to see that it actually links to the things you think it will link with, for example. My best guess is that there is another LLVM installation and the linker finds the wrong one. Could of course be many other things wrong too, it’s just a guess.

*Vivek Pandya*

(Replying to llvm-dev as well - it is part of the normal mailing-list
etiquette to reply-all, so that replies go to list as well as the
individual - then others can see the replies and any follow up)

So, I tried the chapter8/toy.cpp from release_38, and it works on my setup
[I didn't rebuild the compiler, I used mine, built from sources with
changes from February 5th.

I think you need to do some clang++ -v to see that it actually links to
the things you think it will link with, for example. My best guess is that
there is another LLVM installation and the linker finds the wrong one.
Could of course be many other things wrong too, it's just a guess.

Yes Mats, noted the advice.

My clang commands maps to v 7.0 through Xcode's toolchain which is not
updated also it uses same version of ld. but when I tried with clang-3.8
explicitly it did not link libclang_rt.osx.a but Xcode tool chain tries for
that too. Do I need to build compiler-rt along with llvm 3.8 ?

I don't do OSX development, but I'd say, yes you probably do.