Skip to content

Add support for querying kcc compiler #13470

Closed as not planned
Closed as not planned
@Mathias-Buder-Bose

Description

@Mathias-Buder-Bose

Environment

  • OS: Windows 10
  • Compiler: kcc (custom)
  • VS Code Version:
    • Version: 1.99.0 (user setup)
    • Commit: 4437686ffebaf200fa4a6e6e67f735f3edf24ada
    • Date: 2025-04-02T21:35:19.530Z
    • Electron: 34.3.2
    • ElectronBuildId: 11161073
    • Chromium: 132.0.6834.210
    • Node.js: 20.18.3
    • V8: 13.2.152.41-electron.0
    • OS: Windows_NT x64 10.0.19045
  • CMake Version: 3.30.0
  • C++ Extension: ms-vscode.cpptools 1.24.5

Bug Summary and Steps to Reproduce

Summary

VS Code fails to correctly query the kcc compiler when using a compile_commands.json generated by CMake. It attempts to call the compiler with -x c++ which is not recognized by kcc, leading to fallback behavior and broken IntelliSense. In addition, the initialization at startup takes forever.

Steps to Reproduce

  • Install and VS Code C++ extension.
  • Configure a Conan-based CMake project with CMakeToolchain and CMakeDeps generators.
  • Use a custom compiler (in this case kcc).
  • Define environment variable CMAKE_EXPORT_COMPILE_COMMANDS in Windows
  • In VS Code, set:
{
  "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json"
}

Expected Behavior

VS Code should use the flags and definitions from compile_commands.json and correctly provide IntelliSense without trying to query the compiler directly.

Actual Behavior

VS Code attempts to invoke the compiler with:

kcc.exe -x c++ -E -dM nul

But kcc doesn't support the -x option and fails with:

Error: Option '-x' was not recognised.
Run 'kcc -h' for usage information.

Then VS Code falls back to default or broken IntelliSense behavior.

Possible Fixes / Suggestions

  • Allow disabling all compiler probing when compile_commands.json is present and valid.
  • Provide an option to bypass all internal compiler invocations and use only what's in compile_commands.json.
  • Improve support for non-clang/gcc compilers that don’t recognize GCC-like options like -x.

Configuration and Logs

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "intelliSenseMode": "gcc-x86",
            "cStandard": "c17",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

C/C++: Log Diagnostics

Attempting to get defaults from C compiler in compile_commands.json file: 'C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe'
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\cygwin64\bin\gcc.exe'
Querying compiler for default C++ language standard using command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -x c++ -E -dM nul
Querying compiler for default C++ language standard using command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -x c++ -E -dM /dev/null
Detected language standard version: c++98
Querying compiler's default target using command line: "C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe" -dumpmachine
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=c11 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=c99 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=c89 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu23 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu2x -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu18 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu17 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu11 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu1x -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu99 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu9x -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -std=gnu89 -m32 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 64-bit intelliSenseMode.
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\.conan\1cb681\1\tools\kcc\bin\kcc.exe -Wp,-v -E -dM -x c nul
Error: Option '-x' was not recognised.
Run 'kcc -h' for usage information.

KCC help command

PS > kcc.exe -h
Kalimba C compiler driver, version 81
Copyright (c) 2008 - 2023 Qualcomm Technologies International Limited

Usage: kcc [options] <file...>

KCC Driver options:
 --help                   print help
 --version                report all tool versions and exit
 -?                       print help
 -B<path>                 specify tool path and prefix
 -g                       enable debug symbols
 -h                       print help
 -k<chip>                 specify target chip name
 -mark-code-section-type  append '__minim' or '__maxim' to code section names based on
                          instruction set used in compilation unit or assembly module
 -minim                   target MiniMode instruction set
 -n                       report commands rather than running them
 -o <filename>            specify output file
 -save-temps              keep intermediate files around
 -v                       report all tool versions and exit

Compiler options:
 -D<symbol>               define preprocessor symbol
 -E                       preprocess only
 -I<path>                 add a directory to the compiler's include path for preprocessing
 -MABS                    (Linux only) use absolute paths for prerequisites in make dependency fragments
 -MAC                     allow a colon in dependency paths in generated make dependency file
 -MD                      generate make dependency files for compiled code
 -MF<filename>            specify filename for generated make dependency file
 -MT<target name>         specify target for generated make dependency file
 -O<level>                set optimisation level. <level> may be O0, O1, O2/Osize (the default), or O3/Ospeed
 -P                       preprocess only, no directives
 -S                       produce assembly files, then stop
 -U<symbol>               undefine preprocessor symbol
 -W<level>                enable or disable compiler warnings. <level> can be blank or equal to: all, strict, none, WarningName, noWarningName.
 -Xc <argument>           pass next argument through to the compiler
 -Xcompiler <argument>    pass next argument through to the compiler
 -allow-inline            deprecated option (has no effect)
 -dM                      dump list of preprocessor defines to stdout
 -dp                      show matched compiler rules in generated assembly
 -inline-static-called-once automatically inline static functions that are called only once
 -no-debug-inline         avoid making a copy of inline functions in debug mode - this saves code space, but inlined functions will not be debuggable
 -old-mangling            restore pre-KCC 40 mangling of autogenerated data labels (L_x instead of A_x)
 -optional-reads          restore pre-KCC 40 behaviour of implementing optional reads of volatile objects
 -pic                     generate a limited form of position independent code
 -preinclude <filename>   causes <filename> to be automatically included in every source file

Assembler options:
 -A<path>                 add include path to assembler
 -Xa <argument>           pass next argument through to the assembler
 -Xassembler <argument>   pass next argument through to the assembler
 -c                       produce object files, but do not link

Linker options:
 -L<path>                 append to library search path
 -Xl <argument>           pass next argument through to the linker
 -Xlinker <argument>      pass next argument through to the linker
 -gc-sections             enable garbage collection in the linker (discards unused code and data)
 -l<libname>              add a library for linking
 -mno-crt0                don't link in crt0.o automatically
 -mno-libc                don't link in libc.a automatically
 -mno-libcrt              don't link in libcrt.a (basic runtime) automatically
 -mno-libfle              don't link in libfle.a (floating point emulation) automatically
 -no-relax                turn off prefix relaxation in the linker
 -nodefaultlibs           don't automatically link crt0 or any C libraries (no crt0, libc, libcrt, libfle)

Target chip names accepted by -k are:
kalarch4
csra68100_app
csra68100_audio
QCC302x_apps
QCC302x_audio
QCC512x_apps
QCC512x_audio
QCC514x_apps
QCC514x_audio
QCC516x_apps
QCC516x_audio
QCC517x_apps
QCC517x_audio
QCC518x_apps
QCC518x_audio
QCC309x_apps
QCC309x_audio

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions