llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.68k stars 10.92k forks source link

clangd crash when using prebuilt modules of the C standard library #95317

Open AlexRpq opened 2 weeks ago

AlexRpq commented 2 weeks ago

0 libLLVM.so.18.1 0x00007f47b393f716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54 1 libLLVM.so.18.1 0x00007f47b393d6d0 llvm::sys::RunSignalHandlers() + 80 2 libLLVM.so.18.1 0x00007f47b393fddb 3 libc.so.6 0x00007f47b26af520 4 libLLVM.so.18.1 0x00007f47b38bd589 llvm::MemoryBuffer::getMemBufferRef() const + 25 5 libclang-cpp.so.18.1 0x00007f47bce44bfa clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind) + 938 6 libclang-cpp.so.18.1 0x00007f47bcecd0a8 clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) + 5864 7 libclang-cpp.so.18.1 0x00007f47bce49075 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 693 8 libclang-cpp.so.18.1 0x00007f47bce53eb0 9 libLLVM.so.18.1 0x00007f47b388ef8c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 140 10 libLLVM.so.18.1 0x00007f47b388f144 11 libLLVM.so.18.1 0x00007f47b388f27a 12 libc.so.6 0x00007f47b2701ac3 13 libc.so.6 0x00007f47b2793850

CMake: cmake_minimum_required(VERSION 3.28)

# Compilers set(CMAKE_C_COMPILER clang-18) set(CMAKE_CXX_COMPILER clang++-18) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++20 -I/usr/include/c++/v1")

# Required for LSP set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(MyProject VERSION 1.0)

# Set C++ standard set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True)

# Add executable add_executable(MyExecutable src/main.cpp
)

# Specify the precompiled header # target_precompile_headers(MyExecutable PRIVATE src/pch.h)

# Specify source files target_sources(MyExecutable PRIVATE src/main.cpp)

# Add module interface file target_sources(MyExecutable PRIVATE FILE_SET all_my_modules TYPE CXX_MODULES FILES )

# Add flags to handle header units target_compile_options(MyExecutable PRIVATE -fmodules -fimplicit-modules)

Additional command for clangd "clangd-18", "--offset-encoding=utf-16", "--compile-commands-dir=build",

llvmbot commented 2 weeks ago

@llvm/issue-subscribers-clangd

Author: RPQ (AlexRpq)

0 libLLVM.so.18.1 0x00007f47b393f716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54 1 libLLVM.so.18.1 0x00007f47b393d6d0 llvm::sys::RunSignalHandlers() + 80 2 libLLVM.so.18.1 0x00007f47b393fddb 3 libc.so.6 0x00007f47b26af520 4 libLLVM.so.18.1 0x00007f47b38bd589 llvm::MemoryBuffer::getMemBufferRef() const + 25 5 libclang-cpp.so.18.1 0x00007f47bce44bfa clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind) + 938 6 libclang-cpp.so.18.1 0x00007f47bcecd0a8 clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) + 5864 7 libclang-cpp.so.18.1 0x00007f47bce49075 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 693 8 libclang-cpp.so.18.1 0x00007f47bce53eb0 9 libLLVM.so.18.1 0x00007f47b388ef8c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 140 10 libLLVM.so.18.1 0x00007f47b388f144 11 libLLVM.so.18.1 0x00007f47b388f27a 12 libc.so.6 0x00007f47b2701ac3 13 libc.so.6 0x00007f47b2793850 **CMake**: cmake_minimum_required(VERSION 3.28) \# Compilers set(CMAKE_C_COMPILER clang-18) set(CMAKE_CXX_COMPILER clang++-18) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++20 -I/usr/include/c++/v1") \# Required for LSP set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project(MyProject VERSION 1.0) \# Set C++ standard set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) \# Add executable add_executable(MyExecutable src/main.cpp ) \# Specify the precompiled header \# target_precompile_headers(MyExecutable PRIVATE src/pch.h) \# Specify source files target_sources(MyExecutable PRIVATE src/main.cpp) \# Add module interface file target_sources(MyExecutable PRIVATE FILE_SET all_my_modules TYPE CXX_MODULES FILES ) \# Add flags to handle header units target_compile_options(MyExecutable PRIVATE -fmodules -fimplicit-modules) **Additional command for clangd** "clangd-18", "--offset-encoding=utf-16", "--compile-commands-dir=build",