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

Clangd choosing the wrong compile commands #204

Open
MK-HTX opened this issue Feb 18, 2025 · 0 comments
Open

Clangd choosing the wrong compile commands #204

MK-HTX opened this issue Feb 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@MK-HTX
Copy link

MK-HTX commented Feb 18, 2025

Type: Bug Report

Describe the bug

  • OS and Version: Windows 10 22h2
  • VS Code Version: 1.97.1
  • Extension Version: 1.48.0

The following help says 'After you install clangd, you do not need any extra setup.':
https://developer.arm.com/documentation/108029/0000/Get-started-with-an-example-project/Finalize-the-setup-of-your-development-environment/clangd.

But I cannot get it to work correctly for my own CSolution. I have checked and the issue is also present in the SimpleTrustZone project, but due to its simplicity only by inspecting the clangd output window. My own CSolution has different include paths for the for CProject builds, i.e. the non-secure includes RTOS and the secure not. VSCode complains that RTOS related functions are undefined. A check of the clangd output shows that it is choosing the wrong compile commands.

The issue can be reproduced from the CSolution SimpleTrustZone project as follows:

To Reproduce

  1. Open the CSolution SimpleTrustZone project,
  2. Close all files,
  3. Open main_s.c,
  4. Open the clangd output window,
  5. Restart the clangd server.

Expected behavior
The clangd extension is using build commands from the 'CM33_s' cproject for file from the 'CM33_s' project.

Code sample and logs

The cland output windows show the following:

I[17:20:40.959] argv[0]: c:\Users\...\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\19.1.2\clangd_19.1.2\bin\clangd.exe
I[17:20:40.959] argv[1]: --compile-commands-dir=c:\repos\csolution-examples\SimpleTrustZone\out\CM33_s\AVH\Debug
I[17:20:40.959] argv[2]: --compile-commands-dir=c:\repos\csolution-examples\SimpleTrustZone\out\CM33_ns\AVH\Debug

and:

I[17:20:40.999] Loaded compilation database from c:\repos\csolution-examples\SimpleTrustZone\out\CM33_ns\AVH\Debug\compile_commands.json
I[17:20:41.000] ASTWorker building file c:\repos\csolution-examples\SimpleTrustZone\CM33_s\main_s.c version 1 with command inferred from C:\repos\csolution-examples\SimpleTrustZone\CM33_ns\main_ns.c

Additional context

It can be seen that the compile command folders from both CProject folders are provided to clangd, but it is choosing the wrong compilation options. The AST worker is using a compilation command inferred from a CM33_ns CProject file to build and a CM33_s CProject file.

@MK-HTX MK-HTX added the bug Something isn't working label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant