esp-rs / esp-idf-sys

Bindings for ESP-IDF (Espressif's IoT Development Framework)
Apache License 2.0
274 stars 124 forks source link

Build script failure when building esp-idf-sys as dependency of previously working project #61

Closed elidupree closed 2 years ago

elidupree commented 2 years ago

I have a project based on rust-esp32-std-demo that I've been successfully building for my ESP32 in the past, but today, when I said cargo build, it decided to recompile esp-idf-sys and the esp-idf-sys build failed, without me changing anything except for my own code. (I also get the same (similar?) error after switching to the latest esp-idf-sys version.)

I don't know how to tell if this is an esp-idf-sys issue, or an embuild issue, or something else, so I'm reporting it in both places; feel free to close this if it's in the wrong place.

I'm on Debian, and I installed esp-rs using rust-build as of Jan 11 (rust-build commit 6b71e690c35778c7c62ba5a229542cdfae01d6c4).

Console output:

/n/autobuild/eliduprees-emg-mouse/build/emg-server$ cargo build
   Compiling bindgen v0.59.2
   Compiling embuild v0.27.2
   Compiling esp-idf-sys v0.29.1
   Compiling esp-idf-hal v0.32.2
   Compiling esp-idf-svc v0.36.1
   Compiling emg-server v0.1.0 (/n/autobuild/eliduprees-emg-mouse/build/emg-server)
error: failed to run custom build command for `esp-idf-sys v0.29.1`

Caused by:
  process didn't exit successfully: `/n/autobuild/eliduprees-emg-mouse/build/emg-server/target/debug/build/esp-idf-sys-dce598b034e4c44c/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  Found compatible PlatformIO Core 5.2.4 -> /n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/penv/bin/platformio
  cargo:rerun-if-changed=./patches/missing_xtensa_atomics_fix.diff
  cargo:rerun-if-changed=./patches/ping_setsockopt_fix.diff
  cargo:rerun-if-changed=./patches/pthread_destructor_fix.diff
  cargo:rerun-if-changed=./patches/missing_riscv_atomics_fix.diff
  Warning! Ignore unknown configuration option `patches` in section [env]
  Processing debug (board: esp32cam; platform: espressif32; framework: espidf)
  --------------------------------------------------------------------------------
  Verbose mode can be enabled via `-v, --verbose` option
  CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
  PLATFORM: Espressif 32 (3.4.0) > AI Thinker ESP32-CAM
  HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
  DEBUG: Current (esp-prog) External (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.40301.0 (4.3.1) 
   - tool-cmake 3.16.4 
   - tool-esptoolpy 1.30100.210531 (3.1.0) 
   - tool-ninja 1.7.1 
   - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
   - toolchain-riscv32-esp 8.4.0+2021r1 
   - toolchain-xtensa-esp32 8.4.0+2021r1 
   - toolchain-xtensa-esp32s2 8.4.0+2021r1
  Reading CMake configuration...
  LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
  LDF Modes: Finder ~ chain, Compatibility ~ soft
  Found 0 compatible libraries
  Scanning dependencies...
  No dependencies
  Building in debug mode
  Retrieving maximum program size .pio/build/debug/firmware.elf
  Checking size .pio/build/debug/firmware.elf
  Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
  RAM:   [          ]   3.9% (used 12896 bytes from 327680 bytes)
  Flash: [==        ]  15.7% (used 164497 bytes from 1048576 bytes)
  ========================= [SUCCESS] Took 12.18 seconds =========================

  Environment    Status    Duration
  -------------  --------  ------------
  debug          SUCCESS   00:00:12.181
  ========================= 1 succeeded in 00:00:12.181 =========================

  ********************************************************************************
  There are the new updates for platforms (espressif32)
  Please update them via `platformio platform update` command.

  If you want to manually check for the new versions without updating, please use `platformio platform update --dry-run` command.
  ********************************************************************************

  cargo:rerun-if-changed=/n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-sys-0.29.1/src/include/esp-idf/bindings.h

  --- stderr
  Output: "/n/autobuild/eliduprees-emg-mouse/build/emg-server/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-94df6151a6a52853/out/bindings.rs"
  Bindgen builder flags: ["/n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-sys-0.29.1/src/include/esp-idf/bindings.h", "--rust-target", "1.47", "--blocklist-function", "strtold", "--blocklist-function", "_strtold_r", "--blocklist-function", "v.*printf", "--blocklist-function", "v.*scanf", "--blocklist-function", "_v.*printf_r", "--blocklist-function", "_v.*scanf_r", "--blocklist-function", "esp_log_writev", "--no-layout-tests", "--with-derive-default", "--ctypes-prefix", "c_types", "--generate", "functions,types,vars,methods,constructors,destructors", "--use-core", "--no-rustfmt-bindings", "--", "-D__bindgen", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_pm/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-94df6151a6a52853/out/esp-idf/.pio/build/debug/config", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/newlib/platform_include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/freertos/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/freertos/port/xtensa/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_hw_support/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_hw_support/port/esp32/.", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/heap/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/log/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/lwip/include/apps", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/lwip/include/apps/sntp", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/lwip/lwip/src/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/lwip/port/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/lwip/port/esp32/include/arch", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/soc/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/soc/esp32/.", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/soc/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/hal/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/hal/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_rom/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_rom/esp32", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_rom/include/esp32", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_common/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_system/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/driver/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/driver/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_ringbuf/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/efuse/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/efuse/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/xtensa/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/xtensa/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/espcoredump/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_timer/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_ipc/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/vfs/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_wifi/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_wifi/esp32/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_event/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_netif/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_eth/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/tcpip_adapter/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/app_trace/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/mbedtls/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/mbedtls/mbedtls/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/mbedtls/esp_crt_bundle/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/app_update/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/spi_flash/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/bootloader_support/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/nvs_flash/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/pthread/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/xtensa", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/esp32", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/include/esp_supplicant", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/perfmon/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/asio/asio/asio/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/asio/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/cbor/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/unity/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/unity/unity/src", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/cmock/CMock/src", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/coap/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/coap/port/include/coap", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/coap/libcoap/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/coap/libcoap/include/coap2", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/console", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/nghttp/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/nghttp/nghttp2/lib/includes", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp-tls", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp-tls/esp-tls-crypto", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_adc_cal/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_hid/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/tcp_transport/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_http_client/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_http_server/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_https_ota/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/protobuf-c/protobuf-c", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/protocomm/include/common", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/protocomm/include/security", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/protocomm/include/transports", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/mdns/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_local_ctrl/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/sdmmc/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_serial_slave_link/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/esp_websocket_client/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/expat/expat/expat/lib", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/expat/port/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/wear_levelling/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/fatfs/diskio", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/fatfs/vfs", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/fatfs/src", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/freemodbus/common/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/idf_test/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/idf_test/include/esp32", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/jsmn/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/json/cJSON", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/libsodium/libsodium/src/libsodium/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/libsodium/port_include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/mqtt/esp-mqtt/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/openssl/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/spiffs/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/ulp/include", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/framework-espidf/components/wifi_provisioning/include", "-DESP_IDF_COMP_PTHREAD_ENABLED", "-DESP_IDF_COMP_NVS_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_TLS_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_CLIENT_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_SERVER_ENABLED", "-DESP_IDF_COMP_ESPCOREDUMP_ENABLED", "-DESP_IDF_COMP_APP_UPDATE_ENABLED", "-DESP_IDF_COMP_ESP_SERIAL_SLAVE_LINK_ENABLED", "-DESP_IDF_COMP_SPI_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_ADC_CAL_ENABLED", "-DESP_IDF_COMP_MQTT_ENABLED", "--sysroot=/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/toolchain-xtensa-esp32/bin/../xtensa-esp32-elf", "-I/n/autobuild/eliduprees-emg-mouse/build/emg-server/.embuild/platformio/packages/toolchain-xtensa-esp32/bin/../xtensa-esp32-elf/include", "-x", "c", "-DESP_IDF_COMP_PTHREAD_ENABLED", "-DESP_IDF_COMP_NVS_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_TLS_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_CLIENT_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_SERVER_ENABLED", "-DESP_IDF_COMP_ESPCOREDUMP_ENABLED", "-DESP_IDF_COMP_APP_UPDATE_ENABLED", "-DESP_IDF_COMP_ESP_SERIAL_SLAVE_LINK_ENABLED", "-DESP_IDF_COMP_SPI_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_ADC_CAL_ENABLED", "-DESP_IDF_COMP_MQTT_ENABLED", "-target", "xtensa"]
  thread 'main' panicked at 'libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!', /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:538:15
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ivmarkov commented 2 years ago

There are lots of changes recently and we are moving a bit too fast and sometimes breaking things a bit. For which I apologize. My suggestion would be:

elidupree commented 2 years ago

Thanks for the reply! Unfortunately, I've already tried deleting .embuild. Also, I should've mentioned - I get the same error when building the unmodified, latest version of rust-esp32-std-demo (both when I posted, and now, when I've done a git pull and retried it). Here's the console output of my attempt to rebuild rust-esp32-std-demo just now:

/n/esp-rust/rust-build/rust-esp32-std-demo$ cargo build            
    Updating crates.io index
  Downloaded embedded-svc v0.16.5
  Downloaded esp-idf-svc v0.36.6
  Downloaded 2 crates (88.0 KB) in 0.40s
   Compiling uncased v0.9.6
   Compiling esp-idf-hal v0.32.5
   Compiling esp-idf-svc v0.36.6
   Compiling rust-esp32-std-demo v0.22.7 (/n/esp-rust/rust-build/rust-esp32-std-demo)
   Compiling esp-idf-sys v0.30.3
   Compiling embedded-svc v0.16.5
error: failed to run custom build command for `esp-idf-sys v0.30.3`

Caused by:
  process didn't exit successfully: `/n/esp-rust/rust-build/rust-esp32-std-demo/target/debug/build/esp-idf-sys-1b6c7e608263dc0e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  Found compatible PlatformIO Core 5.2.4 -> /n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/penv/bin/platformio
  cargo:rerun-if-changed=./patches/missing_xtensa_atomics_fix.diff
  cargo:rerun-if-changed=./patches/pthread_destructor_fix.diff
  cargo:rerun-if-changed=./patches/missing_riscv_atomics_fix.diff
  cargo:rerun-if-changed=/n/esp-rust/rust-build/rust-esp32-std-demo/sdkconfig.defaults
  cargo:rerun-if-changed=/n/esp-rust/rust-build/rust-esp32-std-demo/sdkconfig.defaults.esp32
  cargo:rerun-if-changed=/n/esp-rust/rust-build/rust-esp32-std-demo/sdkconfig.defaults.esp32s2
  Warning! Ignore unknown configuration option `patches` in section [env]
  Processing debug (board: esp32cam; platform: espressif32; framework: espidf)
  --------------------------------------------------------------------------------
  Verbose mode can be enabled via `-v, --verbose` option
  CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
  PLATFORM: Espressif 32 (3.4.0) > AI Thinker ESP32-CAM
  HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
  DEBUG: Current (esp-prog) External (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.40301.0 (4.3.1) 
   - tool-cmake 3.16.4 
   - tool-esptoolpy 1.30100.210531 (3.1.0) 
   - tool-ninja 1.7.1 
   - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
   - toolchain-riscv32-esp 8.4.0+2021r1 
   - toolchain-xtensa-esp32 8.4.0+2021r1 
   - toolchain-xtensa-esp32s2 8.4.0+2021r1
  Reading CMake configuration...
  LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
  LDF Modes: Finder ~ chain, Compatibility ~ soft
  Found 0 compatible libraries
  Scanning dependencies...
  No dependencies
  Building in debug mode
  Compiling .pio/build/debug/app_update/esp_app_desc.o
  Archiving .pio/build/debug/esp-idf/app_update/libapp_update.a
  Indexing .pio/build/debug/esp-idf/app_update/libapp_update.a
  Generating project linker script .pio/build/debug/esp32.project.ld
  __action_dump([".pio/build/debug/firmware.elf"], [".pio/build/debug/src/main.o"])
  Linking .pio/build/debug/firmware.elf
  Retrieving maximum program size .pio/build/debug/firmware.elf
  Checking size .pio/build/debug/firmware.elf
  Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
  RAM:   [          ]   3.9% (used 12872 bytes from 327680 bytes)
  Flash: [==        ]  15.7% (used 164233 bytes from 1048576 bytes)
  Building .pio/build/debug/firmware.bin
  esptool.py v3.1
  Merged 2 ELF sections
  ========================= [SUCCESS] Took 16.72 seconds =========================

  Environment    Status    Duration
  -------------  --------  ------------
  debug          SUCCESS   00:00:16.722
  ========================= 1 succeeded in 00:00:16.722 =========================
  cargo:rerun-if-changed=/n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-sys-0.30.3/src/include/esp-idf/bindings.h

  --- stderr
  Output: "/n/esp-rust/rust-build/rust-esp32-std-demo/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-85749cb3de2b25fe/out/bindings.rs"
  Bindgen builder flags: ["/n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-sys-0.30.3/src/include/esp-idf/bindings.h", "--rust-target", "1.47", "--blocklist-function", "strtold", "--blocklist-function", "_strtold_r", "--blocklist-function", "v.*printf", "--blocklist-function", "v.*scanf", "--blocklist-function", "_v.*printf_r", "--blocklist-function", "_v.*scanf_r", "--blocklist-function", "esp_log_writev", "--no-layout-tests", "--with-derive-default", "--ctypes-prefix", "c_types", "--generate", "functions,types,vars,methods,constructors,destructors", "--use-core", "--no-rustfmt-bindings", "--", "-D__bindgen", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_pm/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-85749cb3de2b25fe/out/esp-idf/.pio/build/debug/config", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/newlib/platform_include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/freertos/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/freertos/port/xtensa/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_hw_support/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_hw_support/port/esp32/.", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/heap/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/log/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/lwip/include/apps", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/lwip/include/apps/sntp", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/lwip/lwip/src/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/lwip/port/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/lwip/port/esp32/include/arch", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/soc/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/soc/esp32/.", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/soc/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/hal/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/hal/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_rom/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_rom/esp32", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_rom/include/esp32", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_common/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_system/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/driver/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/driver/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_ringbuf/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/efuse/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/efuse/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/xtensa/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/xtensa/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/espcoredump/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_timer/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_ipc/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/vfs/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_wifi/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_wifi/esp32/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_event/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_netif/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_eth/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/tcpip_adapter/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/app_trace/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/mbedtls/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/mbedtls/mbedtls/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/mbedtls/esp_crt_bundle/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/app_update/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/spi_flash/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/bootloader_support/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/nvs_flash/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/pthread/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/xtensa", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_gdbstub/esp32", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/wpa_supplicant/include/esp_supplicant", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/perfmon/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/asio/asio/asio/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/asio/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/cbor/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/unity/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/unity/unity/src", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/cmock/CMock/src", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/coap/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/coap/port/include/coap", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/coap/libcoap/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/coap/libcoap/include/coap2", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/console", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/nghttp/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/nghttp/nghttp2/lib/includes", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp-tls", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp-tls/esp-tls-crypto", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_adc_cal/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_hid/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/tcp_transport/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_http_client/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_http_server/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_https_ota/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/protobuf-c/protobuf-c", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/protocomm/include/common", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/protocomm/include/security", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/protocomm/include/transports", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/mdns/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_local_ctrl/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/sdmmc/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_serial_slave_link/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/esp_websocket_client/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/expat/expat/expat/lib", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/expat/port/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/wear_levelling/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/fatfs/diskio", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/fatfs/vfs", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/fatfs/src", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/freemodbus/common/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/idf_test/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/idf_test/include/esp32", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/jsmn/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/json/cJSON", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/libsodium/libsodium/src/libsodium/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/libsodium/port_include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/mqtt/esp-mqtt/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/openssl/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/spiffs/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/ulp/include", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/framework-espidf/components/wifi_provisioning/include", "-DESP_IDF_COMP_PTHREAD_ENABLED", "-DESP_IDF_COMP_NVS_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_TLS_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_CLIENT_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_SERVER_ENABLED", "-DESP_IDF_COMP_ESPCOREDUMP_ENABLED", "-DESP_IDF_COMP_APP_UPDATE_ENABLED", "-DESP_IDF_COMP_ESP_SERIAL_SLAVE_LINK_ENABLED", "-DESP_IDF_COMP_SPI_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_ADC_CAL_ENABLED", "-DESP_IDF_COMP_MQTT_ENABLED", "-DESP_IDF_COMP_VFS_ENABLED", "-DESP_IDF_COMP_SPIFFS_ENABLED", "-DESP_IDF_COMP_FATFS_ENABLED", "-DESP_IDF_COMP_SOC_ENABLED", "--sysroot=/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/toolchain-xtensa-esp32/bin/../xtensa-esp32-elf", "-I/n/esp-rust/rust-build/rust-esp32-std-demo/.embuild/platformio/packages/toolchain-xtensa-esp32/bin/../xtensa-esp32-elf/include", "-x", "c", "-DESP_IDF_COMP_PTHREAD_ENABLED", "-DESP_IDF_COMP_NVS_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_TLS_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_CLIENT_ENABLED", "-DESP_IDF_COMP_ESP_HTTP_SERVER_ENABLED", "-DESP_IDF_COMP_ESPCOREDUMP_ENABLED", "-DESP_IDF_COMP_APP_UPDATE_ENABLED", "-DESP_IDF_COMP_ESP_SERIAL_SLAVE_LINK_ENABLED", "-DESP_IDF_COMP_SPI_FLASH_ENABLED", "-DESP_IDF_COMP_ESP_ADC_CAL_ENABLED", "-DESP_IDF_COMP_MQTT_ENABLED", "-DESP_IDF_COMP_VFS_ENABLED", "-DESP_IDF_COMP_SPIFFS_ENABLED", "-DESP_IDF_COMP_FATFS_ENABLED", "-DESP_IDF_COMP_SOC_ENABLED", "-target", "xtensa"]
  thread 'main' panicked at 'libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!', /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/ir/context.rs:538:15
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
N3xed commented 2 years ago

Were you always using esp-idf v3.4? And what LLVM/libclang are you using?

You could try updating LLVM/libclang.

elidupree commented 2 years ago

You could try updating LLVM/libclang.

Oh dear. I just realized that the problem was that I forgot to set my LIBCLANG_PATH environment variable to point to the custom one installed by esp-rust. I've got my project working again now.

I wonder if that error message could be improved for this situation? Right now, it reads like "Error: There was an error" - if it had said something like "you used the wrong libclang" then I'd have known what the problem was immediately.

ivmarkov commented 2 years ago

I would still suggest updating your dependencies, because PlatformIO is using a newer ESP-IDF now, and if you remove the .embuild directory of your project, it will likely stop compiling.

As for LLVM/CLang and warnings - feel free to open an issue for that. We can try doing something on that front, but it will be low priority. IMHO bindgen itself needs to improve its error reporting, rather than us working around it - in that particular case, it fails because the target we are passing is not supported by LLVM, so I would expect that it spits out an error message along the lines of "unrecognized target" or suchlike.

N3xed commented 2 years ago

Oh dear. I just realized that the problem was that I forgot to set my LIBCLANG_PATH environment variable to point to the custom one installed by esp-rust. I've got my project working again now.

Nice, good that it's working again.

I wonder if that error message could be improved for this situation? Right now, it reads like "Error: There was an error" - if it had said something like "you used the wrong libclang" then I'd have known what the problem was immediately.

Yeah, like @ivmarkov already said, this is a bindgen issue. We could try to check for this specific case and then output an error message (feel free to make a PR for this), but it should really be improved in bindgen itself. But maybe that is also not so straightforward since they opted to just output a general error message.

With that said, I'll close the issue. You can always reopen if something else is amiss (or even create a new issue).

JeanBlignaut commented 2 years ago

I'm having a similar issue but I'm a novice at this. how where do I set this LIBCLANG_PATH ? Ive tried setting up this toolchain on my Mac natively and via docker container and so far have not been able to compile a simple hello world 😒 and been trying for a week πŸ˜…

JeanBlignaut commented 2 years ago
root@6c18b5fd0939:~/project# cargo build
   Compiling esp-idf-sys v0.30.1
error: failed to run custom build command for `esp-idf-sys v0.30.1`

Caused by:
  process didn't exit successfully: `/root/project/target/debug/build/esp-idf-sys-47b6e8f5fe49b8d5/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  Found compatible PlatformIO Core 5.2.4 -> /root/project/.embuild/platformio/penv/bin/platformio
  cargo:rerun-if-changed=./patches/pthread_destructor_fix.diff
  cargo:rerun-if-changed=./patches/missing_riscv_atomics_fix.diff
  cargo:rerun-if-changed=./patches/ping_setsockopt_fix.diff
  cargo:rerun-if-changed=./patches/missing_xtensa_atomics_fix.diff
  cargo:rerun-if-changed=/root/project/sdkconfig.defaults
  cargo:rerun-if-changed=/root/project/sdkconfig.defaults.esp32
  cargo:rerun-if-changed=/root/project/sdkconfig.defaults.esp32s2
  Warning! Ignore unknown configuration option `patches` in section [env]
  Processing debug (board: esp32cam; platform: espressif32; framework: espidf)
  --------------------------------------------------------------------------------
  Verbose mode can be enabled via `-v, --verbose` option
  os.chdir('/root/project/.embuild/platformio/packages/framework-espidf')
  git init
  Initialized empty Git repository in /root/project/.embuild/platformio/packages/framework-espidf/.git/
  os.chdir('/root/project/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-b79db3d3ea192b49/out/esp-idf')
  os.chdir('/root/project/.embuild/platformio/packages/framework-espidf')
  git apply /root/project/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-b79db3d3ea192b49/out/esp-idf/patches/ping_setsockopt_fix.diff
  os.chdir('/root/project/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-b79db3d3ea192b49/out/esp-idf')

  --- stderr
  error: patch failed: components/lwip/apps/ping/ping_sock.c:274
  error: components/lwip/apps/ping/ping_sock.c: patch does not apply
  *** Error 1
  ========================== [FAILED] Took 1.00 seconds ==========================
  Environment    Status    Duration
  -------------  --------  ------------
  debug          FAILED    00:00:01.001
  ==================== 1 failed, 0 succeeded in 00:00:01.001 ====================
  Error: No such file or directory (os error 2)
ivmarkov commented 2 years ago

I'm having a similar issue but I'm a novice at this. how where do I set this LIBCLANG_PATH ? Ive tried setting up this toolchain on my Mac natively and via docker container and so far have not been able to compile a simple hello world 😒 and been trying for a week πŸ˜…

Your issue is different. You are stuck with (a) newer PlatformIO, but (b) older esp-idf-sys and friends. Just re-clone rust-esp32-std-demo from clean state and rebuild, and the particular problem you are observing should be gone. if not, please reply here, and I'll look deeper into it.

JeanBlignaut commented 2 years ago

Tried again on new Espressif/idf-rust-examples container:


root@911e4a3c7cd1:/opt/rust-esp32-std-demo# cargo +esp build --release
warning: unused config key `unstable.extra-link-arg` in `/opt/rust-esp32-std-demo/.cargo/config.toml`
warning: unused config key `unstable.configurable-env` in `/opt/rust-esp32-std-demo/.cargo/config.toml`
   Compiling compiler_builtins v0.1.49
   Compiling core v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.103
   Compiling cc v1.0.69
   Compiling std v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/std)
   Compiling libc v0.2.109
   Compiling proc-macro2 v1.0.33
   Compiling memchr v2.4.1
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.82
   Compiling cfg-if v1.0.0
   Compiling cc v1.0.72
   Compiling log v0.4.14
   Compiling autocfg v1.0.1
   Compiling serde_derive v1.0.130
   Compiling serde v1.0.130
   Compiling once_cell v1.8.0
   Compiling fnv v1.0.7
   Compiling ryu v1.0.6
   Compiling spin v0.5.2
   Compiling untrusted v0.7.1
   Compiling regex-syntax v0.6.25
   Compiling version_check v0.9.3
   Compiling tinyvec_macros v0.1.0
   Compiling glob v0.3.0
   Compiling serde_json v1.0.72
   Compiling anyhow v1.0.51
   Compiling matches v0.1.9
   Compiling lazy_static v1.4.0
   Compiling crossbeam-utils v0.8.5
   Compiling unicode-bidi v0.3.7
   Compiling gimli v0.26.1
   Compiling same-file v1.0.6
   Compiling unicode-width v0.1.9
   Compiling percent-encoding v2.1.0
   Compiling ppv-lite86 v0.2.15
   Compiling adler v1.0.2
   Compiling bitflags v1.3.2
   Compiling strsim v0.8.0
   Compiling termcolor v1.1.2
   Compiling bindgen v0.57.0
   Compiling humantime v2.1.0
   Compiling rustc-demangle v0.1.21
   Compiling ansi_term v0.12.1
   Compiling vec_map v0.8.2
   Compiling shlex v0.1.1
   Compiling chunked_transfer v1.4.0
   Compiling remove_dir_all v0.5.3
   Compiling lazycell v1.3.0
   Compiling base64 v0.13.0
   Compiling either v1.6.1
   Compiling unicode-segmentation v1.8.0
   Compiling rustc-hash v1.1.0
   Compiling zero v0.1.2
   Compiling peeking_take_while v0.1.2
   Compiling itoa v0.4.8
   Compiling shlex v1.1.0
   Compiling futures-core v0.3.18
   Compiling strsim v0.10.0
   Compiling ident_case v1.0.1
   Compiling az v1.2.0
   Compiling async-trait v0.1.51
   Compiling heapless v0.7.8
   Compiling paste v1.0.6
   Compiling unwind v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/unwind)
   Compiling libloading v0.7.2
   Compiling cmake v0.1.46
   Compiling miniz_oxide v0.4.4
   Compiling num-traits v0.2.14
   Compiling thread_local v1.1.3
   Compiling ring v0.16.20
   Compiling backtrace v0.3.63
   Compiling tinyvec v1.5.1
   Compiling nom v5.1.2
   Compiling clang-sys v1.3.0
   Compiling walkdir v2.3.2
   Compiling textwrap v0.11.0
   Compiling form_urlencoded v1.0.1
   Compiling addr2line v0.17.0
   Compiling rustc-std-workspace-core v1.99.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling xmas-elf v0.8.0
   Compiling heck v0.3.3
   Compiling unicode-normalization v0.1.19
   Compiling quote v1.0.10
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.17
   Compiling object v0.27.1
   Compiling getrandom v0.2.3 (https://github.com/esp-rs-compat/getrandom.git#b8cb133e)
   Compiling atty v0.2.14
   Compiling which v3.1.1
   Compiling dirs-sys v0.3.6
   Compiling which v4.2.2
   Compiling remove_dir_all v0.7.0
   Compiling alloc v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v0.1.10
   Compiling idna v0.2.3
   Compiling regex v1.5.4
   Compiling rand_core v0.6.3
   Compiling clap v2.34.0
   Compiling dirs v4.0.0
   Compiling cexpr v0.4.0
   Compiling rustc-std-workspace-alloc v1.99.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort)
   Compiling url v2.2.2
   Compiling rand_chacha v0.3.1
   Compiling globset v0.4.8
   Compiling env_logger v0.8.4
   Compiling webpki v0.22.0
   Compiling sct v0.7.0
   Compiling panic_unwind v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_unwind)
   Compiling std_detect v0.1.5 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling hashbrown v0.11.0
   Compiling darling_core v0.13.0
   Compiling rand v0.8.4
   Compiling ignore v0.4.18
   Compiling webpki-roots v0.22.1
   Compiling rustls v0.20.2
   Compiling strum_macros v0.21.1
   Compiling thiserror-impl v1.0.30
   Compiling derivative v2.2.0
   Compiling tempfile v3.2.0
   Compiling globwalk v0.8.1
   Compiling darling_macro v0.13.0
   Compiling ureq v2.3.1
   Compiling proc_macro v0.0.0 (/opt/rustup/toolchains/esp/lib/rustlib/src/rust/library/proc_macro)
   Compiling strum v0.21.0
   Compiling thiserror v1.0.30
   Compiling nb v1.0.0
   Compiling cache-padded v1.1.1
   Compiling void v1.0.2
   Compiling waker-fn v1.1.0
   Compiling pin-project-lite v0.2.7
   Compiling fastrand v1.5.0
   Compiling parking v2.0.0
   Compiling byteorder v1.4.3
   Compiling futures-io v0.3.18
   Compiling event-listener v2.5.1
   Compiling display-interface v0.4.1
   Compiling async-task v4.0.3
   Compiling base64 v0.12.3
   Compiling atomic-waker v1.0.0
   Compiling slab v0.4.5
   Compiling mutex-trait v0.2.0
   Compiling byte-slice-cast v0.3.5
   Compiling stable_deref_trait v1.2.0
   Compiling cty v0.2.2
   Compiling micromath v1.1.1
   Compiling socket2 v0.4.2 (https://github.com/esp-rs-compat/socket2#7217ebe8)
   Compiling nb v0.1.3
   Compiling concurrent-queue v1.2.2
   Compiling toml v0.5.8
   Compiling hash32 v0.2.1
   Compiling darling v0.13.0
   Compiling futures-lite v1.12.0
   Compiling async-lock v2.4.0
   Compiling no-std-net v0.5.0
   Compiling http-auth-basic v0.1.3
   Compiling embedded-graphics-core v0.3.3
   Compiling cstr_core v0.2.4
   Compiling polling v2.1.0 (https://github.com/esp-rs-compat/polling#260dded7)
   Compiling float-cmp v0.8.0
   Compiling embedded-hal v0.2.6
   Compiling async-channel v1.6.1
   Compiling enumset_derive v0.5.5
   Compiling cargo_toml v0.9.2
   Compiling proc-macro-crate v1.1.0
   Compiling async-executor v1.4.1
   Compiling async-io v1.6.0
   Compiling embedded-graphics v0.7.1
   Compiling display-interface-spi v0.4.1
   Compiling display-interface-i2c v0.4.0
   Compiling ili9341 v0.5.0 (https://github.com/yuri91/ili9341-rs#8aeefc4a)
   Compiling blocking v1.1.0
   Compiling st7789 v0.6.1
   Compiling num_enum_derive v0.5.4
   Compiling embuild v0.25.4
   Compiling enumset v1.0.8
   Compiling ssd1306 v0.7.0
   Compiling async-net v1.6.1
   Compiling async-fs v1.5.0
   Compiling num_enum v0.5.4
   Compiling smol v1.2.5 (https://github.com/esp-rs-compat/smol#b9a770e7)
   Compiling embedded-svc v0.15.3
   Compiling esp-idf-sys v0.27.0
   Compiling esp-idf-hal v0.27.0
   Compiling esp-idf-svc v0.32.3
   Compiling rust-esp32-std-demo v0.20.6 (/opt/rust-esp32-std-demo)
error: failed to run custom build command for `esp-idf-sys v0.27.0`

Caused by:
  process didn't exit successfully: `/opt/rust-esp32-std-demo/target/release/build/esp-idf-sys-4c914487a370c77f/build-script-build` (exit status: 1)
  --- stdout
  Installer version: 1.0.2
  Platform: Linux-5.13.0-27-generic-x86_64-with-glibc2.29
  Python version: 3.8.10 (default, Sep 28 2021, 16:10:42) 
  [GCC 9.3.0]
  Python path: /opt/esp/python_env/idf5.0_py3.8_env/bin/python3
  Creating a virtual environment at /root/.platformio/penv
  Updating Python package manager (PIP) in a virtual environment
  PIP has been successfully updated!
  Virtual environment has been successfully created!
  Installing PlatformIO Core
  Collecting platformio
    Downloading platformio-5.2.4.tar.gz (219 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 219.1/219.1 KB 445.5 kB/s eta 0:00:00
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
  Collecting bottle==0.12.*
    Using cached bottle-0.12.19-py3-none-any.whl (89 kB)
  Collecting click!=8.0.2,<9,>=8
    Using cached click-8.0.3-py3-none-any.whl (97 kB)
  Collecting colorama
    Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
  Collecting marshmallow<4,>=2
    Using cached marshmallow-3.14.1-py3-none-any.whl (47 kB)
  Collecting pyelftools<1,>=0.27
    Using cached pyelftools-0.27-py2.py3-none-any.whl (151 kB)
  Collecting pyserial==3.*
    Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
  Collecting requests==2.*
    Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.1/63.1 KB 1.4 MB/s eta 0:00:00
  Collecting semantic_version==2.8.*
    Using cached semantic_version-2.8.5-py2.py3-none-any.whl (15 kB)
  Collecting tabulate==0.8.*
    Using cached tabulate-0.8.9-py3-none-any.whl (25 kB)
  Collecting zeroconf==0.37.*
    Downloading zeroconf-0.37.0-py3-none-any.whl (105 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 105.9/105.9 KB 2.0 MB/s eta 0:00:00
  Collecting aiofiles==0.8.*
    Downloading aiofiles-0.8.0-py3-none-any.whl (13 kB)
  Collecting ajsonrpc==1.*
    Using cached ajsonrpc-1.2.0-py3-none-any.whl (22 kB)
  Collecting starlette==0.17.*
    Using cached starlette-0.17.1-py3-none-any.whl (58 kB)
  Collecting uvicorn==0.16.*
    Downloading uvicorn-0.16.0-py3-none-any.whl (54 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.9/54.9 KB 1.6 MB/s eta 0:00:00
  Collecting wsproto==1.0.*
    Using cached wsproto-1.0.0-py3-none-any.whl (24 kB)
  Collecting idna<4,>=2.5
    Using cached idna-3.3-py3-none-any.whl (61 kB)
  Collecting urllib3<1.27,>=1.21.1
    Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.7/138.7 KB 480.8 kB/s eta 0:00:00
  Collecting charset-normalizer~=2.0.0
    Downloading charset_normalizer-2.0.11-py3-none-any.whl (39 kB)
  Collecting certifi>=2017.4.17
    Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
  Collecting anyio<4,>=3.0.0
    Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.2/79.2 KB 1.0 MB/s eta 0:00:00
  Collecting h11>=0.8
    Downloading h11-0.13.0-py3-none-any.whl (58 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.2/58.2 KB 804.4 kB/s eta 0:00:00
  Collecting asgiref>=3.4.0
    Downloading asgiref-3.5.0-py3-none-any.whl (22 kB)
  Collecting ifaddr>=0.1.7
    Using cached ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
  Collecting sniffio>=1.1
    Using cached sniffio-1.2.0-py3-none-any.whl (10 kB)
  Building wheels for collected packages: platformio
    Building wheel for platformio (setup.py): started
    Building wheel for platformio (setup.py): finished with status 'done'
    Created wheel for platformio: filename=platformio-5.2.4-py3-none-any.whl size=344394 sha256=ebbb129fce05bb3b761a74774eb69e70368ed51e76ee98d753e781241ae03e56
    Stored in directory: /root/.cache/pip/wheels/c7/5f/eb/2b681c5612c9a8ace53548f7febbd3edd52d6522ebfe2aafcc
  Successfully built platformio
  Installing collected packages: tabulate, pyserial, pyelftools, ifaddr, certifi, bottle, zeroconf, urllib3, sniffio, semantic_version, marshmallow, idna, h11, colorama, click, charset-normalizer, asgiref, ajsonrpc, aiofiles, wsproto, uvicorn, requests, anyio, starlette, platformio
  Successfully installed aiofiles-0.8.0 ajsonrpc-1.2.0 anyio-3.5.0 asgiref-3.5.0 bottle-0.12.19 certifi-2021.10.8 charset-normalizer-2.0.11 click-8.0.3 colorama-0.4.4 h11-0.13.0 idna-3.3 ifaddr-0.1.7 marshmallow-3.14.1 platformio-5.2.4 pyelftools-0.27 pyserial-3.5 requests-2.27.1 semantic_version-2.8.5 sniffio-1.2.0 starlette-0.17.1 tabulate-0.8.9 urllib3-1.26.8 uvicorn-0.16.0 wsproto-1.0.0 zeroconf-0.37.0

  PlatformIO Core has been successfully installed into an isolated environment `/root/.platformio/penv`!

  The full path to `platformio.exe` is `/root/.platformio/penv/bin/platformio`

  If you need an access to `platformio.exe` from other applications, please install Shell Commands
  (add PlatformIO Core binary directory `/root/.platformio/penv/bin` to the system environment PATH variable):

  See https://docs.platformio.org/page/installation.html#install-shell-commands

  Found compatible PlatformIO Core 5.2.4 -> /root/.platformio/penv/bin/platformio

  --- stderr
  Error: Compatible PlatformIO Core not found.
  Reason: PlatformIO Core was installed using another platform `Linux-5.11.0-1021-azure-x86_64-with-glibc2.29`. Your current platform: Linux-5.13.0-27-generic-x86_64-with-glibc2.29
  Error: invalid type: null, expected a string at line 1 column 9391```
ivmarkov commented 2 years ago
   Compiling embedded-svc v0.15.3
   Compiling esp-idf-sys v0.27.0
   Compiling esp-idf-hal v0.27.0
   Compiling esp-idf-svc v0.32.3
   Compiling rust-esp32-std-demo v0.20.6 (/opt/rust-esp32-std-demo)

These dependencies, and the demo itself are old, and are incompatible with recent PlatformIO releases. Unfortunately, we do not have (yet) a way to "freeze" the PlatformIO dependency, so when it gets updated, you are in a situation like this.

Really, how about just forgetting about ready-to-use containers for a moment, and then proceeding as I suggested:

That should get you in a buildable shape.