vaivaswatha / debugir

DebugIR: Debugging LLVM-IR Files
Apache License 2.0
125 stars 18 forks source link

LLVM 12 support #2

Closed folkertdev closed 3 years ago

folkertdev commented 3 years ago

Hi, I've been using this tool very happily for a long time while building a compiler. Now, for various reasons, we've upgraded to llvm 12. That breaks this tool. I don't really have much familiarity with the LLVM implementation or C++ the language, so the errors are hard to interpret. How hard do you think it would be to upgrade this tool to LLVM 12? Any tips/suggestions/...?

Here's what I've tried so far. In CMakeLists.txt I've bumped the llvm version to 12. I also had to give an explicit install location for llvm but that's probably my system being weird.

There are some minor compiler errors where LLVM now uses StringRef instead of std::string, adding .str() fixes those.

Then there is this (DebugIR.cpp, line ~250) which no longer works.

DebugLoc NewLoc = DebugLoc::get(Line, Col, Scope, InlinedAt);

Looks like that constructor got removed? I think that in most cases NewLoc == Loc? There doesn't seem to be a similar constructor any more, so not sure what to do with this.

Anyway, that's all still kind of OK, but then I'm really stumped by these linker errors:

/usr/bin/ld: CMakeFiles/debugir.dir/DebugIR.cpp.o:(.data.rel.ro+0x10): undefined reference to `typeinfo for llvm::AssemblyAnnotationWriter'
/usr/bin/ld: CMakeFiles/debugir.dir/DebugIR.cpp.o:(.data.rel.ro._ZTIN4llvm18ValueMapCallbackVHIPKNS_5ValueEjNS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE[_ZTIN4llvm18ValueMapCallbackVHIPKNS_5ValueEjNS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE]+0x10): undefined reference to `typeinfo for llvm::CallbackVH'
/usr/bin/ld: CMakeFiles/debugir.dir/DebugIR.cpp.o:(.data.rel.ro._ZTIN4llvm18ValueMapCallbackVHIPKNS_10BasicBlockEPNS_14DILexicalBlockENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE[_ZTIN4llvm18ValueMapCallbackVHIPKNS_10BasicBlockEPNS_14DILexicalBlockENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE]+0x10): undefined reference to `typeinfo for llvm::CallbackVH'
/usr/bin/ld: CMakeFiles/debugir.dir/DebugIR.cpp.o:(.data.rel.ro._ZTIN4llvm18ValueMapCallbackVHIPKNS_8FunctionEPNS_12DISubprogramENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE[_ZTIN4llvm18ValueMapCallbackVHIPKNS_8FunctionEPNS_12DISubprogramENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE]+0x10): undefined reference to `typeinfo for llvm::CallbackVH'
/usr/bin/ld: CMakeFiles/debugir.dir/DebugIR.cpp.o:(.data.rel.ro._ZTIN4llvm18ValueMapCallbackVHIPKNS_5ValueENS_14WeakTrackingVHENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE[_ZTIN4llvm18ValueMapCallbackVHIPKNS_5ValueENS_14WeakTrackingVHENS_14ValueMapConfigIS3_NS_3sys10SmartMutexILb0EEEEEEE]+0x10): undefined reference to `typeinfo for llvm::CallbackVH'
/usr/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x10): undefined reference to `typeinfo for llvm::cl::GenericOptionValue'
/usr/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyIbEE[_ZTIN4llvm2cl15OptionValueCopyIbEE]+0x10): undefined reference to `typeinfo for llvm::cl::GenericOptionValue'
collect2: error: ld returned 1 exit status

maybe relevant detail: my llvm "installation" is an archive downloaded from the llvm github. The install script does not seem to work on my version of ubuntu. Crucially that archive does not seem to contain the .cpp files, so maybe that's the problem?