microsoft / microsoft/vscode-cpptools

Remove behavior where `compilerPath` overrides `compile_commands.json` entries, in favor of using an additional setting.

Aperta
#11,889 24 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@Colengms ci sta già lavorando.

Dal 13/2/2024.

configuration revision enhancement Feature: Compile Commands Feature: Configuration Language Service
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and Version: Windows 10 22H2
  • VS Code Version: 1.85.2
  • C/C++ Extension Version: 1.18.5
Bug Summary and Steps to Reproduce

Bug Summary:

If both "compilerPath" and "compileCommands" are present in "c_cpp_properties.json", the former seems to take precedence during IntelliSense analysis. This results in the command line of the file present in compile_commands.json (e.g. -mcpu) to be ignored, leading to missing defines. Removing "compilerPath" results in the command line from compile_commands.json being taken into the account.

This behaviour goes directly against what c_cpp_properties.json reference documents:

If there is a matching entry in compile_commands.json for a file open in the editor, that command line will be used to configure IntelliSense for that file, instead of the other fields of c_cpp_properties.json.

Additionally, the intended behaviour (compile_commands.json overriding other options) was mentioned yesterday in another issue: https://github.com/microsoft/vscode-cpptools/issues/11880#issuecomment-1901003596.

Defining "compilerPath": "", works as a workaround.

Observed behaviour:

"compilerPath" takes precedence over "compileCommands" for populating system/architecture specific defines.

Expected behaviour:

"compileCommands" takes precedence over "compilerPath" for populating system/architecture specific defines.

Configuration and Logs
c_cpp_properties.json
{
    "configurations": [
        {
            "name": "main",
            "intelliSenseMode": "gcc-arm",
            "compilerPath": "H:/dev/flipper-zero/.ufbt/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.EXE", // This causes issues
            "compileCommands": "${workspaceFolder}/.vscode/compile_commands.json",
            "configurationProvider": "ms-vscode.cpptools",
            "cStandard": "gnu17",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
Language server logs ("compilerPath" absent)
Querying compiler's default target using command line: "H:\dev\flipper-zero\.ufbt\toolchain\x86_64-windows\bin\arm-none-eabi-gcc.EXE" -dumpmachine
Compiler returned default target value: arm-none-eabi
Compiler query command line: H:\dev\flipper-zero\.ufbt\toolchain\x86_64-windows\bin\arm-none-eabi-gcc.EXE -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Wall -Wextra -Wno-address-of-packed-member -Wredundant-decls -Wdouble-promotion -fdata-sections -ffunction-sections -fsingle-precision-constant -fno-math-errno -g -Os -mword-relocations -mlong-calls -fno-common -nostdlib -std=gnu17 -Wp,-v -E -dM -x c nul
Attempting to get defaults from C compiler in compile_commands.json file: 'H:\dev\flipper-zero\.ufbt\toolchain\x86_64-windows\bin\arm-none-eabi-gcc.EXE'
Querying compiler for default C++ language standard using command line: H:\dev\flipper-zero\.ufbt\toolchain\x86_64-windows\bin\arm-none-eabi-g++.EXE -x c++ -E -dM nul
Language server logs ("compilerPath" present)
Querying compiler's default target using command line: "H:/dev/flipper-zero/.ufbt/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.EXE" -dumpmachine
Compiler returned default target value: arm-none-eabi
Compiler query command line: H:/dev/flipper-zero/.ufbt/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.EXE -std=c++17 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'H:/dev/flipper-zero/.ufbt/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.EXE'
Compiler query command line: H:/dev/flipper-zero/.ufbt/toolchain/x86_64-windows/bin/arm-none-eabi-gcc.EXE -std=gnu17 -Wp,-v -E -dM -x c nul
LSP: Message ignored due to no registered handler: $/setTrace
Other Extensions

No response

Additional context

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.