cancel
Showing results for 
Search instead for 
Did you mean: 

CMake rebuild replicates targets in some files

Mikk Leini
Senior

Using:

  • VSCode version: 1.107.1 on Windows 11.
  • STM32CubeIDE for Visual Studio Code version 3.7.0.

I created STM32N6 project that builds two targets: FSBL and Application. I follow the instructions here: https://community.st.com/t5/stm32-mcus/how-to-debug-the-stm32n6-using-vs-code/ta-p/833499

.clangd contents:

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: FSBL/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: FSBL/.*

.vscode/c_cpp_properties.json contents:

{
    "configurations": [
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_FSBL",
            "compileCommands": "${workspaceFolder}/FSBL/build/compile_commands.json"
        }
    ],
    "version": 4
}

 I give "CMake: clean rebuild" command in vscode.

MikkLeini_0-1767861873494.png

Now the files look like this:
.clangd

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: Appli/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: Appli/.*

---

CompileFlags:
  Add:
  - '-ferror-limit=0'
  - '-Wno-implicit-int'
  CompilationDatabase: FSBL/build
Diagnostics:
  Suppress:
  - unused-includes
  - unknown_typename
  - unknown_typename_suggest
  - typename_requires_specqual
If:
  PathMatch: FSBL/.*

and c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_FSBL",
            "compileCommands": "${workspaceFolder}/FSBL/build/compile_commands.json"
        }
    ],
    "version": 4
}

It appears that every time I execute it, the more replicas show up. I mean not just +1 but +N. Even if I clean up these files, I still get +N replicas. Like there's some counter.

 

It is actually even messier. I manually deleted all "build" folders, had c_cpp_properties.json opened and cleaned up in vscode and I hit CMake tab delete cache and reconfigure button (not command). Now my targets are named by this file:

{
    "configurations": [
        {
            "name": "STM32_Appli/build/compile_commands.json",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli/build/compile_commands.json",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        },
        {
            "name": "STM32_Appli/build/compile_commands.json",
            "compileCommands": "${workspaceFolder}/Appli/build/compile_commands.json"
        }
    ],
    "version": 4
}

I don't know what exactly causes it - whether it's something in ST toolset or not. Except this last oddness, nothing else seems to break on CMake clean rebuild command. Even these replicas don't create any big issues, they are just disturbing.

If it's something in ST toolset then maybe you can check it out and solve.

One feature requests would be to allow user sections in .clangd file just like are in source files (e.g. # User config begin:). Due to this issue it would be great to have rules for shared code in same .clangd file, but today the user modifications on this file are overwritten by the toolset.

0 REPLIES 0