Using cxx crate with xtensa-esp32 target

⚓ rust    📅 2025-06-13    👤 surdeus    👁️ 2      

surdeus

Hello,

I've been trying to compile a rust project for the xtensa-esp32s3-espidf target. I set up the project as documented here: Understanding esp-idf-template - The Rust on ESP Book

As part of this project, I'm also trying to compile a library written in c++, so I included the cxx crate.

However, simply including cxx as a dependency broke the build of my project, which was otherwise working fine.

The error is:

$ cargo build
   Compiling esp-idf-sys v0.36.1
   Compiling link-cplusplus v1.0.10
warning: link-cplusplus@1.0.10: error: unknown target triple 'xtensa-unknown-none-elf'
error: failed to run custom build command for `link-cplusplus v1.0.10`

Caused by:
  process didn't exit successfully: `/Users/mattsains/dev/esp-idf-test/target/debug/build/link-cplusplus-2037f0428263751b/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=build.rs
  OUT_DIR = Some(/Users/mattsains/dev/esp-idf-test/target/xtensa-esp32s3-espidf/debug/build/link-cplusplus-1cda7d002a87c738/out)
  OPT_LEVEL = Some(s)
  TARGET = Some(xtensa-esp32s3-espidf)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CXX_xtensa-esp32s3-espidf
  CXX_xtensa-esp32s3-espidf = None
  cargo:rerun-if-env-changed=CXX_xtensa_esp32s3_espidf
  CXX_xtensa_esp32s3_espidf = None
  cargo:rerun-if-env-changed=TARGET_CXX
  TARGET_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(ldproxy)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CXXFLAGS
  TARGET_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS_xtensa_esp32s3_espidf
  CXXFLAGS_xtensa_esp32s3_espidf = None
  cargo:rerun-if-env-changed=CXXFLAGS_xtensa-esp32s3-espidf
  CXXFLAGS_xtensa-esp32s3-espidf = None
  CARGO_ENCODED_RUSTFLAGS = Some(--cfgespidf_time64)
  cargo:warning=error: unknown target triple 'xtensa-unknown-none-elf'

  --- stderr


  error occurred in cc-rs: command did not execute successfully (status code exit status: 1): LC_ALL="C" "c++" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=xtensa-none-elf" "-Wall" "-Wextra" "-o" "/Users/mattsains/dev/esp-idf-test/target/xtensa-esp32s3-espidf/debug/build/link-cplusplus-1cda7d002a87c738/out/a44812d996fcf38b-dummy.o" "-c" "/Users/mattsains/dev/esp-idf-test/target/xtensa-esp32s3-espidf/debug/build/link-cplusplus-1cda7d002a87c738/out/dummy.cc"

I thought it a bit suspicious that it says the unknown target triple is xtensa-unknown-none-elf because I was expecting something like xtensa-esp32s3-espidf-elf but I can't figure out whether I need to set this somewhere and how to set it.

2 posts - 2 participants

Read full topic

🏷️ rust_feed