Skip to content

fix(cbor): Fix build with picolibc (IEC-512)#718

Open
abobija wants to merge 1 commit intoespressif:masterfrom
abobija:cbor-fix-picolibc
Open

fix(cbor): Fix build with picolibc (IEC-512)#718
abobija wants to merge 1 commit intoespressif:masterfrom
abobija:cbor-fix-picolibc

Conversation

@abobija
Copy link
Copy Markdown

@abobija abobija commented Apr 2, 2026

Checklist

  • Component contains License
  • Component contains README.md
  • Component contains idf_component.yml file with url field defined
  • Component was added to upload job
  • Component was added to build job
  • Optional: Component contains unit tests
  • CI passing

Change description

Build of project that uses espressif/cbor^0.6.1~4 component and picolibc (with idf v6+) fails since picolibc does not have implementation of fopencookie function and cookie_io_functions_t typedef.

By defining __APPLE__ we are switching to picolibc supported funopen alternative that makes project successfully compiled on idf v6+ using picolibc. Note that CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY still needs to be enabled to compile with picolibc, even if we switch to __APPLE__.

It would be nice if cbor component could work without defining CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY and rely completely on picolibc without any hacks.

I've opened a PR in origin tinycbor's repo as well to support picolibc, so maybe we will accomplish something:
intel/tinycbor#319

Maybe to wait if intel's tinycbor is going to support picolibc...

Build of project that uses `espressif/cbor^0.6.1~4` component
fails with esp-idf v6.0+ using picolibc since picolibc does
not have implementation of fopencookie function.
By defining `__APPLE__` we are switching to
picolibc supported `funopen` alternative.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot changed the title cbor: Fix build for idf v6+ and picolibc cbor: Fix build for idf v6+ and picolibc (IEC-512) Apr 2, 2026
@abobija abobija changed the title cbor: Fix build for idf v6+ and picolibc (IEC-512) cbor: Fix build for picolibc (IEC-512) Apr 2, 2026
@abobija abobija changed the title cbor: Fix build for picolibc (IEC-512) fix(cbor): Fix build with picolibc (IEC-512) Apr 2, 2026
@mahavirj
Copy link
Copy Markdown
Member

@Lapshin PTAL

@Lapshin
Copy link
Copy Markdown
Collaborator

Lapshin commented Apr 20, 2026

@abobija , thanks for the PR.

Note that CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY still needs to be enabled to compile with picolibc, even if we switch to APPLE.

Could you please elaborate on why it still needs to be enabled?
Regardless of whether this is required, I don't consider this change valuable. Rather than defining __APPLE__, __linux__, __windows__, and other unrelated macros (ESP32 does not fall under any of these), the original https://github.com/intel/tinycbor sources should detect the availability of libc functions in their configure script (or whatever mechanism they use for this purpose).

@Lapshin
Copy link
Copy Markdown
Collaborator

Lapshin commented Apr 20, 2026

@abobija , I thought that commit espressif/esp-idf@51f1861 exists for v6.0, but for some reason is present only in master branch. Will make a backport

@Lapshin
Copy link
Copy Markdown
Collaborator

Lapshin commented Apr 20, 2026

espressif/esp-idf@ae8d484 in release/v6.0 branch. It just did not add in time for v6.0 release. Should be released with bugfix version v6.0.1

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants