Coder Social home page Coder Social logo

Comments (5)

kanihal avatar kanihal commented on August 25, 2024

@PiotrZSL @gavinchou - Any idea on how to resolve this issue?

from codebrowser.

ogoffart avatar ogoffart commented on August 25, 2024

How did you generate that compilation database?
It looks like clang's compilation database parser don't support extra key.

Also your version of LLVM is quite old, perhaps output is a recent addition. (I have no idea about that, just a guess. Upgrading clang might or might not help)

from codebrowser.

kanihal avatar kanihal commented on August 25, 2024

@ogoffart

How did you generate that compilation database?

Since postgres is not a cmake project, I generated compile_commands.json using bear(https://github.com/rizsotto/Bear).

$ cd postgres
$ bear -- ./configure
$ bear -- make

Also your version of LLVM is quite old, ...

I had installed codebrowser_generator using .deb file linked in the woboq website: https://woboq.com/codebrowser-download.html. This is a very old build as you mentioned.

I also tried building codebrowser with LLVM-13(latest version). I get the following error while compiling,

$ cd codebrowser
$ cmake . -DCMAKE_BUILD_TYPE=Release
$ make 

[  8%] Building CXX object generator/CMakeFiles/codebrowser_generator.dir/main.cpp.o
In file included from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:39:
/home/jagadeesha/Downloads/codebrowser/generator/browserastvisitor.h: In member function ‘bool BrowserASTVisitor::VisitEnumConstantDecl(clang::EnumConstantDecl*)’:
/home/jagadeesha/Downloads/codebrowser/generator/browserastvisitor.h:132:130: error: no matching function for call to ‘llvm::APSInt::toString(int) const’
  132 | otator.registerReference(d, d->getLocation(), Annotator::EnumDecl, Annotator::Declaration, d->getInitVal().toString(10));
      |                                                                                                                       ^

In file included from /usr/lib/llvm-13/include/clang/AST/Type.h:34,
                 from /usr/lib/llvm-13/include/clang/AST/CanonicalType.h:17,
                 from /usr/lib/llvm-13/include/clang/AST/ASTContext.h:19,
                 from /usr/lib/llvm-13/include/clang/Frontend/ASTUnit.h:17,
                 from /usr/lib/llvm-13/include/clang/Frontend/FrontendAction.h:23,
                 from /usr/lib/llvm-13/include/clang/Frontend/FrontendActions.h:12,
                 from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:24:
/usr/lib/llvm-13/include/llvm/ADT/APSInt.h:82:8: note: candidate: ‘void llvm::APSInt::toString(llvm::SmallVectorImpl<char>&, unsigned int) const’
   82 |   void toString(SmallVectorImpl<char> &Str, unsigned Radix = 10) const {
      |        ^~~~~~~~
/usr/lib/llvm-13/include/llvm/ADT/APSInt.h:82:40: note:   no known conversion for argument 1 from ‘int’ to ‘llvm::SmallVectorImpl<char>&’
   82 |   void toString(SmallVectorImpl<char> &Str, unsigned Radix = 10) const {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/lib/llvm-13/include/clang/AST/Type.h:33,
                 from /usr/lib/llvm-13/include/clang/AST/CanonicalType.h:17,
                 from /usr/lib/llvm-13/include/clang/AST/ASTContext.h:19,
                 from /usr/lib/llvm-13/include/clang/Frontend/ASTUnit.h:17,
                 from /usr/lib/llvm-13/include/clang/Frontend/FrontendAction.h:23,
                 from /usr/lib/llvm-13/include/clang/Frontend/FrontendActions.h:12,
                 from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:24:
/usr/lib/llvm-13/include/llvm/ADT/APInt.h:1741:8: note: candidate: ‘void llvm::APInt::toString(llvm::SmallVectorImpl<char>&, unsigned int, bool, bool) const’
 1741 |   void toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed,
      |        ^~~~~~~~
/usr/lib/llvm-13/include/llvm/ADT/APInt.h:1741:8: note:   candidate expects 4 arguments, 1 provided
/home/jagadeesha/Downloads/codebrowser/generator/main.cpp: In function ‘bool proceedCommand(std::vector<std::__cxx11::basic_string<char> >, llvm::StringRef, llvm::StringRef, clang::FileManager*, DatabaseType)’:
/home/jagadeesha/Downloads/codebrowser/generator/main.cpp:303:15: error: ‘class clang::tooling::ToolInvocation’ has no member named ‘mapVirtualFile’
  303 |           Inv.mapVirtualFile(f->filename, {f->content , f->size } );
      |               ^~~~~~~~~~~~~~
make[2]: *** [generator/CMakeFiles/codebrowser_generator.dir/build.make:82: generator/CMakeFiles/codebrowser_generator.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:138: generator/CMakeFiles/codebrowser_generator.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

The 2 errors are:

codebrowser/generator/browserastvisitor.h:132:130: error: no matching function for call to ‘llvm::APSInt::toString(int) const’

codebrowser/generator/main.cpp:303:15: error: ‘class clang::tooling::ToolInvocation’ has no member named ‘mapVirtualFile’
303 | Inv.mapVirtualFile(f->filename, {f->content , f->size } );

from codebrowser.

kanihal avatar kanihal commented on August 25, 2024

Workaround Fix:
I followed the instructions given in rizsotto/Bear#196 (comment) to generate compile_commands.json in the older format (i.e. without output field). codebrowser_generator worked fine with the older format.

Adding config.json that I used for reference here.

{
    "compilation": {},
    "output": {
        "content": {
            "include_only_existing_source": true
        },
        "format": {
            "command_as_array": false,
            "drop_output_field": true
        }
    }
}

As for the codebrowser build failure with LLVM-13, I have logged a new issue (#95).

from codebrowser.

gavinchou avatar gavinchou commented on August 25, 2024

@kanihal Since you've solved the db problem, I would like to share some tips on generating compilation.json. Hope it may help in the future.

For any project I'd like to compile with codebrowser, I would like to write another new CMakeList.txt for it to get full control of the source code and dependencies needed by codebrowser, even though it already has one.
Of course, I need some script to help, here is the example
https://github.com/gavinchou/codebrowser/tree/master/examples/build-project-with-template

from codebrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.