ChuanqiXu9 / clangd-for-modules

A preview for C++20 Named Modules Support in clangd.
Other
18 stars 1 forks source link

\n clangd error on module name #4

Open Arthapz opened 1 month ago

Arthapz commented 1 month ago
but the logs are full of errors like

[ERROR][2024-07-15 16:03:31] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/llvm-git/bin/clangd"  "stderr"    "E[16:03:31.557] Scanning modules dependencies for build/../modules/stormkit/Core/Utils/Stacktrac
e.mpp failed: error: unable to handle compilation, expected exactly one compiler job in '/opt/llvm-git/bin/clang -c -Qunused-arguments -m64 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wpe
dantic -Wextra -ffp-model=fast -O3 -mfma -mfpu=neon -mavx -mavx2 -msse -msse2 -msse3 -mssse3 -msse4.2 -stdlib=libc++ -cxx-isystem/opt/llvm-git/include/c++/v1 -Ibuild/.gens/include -I/home/arthapz/Repos
/StormKit/include -D_GLIBCXX_DEBUG -DSTORMKIT_BUILD -DSTORMKIT_BUILD_DEBUG -DSTORMKIT_ASSERT=1 -DSTORMKIT_STATIC -DBOOST_STACKTRACE_USE_ADDR2LINE -DBOOST_STACKTRACE_LINK -isystem /home/arthapz/.xmake/p
ackages/g/glm/1.0.1/e8b755c3b7d04ec88316715dbafe4cb6/include -isystem /home/arthapz/Repos/StormKit/build/.packages/f/frozen/latest/9a1f279102e34dbe91527197132695fd/include -isystem /home/arthapz/.xmake
/packages/u/unordered_dense/v4.4.0/9226fe6ee99949838863899207aec25e/include -isystem /home/arthapz/.xmake/packages/m/magic_enum/v0.9.5/c9d129e2b37f49a5897d1ef2a130e7c3/include -isystem /home/arthapz/.x
make/packages/t/tl_function_ref/v1.0.0/db82eb7eb9e64a40a64595c6319b711b/include -isystem /home/arthapz/.xmake/packages/b/boost/1.84.0/1be587ae28144669827487e346d4bc81/include -isystem /home/arthapz/.xm
ake/packages/l/libbacktrace/v1.0/5ff2e6e6560147f597b99dfa2bbea685/include -Wno-experimental-header-units -fcolor-diagnostics -fexperimental-library -fstrict-aliasing -Wstrict-aliasing -Wno-missing-fiel
d-initializers -Wno-include-angled-in-module-purview -Wno-unknown-attributes -Wno-deprecated-declarations -ggdb3 -Wno-language-extension-token -fmodule-file=std=build/.gens/stormkit-core/linux/x86_64/d
ebug/rules/bmi/cache/modules/500a1880/std.pcm -fmodule-file=stormkit.Core:Parallelism.ThreadUtils=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Parallelism
.ThreadUtils.pcm --precompile -- build/../modules/stormkit/Core/Utils/Stacktrace.mpp'\n\nI[16:03:31.557] Recorded module unit path build/../modules/stormkit/Core/Utils/Stacktrace.mpp doesn't declare mo
dule stormkit.Core:Utils.Stacktrace\n"
@Arthapz For the first error, it says the module unit doesn't declare that module. Maybe it will helpful to check that. I noticed that there is a \n in the error message. So maybe it is related to the new line character.

https://github.com/llvm/llvm-project/pull/66462#issuecomment-2228601446

so i searched a little but didn't found why i get this \n for example

[ERROR][2024-07-16 15:48:06] .../vim/lsp/rpc.lua:770    "rpc"   "/opt/llvm-git/bin/clangd"  "stderr"    "I[15:48:06.472] Recorded module unit path /home/arthapz/Repos/StormKit/modules/stormkit/Core/Uti
ls/App.mpp doesn't declare module stormkit.Core:Utils.App\n"

the mapper file contain

stormkit.Engine:Core /home/arthapz/Repos/StormKit/modules/stormkit/Engine/Core.mpp
stormkit.Core:Utils.App /home/arthapz/Repos/StormKit/modules/stormkit/Core/Utils/App.mpp
stormkit.Core:Utils.Math /home/arthapz/Repos/StormKit/modules/stormkit/Core/Utils/Math.mpp

the compile_commands.json contain

{
  "directory": "/home/arthapz/Repos/StormKit",
  "arguments": ["/opt/llvm-git/bin/clang", "-c", "-Qunused-arguments", "-m64", "-g", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-Wall", "-Wpedantic", "-Wextra", "-ffp-model=fast", "-O3", "-mfma", "-mfpu=neon", "-mavx", "-mavx2", "-msse", "-msse2", "-msse3", "-mssse3", "-msse4.2", "-std=c++26", "-stdlib=libc++", "-cxx-isystem/opt/llvm-git/include/c++/v1", "-Ibuild/.gens/include", "-I/home/arthapz/Repos/StormKit/include", "-D_GLIBCXX_DEBUG", "-DSTORMKIT_BUILD", "-DSTORMKIT_BUILD_DEBUG", "-DSTORMKIT_ASSERT=1", "-DSTORMKIT_STATIC", "-DBOOST_STACKTRACE_USE_ADDR2LINE", "-DBOOST_STACKTRACE_LINK", "-isystem", "/home/arthapz/.xmake/packages/g/glm/1.0.1/e8b755c3b7d04ec88316715dbafe4cb6/include", "-isystem", "/home/arthapz/Repos/StormKit/build/.packages/f/frozen/latest/9a1f279102e34dbe91527197132695fd/include", "-isystem", "/home/arthapz/.xmake/packages/u/unordered_dense/v4.4.0/9226fe6ee99949838863899207aec25e/include", "-isystem", "/home/arthapz/.xmake/packages/m/magic_enum/v0.9.5/c9d129e2b37f49a5897d1ef2a130e7c3/include", "-isystem", "/home/arthapz/.xmake/packages/t/tl_function_ref/v1.0.0/db82eb7eb9e64a40a64595c6319b711b/include", "-isystem", "/home/arthapz/.xmake/packages/b/boost/1.84.0/1be587ae28144669827487e346d4bc81/include", "-isystem", "/home/arthapz/.xmake/packages/l/libbacktrace/v1.0/5ff2e6e6560147f597b99dfa2bbea685/include", "-Wno-experimental-header-units", "-fcolor-diagnostics", "-fexperimental-library", "-fstrict-aliasing", "-Wstrict-aliasing", "-Wno-missing-field-initializers", "-Wno-include-angled-in-module-purview", "-Wno-unknown-attributes", "-Wno-deprecated-declarations", "-ggdb3", "-Wno-language-extension-token", "-fmodule-file=std=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/std.pcm", "-fmodule-file=stormkit.Core:Utils.Numerics=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Utils.Numerics.pcm", "-fmodule-file=stormkit.Core:Coroutines=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Coroutines.pcm", "-fmodule-file=stormkit.Core:Meta.Concepts=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Meta.Concepts.pcm", "-fmodule-file=stormkit.Core:Meta.Traits=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Meta.Traits.pcm", "-fmodule-file=stormkit.Core:TypeSafe.AsCast=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-TypeSafe.AsCast.pcm", "-fmodule-file=stormkit.Core:TypeSafe.Boolean=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-TypeSafe.Boolean.pcm", "-fmodule-file=stormkit.Core:TypeSafe.Borrowed=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-TypeSafe.Borrowed.pcm", "-fmodule-file=stormkit.Core:Utils.Assert=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Utils.Assert.pcm", "-fmodule-file=stormkit.Core:Utils.Descriptors=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Utils.Descriptors.pcm", "-fmodule-file=stormkit.Core:Utils.Stacktrace=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Utils.Stacktrace.pcm", "-fmodule-file=stormkit.Core:Parallelism.ThreadUtils=build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Parallelism.ThreadUtils.pcm", "-x", "c++-module", "--precompile", "-o", "build/.gens/stormkit-core/linux/x86_64/debug/rules/bmi/cache/modules/500a1880/stormkit.Core-Utils.App.pcm", "modules/stormkit/Core/Utils/App.mpp"],
  "file": "modules/stormkit/Core/Utils/App.mpp"
},

and the file contain

module;

#include <stormkit/Core/PlatformMacro.hpp>

#include <stormkit/Core/MemoryMacro.hpp>

export module stormkit.Core:Utils.App;

import std;

import :Utils.Numerics;

export namespace stormkit::core {
    class STORMKIT_API App {
      public:
        App() noexcept          = default;
        virtual ~App() noexcept = default;

        App(App&&) noexcept                    = delete;
        auto operator=(App&&) noexcept -> App& = delete;

        App(const App&) noexcept                    = delete;
        auto operator=(const App&) noexcept -> App& = delete;

        virtual auto run(std::span<const std::string_view> args) -> Int = 0;
    };
} // namespace stormkit::core
ChuanqiXu9 commented 1 month ago

The log looks odd to me. I don't remember I saw \n in my logs.

I think maybe you can debug it. The codes for modules map is at: https://github.com/ChuanqiXu9/clangd-for-modules/blob/13b00fff9016f065697ef62ecbe42087545e463a/clang-tools-extra/clangd/ProjectModules.cpp#L241-L283 . It is relatively easy and independent. I believe you can understand what is it doing.

And also you can provide a reduced example so that I can try to reproduce it in my environments.

ChuanqiXu9 commented 1 month ago

And it is odd that why your message say:

Recorded module unit path build/../modules/stormkit/Core/Utils/Stacktrace.mpp doesn't declare mo
dule stormkit.Core:Utils.Stacktrace\n"

but Stacktrace.mpp and module name stormkit.Core:Utils.Stacktrace doesnt' show up in your module map file.

Arthapz commented 1 month ago

And it is odd that why your message say:


Recorded module unit path build/../modules/stormkit/Core/Utils/Stacktrace.mpp doesn't declare mo

dule stormkit.Core:Utils.Stacktrace\n"

but Stacktrace.mpp and module name stormkit.Core:Utils.Stacktrace doesnt' show up in your module map file.

Yeah i didn't post the whole map because it's very big and used Utils.App as exemple instead of Stacktrace