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

Cmake tools selects on 1.19.49 a different compiler than on 1.18.44 when reconfiguring #4032

Closed
the-programmer opened this issue Aug 30, 2024 · 12 comments
Labels
bug a bug in the product regression used to work and no longer does. Regressions are typically high priority

Comments

@the-programmer
Copy link

the-programmer commented Aug 30, 2024

Brief Issue Summary

This is a follow-up of #4018.
In my CMakeLists.txt I have the following line set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/arm_none_eabi_gcc.cmake). This is done so CMake selects the correct compiler for cross-compiling.

However it seems that a change in 1.19.49 breaks the cross compile. In version 1.19.49 CMake Tools selects the Visual studio 17 C compiler instead of my toolchain.

My toolchain is attached. (The tool "arm-none-eabi-dump" is something internal) arm_none_eabi_gcc.cmake

My CMakeLists.txt is also attached. CMakeLists.txt

CMake Tools Diagnostics

Diagnostics of 1.19.49

{
  "os": "win32",
  "vscodeVersion": "1.92.2",
  "cmtVersion": "1.19.49",
  "configurations": [
    {
      "folder": "c:\\Development\\[...]\\[...]",
      "cmakeVersion": "3.30.2",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release",
      "MinSizeRel",
      "RelWithDebInfo"
    ],
    "requests": [
      "file:///c%3A/Development/[...].c",
      "file:///c%3A/Development/[...].c",
      "file:///c%3A/Development/[...].c"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 13,
    "executablesCount": 1,
    "librariesCount": 10,
    "targets": [...]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}
{
  "os": "win32",
  "vscodeVersion": "1.92.2",
  "cmtVersion": "1.19.49",
  "configurations": [
    {
      "folder": "c:\\Development\\[...]\\[...]",
      "cmakeVersion": "3.30.2",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release",
      "MinSizeRel",
      "RelWithDebInfo"
    ],
    "requests": [
      "file:///c%3A/Development/[...].c",
      "file:///c%3A/Development/[...].c",
      "file:///c%3A/Development/[...].c"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 13,
    "executablesCount": 1,
    "librariesCount": 10,
    "targets": [...]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Diagnostics of 1.18.44

{
  "os": "win32",
  "vscodeVersion": "1.92.2",
  "cmtVersion": "1.18.44",
  "configurations": [
    {
      "folder": "c:\\Development\\[...]\\[...]",
      "cmakeVersion": "3.30.2",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///c%3A/Development/[...]/.c",
      "file:///c%3A/Development/[...]/.c",
      "file:///c%3A/Development/[...]/.c"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files (x86)/arm gnu toolchain arm-none-eabi/12.3 rel1/bin/arm-none-eabi-gcc.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files (x86)/arm gnu toolchain arm-none-eabi/12.3 rel1/bin/arm-none-eabi-gcc.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Development/[...].c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files (x86)/arm gnu toolchain arm-none-eabi/12.3 rel1/bin/arm-none-eabi-gcc.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-w -ggdb -std=gnu99 -mcpu=cortex-m3 -march=armv7-m -ABI=eabi -mthumb -MD -mapcs-frame -fno-common -fpermissive -fsigned-char -fomit-frame-pointer -Os -g"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 11,
    "executablesCount": 1,
    "librariesCount": 10,
    "targets": [...]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

The Trace rebuild log from 1.19.49

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" --version
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" -E capabilities
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[kit] Not reading non-existent kits file: C:\Users\[...]\AppData\Local\CMakeTools\cmake-tools-kits.json
[kit] Not reading non-existent kits file: c:\Development\[...]\[...]\.vscode\cmake-kits.json
[main] Injecting new Kit into CMake driver
[variant] Loaded new set of variants
[main] CMakeProject instance initialization complete.
[extension] Configuring workspace on open c:\Development\[...]\[...]
[main] Starting new CMake driver
[main] Starting CMake driver
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using kit
[driver] CMakeDriver Kit set to __unspec__
[kit] The environment for kit '__unspec__': {...}
[driver] Trying to detect generator supported by system
[expand] expanded ${workspaceFolder}/build
[cache] Reading CMake cache file c:/Development/[...]/[...]/build/CMakeCache.txt
[cache] Parsing CMake cache string
[cmakefileapi-driver] Removing c:/Development/[...]/[...]/build/CMakeCache.txt
[driver] Setting new variant Debug
[expand] expanded ${workspaceFolder}/build
[main] Configuring project: [...] 
[main] Saving open files before configure/build
[expand] expanded ${workspaceFolder}/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[expand] expanded ${workspaceFolder}/build
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.exe with arguments ["-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-Wno-dev","-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON","--no-warn-unused-cli","-SC:/Development/[...]/[...]","-Bc:/Development/[...]/[...]/build"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Wno-dev -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON --no-warn-unused-cli -SC:/Development/[...]/[...] -Bc:/Development/[...]/[...]/build
[proc]   with environment: [...]
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Building for: Visual Studio 17 2022
[cmake] -- The C compiler identification is MSVC 19.40.33813.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Configuring done (7.2s)
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: C:/Development/[...]/[...]/build
[cmakefileapi-parser] Read reply folder: c:\Development\[...]\[...]\build\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: [...]
[cache] Reading CMake cache file c:/Development/[...]/[...]/build/CMakeCache.txt
[cache] Parsing CMake cache string

And from 1.18.44

[main] Configuring project: [...] 
[main] Saving open files before configure/build
[driver] Removing c:/Development/[...]/[...]/build/CMakeCache.txt
[driver] Removing c:\Development\[...]\[...]\build\CMakeFiles
[expand] expanded ${workspaceFolder}/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[expand] expanded ${workspaceFolder}/build
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.exe with arguments ["-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-Wno-dev","-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON","--no-warn-unused-cli","-SC:/Development/[...]/[...]","-Bc:/Development/[...]/[...]/build","-G","Ninja"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Wno-dev -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON --no-warn-unused-cli -SC:/Development/[...]/[...] -Bc:/Development/[...]/[...]/build -G Ninja
[proc]   with environment: [...]
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 12.3.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.3 rel1/bin/arm-none-eabi-gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Configuring done (1.1s)
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: C:/Development/[...]/[...]/build
[cmakefileapi-parser] Read reply folder: c:\Development\[...]\[...]\build\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: [[...]
[cache] Reading CMake cache file c:/Development/[...]/[...]/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [7409] cmake.cleanConfigureAll finished (returned {"result":0,"resultType":0})

Additional Information

The only thing is that I currently don't have the time to make a full demo project that can show the issue. If required, I'll try to create it but I hope that this is sufficiënt.

@gcampbell-msft
Copy link
Collaborator

@the-programmer What generator are you intending to use for your project?

What do you have set in cmake.generator and cmake.preferredGenerators?

@gcampbell-msft
Copy link
Collaborator

Looking at your diagnostics log, I feel pretty confident that the issue is from the same issue as #4005. We are aware of the issue and are actively trying to get a fix out.

@the-programmer
Copy link
Author

In both cases, the generator is "empty". Both in the Workspace and User settings.

@gcampbell-msft
Copy link
Collaborator

@the-programmer Oh interesting, presuming you are using kits, what is the definition of the kit you are using?

@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented Aug 30, 2024

Ah, I think I know what the issue is, it's not the same scenario as #4005, but it does come from the same changes over the last release.

Context for people investigating this, I believe it's because we're adding defaults to the preferredGenerators list but then we don't find them on PATH and so we "can't find it". We are investigating a fix.

@the-programmer
Copy link
Author

I am not (intentionally) using kits for this.
I (did) have a kit file at C:\Users\[...]\AppData\Local\CMakeTools\cmake-tools-kits.json but I renamed that to cmake-tools-kits.json.old so CMake/CMake Tools doesn't detect the contents.

@gcampbell-msft gcampbell-msft added bug a bug in the product regression used to work and no longer does. Regressions are typically high priority and removed triage labels Aug 30, 2024
@gcampbell-msft
Copy link
Collaborator

gcampbell-msft commented Aug 30, 2024

@the-programmer Could you test with this vsix and let me know if it resolves your issue?

cmake-tools.zip

@gcampbell-msft
Copy link
Collaborator

The fix for this issue will be released in the next hour or so in v1.20.2.

@the-programmer
Copy link
Author

Thanks. I'll try it on Monday.

@github-project-automation github-project-automation bot moved this from Blocked to Completed in CMake Tools Aug 30, 2024
@the-programmer
Copy link
Author

So, I just tried the pre-release versions 1.20.2 and 1.20.3. However, both of them still select Visual Studio as the compiler.
Any ideas what could be causing this? or do you need more information?

@the-programmer
Copy link
Author

@gcampbell-msft, Since your response times are usually fast. I was wondering if you noted my last comment. (The issue isn't fixed in 1.20.3)

@gcampbell-msft
Copy link
Collaborator

@the-programmer Thanks for following up. The most recent official version release should solve your issue.

The fixes in #4033 should resolve your issue. However, if they do not, please open a new issue so that we can properly track it. Thanks.

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 regression used to work and no longer does. Regressions are typically high priority
Projects
Status: Completed
Development

No branches or pull requests

2 participants