microsoft / microsoft/vscode-cpptools

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

Offen
#11,889 24 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@Colengms arbeitet bereits daran.

Seit 13.2.2024.

configuration revision enhancement Feature: Compile Commands Feature: Configuration Language Service
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.