Skip to content

compilerPath with full path to cl.exe is not used - default cl.exe location is used instead. #6746

Description

@0xabu

Type: LanguageService

Describe the bug

  • OS and Version: Windows 20H2
  • VS Code Version: 1.52.1
  • C/C++ Extension Version: 1.1.3

I am trying in every possible way to tell the extension to use a locally-installed MSVC instance, but it persists in picking up the GCC from WSL. This is a regression, but when in the last few months it started I can't tell you exactly.

global settings.json has:

    "C_Cpp.default.compilerPath": "",

Workspace settings.json has:

    "C_Cpp.default.compilerPath": "C:\\NugetCache\\.A\\VisualCppTools.jysOK2m_XNGtcXqE_1Xr3g\\lib\\native\\bin\\x86_amd64\\CL.exe",

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32 Guest",
            "compileCommands": "${workspaceFolder}/compile_commands.json",
            "compilerPath": "C:\\NugetCache\\.A\\VisualCppTools.jysOK2m_XNGtcXqE_1Xr3g\\lib\\native\\bin\\x86_amd64\\CL.exe",
            "intelliSenseMode": "msvc-x64"
        },
        ...
    ],
    "version": 4
}

compile_commands.json is autogenerated and includes commands pointing to the same CL.exe, e.g.:

{"directory": "C:\\src\\xxx\\Tests\\AsyncIO",
 "command": "C:\\NugetCache\\.A\\VisualCppTools.jysOK2m_XNGtcXqE_1Xr3g\\lib\\native\\bin\\x86_amd64\\CL.exe /c ...",
 "file": "xxx.cpp"},

However, the extension persists in trying to use GCC, and consequently ends up with broken defines, includes, etc. See log output below.

Expected behavior
Use my configured cl.exe and don't even look for gcc!

Logs
cpptools/didChangeCppProperties
MSVC intelliSenseMode specified.  Configuring for compiler cl.exe.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: '/usr/bin/gcc'
Compiler probe command line: "/usr/bin/gcc" -std=gnu11 -Wp,-v -E -dD -x c -m64  nul
Failed to spawn process. Error: 2 (The system cannot find the file specified.)
  WSL compiler detected
Compiler include path not found: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\End of search list.
Code browsing service initialized
MSVC intelliSenseMode specified.  Configuring for compiler cl.exe.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: '/usr/bin/gcc'
Compiler probe command line: "/usr/bin/gcc" -std=gnu++14 -Wp,-v -E -dD -x c++ -m64  nul
Failed to spawn process. Error: 2 (The system cannot find the file specified.)
  WSL compiler detected
Compiler include path not found: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\End of search list.
MSVC intelliSenseMode specified.  Configuring for compiler cl.exe.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: '/usr/bin/gcc'
MSVC intelliSenseMode specified.  Configuring for compiler cl.exe.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: '/usr/bin/gcc'

(above 3 messages repeat hundreds of times)

  Folder: C:/Users/baumann/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/ will be indexed
  Folder: C:/Users/baumann/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/7/include/ will be indexed
  Folder: C:/Users/baumann/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/ will be indexed
  Folder: C:/Users/baumann/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include/ will be indexed
  Folder: C:/NugetCache/.A/VisualCppTools.jysOK2m_XNGtcXqE_1Xr3g/lib/native/include/ will be indexed
  ...
(remaining folders that should be indexed are listed, but note the system includes from WSL should *not* be here)

sending compilation args for xxx.cpp
  ...
  (my project's include paths)
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\include\c++\7
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\include\x86_64-linux-gnu\c++\7
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\include\c++\7\backward
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\7\include
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\local\include
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\7\include-fixed
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\include\x86_64-linux-gnu
  include: C:\Users\baumann\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\include
  define: __STDC__=1
  define: __cplusplus=201402L
  define: __STDC_UTF_16__=1
  define: __STDC_UTF_32__=1
  define: __STDC_HOSTED__=1
  define: __GNUC__=7
  define: __GNUC_MINOR__=5
  define: __GNUC_PATCHLEVEL__=0
  ...

(obviously these defines/includes are all wrong)

Screenshots

Additional context

Metadata

Metadata

Labels

Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions