dgp1130 / llvm-bazel-foolang

An example of building a custom programming language with LLVM using Bazel.
MIT License
7 stars 1 forks source link

Doesn't run with llvm 8.0.0 #1

Open adamrk opened 5 years ago

adamrk commented 5 years ago

I tried this out with LLVM 8.0.0, but it failed with the error below about a bunch of undefined references. Not sure why that is - I looked up the first example (llvm::dwarf::OperationEncodingString) which seems to be in the header include/llvm/BinaryFormat/Dwarf.h and the archive lib/libLLVMBinaryFormat.a. Any tips for looking into this?

$ bazel build :compiler
INFO: SHA256 (https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz) = 0f5c314f375ebd5c35b8c1d5e5b161d9efaeff0523bac287f8b4e5b751272f51
INFO: Analysed target //:compiler (10 packages loaded, 2326 targets configured).
INFO: Found 1 target...
ERROR: /home/adam/projects/llvm-bazel-foolang/BUILD:4:1: Linking of rule '//:compiler' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc -o bazel-out/k8-fastbuild/bin/compiler -Wl,-S '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -pass-exit-codes -Wl,@bazel-out/k8-fastbuild/bin/compiler-2.params

Use --sandbox_debug to see verbose messages from the sandbox
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function writeDIExpression(llvm::raw_ostream&, llvm::DIExpression const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::OperationEncodingString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::MacinfoString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::ConventionString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::MacinfoString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::ConventionString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::LanguageString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::LanguageString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::AttributeEncodingString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::AttributeEncodingString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::LanguageString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function WriteMDNodeBodyInternal(llvm::raw_ostream&, llvm::MDNode const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module const*): error: undefined reference to 'llvm::dwarf::LanguageString(unsigned int)'
external/llvm/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/libLLVMCore.a(AsmWriter.cpp.o):AsmWriter.cpp:function (anonymous namespace)::MDFieldPrinter::printTag(llvm::DINode const*): error: undefined reference to 'llvm::dwarf::TagString(unsigned int)'
collect2: error: ld returned 1 exit status
Target //:compiler failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 221.156s, Critical Path: 0.27s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
dgp1130 commented 5 years ago

(Sorry for the delayed response, I guess I don't have my GitHub notifications set up correctly.)

Unfortunately I don't have much direction to give you. I'm not that familiar with LLVM's toolchain (or even most C build tools). Best I can do is point you to the Bazel build rule for it: https://github.com/dgp1130/llvm-bazel-foolang/blob/master/llvm.bzl#L50. It's possible that we might need to update the link options or add some extra files to the srcs or hdrs. The missing files you mentioned seem to be included in the globs, so I'm not sure why they would cause this particular error. Wish I had some better direction to give you here.

adamrk commented 5 years ago

Yeah I thought there might be some files from the include directory missing, but they all seem fine. Thanks anyway!