GNU bug report logs - #52054
clangd cannot find <stddef.h>

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Date: Tue, 23 Nov 2021 10:09:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52054 in the body.
You can then email your comments to 52054 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to emmanuel.agullo <at> inria.fr, bug-guix <at> gnu.org:
bug#52054; Package guix. (Tue, 23 Nov 2021 10:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
New bug report received and forwarded. Copy sent to emmanuel.agullo <at> inria.fr, bug-guix <at> gnu.org. (Tue, 23 Nov 2021 10:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: bug-guix <at> gnu.org
Subject: clangd cannot find <stddef.h>
Date: Tue, 23 Nov 2021 11:08:24 +0100
Hello,

‘clangd’ fails to find <stddef.h>, as shown here:

--8<---------------cut here---------------start------------->8---
$ printf '#include <stdlib.h>\nint foo (int x) {return x+2; }' > t.c
$ guix shell -C -D hello --with-c-toolchain=hello=clang-toolchain clang:extra strace
guix shell: warning: transformation 'with-c-toolchain' had no effect on strace <at> 5.8
guix shell: warning: transformation 'with-c-toolchain' had no effect on clang <at> 12.0.1
[env]$ clang -c t.c
[env]$ clangd --check=t.c
I[10:02:40.349] clangd version 12.0.1
I[10:02:40.349] PID: 3
I[10:02:40.349] Working directory: /home/ludo/tmp/clangd-bug
I[10:02:40.349] argv[0]: clangd
I[10:02:40.349] argv[1]: --check=t.c
I[10:02:40.349] Entering check mode (no LSP server)
I[10:02:40.349] Testing on source file /home/ludo/tmp/clangd-bug/t.c
I[10:02:40.349] Loading compilation database...
I[10:02:40.349] Failed to find compilation database for /home/ludo/tmp/clangd-bug/t.c
I[10:02:40.349] Generic fallback command is: /gnu/store/nk5lp7wisgdlvds5camvcchgh19hnn23-clang-12.0.1/bin/clang /home/ludo/tmp/clangd-bug/t.c -fsyntax-only -resource-dir=/gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1
I[10:02:40.350] Parsing command...
I[10:02:40.352] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name t.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1 -c-isystem /gnu/store/xl7wammzljnp0rg496n96h5m69y25isg-profile/include -cxx-isystem /gnu/store/xl7wammzljnp0rg496n96h5m69y25isg-profile/include -internal-isystem /usr/local/include -internal-isystem /gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1/include -internal-externc-isystem /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include -fdebug-compilation-dir /home/ludo/tmp/clangd-bug -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -x c /home/ludo/tmp/clangd-bug/t.c
I[10:02:40.352] Building preamble...
I[10:02:40.368] Indexing headers...
E[10:02:40.382] [pp_file_not_found] Line 1: in included file: 'stddef.h' file not found
I[10:02:40.382] Building AST...
I[10:02:40.386] Indexing AST...
I[10:02:40.386] Testing features at each token (may be slow in large files)
I[10:02:40.387] All checks completed, 1 errors
[env]$ ls /gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1
ls: cannot access '/gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1': No such file or directory
[env]$ readlink -f $(type -P clang)
/gnu/store/nk5lp7wisgdlvds5camvcchgh19hnn23-clang-12.0.1/bin/clang-12
[env]$ find -L /gnu/store/nk5lp7wisgdlvds5camvcchgh19hnn23-clang-12.0.1/ -name stddef.h
/gnu/store/nk5lp7wisgdlvds5camvcchgh19hnn23-clang-12.0.1/lib/clang/12.0.1/include/stddef.h
[env]$ exit
$ guix describe
Generacio 195	Nov 22 2021 00:37:58	(nuna)
  guix 24aa7b3
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 24aa7b3c21309b63cc6e8e18d6417d2cddccf6c6
--8<---------------cut here---------------end--------------->8---

Above, the directory passed as ‘-resource-dir’ does not exist: instead
of ‘…-clang-12.0.1-extra’ it should be ‘…-clang-12.0.1’.

This directory name is determined in ‘clangd/CompileCommands.cpp’:

--8<---------------cut here---------------start------------->8---
std::string detectStandardResourceDir() {
  static int Dummy; // Just an address in this process.
  return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
}

[…]

CommandMangler CommandMangler::detect() {
  CommandMangler Result;
  Result.ClangPath = detectClangPath();
  Result.ResourceDir = detectStandardResourceDir();
  Result.Sysroot = detectSysroot();
  return Result;
}

[…]

  if (ResourceDir && !Has("-resource-dir"))
    Cmd.push_back(("-resource-dir=" + *ResourceDir));
--8<---------------cut here---------------end--------------->8---

We should either fix ‘GetResourcesPath’ or patch the file above so it
returns the Clang directory name known at build time.

Ludo’.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 16 Feb 2022 15:59:01 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
bug acknowledged by developer. (Wed, 16 Feb 2022 15:59:01 GMT) Full text and rfc822 format available.

Message #10 received at 52054-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 52054-done <at> debbugs.gnu.org
Cc: emmanuel.agullo <at> inria.fr
Subject: Re: bug#52054: clangd cannot find <stddef.h>
Date: Wed, 16 Feb 2022 16:57:57 +0100
Hi,

Ludovic Courtès <ludovic.courtes <at> inria.fr> skribis:

> ‘clangd’ fails to find <stddef.h>, as shown here:
>
> $ printf '#include <stdlib.h>\nint foo (int x) {return x+2; }' > t.c
> $ guix shell -C -D hello --with-c-toolchain=hello=clang-toolchain clang:extra strace
> guix shell: warning: transformation 'with-c-toolchain' had no effect on strace <at> 5.8
> guix shell: warning: transformation 'with-c-toolchain' had no effect on clang <at> 12.0.1
> [env]$ clang -c t.c
> [env]$ clangd --check=t.c
> I[10:02:40.349] clangd version 12.0.1
> I[10:02:40.349] PID: 3
> I[10:02:40.349] Working directory: /home/ludo/tmp/clangd-bug
> I[10:02:40.349] argv[0]: clangd
> I[10:02:40.349] argv[1]: --check=t.c
> I[10:02:40.349] Entering check mode (no LSP server)
> I[10:02:40.349] Testing on source file /home/ludo/tmp/clangd-bug/t.c
> I[10:02:40.349] Loading compilation database...
> I[10:02:40.349] Failed to find compilation database for /home/ludo/tmp/clangd-bug/t.c
> I[10:02:40.349] Generic fallback command is: /gnu/store/nk5lp7wisgdlvds5camvcchgh19hnn23-clang-12.0.1/bin/clang /home/ludo/tmp/clangd-bug/t.c -fsyntax-only -resource-dir=/gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1
> I[10:02:40.350] Parsing command...
> I[10:02:40.352] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name t.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1 -c-isystem /gnu/store/xl7wammzljnp0rg496n96h5m69y25isg-profile/include -cxx-isystem /gnu/store/xl7wammzljnp0rg496n96h5m69y25isg-profile/include -internal-isystem /usr/local/include -internal-isystem /gnu/store/hnw2acjhfpj5l2zrazj5fvq5ksy002f1-clang-12.0.1-extra/lib/clang/12.0.1/include -internal-externc-isystem /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include -fdebug-compilation-dir /home/ludo/tmp/clangd-bug -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -x c /home/ludo/tmp/clangd-bug/t.c
> I[10:02:40.352] Building preamble...
> I[10:02:40.368] Indexing headers...
> E[10:02:40.382] [pp_file_not_found] Line 1: in included file: 'stddef.h' file not found
> I[10:02:40.382] Building AST...
> I[10:02:40.386] Indexing AST...
> I[10:02:40.386] Testing features at each token (may be slow in large files)
> I[10:02:40.387] All checks completed, 1 errors

Fixed with 35ea49daf6cdef5bf6156dd90add77cede364a4b (thanks, Greg!).

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 17 Mar 2022 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.