Ericsson / CodeCompass

CodeCompass is a software comprehension tool for large scale software written in C/C++ and Java
https://codecompass.net
GNU General Public License v3.0
521 stars 102 forks source link

Making codebase macOS compatible #637

Open mcserep opened 1 year ago

mcserep commented 1 year ago

Build Guide on macOS

Tested on:

In contrast to the official guide of the project, we will use not GNU, but Clang to build CodeCompass and - most of - its dependencies. It is crucial to build them with the same compiler, otherwise if you are lucky, then you will get link-time unresolved symbol errors. If you are unlucky, then you will get runtime crashes and only in certain situations.
Since we would like to install as many dependencies from HomeBrew, as possible, and they were compiled with Clang (e.g. the Boost Library), we also use Clang.

Apple macOs comes with Clang (installation of XCode could be required), at the time of writing this guide, with v15. It is important to note, that the standard gcc and g++ binaries are linked to Clang instead as well.

  1. Install HomeBrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install available dependencies from HomeBrew:

    brew install wget
    brew install node
    brew install sqlite
    brew install cmake
    brew install llvm@15
    brew install gcc
    brew install boost
    brew install bison
    brew install graphviz
    brew install googletest
    brew install libgit2
    brew install libmagic
    brew install openssl@3
    brew install gnu-sed
    brew install coreutils

    Note: the gnu-sed and coreutils packages are required by GNU Bash scripts in CodeCompss.

    • gnu-sed is required for expected GNU sed usage in webgui-new/thrift-codegen.sh, for building the new web GUI.
    • coreutils is required for downloading and installing the latest Build2 by scripts/install_latest_build2.sh (e.g. commands nproc and sha256sum).
  3. Download and install OpenJDK. At the time of writing this guide, JDK v21 is the current stable version. Download it from https://jdk.java.net/21/, and extract it to /Library/Java/JavaVirtualMachines:

    sudo tar xzf openjdk-21_macos-aarch64_bin.tar -C /Library/Java/JavaVirtualMachines

    Alternatively you could install OpenJDK from HomeBrew (brew install java). Pay attention to the instructions displayed after install, as this package is keg-only, which means it was not symlinked into /opt/homebrew/ (because it would shadow the macOS java wrapper), therefore you must create a symlink in /Library/Java/JavaVirtualMachines or add the installation directory to your PATH.

  4. Build and install Thrift as described in the guide. Extra steps to do before:

    • Make sure beforehand that bison installed through HomeBrew is available on your PATH:

      export PATH="/opt/homebrew/opt/bison/bin:$PATH"

      This package is keg-only, which means it was not symlinked into /opt/homebrew/, because macOS already provides this software, but an older version (v2.3), not suitable for compiling Thrift.

    • Homebrew installed several C++ related dependencies into the /opt/homebrew/ folder with the gcc package. We need to make these available for Thrift to successfully build its C++ library. (Before running the configuration script.)

      export CXXFLAGS="$CXXFLAGS -I/opt/homebrew/include"
      export LDFLAGS="$LDFLAGS -L/opt/homebrew/lib"
    • Thrift compiles with some warning, when built with Clang, which by default will be treated as errors. Therefore we need to set the -Wno-error flag before calling the configuration script.

      export CXXFLAGS="$CXXFLAGS -Wno-error"

    When executing the ./configure script, pass the --with-openssl=/opt/homebrew/opt/openssl flag as well, so OpenSSL installed through HomeBrew could be found by Thrift.

  5. Build and install ODB as described in the guide, but while ODB runtime libraries (libodb) have to be built with Clang (to avoid linking issues), the ODB Compiler itself can only be built with GNU.

    Therefore we will build ODB in 2 steps into the <libodb_build_dir> and the <odb_build_dir> folders. A shared <odb_install_dir> installation destination can still be used though.

    • Build the ODB runtime libraries. Note, that the g++ compiler is the default Clang compiler of macOS - if not, it should be modified accordingly.

      # Configuring the build
      cd <libodb_build_dir>
      bpkg create --quiet --jobs $(nproc) cc \
      config.cxx=g++ \
      config.cc.coptions=-O3 \
      config.bin.rpath=<odb_install_dir>/lib \
      config.install.root=<odb_install_dir>
      
      # Getting the source
      bpkg add https://pkg.cppget.org/1/beta --trust-yes
      bpkg fetch --trust-yes
      
      # Building ODB runtime library
      bpkg build libodb --yes
      bpkg build libodb-sqlite --yes
      bpkg build libodb-pgsql --yes
      bpkg install --all --recursive
    • Build the ODB Compiler. Here the g++-13 GNU compiler is used, as at the time of writing this guide, GCC v13 is the default version installed by HomeBrew, but it could differ later.

      Furthermore, you need to add the /opt/homebrew/ folder to the include and link path as shown below, so dependencies installed through HomeBrew (like GMP) will be found. In case you receive a strange compilation error Assertion failed: (resultIndex < sectData.atoms.size()), try adding -ld_classic to the link flags, due to an XCode ld linker incompatibility issue with GNU.

      # Configuring the build
      cd <odb_build_dir>
      bpkg create --quiet --jobs $(nproc) cc \
      config.cxx=g++-13 \
      config.cc.poptions=-I/opt/homebrew/include \
      config.cc.coptions=-O3 \
      config.cc.loptions=-Wl,-ld_classic \
      config.bin.rpath=<odb_install_dir>/lib \
      config.install.root=<odb_install_dir>
      
      # Getting the source
      bpkg add https://pkg.cppget.org/1/beta --trust-yes
      bpkg fetch --trust-yes
      
      # Building ODB Compiler
      bpkg build odb --yes
      bpkg install odb
  6. Build CodeCompass.

    # Configure environment
    export CMAKE_PREFIX_PATH=<thrift_install_dir>:$CMAKE_PREFIX_PATH
    export CMAKE_PREFIX_PATH=<odb_install_directory>:$CMAKE_PREFIX_PATH
    export CMAKE_PREFIX_PATH=/opt/homebrew:$CMAKE_PREFIX_PATH
    # to detect dependencies installed with HomeBrew
    
    export PATH=<thrift_install_dir>/bin:$PATH
    export PATH=<odb_install_directory>/bin:$PATH
    export PATH=/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH
    # for sed usage in webgui-new/thrift-codegen.sh
    
    # Create build directory
    mkdir build
    cd build
    
    # Run CMake
    cmake .. \
     -DCMAKE_INSTALL_PREFIX=../install \
     -DDATABASE=pgsql \
     -DCMAKE_BUILD_TYPE=Debug \
     -DLLVM_DIR=/opt/homebrew/opt/llvm@15/lib/cmake/llvm \
     -DClang_DIR=/opt/homebrew/opt/llvm@15/lib/cmake/clang
    
    # Build project
    make -j $(sysctl -n hw.logicalcpu)
    
    # Copy files to install directory
    make install

Ongoing issues

mcserep commented 1 year ago

:warning: Temporary fix: not including the prctl.h when compiling on macOS and omitting the behaviour described below. While it is useful, it is not crucial and parsing should basically work without it.

:exclamation: Issue: The functionality described by prctl.h in Linux does not exist on macOS.

This is used by the searchparser, so that if the parent process stops, the process running Lucene will also stop with it.

Compilation failure:

/Users/mate/Documents/Repos/CodeCompass/util/src/pipedprocess.cpp:6:10: fatal error: 'sys/prctl.h' file not found
#include <sys/prctl.h>
         ^~~~~~~~~~~~~
1 error generated.
mcserep commented 1 year ago

:heavy_check_mark: Fixed! The solution was that libodb and CodeCompass must be compiled with the same compiler, this will be Clang in our case.

:exclamation: Issue: fail to link libutil against libodb-sqlite. The appropriate library with the correct path is passed to the command (highlighted with bold text), yet odb::sqlite::database::database is undefined. When building against pgsql, the issue is the same.

[ 13%] Linking CXX shared library libutil.dylib cd /Users/mate/Documents/Repos/CodeCompass/build/util && /opt/homebrew/Cellar/cmake/3.27.6/bin/cmake -E cmake_link_script CMakeFiles/util.dir/link.txt --verbose=1 /Library/Developer/CommandLineTools/usr/bin/c++ -W -Wall -Wextra -pedantic -DDATABASE_SQLITE -DBOOST_LOG_DYN_LINK -O0 -ggdb3 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.5 -dynamiclib -Wl,-headerpad_max_install_names -o libutil.dylib -install_name @rpath/libutil.dylib CMakeFiles/util.dir/src/dbutil.cpp.o CMakeFiles/util.dir/src/dynamiclibrary.cpp.o CMakeFiles/util.dir/src/filesystem.cpp.o CMakeFiles/util.dir/src/graph.cpp.o CMakeFiles/util.dir/src/legendbuilder.cpp.o CMakeFiles/util.dir/src/logutil.cpp.o CMakeFiles/util.dir/src/parserutil.cpp.o CMakeFiles/util.dir/src/pipedprocess.cpp.o CMakeFiles/util.dir/src/util.cpp.o -Wl,-rpath,/opt/odb/lib /opt/homebrew/lib/libboost_log-mt.dylib /opt/homebrew/lib/libboost_program_options-mt.dylib /opt/homebrew/lib/libboost_regex-mt.dylib /opt/homebrew/lib/libboost_system-mt.dylib /opt/homebrew/lib/libboost_thread-mt.dylib /opt/odb/lib/libodb.dylib /opt/odb/lib/libodb-sqlite.dylib /opt/homebrew/lib/libgvc.dylib /opt/homebrew/lib/libcgraph.dylib /opt/odb/lib/libsqlite3.dylib /opt/homebrew/lib/libboost_filesystem-mt.dylib /opt/homebrew/lib/libboost_atomic-mt.dylib /opt/homebrew/lib/libboost_chrono-mt.dylib

ld: Undefined symbols: odb::sqlite::database::database(int&, char**, bool, int, bool, std::1::basic_string<char, std::__1::char_traits, std::1::allocator> const&, odb::details::transfer_ptr), referenced from: cc::util::connectDatabase(std::1::basic_string<char, std::__1::char_traits, std::1::allocator> const&, bool) in dbutil.cpp.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

mcserep commented 1 year ago

:heavy_check_mark: Fixed! by defining the sighandler_t function pointer type when compiling on macOS.

:exclamation: Issue: The multi-threaded management of the Mongoose-based web server uses signal management to catch SIGINT and SIGTERM signals, to stop serving on all threads. While it uses the POSIX-compliant system signal.h (which should also work on macOS), it also uses GNU extension elements from it (see sighandler_t), which is not included in the macOS version of this system header.

Compilation failure:

In file included from /Users/mate/Documents/Repos/CodeCompass/webserver/src/webserver.cpp:17:
/Users/mate/Documents/Repos/CodeCompass/webserver/src/threadedmongoose.h:23:11: error: unknown type name 'sighandler_t'; did you mean 'mg_handler_t'?
  typedef sighandler_t SignalHandler;

While PR #388 removes the dependency for the signal.h header, it has several issues before it could be merged.

mcserep commented 1 year ago

:heavy_check_mark: Fixed! automagically by updating to LLVM v15 (from v11). Most likely the LLVM v11 in HomeBrew was corrupt, as the reason for uprading to v15 in the first place was that v11 produced inexplainable errors.

:exclamation: Issue: When linking the cpp_reparse service, some types from the C++ standard library are not found. Only this one plugin has such problems.

Compilation failure:

[ 68%] Linking CXX shared library libcppreparseservice.dylib
cd /Users/mate/Documents/Repos/CodeCompass/build-sqlite/plugins/cpp_reparse/service && /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -E cmake_link_script CMakeFiles/cppreparseservice.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/c++ -W -Wall -Wextra -pedantic  -DDATABASE_SQLITE   -DBOOST_LOG_DYN_LINK -O2 -ggdb3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.5 -dynamiclib -Wl,-headerpad_max_install_names -o libcppreparseservice.dylib -install_name @rpath/libcppreparseservice.dylib CMakeFiles/cppreparseservice.dir/src/plugin.cpp.o CMakeFiles/cppreparseservice.dir/src/cppreparseservice.cpp.o CMakeFiles/cppreparseservice.dir/src/astcache.cpp.o CMakeFiles/cppreparseservice.dir/src/asthtml.cpp.o CMakeFiles/cppreparseservice.dir/src/databasefilesystem.cpp.o CMakeFiles/cppreparseservice.dir/src/reparser.cpp.o   -L/opt/homebrew/opt/llvm@11/lib  -Wl,-rpath,/opt/homebrew/opt/llvm@11/lib -Wl,-rpath,/Users/mate/Documents/Repos/CodeCompass/build-sqlite/service/project -Wl,-rpath,/opt/odb/install/lib -Wl,-rpath,/Users/mate/Documents/Repos/CodeCompass/build-sqlite/util ../../../model/libmodel.a ../../cpp/model/libcppmodel.a ../../../webserver/libmongoose.a ../../../service/project/libprojectservice.dylib /usr/local/lib/libthrift.dylib libcppreparsethrift.a /opt/homebrew/opt/llvm@11/lib/libclangTooling.a /opt/homebrew/opt/llvm@11/lib/libclangFrontend.a /opt/homebrew/opt/llvm@11/lib/libclangBasic.a /opt/homebrew/opt/llvm@11/lib/libclangAST.a /opt/odb/install/lib/libssl.dylib ../../../util/libutil.dylib /opt/homebrew/lib/libboost_log-mt.dylib /opt/homebrew/lib/libboost_filesystem-mt.dylib /opt/homebrew/lib/libboost_atomic-mt.dylib /opt/homebrew/lib/libboost_chrono-mt.dylib /opt/homebrew/lib/libboost_program_options-mt.dylib /opt/homebrew/lib/libboost_regex-mt.dylib /opt/homebrew/lib/libboost_system-mt.dylib /opt/homebrew/lib/libboost_thread-mt.dylib /opt/homebrew/lib/libgvc.dylib /opt/homebrew/lib/libcgraph.dylib /opt/odb/install/lib/libsqlite3.dylib ../../../model/libmodel.a /opt/odb/install/lib/libodb.dylib /opt/odb/install/lib/libodb-sqlite.dylib ../../../service/project/libprojectthrift.a ../../../service/project/libcommonthrift.a /opt/homebrew/opt/llvm@11/lib/libclangParse.a /opt/homebrew/opt/llvm@11/lib/libclangDriver.a /opt/homebrew/opt/llvm@11/lib/libclangFormat.a /opt/homebrew/opt/llvm@11/lib/libclangToolingInclusions.a /opt/homebrew/opt/llvm@11/lib/libclangSerialization.a /opt/homebrew/opt/llvm@11/lib/libclangSema.a /opt/homebrew/opt/llvm@11/lib/libclangEdit.a /opt/homebrew/opt/llvm@11/lib/libclangAnalysis.a /opt/homebrew/opt/llvm@11/lib/libclangASTMatchers.a /opt/homebrew/opt/llvm@11/lib/libclangToolingCore.a /opt/homebrew/opt/llvm@11/lib/libclangAST.a /opt/homebrew/opt/llvm@11/lib/libclangRewrite.a /opt/homebrew/opt/llvm@11/lib/libclangLex.a /opt/homebrew/opt/llvm@11/lib/libclangBasic.a /opt/homebrew/opt/llvm@11/lib/libLLVM.dylib 
ld: warning: ignoring duplicate libraries: '../../../model/libmodel.a', '/opt/homebrew/opt/llvm@11/lib/libclangAST.a', '/opt/homebrew/opt/llvm@11/lib/libclangBasic.a'
ld: Undefined symbols:
  std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char>>::str() const, referenced from:
      boost::property_tree::file_parser_error::format_what(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned long) in plugin.cpp.o
      cc::service::language::ASTHTMLActionFactory::str() const in asthtml.cpp.o
      findCompilationDatabaseFromDirectory(llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) in libclangTooling.a[5](CompilationDatabase.cpp.o)
      clang::threadSafety::sx::toString(clang::threadSafety::til::SExpr const*) in libclangAnalysis.a[22](ThreadSafety.cpp.o)
  std::__1::basic_filebuf<char, std::__1::char_traits<char>>::open(char const*, unsigned int), referenced from:
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::basic_ifstream(char const*, unsigned int) in plugin.cpp.o
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
  std::__1::basic_filebuf<char, std::__1::char_traits<char>>::basic_filebuf(), referenced from:
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::basic_ifstream(char const*, unsigned int) in plugin.cpp.o
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
  std::__1::basic_filebuf<char, std::__1::char_traits<char>>::~basic_filebuf(), referenced from:
      void boost::property_tree::json_parser::read_json<boost::property_tree::basic_ptree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, boost::property_tree::basic_ptree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::locale const&) in plugin.cpp.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::basic_ifstream(char const*, unsigned int) in plugin.cpp.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::~basic_ifstream() in plugin.cpp.o
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
  VTT for std::__1::basic_ifstream<char, std::__1::char_traits<char>>, referenced from:
      void boost::property_tree::json_parser::read_json<boost::property_tree::basic_ptree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, boost::property_tree::basic_ptree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::locale const&) in plugin.cpp.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::basic_ifstream(char const*, unsigned int) in plugin.cpp.o
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::~basic_ifstream() in plugin.cpp.o
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
  VTT for std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>, referenced from:
      boost::property_tree::file_parser_error::format_what(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned long) in plugin.cpp.o
      std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_stringstream[abi:v160006]() in plugin.cpp.o
      std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_stringstream() in plugin.cpp.o
      findCompilationDatabaseFromDirectory(llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) in libclangTooling.a[5](CompilationDatabase.cpp.o)
      clang::threadSafety::sx::toString(clang::threadSafety::til::SExpr const*) in libclangAnalysis.a[22](ThreadSafety.cpp.o)
  VTT for std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>, referenced from:
      cc::service::language::CppReparseServiceHandler::getAsHTML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in cppreparseservice.cpp.o
      cc::service::language::ASTHTMLActionFactory::~ASTHTMLActionFactory() in cppreparseservice.cpp.o
      cc::service::language::CppReparseServiceHandler::getAsHTMLForNode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in cppreparseservice.cpp.o
      cc::service::language::ASTHTMLActionFactory::ASTHTMLActionFactory() in cppreparseservice.cpp.o
      std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_ostringstream() in cppreparseservice.cpp.o
  vtable for std::__1::basic_ifstream<char, std::__1::char_traits<char>>, referenced from:
      std::__1::basic_ifstream<char, std::__1::char_traits<char>>::basic_ifstream(char const*, unsigned int) in plugin.cpp.o
      clang::LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef) in libclangFrontend.a[20](LayoutOverrideSource.cpp.o)
  vtable for std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char>>, referenced from:
      boost::property_tree::file_parser_error::format_what(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned long) in plugin.cpp.o
      std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_stringstream[abi:v160006]() in plugin.cpp.o
      std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_stringstream() in plugin.cpp.o
      cc::service::language::CppReparseServiceHandler::getAsHTML(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in cppreparseservice.cpp.o
      cc::service::language::ASTHTMLActionFactory::~ASTHTMLActionFactory() in cppreparseservice.cpp.o
      cc::service::language::CppReparseServiceHandler::getAsHTMLForNode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in cppreparseservice.cpp.o
      cc::service::language::ASTHTMLActionFactory::ASTHTMLActionFactory() in cppreparseservice.cpp.o
      ...
  vtable for std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>, referenced from:
      std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_stringstream[abi:v160006]() in plugin.cpp.o
      findCompilationDatabaseFromDirectory(llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) in libclangTooling.a[5](CompilationDatabase.cpp.o)
      clang::threadSafety::sx::toString(clang::threadSafety::til::SExpr const*) in libclangAnalysis.a[22](ThreadSafety.cpp.o)
  vtable for std::__1::basic_ostringstream<char, std::__1::char_traits<char>, std::__1::allocator<char>>, referenced from:
      cc::service::language::ASTHTMLActionFactory::ASTHTMLActionFactory() in cppreparseservice.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [plugins/cpp_reparse/service/libcppreparseservice.dylib] Error 1
make[1]: *** [plugins/cpp_reparse/service/CMakeFiles/cppreparseservice.dir/all] Error 2
make: *** [all] Error 2
mcserep commented 1 year ago

✔️ Fixed! The error was related to Thrift not being linked correctly to the OpenSSL library installed through HomeBrew. The build guide have been updated accordingly.

Issue: cannot dynamically link searchparser plugin in runtime.

Runtime failure:

./CodeCompass_parser -l    
libc++abi: terminating due to uncaught exception of type std::runtime_error: Failed to load "/Users/mate/Documents/Repos/CodeCompass/install_sqlite/lib/parserplugin/libsearchparser.dylib": dlopen(/Users/mate/Documents/Repos/CodeCompass/install_sqlite/lib/parserplugin/libsearchparser.dylib, 0x0002): symbol not found in flat namespace '_GENERAL_NAME_free'

Other parser plugins can be loaded properly.

mcserep commented 7 months ago

:warning: Temporary fix: disabled macro expansion in the C++ plugin completely.

:exclamation: Issue: Pragmas defined with the _Pragma operator are double preprocessed, leading to parsing errors. See #731 for further details.

mcserep commented 7 months ago

:exclamation: Issue: Relative paths in the compile_commands.json for the file field are not handled properly. In case the directory is /source/, the file is file.cpp and the execution directory of CodeCompass_parser is /cc/, then instead of /source/file.cpp, the non-existent file /cc/file.cpp is being parse, leading to parsing error. Seemingly the directory field in the compile_commands.json file is not respected at all.

mcserep commented 7 months ago

:heavy_check_mark: Fixed! skip compilation commands with the -x objective-c++ flag.

:exclamation: Issue: CodeCompass cannot parse Objective-C++ code with .cpp extension. Clang is capable to compile Objective-C++ (which is a mixture of standard C++ and Objective-C), this can be specified in two ways:

CodeCompass skips the .mm files during parsing. However, a segfault occurs with Objective-C++ files with the .cpp extension. I have not yet debugged why the segfault occurs exactly, but it occurs even when no Objective-C is present in the code, but the -x objective-c++ flag is passed.