Skip to content

Building with esp-id-sys/std fails on nightly in linux due to missing O_NOFOLLOW #389

@eteq

Description

@eteq

Bug description

When I start a new project based on the RISCV/nightly rust toolchain, I get an error about a missing symbol from libc in the build of std (exact message below). I think the origin of this is rust-lang/rust@9c46cdb, which introduced the use of O_NOFOLLOW in std. A workaround that fixes it is to use nightly-2025-08-19 as the toolchain, which is the last one before the offending commit was merged.

The catch is: I don't really understand why this is failing, which is why I'm reporting it here instead of upstream. It still might be an upstream bug of course, but if I make a non-esp-idf-sys-based project everything works fine even on the latest nightly. That said, I really don't understand the std-building process well enough to know for sure how widespread this problem. Happy to try some more troubleshooting if someone offers guidance, though.

exact error message

error[E0425]: cannot find value `O_NOFOLLOW` in crate `libc`
   --> /home/esp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/fs/mod.rs:122:43
    |
122 |     OpenOptions::new().custom_flags(libc::O_NOFOLLOW).open(path)?.set_permissions(perm)
    |                                           ^^^^^^^^^^ not found in `libc`

For more information about this error, try `rustc --explain E0425`.
  • Would you like to work on a fix? maybe

To Reproduce

  1. use the esp-idf-template to make a esp-idf-sys/std-based esp crate
  2. set everything up following the default instructions in the rust on esp book (I used the devcontainer, but I got identical results on a system set up similarly)
  3. run cargo check

Expected behavior

The build should succeed

Environment

  • Crate (esp-idf-sys) version: master
  • ESP-IDF branch or tag: 5.3
  • Target device (MCU): esp32c6 or probably anything RISCV that uses nightly
  • OS: nixos

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions