Compiler path error

I am currently using espressif 5.3.0 on a Mac with no problems and I am testing version 6.0.0 on “backup” Mac, identical to the first one.
When I try and compile a piece of code developed with framework espidf, on opening Vscode I get the following strange error/warning:
[1/20/2023, 10:23:20 AM] Unable to resolve configuration with compilerPath “/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc”. Using “/usr/bin/clang” instead.
If I try and compile the code, the process starts off correctly and then I get tons of syntax errors, as if indeed it was compiling using a wrong compiler.
The very same code does compile perfectly on my “main” Mac.
Another code developed under the Arduino framework does compile properly.

I tried erasing .platformio/ completely and getting everything re-installed, but the problem remains.
Also rolling back to 5.3.0 does not help - and I think the problem is not related to the new platform.
Any suggestions on what I could try to fix the problem?

As an addition to the previous info, this is the output of a successful compilation of my “main” Mac. Further down the output of the problematic compilation is added (just a part of it…)

Succesful compile:

  • Executing task in folder esp32_nat_router-master: platformio run

Warning! Ignore unknown configuration option monitor_flags in section [env:esp32dev]
Processing esp32dev (platform: GitHub - platformio/platform-espressif32: Espressif 32: development platform for PlatformIO; framework: espidf; board: esp32dev)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (5.3.0+sha.8b5e233) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-espidf @ 3.40403.0 (4.4.3)
  • tool-cmake @ 3.16.4
  • tool-esptoolpy @ 1.40400.0 (4.4.0)
  • tool-ninja @ 1.9.0
  • toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5

[notice] A new release of pip available: 22.3 → 22.3.1
[notice] To update, run: pip install --upgrade pip
Reading CMake configuration…
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 9.7% (used 31724 bytes from 327680 bytes)
Flash: [========= ] 88.4% (used 926449 bytes from 1048576 bytes)
================================================ [SUCCESS] Took 17.14 seconds ================================================

  • Terminal will be reused by tasks, press any key to close it.

Failing compilation:

  • Executing task in folder esp32_nat_router-master: platformio run --environment esp32dev

Warning! Ignore unknown configuration option monitor_flags in section [env:esp32dev]
Processing esp32dev (platform: espressif32; framework: espidf; board: esp32dev)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (6.0.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-
arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-espidf @ 3.50000.0 (5.0.0)
  • tool-cmake @ 3.16.4
  • tool-esptoolpy @ 1.40400.0 (4.4.0)
  • tool-ninja @ 1.9.0
  • toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
  • toolchain-xtensa-esp32 @ 11.2.0+2022r1
    Reading CMake configuration…
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio/build/esp32dev/main/esp32_nat_router.o
    Compiling .pio/build/esp32dev/main/http_server.o
    Generating LD script .pio/build/esp32dev/memory.ld
    Compiling .pio/build/esp32dev/app_trace/app_trace.o
    Compiling .pio/build/esp32dev/app_trace/app_trace_util.o
    Compiling .pio/build/esp32dev/app_trace/host_file_io.o
    In file included from main/http_server.c:23:
    main/pages.h:167:70: warning: backslash-newline at end of file
    167 | #define LOCK_PAGE “HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n\
    |
    In file included from main/http_server.c:24:
    components/cmd_router/router_globals.h:43:23: error: unknown type name ‘u8_t’
    43 | esp_err_t add_portmap(u8_t proto, u16_t mport, u32_t daddr, u16_t dport);
    | ^~~~
    components/cmd_router/router_globals.h:43:35: error: unknown type name ‘u16_t’
    43 | esp_err_t add_portmap(u8_t proto, u16_t mport, u32_t daddr, u16_t dport);
    | ^~~~~
    components/cmd_router/router_globals.h:43:48: error: unknown type name ‘u32_t’
    43 | esp_err_t add_portmap(u8_t proto, u16_t mport, u32_t daddr, u16_t dport);
    | ^~~~~
    components/cmd_router/router_globals.h:43:61: error: unknown type name ‘u16_t’
    43 | esp_err_t add_portmap(u8_t proto, u16_t mport, u32_t daddr, u16_t dport);
    | ^~~~~
    components/cmd_router/router_globals.h:44:23: error: unknown type name ‘u8_t’
    44 | esp_err_t del_portmap(u8_t proto, u16_t mport);
    | ^~~~
    components/cmd_router/router_globals.h:44:35: error: unknown type name ‘u16_t’
    44 | esp_err_t del_portmap(u8_t proto, u16_t mport);
    | ^~~~~
    main/http_server.c:258:13: warning: ‘stop_webserver’ defined but not used [-Wunused-function]
    258 | static void stop_webserver(httpd_handle_t server)
    | ^~~~~~~~~~~~~~
    Compiling .pio/build/esp32dev/app_trace/gcov/gcov_rtio.o
    Compiling .pio/build/esp32dev/app_trace/port/port_uart.o
    *** [.pio/build/esp32dev/main/http_server.o] Error 1
    main/esp32_nat_router.c: In function ‘initialize_filesystem’:
    main/esp32_nat_router.c:177:5: warning: ‘esp_vfs_fat_spiflash_mount’ is deprecated: esp_vfs_fat_spiflash_mount is deprecated, plea
    se use esp_vfs_fat_spiflash_mount_rw_wl instead [-Wdeprecated-declarations]
    177 | esp_err_t err = esp_vfs_fat_spiflash_mount(MOUNT_PATH, “storage”, &mount_config, &wl_handle);
    | ^~~~~~~~~
    In file included from main/esp32_nat_router.c:20:
    /Users/gabriele/.platformio/packages/framework-espidf/components/fatfs/vfs/esp_vfs_fat.h:292:11: note: declared here
    292 | esp_err_t esp_vfs_fat_spiflash_mount(const char* base_path,
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~
    main/esp32_nat_router.c: In function ‘print_portmap_tab’:
    main/esp32_nat_router.c:217:13: error: unknown type name ‘ip4_addr_t’; did you mean ‘in_addr_t’?
    217 | ip4_addr_t addr;
    | ^~~~~~~~~~
    | in_addr_t
    main/esp32_nat_router.c:218:17: error: request for member ‘addr’ in something not a structure or union
    218 | addr.addr = my_ip;
    | ^
    In file included from /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif.h:12,
    from /Users/gabriele/.platformio/packages/framework-espidf/components/esp_wifi/include/esp_wifi_default.h:10,
    from /Users/gabriele/.platformio/packages/framework-espidf/components/esp_wifi/include/esp_wifi.h:58,
    from main/esp32_nat_router.c:25:
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:42:72: error: request for m
    ember ‘addr’ in something not a structure or union
    42 | #define esp_ip4_addr_get_byte(ipaddr, idx) (((const uint8_t*)(&(ipaddr)->addr))[idx])
    | ^~
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:43:31: note: in expansion o
    f macro ‘esp_ip4_addr_get_byte’
    43 | #define esp_ip4_addr1(ipaddr) esp_ip4_addr_get_byte(ipaddr, 0)
    | ^~~~~~~~~~~~~~~~~~~~~
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:49:45: note: in expansion o
    f macro ‘esp_ip4_addr1’
    49 | #define esp_ip4_addr1_16(ipaddr) ((uint16_t)esp_ip4_addr1(ipaddr))
    | ^~~~~~~~~~~~~
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:54:24: note: in expansion o
    f macro ‘esp_ip4_addr1_16’
    54 | #define IP2STR(ipaddr) esp_ip4_addr1_16(ipaddr), \
    | ^~~~~~~~~~~~~~~~
    main/esp32_nat_router.c:219:37: note: in expansion of macro ‘IP2STR’
    219 | printf (IPSTR”:%d → ", IP2STR(&addr), portmap_tab[i].mport);
    | ^~~~~~
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:42:72: error: request for m
    ember ‘addr’ in something not a structure or union
    42 | #define esp_ip4_addr_get_byte(ipaddr, idx) (((const uint8_t*)(&(ipaddr)->addr))[idx])
    | ^~
    /Users/gabriele/.platformio/packages/framework-espidf/components/esp_netif/include/esp_netif_ip_addr.h:44:31: note: in expansion o
    f macro ‘esp_ip4_addr_get_byte’
    44 | #define esp_ip4_addr2(ipaddr) esp_ip4_addr_get_byte(ipaddr, 1)
    | ^~~~~~~~~~~~~~~~~~~~~

So the compilation errors in this environment go away when you use platform = espressif32@5.3.0 in the platformio.ini?

No, on my backup Mac I get the errors whichever platform I use, both with 5.3.0 and with 6.0.0.
On my main Mac I use only 5.3.0, and there the code compiles flawlessly.

Have you tried removing the package / platform files yet?

rm -rf ~/.platformio/cache/*
rm -rf ~/.platformio/packages/*
rm -rf ~/.platformio/platforms/*

Yes, I did remove the complete .platformio folder and let the system restore everything.
No change. still the same error.

I tried to force compilation using platform = espressif32@5.3.0 and I got the errors herebelow. Does this help to figure out what is going wrong in my “backup” setup??

  • Executing task in folder esp32_nat_router-master: platformio run

Warning! Ignore unknown configuration option monitor_flags in section [env:esp32dev]
Processing esp32dev (platform: espressif32@5.3.0; framework: espidf; board: esp32dev)

Platform Manager: Installing espressif32 @ 5.3.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: espressif32@5.3.0 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 has been installed!
Tool Manager: Installing platformio/framework-espidf @ ~3.40403.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: framework-espidf@3.40403.0 has been installed!
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (5.3.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-espidf @ 3.40403.0 (4.4.3)
  • tool-cmake @ 3.16.4
  • tool-esptoolpy @ 1.40400.0 (4.4.0)
  • tool-ninja @ 1.9.0
  • toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    Installing ESP-IDF’s Python dependencies
    Collecting cryptography<35.0.0,>=2.1.4
    Using cached cryptography-3.4.8-cp36-abi3-macosx_10_10_x86_64.whl (2.0 MB)
    Collecting pyparsing<2.4.0,>=2.0.3
    Using cached pyparsing-2.3.1-py2.py3-none-any.whl (61 kB)
    Collecting kconfiglib==13.7.1
    Using cached kconfiglib-13.7.1-py2.py3-none-any.whl (145 kB)
    Collecting cffi>=1.12
    Using cached cffi-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl (179 kB)
    Collecting pycparser
    Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
    Installing collected packages: pyparsing, pycparser, kconfiglib, cffi, cryptography
    Attempting uninstall: pyparsing
    Found existing installation: pyparsing 3.0.9
    Uninstalling pyparsing-3.0.9:
    Successfully uninstalled pyparsing-3.0.9
    Attempting uninstall: pycparser
    Found existing installation: pycparser 2.21
    Uninstalling pycparser-2.21:
    Successfully uninstalled pycparser-2.21
    Rolling back uninstall of pycparser
    Moving to /Users/gabriele/.platformio/penv/lib/python3.9/site-packages/pycparser-2.21.dist-info/
    from /Users/gabriele/.platformio/penv/lib/python3.9/site-packages/~ycparser-2.21.dist-info
    Moving to /Users/gabriele/.platformio/penv/lib/python3.9/site-packages/pycparser/
    from /Users/gabriele/.platformio/penv/lib/python3.9/site-packages/~ycparser
    ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘/Users/gabriele/.platformio/penv/lib/python3.9/site-packages/pycparser-2.21.dist-info/INSTALLER3phvcppi.tmp’

*** Error 1
Reading CMake configuration…
– Found Git: /usr/bin/git (found version “2.17.2 (Apple Git-113)”)
– The C compiler identification is GNU 8.4.0
– The CXX compiler identification is GNU 8.4.0
– The ASM compiler identification is GNU
– Found assembler: /Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc
– Check for working C compiler: /Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc
– Check for working C compiler: /Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc – broken
– Configuring incomplete, errors occurred!
See also “/Users/gabriele/Documents/PlatformIO/Projects/esp32_nat_router-master/.pio/build/esp32dev/CMakeFiles/CMakeOutput.log”.
See also “/Users/gabriele/Documents/PlatformIO/Projects/esp32_nat_router-master/.pio/build/esp32dev/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any of the parent directories): .git
CMake Error at /Users/gabriele/.platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/gabriele/Documents/PlatformIO/Projects/esp32_nat_router-master/.pio/build/esp32dev/CMakeFiles/CMakeTmp

Run Build Command(s):/Users/gabriele/.platformio/packages/tool-ninja/ninja cmTC_a7d7f && [1/2] Building C object CMakeFiles/cmTC_a7d7f.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_a7d7f.dir/testCCompiler.c.obj 
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_a7d7f.dir/testCCompiler.c.obj   -c testCCompiler.c
xtensa-esp32-elf-gcc: error: testCCompiler.c: No such file or directory
xtensa-esp32-elf-gcc: fatal error: no input files
compilation terminated.
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/Users/gabriele/.platformio/packages/framework-espidf@3.40403.0/tools/cmake/project.cmake:296 (__project)
CMakeLists.txt:6 (project)

=================================== [FAILED] Took 180.63 seconds ===================================

  • The terminal process “platformio ‘run’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

AT LAST IT COMPILED CORRECTLY!!!

I just re-run a build without changing absolutely anything… and it just worked !
No clue as to why it was not working before.
Amazing…

Rgds.