Skip to content

espidf: Don't declare flock - #5660

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
vignesh-chaturvedi:espidf-no-flock
Oct 26, 2026
Merged

tgross35 merged 1 commit into
rust-lang:mainfrom
vignesh-chaturvedi:espidf-no-flock

Conversation

@vignesh-chaturvedi

Copy link
Copy Markdown
Contributor

This PR stops declaring flock for target_os = "espidf".

Both newlib and picolibc declare flock in sys/_default_fcntl.h, but I couldn't find an implementation in either library or ESP-IDF. Using flock on this target would therefore result in a linker error. ivmarkov also confirmed that ESP-IDF does not support it and suggested excluding it for this target (discussion).

Fixes rust-lang/libc#4723. Emscripten and Redox will keep flock in libc, as Ralf suggested that the symbols should remain available even though their implementations are incorrect.

I've kept flock in libc-test/semver/unix.txt. ESP-IDF isn't built in CI, so the API list isn't checked against that target. Solaris only passes that check because it has a struct flock.

Testing

Ran:

RUSTFLAGS=-Dwarnings cargo +nightly check -Zbuild-std=core --target riscv32imc-esp-espidf

libc::flock no longer resolves on ESP-IDF.

ESP-IDF's newlib and picolibc headers declare `flock`, but
neither provides an implementation, so using it results in a
linker error.

An ESP-IDF maintainer confirmed this in rust-lang#4723.

Exclude `flock` for ESP-IDF, as is already done for Solaris.

Link: https://github.com/espressif/newlib-esp32/blob/437b547d4dcb3255e03e10d1ea0def24a6757da4/newlib/libc/include/sys/_default_fcntl.h#L221-L223
Link: https://github.com/espressif/picolibc/blob/b955d786c04a5375cee4671605a28b498bec738d/newlib/libc/include/sys/_default_fcntl.h#L221-L223
Link: rust-lang#4723 (comment)
Assisted-by: LLM
@rustbot

rustbot commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35

Copy link
Copy Markdown
Member

Cc @ivmarkov, this is what you suggested in #4723 (comment)

@tgross35 tgross35 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is fine, thank you!

View changes since this review

@tgross35
tgross35 added this pull request to the merge queue Oct 26, 2026
@ivmarkov

Copy link
Copy Markdown
Contributor

@tgross35 Thank you for your fast reaction!

Unfortunately, the fix needs to reach Rust STD as well, or in other words, we need a libc 0.2 release (and then I can PR a libc version bump to the Cargo.toml of STD).

Is there anything I can help with to expedite this?

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Oct 26, 2026
@tgross35

Copy link
Copy Markdown
Member

I added the nominated label (for future reference can be added via rustbot) but what needs to be updated in std? It can't be using flock on espidf today, otherwise that would be a linker failure IIUC.

Merged via the queue into rust-lang:main with commit e747b1a Oct 26, 2026
60 checks passed
@ivmarkov

Copy link
Copy Markdown
Contributor

I added the nominated label (for future reference can be added via rustbot) but what needs to be updated in std? It can't be using flock on espidf today, otherwise that would be a linker failure IIUC.

@tgross35
Ahhh.... sorry - I confused this issue with #5662. When (or if) #5662 is merged, then we would need a new libc 0.2 release.

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

Labels

O-unix stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove flock where not supported

4 participants