Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM 19 migration #775

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

LLVM 19 migration #775

wants to merge 6 commits into from

Conversation

wbqpk3
Copy link
Collaborator

@wbqpk3 wbqpk3 commented Nov 22, 2024

This patch implements LLVM 19, clang-19 support. The changes are not backwards compatible, meaning it no longer compiles with older LLVM.

Upgraded dependencies:

  • Boost: version 1.86.0 (current Boost version 1.74.0 does not compile with clang-19)
  • C++ standard upgraded to 17 (required by clang-19)

Prerequisites

The new Boost version is not in the Ubuntu 22.04 repositories, it needs to be compiled from source.
Download from https://www.boost.org/users/download/, steps:

./bootstrap.sh --prefix=path/to/installation/prefix
./b2 install

LLVM 19 is also not in the repositories.
Download from https://apt.llvm.org/, steps:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19 all

Compiling CodeCompass

Configure CMake with these flags:

-DLLVM_DIR=/usr/lib/llvm-19/cmake
-DClang_DIR=/usr/lib/cmake/clang-19 
-DCMAKE_C_COMPILER=clang-19 
-DCMAKE_CXX_COMPILER=clang++-19

We may encounter the following error:

In file included from CodeCompass/plugins/cpp/parser/src/cppparser.cpp:26:
In file included from CodeCompass/util/include/util/logutil.h:4:
In file included from /usr/local/include/boost/log/trivial.hpp:23:
In file included from /usr/local/include/boost/log/sources/severity_logger.hpp:23:
In file included from /usr/local/include/boost/log/sources/basic_logger.hpp:36:
In file included from /usr/local/include/boost/log/core/core.hpp:23:
In file included from /usr/local/include/boost/log/core/record.hpp:21:
In file included from /usr/local/include/boost/log/attributes/attribute_value_set.hpp:27:
In file included from /usr/local/include/boost/log/attributes/attribute_value.hpp:18:
In file included from /usr/local/include/boost/type_index.hpp:29:
In file included from /usr/local/include/boost/type_index/stl_type_index.hpp:34:
In file included from /usr/local/include/boost/core/demangle.hpp:32:
/usr/lib/llvm-19/include/cxxabi.h:55:1: error: functions that differ only in their return type cannot be overloaded
   50 | extern _LIBCXXABI_FUNC_VIS __cxa_exception*
      |                            ~~~~~~~~~~~~~~~~
   51 | #ifdef __wasm__
   52 | // In Wasm, a destructor returns its argument
   53 | __cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
   54 | #else
   55 | __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
      | ^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/cxxabi_init_exception.h:70:7: note: previous declaration is here
   69 |       __cxa_refcounted_exception*
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |       __cxa_init_primary_exception(void *object, std::type_info *tinfo,
      |       ^

This can be resolved by installing LLVM-18 removing the following packages:

sudo apt purge libc++1-19 libc++-19-dev libc++abi1-19 libc++abi-19-dev

Finally, CodeCompass should build without errors.
I also successfully parsed the gtest C++ project.

@wbqpk3 wbqpk3 marked this pull request as draft November 22, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant