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

esp-idf-sys fails to compile in idf-rust:esp32s3_1.73.0.1 docker image #313

Closed
Joku1806 opened this issue Nov 8, 2023 · 2 comments
Closed

Comments

@Joku1806
Copy link

Joku1806 commented Nov 8, 2023

Hello,

I followed the install instructions for the std toolchain from here and generated a project with cargo generate esp-rs/esp-idf-template cargo.

Locally, everything builds fine and a .embuild directory is created automatically, but in this Docker Image this does not happen.

I don't know why this happens, as far as I can tell from the layers all required dependencies are installed and I also sourced $HOME/export-esp.sh before building.

Here are the CI logs:

Running with gitlab-runner 16.5.0 (853330f9)
  on esp32 vxqhoGEM1, system ID: s_089face47da2
Preparing the "docker" executor 00:04
Using Docker executor with image espressif/idf-rust:esp32s3_1.73.0.1 ...
Authenticating with credentials from $DOCKER_AUTH_CONFIG
Pulling docker image espressif/idf-rust:esp32s3_1.73.0.1 ...
Using docker image sha256:6313f85adb406f1e7a99293fdc4f8e8ffbf2726b1708d9b133f39c378f0d6859 for espressif/idf-rust:esp32s3_1.73.0.1 with digest espressif/idf-rust@sha256:e5968bf4b848c73cdc0b6469d21e88cc5c2ac9dd7378c6161fa324225f8a069f ...
Preparing environment 00:02
Running on runner-vxqhogem1-project-30397-concurrent-0 via homebox...
Getting source from Git repository 00:02
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/tkn/teaching/pj2023w/practical-network-coding-with-esp32/.git/
Checking out 101a7b08 as detached HEAD (ref is 8-create-test-infrastructure-and-run-tests-in-ci)...
Removing Cargo.lock
Removing target/
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:35
Using docker image sha256:6313f85adb406f1e7a99293fdc4f8e8ffbf2726b1708d9b133f39c378f0d6859 for espressif/idf-rust:esp32s3_1.73.0.1 with digest espressif/idf-rust@sha256:e5968bf4b848c73cdc0b6469d21e88cc5c2ac9dd7378c6161fa324225f8a069f ...
$ source /home/esp/export-esp.sh
$ cargo build
    Updating crates.io index
 Downloading crates ...
  Downloaded log v0.4.20
  Downloaded thread_local v1.1.7
  Downloaded strum v0.24.1
  Downloaded glob v0.3.1
  Downloaded errno v0.3.6
  Downloaded pin-utils v0.1.0
  Downloaded embedded-hal-nb v1.0.0-rc.1
  Downloaded stable_deref_trait v1.2.0
  Downloaded futures-task v0.3.29
  Downloaded cexpr v0.6.0
  Downloaded peeking_take_while v0.1.2
  Downloaded const_format_proc_macros v0.2.32
  Downloaded toml_edit v0.20.7
  Downloaded ident_case v1.0.1
  Downloaded thiserror-impl v1.0.50
  Downloaded normpath v1.1.1
  Downloaded embassy-futures v0.1.0
  Downloaded thiserror v1.0.50
  Downloaded fs_at v0.1.10
  Downloaded itoa v1.0.9
  Downloaded rustc_version v0.4.0
  Downloaded defmt-macros v0.3.6
  Downloaded unicode-xid v0.2.4
  Downloaded uncased v0.9.9
  Downloaded memchr v2.6.4
  Downloaded enumset v1.1.3
  Downloaded hashbrown v0.14.2
  Downloaded which v4.4.2
  Downloaded strum_macros v0.24.3
  Downloaded futures-util v0.3.29
  Downloaded serde v1.0.192
  Downloaded winnow v0.5.19
  Downloaded rustix v0.38.21
  Downloaded bstr v1.7.0
  Downloaded linux-raw-sys v0.4.10
  Downloaded regex-automata v0.4.3
  Downloaded syn v2.0.39
  Downloaded syn v1.0.109
  Downloaded libc v0.2.150
  Downloaded embuild v0.31.4
  Downloaded esp-idf-svc v0.47.2
  Downloaded chrono v0.4.31
  Downloaded regex v1.10.2
  Downloaded regex-syntax v0.8.2
  Downloaded esp-idf-hal v0.42.4
  Downloaded nix v0.26.4
  Downloaded serde_json v1.0.108
  Downloaded aho-corasick v1.1.2
  Downloaded unicode-ident v1.0.12
  Downloaded defmt v0.3.5
  Downloaded hash32 v0.2.1
  Downloaded proc-macro2 v1.0.69
  Downloaded const_format v0.2.32
  Downloaded nom v7.1.3
  Downloaded indexmap v2.1.0
  Downloaded minimal-lexical v0.2.1
  Downloaded heapless v0.7.16
  Downloaded cc v1.0.83
  Downloaded ignore v0.4.20
  Downloaded embedded-svc v0.26.2
  Downloaded ryu v1.0.15
  Downloaded serde_derive v1.0.192
  Downloaded darling_core v0.20.3
  Downloaded esp-idf-sys v0.33.7
  Downloaded walkdir v2.4.0
  Downloaded embedded-hal v0.2.7
  Downloaded embedded-hal v1.0.0-rc.1
  Downloaded semver v1.0.20
  Downloaded libloading v0.7.4
  Downloaded spin v0.9.8
  Downloaded darling v0.20.3
  Downloaded proc-macro-error v1.0.4
  Downloaded anyhow v1.0.75
  Downloaded clang-sys v1.6.1
  Downloaded scopeguard v1.2.0
  Downloaded bindgen v0.63.0
  Downloaded toml_datetime v0.6.5
  Downloaded globwalk v0.8.1
  Downloaded strum v0.25.0
  Downloaded void v1.0.2
  Downloaded critical-section v1.1.2
  Downloaded pin-project-lite v0.2.13
  Downloaded cargo-platform v0.1.4
  Downloaded atomic-waker v1.1.2
  Downloaded embedded-can v0.4.1
  Downloaded version_check v0.9.4
  Downloaded nb v1.1.0
  Downloaded lazy_static v1.4.0
  Downloaded fastrand v2.0.1
  Downloaded num_enum v0.7.1
  Downloaded rustc-hash v1.1.0
  Downloaded build-time v0.1.3
  Downloaded cfg-if v1.0.0
  Downloaded cargo_metadata v0.15.4
  Downloaded cvt v0.1.2
  Downloaded embedded-io v0.6.1
  Downloaded defmt-parser v0.3.3
  Downloaded embassy-time v0.1.5
  Downloaded either v1.9.0
  Downloaded envy v0.4.2
  Downloaded fnv v1.0.7
  Downloaded tempfile v3.8.1
  Downloaded strum_macros v0.25.3
  Downloaded quote v1.0.33
  Downloaded once_cell v1.18.0
  Downloaded lazycell v1.3.0
  Downloaded embassy-sync v0.3.0
  Downloaded camino v1.1.6
  Downloaded cmake v0.1.50
  Downloaded futures-core v0.3.29
  Downloaded lock_api v0.4.11
  Downloaded same-file v1.0.6
  Downloaded bitflags v2.4.1
  Downloaded byteorder v1.5.0
  Downloaded enumset_derive v0.8.1
  Downloaded rustversion v1.0.14
  Downloaded num_enum_derive v0.7.1
  Downloaded home v0.5.5
  Downloaded iana-time-zone v0.1.58
  Downloaded num-traits v0.2.17
  Downloaded equivalent v1.0.1
  Downloaded proc-macro-crate v2.0.0
  Downloaded filetime v0.2.22
  Downloaded globset v0.4.13
  Downloaded autocfg v1.1.0
  Downloaded no-std-net v0.5.0
  Downloaded embedded-io-async v0.6.0
  Downloaded remove_dir_all v0.8.2
  Downloaded bitflags v1.3.2
  Downloaded heck v0.4.1
  Downloaded shlex v1.2.0
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded darling_macro v0.20.3
  Downloaded nb v0.1.3
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling serde v1.0.192
   Compiling cfg-if v1.0.0
   Compiling libc v0.2.150
   Compiling memchr v2.6.4
   Compiling fnv v1.0.7
   Compiling semver v1.0.20
   Compiling regex-syntax v0.8.2
   Compiling bitflags v1.3.2
   Compiling glob v0.3.1
   Compiling syn v1.0.109
   Compiling rustix v0.38.21
   Compiling lazy_static v1.4.0
   Compiling bitflags v2.4.1
   Compiling log v0.4.20
   Compiling rustversion v1.0.14
   Compiling linux-raw-sys v0.4.10
   Compiling once_cell v1.18.0
   Compiling autocfg v1.1.0
   Compiling same-file v1.0.6
   Compiling minimal-lexical v0.2.1
   Compiling serde_json v1.0.108
   Compiling thiserror v1.0.50
   Compiling thread_local v1.1.7
   Compiling clang-sys v1.6.1
   Compiling aho-corasick v1.1.2
   Compiling bstr v1.7.0
   Compiling nom v7.1.3
   Compiling walkdir v2.4.0
   Compiling libloading v0.7.4
   Compiling quote v1.0.33
   Compiling cvt v0.1.2
   Compiling home v0.5.5
   Compiling heck v0.4.1
   Compiling syn v2.0.39
   Compiling ryu v1.0.15
   Compiling anyhow v1.0.75
   Compiling bindgen v0.63.0
   Compiling itoa v1.0.9
   Compiling either v1.9.0
   Compiling shlex v1.2.0
   Compiling rustc-hash v1.1.0
   Compiling normpath v1.1.1
   Compiling peeking_take_while v0.1.2
   Compiling lazycell v1.3.0
   Compiling fastrand v2.0.1
   Compiling camino v1.1.6
   Compiling lock_api v0.4.11
   Compiling scopeguard v1.2.0
   Compiling ident_case v1.0.1
   Compiling num-traits v0.2.17
   Compiling nb v1.1.0
   Compiling futures-core v0.3.29
   Compiling nix v0.26.4
   Compiling cc v1.0.83
   Compiling filetime v0.2.22
   Compiling futures-task v0.3.29
   Compiling byteorder v1.5.0
   Compiling spin v0.9.8
   Compiling hash32 v0.2.1
   Compiling futures-util v0.3.29
   Compiling regex-automata v0.4.3
   Compiling cmake v0.1.50
   Compiling fs_at v0.1.10
   Compiling cexpr v0.6.0
   Compiling which v4.4.2
   Compiling remove_dir_all v0.8.2
   Compiling tempfile v3.8.1
   Compiling stable_deref_trait v1.2.0
   Compiling iana-time-zone v0.1.58
   Compiling pin-project-lite v0.2.13
   Compiling pin-utils v0.1.0
   Compiling embassy-time v0.1.5
   Compiling unicode-xid v0.2.4
   Compiling const_format_proc_macros v0.2.32
   Compiling nb v0.1.3
   Compiling version_check v0.9.4
   Compiling void v1.0.2
   Compiling embassy-sync v0.3.0
   Compiling critical-section v1.1.2
   Compiling embedded-hal v0.2.7
   Compiling uncased v0.9.9
   Compiling chrono v0.4.31
   Compiling embedded-io v0.6.1
   Compiling embedded-hal v1.0.0-rc.1
   Compiling atomic-waker v1.1.2
   Compiling embedded-can v0.4.1
   Compiling embedded-hal-nb v1.0.0-rc.1
   Compiling no-std-net v0.5.0
   Compiling embassy-futures v0.1.0
   Compiling darling_core v0.20.3
   Compiling const_format v0.2.32
   Compiling regex v1.10.2
   Compiling globset v0.4.13
   Compiling ignore v0.4.20
   Compiling serde_derive v1.0.192
   Compiling thiserror-impl v1.0.50
   Compiling num_enum_derive v0.7.1
   Compiling build-time v0.1.3
   Compiling globwalk v0.8.1
   Compiling darling_macro v0.20.3
   Compiling strum_macros v0.24.3
   Compiling num_enum v0.7.1
   Compiling darling v0.20.3
   Compiling enumset_derive v0.8.1
   Compiling strum v0.24.1
   Compiling enumset v1.1.3
   Compiling cargo-platform v0.1.4
   Compiling envy v0.4.2
   Compiling rustc_version v0.4.0
   Compiling heapless v0.7.16
   Compiling embuild v0.31.4
   Compiling cargo_metadata v0.15.4
   Compiling embedded-svc v0.26.2
   Compiling esp-idf-sys v0.33.7
   Compiling esp-idf-hal v0.42.4
   Compiling esp-idf-svc v0.47.2
   Compiling cope v0.1.0 (/builds/tkn/teaching/pj2023w/practical-network-coding-with-esp32)
error: failed to run custom build command for `esp-idf-sys v0.33.7`
Caused by:
  process didn't exit successfully: `/builds/tkn/teaching/pj2023w/practical-network-coding-with-esp32/target/debug/build/esp-idf-sys-9f4c62a2e5e74fcb/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
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER
  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: None,
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: None,
      native: NativeConfig {
          esp_idf_version: None,
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: None,
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Error: Unsupported target 'x86_64-unknown-linux-gnu'
Cleaning up project directory and file based variables 00:06
ERROR: Job failed: exit code 1

Here is the relevant part with RUST_BACKTRACE=1:

esp@48abec0f69f5:~/practical-network-coding-with-esp32$ cargo build
   Compiling esp-idf-sys v0.33.7
error: failed to run custom build command for `esp-idf-sys v0.33.7`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/esp/practical-network-coding-with-esp32/target/debug/build/esp-idf-sys-9f4c62a2e5e74fcb/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
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER

  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: None,
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: None,
      native: NativeConfig {
          esp_idf_version: None,
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: None,
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Error: Unsupported target 'x86_64-unknown-linux-gnu'

  Stack backtrace:
     0: anyhow::error::<impl anyhow::Error>::msg
     1: build_script_build::native::cargo_driver::chip::Chip::detect
     2: build_script_build::native::cargo_driver::build
     3: build_script_build::native::build
     4: build_script_build::main
     5: core::ops::function::FnOnce::call_once
     6: std::sys_common::backtrace::__rust_begin_short_backtrace
     7: std::rt::lang_start::{{closure}}
     8: std::rt::lang_start_internal
     9: std::rt::lang_start
    10: main
    11: <unknown>
    12: __libc_start_main
    13: _start

After the failed compilation, there is no .embuild directory:

esp@48abec0f69f5:~/practical-network-coding-with-esp32$ ls -hartl
total 104K
-rw-r--r-- 1 esp esp  521 Nov  8 00:14 .editorconfig
drwxr-xr-x 2 esp esp 4.0K Nov  8 00:15 src
-rw-r--r-- 1 esp esp  465 Nov  8 00:15 sdkconfig.defaults
-rw-r--r-- 1 esp esp   28 Nov  8 00:15 rust-toolchain.toml
-rw-r--r-- 1 esp esp   53 Nov  8 00:15 build.rs
-rw-r--r-- 1 esp esp  841 Nov  8 00:15 README.md
-rw-r--r-- 1 esp esp  262 Nov  8 00:15 .gitlab-ci.yml
-rw-r--r-- 1 esp esp   48 Nov  8 00:15 .gitignore
drwx------ 1 esp esp 4.0K Nov  8 00:15 ..
drwxr-xr-x 8 esp esp 4.0K Nov  8 00:15 .git
-rw-r--r-- 1 esp esp  47K Nov  8 00:16 Cargo.lock
-rw-r--r-- 1 esp esp  859 Nov  8 00:26 Cargo.toml
drwxr-xr-x 5 esp esp 4.0K Nov  8 00:27 .
drwxr-xr-x 3 esp esp 4.0K Nov  8 00:27 target

I also tried to manually add embuild using cargo add, but that did not help. Other than that, I am not sure what could be the problem.

@github-project-automation github-project-automation bot moved this to Todo in esp-rs Nov 8, 2023
@Joku1806 Joku1806 changed the title esp-idf-svc fails to compile in idf-rust:esp32s3_1.73.0.1 docker image esp-idf-sys fails to compile in idf-rust:esp32s3_1.73.0.1 docker image Nov 8, 2023
@ivmarkov
Copy link
Collaborator

ivmarkov commented Nov 8, 2023

Build fails with:
Error: Unsupported target 'x86_64-unknown-linux-gnu',

I.e. you are trying to build esp-idf-sys for your host target, which is impossible. You should build with a target like xtensa-esp32-espidf or suchlike.

These targets are usually configured in .cargo/config.toml file inside your binary crate, but I actually don't see the .cargo directory in your project layout?

@Joku1806
Copy link
Author

Joku1806 commented Nov 8, 2023

Oh yeah, that seems to work.
I am very new to rust development and saw that .cargo is a dotfile and thought that everything build-related is defined in the Cargo.toml, so I immediately added it to the .gitignore without checking it first.

Sorry for the confusion, going to close this!

@Joku1806 Joku1806 closed this as completed Nov 8, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants