This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Docs] Fix RAVFrontendAction doc's CMakelists.txt for Shared build
ClosedPublic

Authored by xgupta on Jan 30 2021, 7:34 AM.

Details

Summary

Example tutorial giving undefine reference error while building with BUILD_SHARED_LIBS=ON.

Diff Detail

Event Timeline

xgupta requested review of this revision.Jan 30 2021, 7:34 AM
xgupta created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2021, 7:34 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
xgupta edited the summary of this revision. (Show Details)Jan 30 2021, 7:34 AM
xgupta accepted this revision.Feb 1 2021, 11:39 PM

I build the project on my system x64 with shared libraries enable. It is working correctly. It is also NFC.

This revision is now accepted and ready to land.Feb 1 2021, 11:39 PM
This revision was landed with ongoing or failed builds.Feb 1 2021, 11:41 PM
This revision was automatically updated to reflect the committed changes.

Hi @xgupta , thank you for working on this!

It's quite easy to miss dependencies when building with BUILD_SHARED_LIBS=Off (i.e. with the default setting - static libs). IIUC, that's what happened here. This example clearly requires the following:

  • ASTConsumer implemented in clangAST
  • FullSourceLoc implemented in clangBasic
  • ASTFrontendAction implemented in clangFrontend
  • PCHContainerOperations (required for the invocation of runToolOnCode) implemented in clangSerialization

All the above were missing and your patch fixes that, thank you a ton! I think that this is also missing (implements llvm::outs()):

set(LLVM_LINK_COMPONENTS
  Support
  )

I tested on Darwin with BUILD_SHARED_LIBS=On and I'm getting build errors without it:

Undefined symbols for architecture x86_64:
  "llvm::outs()", referenced from:
      FindNamedClassVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl*) in FindClassDecls.cpp.o

PS Apologies for taking so much time to review this!

Thank @awarzynski for reviewing and explaining the details. I somehow missed it. Should be fixed by https://github.com/llvm/llvm-project/commit/d1ef9a63a68850bbe8cd8877f69c41833804c8dc