microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

Custom browse configuration return wrong compilerPath #11465

Closed julienlavergne closed 3 weeks ago

julienlavergne commented 12 months ago

Brief Issue Summary

When setting up, the C/C++ extension returns an warning mentionning a non existing compilerPath provided by the Cmake Tools extension. The thing is, I do not have that path anywhere visible in my configuration, so I do not know where it comes from.

The warning appears in the C/C++ configuration warnings output window, and does not seem to be blocking to get everything working. I am simply not sure if it hides a bigger problem.

In my setup, I have a multiroot workspace. The active project is a CMake project, the others are a mixed bag, some are CMake, some are not. I am running vscode on Windows and ssh on a Linux box. The C/C++ and CMake Tools extension are installed both locally and remotely. I must say, everything works fine except for this strange warning.

Looking at the logs "C/C++", I get this for all the projects in my workspace except the main active one:

  ...
  Folder: /home/myhome/workspace/other-non-cmake-project-1/ will be indexed
Custom browse configuration received: {
  "browsePath": [
    ... (lots of include directoring pointing to folders in /home/myhome/workspace/)
  ],
  "compilerPath": "/export/products/gcc-13.1.0/bin/g++",
  "compilerFragments": [
    "-Wall -Wextra -Wshadow -pipe  -Wno-unused-parameter  -DNDEBUG -fdata-sections -ffunction-sections -march=westmere -D_REENTRANT -D_XOPEN_SOURCE=700  -finline-limit=1000 -fno-associative-math -fdevirtualize-at-ltrans -funsafe-loop-optimizations -floop-interchange -floop-strip-mine -floop-block -fgraphite-identity -gdwarf-5 -ggdb3 -gz -O3  -DNDEBUG -std=gnu++20 -flto=auto -fno-fat-lto-objects -fPIC -fvisibility=hidden -fvisibility-inlines-hidden",
    "-Wno-unused-but-set-parameter",
    "-Wlogical-op",
    "-Wduplicated-cond",
    "-fdiagnostics-color=auto"
  ],
  "compilerArgsLegacy": []
}

For the main active project, I get:

  Folder: /home/myhome/workspace/my-main-cmake-project/ will be indexed
Custom browse configuration received: {
  "browsePath": [
    ... (lots of include directoring pointing to folders in /home/myhome/workspace/)
  ],
  "compilerPath": "/export/products/gcc-13.2.0/bin/g++",
  "compilerArgs": [],
  "compilerFragments": [
    "-Wall -Wextra -Wshadow -pipe  -Wno-unused-parameter  -DNDEBUG -fdata-sections -ffunction-sections -march=westmere -D_REENTRANT -D_XOPEN_SOURCE=700  -finline-limit=1000 -fno-associative-math -fdevirtualize-at-ltrans -funsafe-loop-optimizations -floop-interchange -floop-strip-mine -floop-block -fgraphite-identity -gdwarf-5 -ggdb3 -gz -O3  -DNDEBUG -std=gnu++23 -flto=auto -fno-fat-lto-objects -fPIC -fvisibility=hidden -fvisibility-inlines-hidden",
    "-Wno-unused-but-set-parameter",
    "-Wlogical-op",
    "-Wduplicated-cond",
    "-fdiagnostics-color=auto"
  ]
}

(Besides the fact that I do not understand why CMake Tools is involved in non-CMake projects, or even in CMake project I did not configure.) Note the difference of version in the compiler: gcc-13.1.0 vs gcc-13.2.0, and the inclusion of compilerArgsLegacy instead of compilerArgs.

"gcc-13.1.0" was really installed there at some point in the past, but it's gone now. And there is no reference to "gcc-13.1.0" anywhere in my settings or cmake files. I started with empty build folder in my main project, and I even deleted the whole .vscode-server on my Linux remote to make sure it was not keeping some settings in a Cache.

I tried to reset the things as much as I could:

but the warning is there each time I open VSCode after the configure is done.

Where does compilerPath comes from in the Custom browse configuration sent from CMake Tools for projects that are not CMake or for projects that are not configured ? Why is CMake even involved at all here ? The compile-commands of my main project is enough to feed intelisense for all the projects in my workspace, and I don't expect there is anything to do for them indiviually.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.82.0",
  "cmtVersion": "1.15.31",
  "configurations": [
    {
      "folder": "/home/myhome/workspace/my-main-cmake-project",
      "cmakeVersion": "3.27.0",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/export/products/gcc-13.2.0/bin/gcc",
        "CXX": "/export/products/gcc-13.2.0/bin/g++"
      }
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-1",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-2",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-3",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-4",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-5",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-6",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-7",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-non-cmake-project-1",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-8",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-9",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-cmake-project-10",
      "cmakeVersion": "3.27.0",
      "configured": false,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/myhome/workspace/other-non-cmake-project-2",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "RelWithDebInfo",
    "buildTypesSeen": [
      "RelWithDebInfo"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 796,
    "executablesCount": 242,
    "librariesCount": 44,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[proc] Executing command: cmake --version
[proc] Executing command: cmake -E capabilities
[variant] Loaded new set of variants
[kit] Successfully loaded 3 kits from /home/myhome/.local/share/CMakeTools/cmake-tools-kits.json
[variant] Loaded new set of variants
[variant] Loaded new set of variants
[proc] Executing command: /opt/tools/cmake-3.27.0/bin/cmake --version
[proc] Executing command: /opt/tools/cmake-3.27.0/bin/cmake -E capabilities
[variant] Loaded new set of variants
[variant] Loaded new set of variants
[variant] Loaded new set of variants
[main] Configuring project: my-main-cmake-project 
[variant] Loaded new set of variants
[variant] Loaded new set of variants
[proc] Executing command: /opt/tools/cmake-3.27.0/bin/cmake --no-warn-unused-cli --fresh -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S/home/myhome/workspace/my-main-cmake-project -B/home/myhome/workspace/my-main-cmake-project/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Place autodetected to be X
[cmake] -- Found Python3: /export/products/python-3.9.4/bin/python3.9 (found version "3.9.4") found components: Interpreter 
[cmake] -- Found GCOVR: /export/products/python-3.9.4/bin/gcovr  
[cmake] -- Found Git: /opt/tools/git-2.39.1/bin/git (found version "2.39.1") 
[cmake] -- my-main-cmake-project: version: 2.49.0, tag: 2.49.0-54-g553f0bf95
[cmake] -- The C compiler identification is GNU 13.2.0
[cmake] -- The CXX compiler identification is GNU 13.2.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /export/products/gcc-13.2.0/bin/gcc - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /export/products/gcc-13.2.0/bin/g++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
[cmake] -- Looking for pthread_create in pthreads
[variant] Loaded new set of variants
[cmake] -- Looking for pthread_create in pthreads - not found
[cmake] -- Looking for pthread_create in pthread
[cmake] -- Looking for pthread_create in pthread - found
[cmake] -- Found Threads: TRUE  
[cmake] -- Found OpenSSL: /export/products/openssl-1.1.1n/lib/libcrypto.so (found version "1.1.1n")  
[cmake] -- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7")  
[cmake] -- Found OpenOnload: /export/products/onload-7.1.0.265/build/gnu_x86_64/lib/onload_ext/libonload_ext.a  
[cmake] -- Found Boost: /opt/tools/boost-1.81.0/lib/cmake/Boost-1.81.0/BoostConfig.cmake (found version "1.81.0")  
[cmake] -- Found LibPcap: /export/products/libpcap-1.10.3/lib/libpcap.a  
[cmake] -- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1") 
[cmake] -- Checking for one of the modules 'libnl-genl-3.0'
[cmake] -- Checking for one of the modules 'libnl-route-3.0'
[cmake] -- Found GTest: /export/products/googletest-1.13.0/lib64/cmake/GTest/GTestConfig.cmake (found version "1.13.0")  
[variant] Loaded new set of variants
[cmake] -- Found Boost: /opt/tools/boost-1.81.0/lib/cmake/Boost-1.81.0/BoostConfig.cmake (found suitable version "1.81.0", minimum required is "1.56.0")  
[cmake] -- Found Xerces: /export/products/xerces-c-3.2.4/lib/libxerces-c.a  
[cmake] -- Configuring nitrogen_feeder
[variant] Loaded new set of variants
[variant] Loaded new set of variants
[cmake] -- Configuring nitrogen_op
[cmake] -- Performing Test HAS_STD_VARIANT
[cmake] -- Performing Test HAS_STD_VARIANT - Success
[cmake] -- Configuring nitrogen_protocols
[cmake] -- Configuring nitrogen_fix_adapter
[cmake] -- Found Vera: /export/products/vera++-1.3.0/bin/vera++  
[variant] Loaded new set of variants
[cmake] -- Found ClangFormat: /export/products/clang-format-17.0.0/bin/clang-format  
[cmake] -- Configuring done (2.4s)
[cmake] -- Generating done (1.6s)
[cmake] -- Build files have been written to: /home/myhome/workspace/my-main-cmake-project/build

Additional Information

/home/myhome/workspace/my-main-cmake-project/.vscode/c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

/home/myhome/workspace/my-main-cmake-project/.vscode/settings.json

{
    "C_Cpp.clang_format_path": "/opt/tools/clang-format/bin/clang-format",
    "cmake.configureArgs": [
        "--fresh"
    ],
    "cmake.configureOnEdit": false,
    "cmake.configureOnOpen": true,
    "cmake.ctest.parallelJobs": 8,
    "cmake.parallelJobs": 8,
    "cmake.preferredGenerators": [
        "Ninja",
    ],
    "explorer.excludeGitIgnore": true,
    "files.eol": "\n",
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "files.trimTrailingWhitespace": true,
    "search.useParentIgnoreFiles": true
}

I do not have any CMake settings in my User settings. Only the C/C++ "C_Cpp.loggingLevel": "Debug"

gcampbell-msft commented 11 months ago

Passing this to vscode-cpptools because I think this might be an issue in interrogating the compiler.

@sean-mcmanus Could you transfer this bug?

bobbrow commented 7 months ago

@Colengms could you take a look at this issue? It appears to have been missed.

Colengms commented 7 months ago

Hi @julienlavergne . You mentioned that you have set, "C_Cpp.loggingLevel": "Debug" already. Could you provide the contents of the C/C++ output channel, from startup until opening a file (that should be configurable via CMake Tools)? That should give us some clues as to the source of the compiler path, and whether the warning is interfering with your IntelliSense configurations.

github-actions[bot] commented 3 weeks ago

This issue has been closed because it needs more information and has not had recent activity.