Skip to content

Problems with est-idf-sys on Mac m1 while building rust template example #1005

@samutigro

Description

@samutigro

I had problems with est-idf-sys on my Mac m1 while building rust template example, every time I tried to build the project it was failing with this error:

error: failed to run custom build command for esp-idf-sys v0.34.1`

Caused by:
process didn't exit successfully: /Users/samueleauteri/Desktop/Rust/template/target/debug/build/esp-idf-sys-5ad39a82e35dc1cd/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
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
cargo:rerun-if-changed=/Users/samueleauteri/Desktop/Rust/template/sdkconfig.defaults
CMAKE_PREFIX_PATH_xtensa-esp32-espidf = None
CMAKE_PREFIX_PATH_xtensa_esp32_espidf = None
TARGET_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_xtensa-esp32-espidf = None
CMAKE_xtensa_esp32_espidf = None
TARGET_CMAKE = None
CMAKE = None
running: cd "/Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out/build" && CMAKE_PREFIX_PATH="" EXTRA_COMPONENT_DIRS="" IDF_COMPONENT_MANAGER="1" IDF_PATH="/Users/samueleauteri/esp/esp-idf" IDF_TARGET="esp32" PATH="/Users/samueleauteri/esp/esp-idf/components/espcoredump:/Users/samueleauteri/esp/esp-idf/components/partition_table:/Users/samueleauteri/esp/esp-idf/components/app_update:/Users/samueleauteri/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/Users/samueleauteri/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/Users/samueleauteri/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/Users/samueleauteri/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/Users/samueleauteri/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/Users/samueleauteri/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/Users/samueleauteri/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/Users/samueleauteri/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/Users/samueleauteri/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/Users/samueleauteri/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/Users/samueleauteri/.espressif/python_env/idf5.2_py3.10_env/bin:/Users/samueleauteri/esp/esp-idf/tools:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/samueleauteri/.cargo/bin:/Library/flutter/bin:/Users/samueleauteri/.rvm/bin" PROJECT_DIR="/Users/samueleauteri/Desktop/Rust/template" SDKCONFIG_DEFAULTS="/Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out/gen-sdkconfig.defaults;/Users/samueleauteri/Desktop/Rust/template/sdkconfig.defaults" "cmake" "/Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=/Users/samueleauteri/esp/esp-idf/tools/cmake/toolchain-esp32.cmake" "-DCMAKE_BUILD_TYPE=" "-DPYTHON=/Users/samueleauteri/.espressif/python_env/idf5.2_py3.10_env/bin/python" "-DCMAKE_INSTALL_PREFIX=/Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out" "-DCMAKE_C_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections --target=xtensa-esp32-espidf" "-DCMAKE_CXX_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections --target=xtensa-esp32-espidf" "-DCMAKE_ASM_FLAGS= -mlongcalls -ffunction-sections -fdata-sections --target=xtensa-esp32-espidf"
-- Found Git: /opt/homebrew/bin/git (found version "2.44.0")
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc
-- Check for working C compiler: /Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc - broken
-- Configuring incomplete, errors occurred!

--- stderr
Build configuration: BuildConfig {
esp_idf_tools_install_dir: None,
esp_idf_sdkconfig: None,
esp_idf_sdkconfig_defaults: None,
mcu: Some(
"esp32",
),
native: NativeConfig {
esp_idf_version: Some(
Tag(
"v5.2",
),
),
esp_idf_repository: None,
esp_idf_cmake_generator: None,
idf_path: Some(
"/Users/samueleauteri/esp/esp-idf",
),
extra_components: [],
esp_idf_components: None,
esp_idf_component_manager: None,
},
esp_idf_sys_root_crate: None,
}
Using activated esp-idf v5.2.0 environment at '/Users/samueleauteri/esp/esp-idf'
CMake Error at /opt/homebrew/Cellar/cmake/3.28.3/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

  "/Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

  Change Dir: '/Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out/build/CMakeFiles/CMakeScratch/TryCompile-5oGRPm'
  
  Run Build Command(s): /opt/homebrew/bin/ninja -v cmTC_26079
  [1/2] /Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address  -ffunction-sections -fdata-sections --target=xtensa-esp32-espidf -o CMakeFiles/cmTC_26079.dir/testCCompiler.c.obj -c /Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out/build/CMakeFiles/CMakeScratch/TryCompile-5oGRPm/testCCompiler.c
  FAILED: CMakeFiles/cmTC_26079.dir/testCCompiler.c.obj 
  /Users/samueleauteri/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address  -ffunction-sections -fdata-sections --target=xtensa-esp32-espidf -o CMakeFiles/cmTC_26079.dir/testCCompiler.c.obj -c /Users/samueleauteri/Desktop/Rust/template/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-e7fbd4070e43cbc1/out/build/CMakeFiles/CMakeScratch/TryCompile-5oGRPm/testCCompiler.c
  xtensa-esp-elf-gcc: error: unrecognized command-line option '--target=xtensa-esp32-espidf'
  ninja: build stopped: subcommand failed.
  
  



CMake will not be able to correctly generate this project.

Call Stack (most recent call first):
/Users/samueleauteri/esp/esp-idf/tools/cmake/project.cmake:506 (__project)
CMakeLists.txt:28 (project)

thread 'main' panicked at /Users/samueleauteri/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

command did not execute successfully, got: exit status: 1

build script failed, must exit now
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace`

I made it work following https://github.com/esp-rs/esp-idf-sys/issues/287

[patch.crates-io]
cc = { git = "https://github.com/rust-lang/cc-rs", tag = "1.0.83" }

this + a cargo update fixed everything

Activity

NobodyXu

NobodyXu commented on Mar 9, 2024

@NobodyXu
Collaborator

Thanks for reporting, may I ask what command is used and how to reproduce it?

samutigro

samutigro commented on Mar 9, 2024

@samutigro
Author

Thanks for reporting, may I ask what command is used and how to reproduce it?

i was using this template https://github.com/esp-rs/esp-idf-template and I was failing after launching cargo build

NobodyXu

NobodyXu commented on Mar 10, 2024

@NobodyXu
Collaborator

@samutigro can you try cc::Build::no_default_flags (can be set by environment variables CRATE_CC_NO_DEFAULTS)?

madsmtm

madsmtm commented on Mar 10, 2024

@madsmtm
Collaborator

Am having the same issue, can confirm that compiling with CRATE_CC_NO_DEFAULTS=1 works.

NobodyXu

NobodyXu commented on Mar 17, 2024

@NobodyXu
Collaborator

It seems like #1000 might fix this issue, can anyone have a try of that PR please?

jwhitlark

jwhitlark commented on Apr 8, 2024

@jwhitlark

I ran into this issue while following the embedded rust on Espressif tutorial, specifically here. I confirm that CRATE_CC_NO_DEFAULTS=1 cargo run works, and flashes the board and correctly starts it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-appleApple targets and toolchains

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jwhitlark@madsmtm@NobodyXu@samutigro

        Issue actions

          Problems with `est-idf-sys` on Mac m1 while building rust template example · Issue #1005 · rust-lang/cc-rs