Skip to content

VS Code reports language server error related to generated compilerPath in c_cpp_properties.json by Arduino extension #10385

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

Closed
milanbx opened this issue Jan 15, 2023 · 6 comments
Assignees
Labels
Language Service more info needed The issue report is not actionable in its current state

Comments

@milanbx
Copy link

milanbx commented Jan 15, 2023

Environment

Version: 1.74.3
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T16:59:02.252Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: No

Bug Summary

After upgrading ESP8266/Arduino core to v3.1.1, the Arduino extension regenerated th c_cpp_properties.json file with a compilerPath attribute having value causing following C/C++ configuration error:
Unable to resolve configuration with compilerPath: "@D:\Portable\Arduino\portable\packages\esp8266\hardware\esp8266\3.1.1\tools\warnings\default-g++"
On top of this line from C/C++ Configuration Warning output, the Code UI shows 5 instances of cpptools output windows, all having same content (see also snapshot below):
[Error - 18:20:27] Connection to server got closed. Server will not be restarted.
obrazek
Then, the intellisense stops working at all, no cross reference can be followed (Ctrl+left mouse click) to see details of function or variable declaration etc.

Steps to reproduce

Just run VS Code, open any sketch with Arduino code (*.ino), even empty one. Popup error start to come up in the lower right corner - see snapshot:
obrazek

Code snippet

Every, does not matter, even this simple blinking LED example:

byte go = LOW;
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, go);
}
void loop() {
    delay(500);
    go = 1 - go;
    digitalWrite(LED_BUILTIN, go);
}

Configuration

{
    "version": 4,
    "configurations": [
        {
            "name": "Arduino",
            "compilerPath": "@D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\tools\\warnings\\default-g++",
            "compilerArgs": [
                "-U__STRICT_ANSI__",
                "-free",
                "-fipa-pta",
                "-Werror=return-type",
                "-mlongcalls",
                "-mtext-section-literals",
                "-fno-rtti",
                "-falign-functions=4",
                "-std=gnu++17"
            ],
            "intelliSenseMode": "gcc-x64",
            "includePath": [
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\tools\\sdk\\include",
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\tools\\sdk\\lwip2\\include",
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\cores\\esp8266",
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\variants\\generic",
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\libraries\\ESP8266WiFi\\src"
            ],
            "forcedInclude": [
                "D:\\Portable\\Arduino\\portable\\packages\\esp8266\\hardware\\esp8266\\3.1.1\\cores\\esp8266\\Arduino.h"
            ],
            "cStandard": "c11",
            "cppStandard": "c++17",
            "defines": [
                "__ets__",
                "ICACHE_FLASH",
                "_GNU_SOURCE",
                "ESP8266",
                "MMU_IRAM_SIZE=0x8000",
                "MMU_ICACHE_SIZE=0x8000",
                "NONOSDK22x_191122=1",
                "F_CPU=80000000L",
                "LWIP_OPEN_SRC",
                "TCP_MSS=536",
                "LWIP_FEATURES=1",
                "LWIP_IPV6=0",
                "ARDUINO=10819",
                "ARDUINO_ESP8266_GENERIC",
                "ARDUINO_ARCH_ESP8266",
                "ARDUINO_BOARD=\"ESP8266_GENERIC\"",
                "ARDUINO_BOARD_ID=\"generic\"",
                "LED_BUILTIN=2",
                "FLASHMODE_DOUT",
                "USBCON"
            ]
        }
    ]
}

Other Extensions

Arduino: 0.4.12
C/C++ Extension Pack: 1.3.0

VS Code Dev Tools Console Log

vscode-app-1673804966418.log

@Colengms
Copy link
Contributor

Hi @milanbx .

The "@" followed by a path is a valid compiler argument for gcc, clang and CL.exe. It indicates that additional arguments should be read from the indicated file.

https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options (bottom of the page)

https://learn.microsoft.com/en-us/cpp/build/reference/at-specify-a-compiler-response-file?view=msvc-170

However, the C/C++ extension does not support that syntax when used as the compiler path itself, only as an argument to a compiler that supports it. If the Arduino extension generated that compilerPath, I'd suggest opening an issue about it in the Arduino extension repo

@Colengms Colengms self-assigned this Jan 18, 2023
@Colengms Colengms added Language Service more info needed The issue report is not actionable in its current state labels Jan 18, 2023
@milanbx
Copy link
Author

milanbx commented Jan 18, 2023

Hi @Colengms and thanks for your explanation of the "@" prefix. I was wondering too, what that usage means of this syntax pointing to whole path of files instead of one. Arduino extension might generate this in gooe faith, it will instruct the compiler to look into every configuration file in the targeted folder.
Anyway, it does not matter and I have also opend an issue in Arduino repo: microsoft/vscode-arduino#1567
But also in ESP8266 core repo: esp8266/Arduino#8809
I will also add a link to your answer in that issue.
Thanks for help.

@Colengms
Copy link
Contributor

Hi @milanbx .

Also, I'm not able to reproduce the crash you are seeing. Which version of the C/C++ extension are you reproducing this with?

Would you be able to connect the debugger to cpptools.exe, and get a stack from the crash? Assuming the crash is related to an issue with the configuration, you may be able to temporarily modify or rename c_cpp_properties.json long enough to connect the debugger, then restore it to trigger the crash.

https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv

@milanbx
Copy link
Author

milanbx commented Jan 19, 2023

The C/C++ for Visual Studio Code is version 1.13.9, bundled within C/C++ Extension Pack version 1.3.0.
As for connecting the debuger to cpptools.exe, I was not successfull. I have followed the procedure as describer in the article, but failed in the step, where the process should be found - no such process exists (see snapshot):
obrazek
I have renamed the c_cpp_properties.json file prior to teh attempt.

@Colengms Colengms closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
@Colengms
Copy link
Contributor

Hi @milanbx . I believe I closed this issue prematurely, based on the first part being resolved. Are you still able to reproduce the crash?

@Colengms Colengms reopened this Feb 27, 2023
@milanbx
Copy link
Author

milanbx commented Feb 28, 2023

Hi, the issue was casused by Arduino ESP8266 Core liberary settings and solved here: esp8266/Arduino#8809. I am not able to reproduce this again. Thanks.

@milanbx milanbx closed this as completed Feb 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Language Service more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

2 participants