vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

"Unable to automatically determine debugger" for intel compiler mpiicpc

Open hideo67 opened this issue 3 years ago • 3 comments

Brief Issue Summary

Hi,

I have recently posted an issue to the vscode C/C++ Language Extension project about adding support to an intel compiler, and the team kindly scheduled support for it ( microsoft/vscode-cpptools#9410 ).

While waiting for that support, I tried debugging, and stumbled upon the following message:

[debugger] Unable to automatically determine debugger corresponding to compiler: /opt/some_dir/intel/impi/2019.9.304/intel64/bin/mpiicpc

There seems to be a couple of similar issues for other compilers, so I would like to ask if this can be supported.

FYI, there are a bunch of command names that come from the intel compiler suite:

  • icc C compiler
  • icx C compiler, LLVM based
  • icpc C++ compiler
  • icpx C++ compiler, LLVM based
  • mpiicc icc with options set for the MPI library
  • mpiicpc icpc with options set for the MPI library

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

hideo67 avatar Jun 17 '22 01:06 hideo67

The extension has some heuristics to guess the debugger configuration based on the compiler being used. When this guessing fails, you can force whatever settings you need by using the cmake.debugConfig setting. Whatever you would have set for your debug config in launch.json can be set there.

I don't have experience with the Intel compiler, so I don't know if the msvc debugger or the clang/gcc debugger published with the C++ extension will work for you though. Which debugger do you normally use for programs built with the Intel compiler?

bobbrow avatar Jun 17 '22 16:06 bobbrow

Thanks. Regarding the debugger I use, I am a casual user of the intel compiler, and I use gdb.

Thanks for the info on "cmake.debugConfig". However I couldn't find documentation for it other than the conversation in #53 . I think it should appear in the table on this github page.

Based on the Debug using a launch.json file page, I made a settings.json file such as:

{
    "files.associations": {
        "iostream": "cpp",
        "iosfwd": "cpp",
        "*.tcc": "cpp"
    },
    "cmake.debugConfig": {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        // Resolved by CMake Tools:
        "program": "${command:cmake.launchTargetPath}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "console": "internalConsole",
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
}

However I have not reached what I am trying to get.

On the CMake view, I selected an executable target and chose "debug" from the right button menu, but still got the error

[debugger] Unable to automatically determine debugger corresponding to compiler: /opt/some_dir/intel/impi/2019.9.304/intel64/bin/mpiicpc

I guess I have to provide info that for this particular compiler, you can use gdb.

Am I taking something wrong?

hideo67 avatar Jun 18 '22 08:06 hideo67

adding the follow line solved the problem.

"miDebuggerPath" : "/usr/bin/gdb",

hideo67 avatar Jun 18 '22 08:06 hideo67

[edited / deleted comment]

newer info found -- see below...

warrenstephens avatar Feb 22 '23 22:02 warrenstephens

Actually a feature was added previously https://github.com/microsoft/vscode-cmake-tools/issues/809#issuecomment-656419744 to help with the environment setup for compilers, and which showed how to use it with the Intel compilers.

I have updated it here for the 2023.0.0 install of the Intel oneAPI tools. Here is my new cmake-tools-kits.json file:

[
  {
    "name": "GCC 11.3.0 x86_64-linux-gnu",
    "compilers": {
      "C": "/usr/bin/gcc",
      "CXX": "/usr/bin/g++"
    }
  },
  {
    "name": "Intel oneAPI Compilers 2023.0.0",
    "environmentSetupScript": "/opt/intel/oneapi/setvars.sh",
    "compilers": {
      "C":   "/opt/intel/oneapi/compiler/2023.0.0/linux/bin/icx",
      "CXX": "/opt/intel/oneapi/compiler/2023.0.0/linux/bin/icpx",
      "Fortran": "/opt/intel/oneapi/compiler/2023.0.0/linux/bin/ifx"
    }
  }
]

The key addition was the "environmentSetupScript" line.

This change fixed the palette command "CMake: Configure" which was failing previously. Now this command palette sequence works starting with a clean project:

  1. CMake: Configure
  2. CMake: Build
  3. oneAPI: Initialize default environment variables
  4. oneAPI: Generate launch configurations

And then I can select Run / Start Debugging -- nice!

Also, I tested this sequence in both Fortran and C++ projects.

warrenstephens avatar Feb 23 '23 22:02 warrenstephens