Skip to content

[regression] "compileCommands" is ignored when custom tool chain is used by project #3102

Closed

Description

@lsmgeb89

Type: LanguageService

Describe the bug

  • OS and Version: Ubuntu 18.04.1 LTS
  • VS Code Version:
    Version: 1.30.2
    Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
    Date: 2019-01-07T22:49:48.319Z
    Electron: 2.0.12
    Chrome: 61.0.3163.100
    Node.js: 8.9.3
    V8: 6.1.534.41
    OS: Linux x64 4.15.0-43-generic
    
  • C/C++ Extension Version: Version 0.21.0 January 23, 2019
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is: Current version of cpptools ignores the compileCommands attribute so that header files could not be found and IntelliSense falls back to tag parser. But the same config works in the previous version of cpptools.

To Reproduce

  • Below configs are generalized to omit project details, but kept accurate folder structures.
  • Here is the c_cpp_properties.json for the previous version of cpptools:
    {
        "configurations": [
            {
                "name": "Linux",
                "compileCommands": "${workspaceFolder}/compile_commands.json",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "compilerPath": "/home/bob/toolchain/bin/g++ --sysroot=/home/bob/toolchain",
                "cStandard": "c11",
                "cppStandard": "c++14",
                "intelliSenseMode": "gcc-x64"
            }
        ],
        "version": 4
    }
    and compile_commands.json contains a lot of entries like below.
    [
      {
        "directory": "/home/bob/proj/foo",
        "command": "ccache g++ -I/home/bob/proj -std=c++14 -D__FOO_BAR__ -Wall -Werror --sysroot /home/bob/toolchain -o CMakeFiles/foo.dir/bar.cc.o -c /home/bob/proj/foo/bar.cc",
        "file": "/home/bob/proj/foo/bar.cc"
      },
      {
        "...": "..."
      }
    ]
  • After upgrading to current version of cpptools, above config does NOT work. Header files could not be found properly by showing errors like "cannot open source file ..." and "#include errors detected. Consider updating your compile_commands.json or includePath. IntelliSense features for this translation unit (/home/bob/proj/foo/bar.cc) will be provided by the Tag Parser."
  • After update c_cpp_properties.json to below, the errors disappear.
    {
        "configurations": [
            {
                "name": "Linux",
                "includePath": [
                    "${workspaceFolder}/**",
                    "/home/bob/toolchain/include/**"
                ],
                "defines": [],
                "compilerPath": "/home/bob/toolchain/bin/g++ --sysroot=/home/bob/toolchain",
                "cStandard": "c11",
                "cppStandard": "c++14",
                "intelliSenseMode": "gcc-x64"
            }
        ],
        "version": 4
    }

Expected behavior

  • But second version of c_cpp_properties.json does NOT contain "compileCommands" so that first version is better than second version because compile_commands.json provides the most accurate information.
  • So expected behavior is to at least make first version of c_cpp_properties.json works.
  • A better way is to define a clear support for the project by using custom tool chain. Define what attribute should be provided in the c_cpp_properties.json so that many similar issues related to custom tool chain could be resolved.

Activity

  1. sean-mcmanus commented on Jan 29, 2019

    @sean-mcmanus
    Contributor

    This was caused by the change for #2793 . Bob Brown (@bobbrow) Prioritizing the compile_commands.json compiler over the compilerPath breaks users who relied on the opposite behavior -- i.e. we broke everyone who who used compilerPath to get around the ccache issue in compile_command.json (see #1251, which fixed this).

  2. lsmgeb89 commented on Jan 29, 2019

    @lsmgeb89
    Author

    Sean McManus (@sean-mcmanus) I see these different cases make this complicated.

    Maybe note that the difference is not only about "compileCommands".
    In the second c_cpp_properties.json, there is one more path "/home/bob/toolchain/include/**" under the "includePath" than the first one.

  3. bobbrow commented on Jan 29, 2019

    @bobbrow
    Contributor

    My fix for #2793 was incorrect. The correct fix for #2793 is to not auto-populate the compilerPath when compileCommands is set. I will fix this up.

  4. added 2 commits that reference this issue on Jan 29, 2019
  5. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Feb 2, 2019
  6. sean-mcmanus commented on Feb 7, 2019

    @sean-mcmanus
    Contributor

    The compilerPath not getting used bug should be fixed with 0.22.0-insiders. You can get it via setting the C_Cpp.updateChannel setting to "Insiders", or downloading it manually from https://github.com/Microsoft/vscode-cpptools/releases .

  7. lsmgeb89 commented on Feb 8, 2019

    @lsmgeb89
    Author

    Sean McManus (@sean-mcmanus) Bob Brown (@bobbrow)
    The bug is tested and confirmed fixed in the version 0.22.0-insiders.
    Thanks!

  8. locked and limited conversation to collaborators on Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.regressionA bug that didn't exist in a previous release

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions