Skip to content

Conversation

@ivmarkov
Copy link
Collaborator

@ivmarkov ivmarkov commented Jan 16, 2026

Addresses #98

Turns out, inventing a generic, cross-platform "sysroot" for clang+esp-mbedtls is so simple, that it does not make any sense to compile with GCC by default, and thus ask users to install the (cross) GCC toolchain for their target.

This suddenly makes on-the-fly compilation of esp-mbedtls so much eaiser!

We can just tell users: "install your system clang"*.

(*)
Caveat 1: System clang (sudo apt-get install clang) won't work for xtensa targets until after upstream llvm (and thus clang) get support for the xtensa targets. But in the meantime, espup would do.
Caveat 2: Users would also need cmake + ninja pre-installed. For now. But this is also no big deal.

It would have been so nice to have rustup distribute clang as well, but it seems this effort had died: rust-lang/rust#56371

@ivmarkov ivmarkov force-pushed the clang-build branch 2 times, most recently from b11667b to 4e6caa3 Compare January 16, 2026 15:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR transitions the esp-mbedtls build system from using GCC by default to using clang. It introduces a custom, cross-platform sysroot to eliminate the dependency on target-specific GCC toolchains for C header files. This significantly simplifies the build process by allowing users to use any system-installed clang for cross-compilation.

Changes:

  • Made clang the default compiler with GCC now optional via use-gcc feature
  • Created a minimal cross-platform sysroot in esp-mbedtls-sys/gen/sysroot/ with essential headers
  • Added tinyrlibc dependency to ESP examples to provide runtime C library functions
  • Updated generated bindings to remove GCC-specific type definitions and reduce code size
  • Renamed force-esp-riscv-toolchain feature to force-esp-riscv-gcc for clarity

Reviewed changes

Copilot reviewed 17 out of 40 changed files in this pull request and generated no comments.

Show a summary per file
File Description
xtask/src/main.rs Updated CLI to add --gcc flag and renamed force-esp-riscv-toolchain to force-esp-riscv-gcc
examples/esp/*.rs Added tinyrlibc imports to all ESP example binaries
examples/esp/Cargo.toml Added tinyrlibc dependency with memchr feature
esp-mbedtls/Cargo.toml Added use-gcc feature and renamed force-esp-riscv-toolchain
esp-mbedtls-sys/src/include/*.rs Simplified generated bindings by removing GCC-specific types and definitions
esp-mbedtls-sys/src/accel/esp.rs Made static variables public and added nohook feature flag support
esp-mbedtls-sys/gen/sysroot/include/*.h Added minimal sysroot headers using compiler builtins
esp-mbedtls-sys/gen/builder.rs Added clang sysroot support and updated C compiler argument generation
esp-mbedtls-sys/build.rs Updated to use clang by default with sysroot path
esp-mbedtls-sys/README.md Updated documentation to reflect clang as default
.github/workflows/ci.yml Updated PATH to include clang binaries and removed -e flags from xtask commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This was referenced Jan 16, 2026
Copy link
Collaborator

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome that we need that little for a suitable mini-sysroot

@ivmarkov ivmarkov merged commit a9e807a into main Jan 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants