clangd does not work since precompiled headers were introduced #374

Closed
opened 2024-06-04 15:28:08 +00:00 by tom-hubrecht · 7 comments

Describe the bug

clangd is unable to deal with precompiled headers as they are tied to compiler internals, and so it now outputs errors like :
No type named 'string_view' in namestapce 'std'

Steps To Reproduce

  • Switch to latest main
  • run meson setup build --wipe
  • open an ide with clangd as the LSP
  • watch the world crash in incomprehension

Expected behavior

clangd not hallucinating errors ?

nix --version output

Additional context

I tried https://gerrit.lix.systems/c/lix/+/1383 but it seems that it does not really work

## Describe the bug clangd is unable to deal with precompiled headers as they are tied to compiler internals, and so it now outputs errors like : `No type named 'string_view' in namestapce 'std'` ## Steps To Reproduce - Switch to latest main - run `meson setup build --wipe` - open an ide with clangd as the LSP - watch the world crash in incomprehension ## Expected behavior clangd not hallucinating errors ? ## `nix --version` output ## Additional context I tried https://gerrit.lix.systems/c/lix/+/1383 but it seems that it does not really work
tom-hubrecht added the
bug
label 2024-06-04 15:28:08 +00:00
Owner

wait a minute, are you using a clang stdenv for development? if that's not the case, i think that's your problem. it also explains why i didn't notice it while working on this.

wait a minute, are you using a clang stdenv for development? if that's not the case, i think that's your problem. it also explains why i didn't notice it while working on this.
Owner

i think my preferred fix is to ship a .clangd that deletes gcc's pch args.

i think my preferred fix is to ship a .clangd that deletes gcc's pch args.
Owner

can we disable precompiled headers for non-clang devshells specifically, maybe with a warning or a -without-lsp variant? we tend to use clangd as lsp but gcc stdenv for compiling stuff primarily because we've had much worse experience with gcc bugs than clang bugs :/

can we disable precompiled headers for non-clang devshells specifically, maybe with a warning or a `-without-lsp` variant? we tend to use clangd as lsp but gcc stdenv for compiling stuff primarily because we've had much worse experience with gcc bugs than clang bugs :/
Author

wait a minute, are you using a clang stdenv for development? if that's not the case, i think that's your problem. it also explains why i didn't notice it while working on this.

No, I'm using the gcc stdenv...

> wait a minute, are you using a clang stdenv for development? if that's not the case, i think that's your problem. it also explains why i didn't notice it while working on this. No, I'm using the gcc stdenv...
Owner

Unsure what the correct fix for this is; we tried:

CompileFlags:
  Remove: [-fpch-preprocess, "-include precompiled-headers.hh"]

Which should work, but does not, as confirmed by looking at the output of clangd --check=src/libstore/filetransfer.cc under cc1 args.

relevant clang code, which i don't want to debug today: 8c5a7a1fc4/clang-tools-extra/clangd/ConfigCompile.cpp (L268-L279)

aff197ff21/clang-tools-extra/clangd/CompileCommands.cpp (L593)

Unsure what the correct fix for this is; we tried: ``` CompileFlags: Remove: [-fpch-preprocess, "-include precompiled-headers.hh"] ``` Which should work, but does not, as confirmed by looking at the output of `clangd --check=src/libstore/filetransfer.cc` under cc1 args. relevant clang code, which i don't want to debug today: https://github.com/llvm/llvm-project/blob/8c5a7a1fc4890fcae50f8e8a61d5a2e2b1ebd7e5/clang-tools-extra/clangd/ConfigCompile.cpp#L268-L279 https://github.com/llvm/llvm-project/blob/aff197ff2163a4b7732d08b833906cc21f4a5c89/clang-tools-extra/clangd/CompileCommands.cpp#L593
Owner

can we disable precompiled headers for non-clang devshells specifically, maybe with a warning or a -without-lsp variant? we tend to use clangd as lsp but gcc stdenv for compiling stuff primarily because we've had much worse experience with gcc bugs than clang bugs :/

We can do this

> can we disable precompiled headers for non-clang devshells specifically, maybe with a warning or a `-without-lsp` variant? we tend to use clangd as lsp but gcc stdenv for compiling stuff primarily because we've had much worse experience with gcc bugs than clang bugs :/ We can do this
qyriad self-assigned this 2024-06-06 17:54:17 +00:00
qyriad added the
Area/build-packaging
label 2024-06-06 18:56:09 +00:00
Owner
https://gerrit.lix.systems/c/lix/+/1403
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#374
No description provided.