Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMT not providing chosen compilerPath to cpptools #702

Closed
DavidA2014 opened this issue Jun 25, 2019 · 12 comments
Closed

CMT not providing chosen compilerPath to cpptools #702

DavidA2014 opened this issue Jun 25, 2019 · 12 comments
Labels
bug a bug in the product Feature: cpptools integration stale-old to use with the close-old-issues bot
Milestone

Comments

@DavidA2014
Copy link

DavidA2014 commented Jun 25, 2019

  • Operating System: VS Code running on Windows 10 with remotes ssh connection to Centos 7.6
  • CMake Version: 3.13.5
  • VSCode Version: 1.35.1
  • CMake Tools Extension Version: 1.1.3
  • Compiler/Toolchain: RH Developer Toolset 7 (gcc 7.3.1)

I am building an executable on Centos 7.6 using RH Developer Toolset 7. The native g++ compiler is gcc 4.8.2 but the toolset gives gcc 7.3.1. I select the toolset by setting environment variables:

export CXX="/opt/rh/devtoolset-7/root/usr/bin/g++"
export CC="/opt/rh/devtoolset-7/root/usr/bin/gcc"

CMT prompts for which kit to use:

image

I choose 'unspecified' and CMT correctly uses "/opt/rh/devtoolset-7/root/usr/bin/g++":

# Show compiler path
message(STATUS "Compiler path: " ${CMAKE_CXX_COMPILER})

[cmake] Compiler path: /opt/rh/devtoolset-7/root/usr/bin/g++
[cmake] Configuring done

However cpp-tools uses gcc 4.8.2:

Code browsing service initialized
  Folder: /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/ will be indexed
  Folder: /usr/local/include/ will be indexed
  Folder: /usr/include/ will be indexed
  Folder: <snip>/prototypes/hello_world/ will be indexed
Populate include completion cache.
Discovering files...
  Processing folder (recursive): /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/
  Processing folder (recursive): /usr/local/include/
  Processing folder (recursive): /usr/include/
  Processing folder (recursive): <snip>/prototypes/hello_world/
  Discovering files: 2056 file(s) processed
  9 file(s) removed from database
Done discovering files.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
IntelliSense Engine = Default.
Autocomplete is enabled.

So I think that CMT is not supplying the correct compilerPath to cpptools after the kit is selected.

I know I can specify compilerPath directly to cpptools in settings.json but it would be nice if CMT did so.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jun 25, 2019

@DavidA2014 Your logs are not showing the CMake Tools configurations...do you see any logs that show info about a configuration provider -- after you open a .cpp file?

@DavidA2014
Copy link
Author

@sean-mcmanus When I open the workspace containing my 'hello_world' project I choose to configure the project and then (or perhaps before) the following appears in the 'C/C++: hello_world' output window:

IntelliSense Engine = Default.
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
File exclude: **/.vscode
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/.vscode
Code browsing service initialized
  Folder: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/ will be indexed
  Folder: /usr/local/include/ will be indexed
  Folder: /opt/rh/devtoolset-7/root/usr/include/ will be indexed
  Folder: /usr/include/ will be indexed
  Folder: /home/<snip>/trunk/software/prototypes/hello_world/ will be indexed
Populate include completion cache.
Discovering files...
  Processing folder (recursive): /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include/
Checking for syntax errors: file:///home/<snip>ia/trunk/software/prototypes/hello_world/Message.cpp
  Processing folder (recursive): /usr/local/include/
  Processing folder (recursive): /opt/rh/devtoolset-7/root/usr/include/
  Processing folder (recursive): /usr/include/
  Processing folder (recursive): /home/<snip>/trunk/software/prototypes/hello_world/
  Discovering files: 2869 file(s) processed
  0 file(s) removed from database
Done discovering files.
Parsing remaining files...
  Parsing: 1 files(s) processed
Done parsing remaining files.
Checking for syntax errors: file:///home/<snip>ia/trunk/software/prototypes/hello_world/Message.cpp

In the folder settings.json I have:

{
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools",
"cmake.buildDirectory": "${workspaceRoot}/${buildType}",
"C_Cpp.loggingLevel": "Debug",
}

I have also now provided a c_cpp_properties.json file in the project folder to specify the compiler:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

(I realise I shouldn't have to do that but it is the only way I can get Intellisense to use the correct compiler currently).

I occasionally see a message about configuration provider but I can't trigger it reliably. Certainly doesn't happen when I open a .cpp file.

@andreeis andreeis added the bug a bug in the product label Apr 27, 2020
@andreeis andreeis added this to the On Deck milestone Apr 27, 2020
@andreeis
Copy link
Contributor

@DavidA2014 , we are going to investigate your scenario (I'm not closing the issue) but in the mean time, please upgrade to latest CMake Tools and let us know if you still see this happening.

@DavidA2014
Copy link
Author

Thanks. Is 1.3.1 still the latest release?

@andreeis
Copy link
Contributor

Yes. I saw you reported the issue for 1.1.3 and didn't know you upgraded since then.

@ss185427
Copy link

ss185427 commented May 6, 2021

  • Operating System: VS Code running on Windows 10 attached to Oracle Linux 7.9 container
  • CMake Version: 3.17.5
  • VSCode Version: 1.56.0
  • CMake Tools Extension Version: 1.7.1
  • Compiler/Toolchain: RH Developer Toolset 4 (GCC 5.3.1)

I'm facing the same issue on an Oracle Linux 7.9 container with devtoolset-4-gcc-c++ installed. Running which g++ returns /opt/rh/devtoolset-4/root/usr/bin/g++ and g++ -v returns gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC).
However, CMake Tools only displays GCC 4.8.5 kit as an option.
Edit: On updating the container configuration to use "userEnvProbe": "loginInteractiveShell", CMake Tools is able to locate the C compiler "C": "/opt/rh/devtoolset-4/root/usr/bin/x86_64-redhat-linux-gcc-5.3.1" only .
The same directory has multiple g++ binaries which are not added to the kit.

ls /opt/rh/devtoolset-4/root/usr/bin
c++  cpp  gcc     gcc-nm      gcov       i686-redhat-linux-gcc-5.3.1  x86_64-redhat-linux-c++  x86_64-redhat-linux-gcc
cc   g++  gcc-ar  gcc-ranlib  gcov-tool  sudo                         x86_64-redhat-linux-g++  x86_64-redhat-linux-gcc-5.3.1

@andreeis
Copy link
Contributor

andreeis commented May 7, 2021

@ss185427, can you send us the "CMake/Build" output channel text after a "Scan for kits" command? Set "cmake.loggingLevel" to "Debug" before that. Also upgrade the extension since we released 1.7.2 today.

@ss185427
Copy link

ss185427 commented May 7, 2021

Thank you for the quick response.
Here's the output log, after updating to v1.7.2 and setting logging level to Debug - CmakeTools.txt

@andreeis
Copy link
Contributor

andreeis commented May 7, 2021

Unfortunately, the logging for the kits scanning feature is not very useful. We will improve it and once the change is merged in the code base we will create a vsix for you to reproduce this issue again and send us better logs.
Until then, you can complete your kit definition with the CXX compiler and make sure you don't scan again (it will overwrite your edit). Let us know if you encounter any issues with fixing the kit definition directly in the kits file.

@ss185427
Copy link

Manually editing the kit configuration as you mentioned is working.

@github-actions
Copy link

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.

@github-actions github-actions bot added the stale-old to use with the close-old-issues bot label Oct 19, 2023
Copy link

This issue is now closed due to there being no activity on it for the past 14 days since being marked as 'stale-old'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: cpptools integration stale-old to use with the close-old-issues bot
Projects
None yet
Development

No branches or pull requests

5 participants