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

Debug shows "No compiler found in cache file." dialog #2121

Closed
anb0s opened this issue Sep 12, 2021 · 16 comments
Closed

Debug shows "No compiler found in cache file." dialog #2121

anb0s opened this issue Sep 12, 2021 · 16 comments

Comments

@anb0s
Copy link

anb0s commented Sep 12, 2021

Brief Issue Summary

We are using CMakePresets and configure, build and run (Shift + F5) are working as expected. But using the debug-button shows dialog with only this error: "No compiler found in cache file."

Expected:

The Debug session with builded application is starting or more detailed error is shown to investigate the configuration issue...

Apparent Behavior:

Push the debug-button:

image

shows dialog with only this error:

"No compiler found in cache file."

image

CMake Tools Log

main] Building folder: oae.jupiter.s7plcapp 
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/andre/git/oae.jupiter.s7plcapp/build/default
[build] ninja: no work to do.
[build] Build finished with exit code 0
[main] Building folder: oae.jupiter.s7plcapp s7plcapp
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/andre/git/oae.jupiter.s7plcapp/build/default --target s7plcapp
[build] ninja: no work to do.
[build] Build finished with exit code 0

Developer Tools Log

???

Platform and Versions

  • Operating System: WSL2 with Debian 11 Bullseye (VSCode running @ Windows 10 1909)
  • CMake Version: 3.21.2
  • VSCode Version: 1.60.0
  • CMake Tools Extension Version: 1.8.1
  • Compiler/Toolchain: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

Other Notes/Information

...

@linquize
Copy link

What platform and compiler are you using?

@anb0s
Copy link
Author

anb0s commented Sep 12, 2021

What platform and compiler are you using?

Ah sorry, somehow the description was not saved properly. I've updated the issues description now...

@bobbrow
Copy link
Member

bobbrow commented Sep 13, 2021

The debug button at the bottom tries to guess which debugger to use based on information about your compiler found in the CMakeCache.txt and it generates the launch.json information on the fly. If it can't find a CMAKE_CXX_COMPILER or CMAKE_C_COMPILER entry in your cache, it doesn't know where to look to find the debugger and you get this error message.

The workaround is supposed to be to set the debugger yourself in the cmake.debugConfig setting object like this:

"cmake.debugConfig": {
  "MIMode": "gdb",
  "miDebuggerPath": "/path/to/debugger/gdb"
}

But I'm seeing that this error will be thrown just before that setting can override the cache lookup. It should be a quick fix. I'll try to get to it today.

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

@bobbrow ok, thanks!

I've also tried to configure a launch for this to set debugger etc. like described in the docu:

    {
      "name": "S7 PLC App",
      "type": "cppdbg",
      "request": "launch",
      "program": "${command:cmake.launchTargetPath}",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [
        {
          // add the directory where our target was built to the PATHs
          // it gets resolved by CMake Tools:
          "name": "PATH",
          "value": "$PATH:${command:cmake.launchTargetDirectory}"
        }
      ],
      "externalConsole": false,
      "MIMode": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },

but receive the error message:
image

Is it related or shold it work in general with presets?

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

... If it can't find a CMAKE_CXX_COMPILER or CMAKE_C_COMPILER entry in your cache, it doesn't know where to look to find the debugger and you get this error message.

Just curious: the configuration is done via presets and the folder with cmake cache build/<preset-name> is available (run is working), is there a another logic or reason why the cmake cache is not found?

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

... If it can't find a CMAKE_CXX_COMPILER or CMAKE_C_COMPILER entry in your cache, it doesn't know where to look to find the debugger and you get this error message.

Just curious: the configuration is done via presets and the folder with cmake cache build/<preset-name> is available (run is working), is there a another logic or reason why the cmake cache is not found?

ok, i think another issue is there, because in the presets we are also using toolchain-files and in the cache it cannot find CMAKE_CXX_COMPILER or CMAKE_C_COMPILER, only this line is there:

//No help, variable specified on the command line.
CMAKE_TOOLCHAIN_FILE:UNINITIALIZED=cmake/toolchains/linux_gcc_x86_64_x32.cmake

Should i create another request for this?

@bobbrow
Copy link
Member

bobbrow commented Sep 14, 2021

Do you use set(CMAKE_CXX_COMPILER ... CACHE ...) in your toolchain? (docs) That might fix it.

If that doesn't work, I also built a version of the extension with my proposed fix so you can use the override mechanism. To try it out:

  1. Download the build artifact here: https://github.com/microsoft/vscode-cmake-tools/suites/3767308809/artifacts/92652787
  2. Unzip the VSIX file
  3. Run the "Install from VSIX..." command in VS Code and select the VSIX file

@bobbrow
Copy link
Member

bobbrow commented Sep 14, 2021

As for the launch.json error, that's not something I've seen much. The C++ extension shows that message if it thinks it hasn't finished installing its dependencies. You might want to try uninstalling/reinstalling that extension if you continue to see that error.

The updated docs for debugging with launch.json are in our repository. There's a minor edit for the PATH variable that will save you a duplicate build step.

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

Do you use set(CMAKE_CXX_COMPILER ... CACHE ...) in your toolchain? (docs) That might fix it.

If that doesn't work, I also built a version of the extension with my proposed fix so you can use the override mechanism. To try it out:

  1. Download the build artifact here: https://github.com/microsoft/vscode-cmake-tools/suites/3767308809/artifacts/92652787
  2. Unzip the VSIX file
  3. Run the "Install from VSIX..." command in VS Code and select the VSIX file

Thanks, i've tried the new version of the plugin first.

Added to settings.json file:

 "cmake.debugConfig": {
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/bin/gdb"
    }

Now it shows this output in the console:

[main] Building folder: oae.jupiter.s7plcapp s7plcapp
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/andre/git/oae.jupiter.s7plcapp/build/default --target s7plcapp
[build] ninja: no work to do.
[build] Build finished with exit code 0
[proc] Executing command: /usr/bin/gdb --version

and then the same error dialog like with manually configured launches:
image

I'm investigating, but have no idea how it's related to install of the plugin, may be something with WSL2...

@bobbrow
Copy link
Member

bobbrow commented Sep 14, 2021

It's definitely an issue with the cpptools extension. Did you attempt to reinstall it? If you did and it's still broken, I would recommend opening an issue in that repository. You might be able to get past it by installing the full VSIX from here: https://github.com/microsoft/vscode-cpptools/releases/download/1.6.0/cpptools-linux.vsix. This package includes all of the dependencies as opposed to the one from the VS Code Marketplace which is bare-bones and then downloads the OS-specific dependencies after installation.

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

Do you use set(CMAKE_CXX_COMPILER ... CACHE ...) in your toolchain? (docs) That might fix it.

FYI: Thanks, now without the entry cmake.debugConfig in settings.xml and adding CMAKE_CXX_COMPILER etc. in toolchains file to the cache the reported error is not shown anymore :) and it executes this:

[build] Build finished with exit code 0
[proc] Executing command: gdb --version

but same error dialog as above with Open 'launch.json' appears...

@bobbrow
Copy link
Member

bobbrow commented Sep 14, 2021

Great! The remaining issue has to do with cpptools. If my ideas above didn't work for you, you can open a new issue for it here: https://github.com/microsoft/vscode-cpptools/issues/new/choose.

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

It's definitely an issue with the cpptools extension. Did you attempt to reinstall it? If you did and it's still broken, I would recommend opening an issue in that repository. You might be able to get past it by installing the full VSIX from here: https://github.com/microsoft/vscode-cpptools/releases/download/1.6.0/cpptools-linux.vsix. This package includes all of the dependencies as opposed to the one from the VS Code Marketplace which is bare-bones and then downloads the OS-specific dependencies after installation.

BIG THANKS 🥇 i was blind ;) That was the issue with WSL2 and not finished cpptools installation! I've used the full pakage and now this error is gone :) and i can debug !!!

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

The updated docs for debugging with launch.json are in our repository. There's a minor edit for the PATH variable that will save you a duplicate build step.

Yes the parameters in the manual launch config "program": "${command:cmake.launchTargetPath}", and "value": "$PATH:${command:cmake.launchTargetDirectory}" are working, Thanks!

@anb0s
Copy link
Author

anb0s commented Sep 14, 2021

Great! The remaining issue has to do with cpptools. If my ideas above didn't work for you, you can open a new issue for it here: https://github.com/microsoft/vscode-cpptools/issues/new/choose.

All the ideas and the fix from this issues are working, perfect!!!

@bobbrow
Copy link
Member

bobbrow commented Sep 15, 2021

Glad to hear that everything is working for you. As an FYI, we just found out that the VS Code Marketplace has finished adding support for platform-specific VSIX packages which means that cpptools will be able to upload the full packages to the Marketplace starting with the next release. This means that you should never have the extension tell you it is still installing starting with v1.7.0.

@bobbrow bobbrow closed this as completed Sep 15, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants