Skip to content

unix-ffi/ffilib/ffilib.py: Extend libc versions range.#1122

Open
agatti wants to merge 1 commit into
micropython:masterfrom
agatti:freebsd-fixes
Open

unix-ffi/ffilib/ffilib.py: Extend libc versions range.#1122
agatti wants to merge 1 commit into
micropython:masterfrom
agatti:freebsd-fixes

Conversation

@agatti

@agatti agatti commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR extends the range of libc library versions that are looked up when required by user code.

FreeBSD 14.1-RELEASE and later versions require an update to the range since they bumped up their libc major version, from 6 to 7. This has the side-effect of guaranteeing at least one failed lookup on modern Linux systems, where the libc is still at version 6.

With updated FreeBSD support in MicroPython core, now sys.platform properly returns freebsd. This required a minor change in the code deciding whether to look for .so, .dylib, or .dll files, since linux is no longer the default fallback for generic unix systems.

(Hopefully) closes #962.

Testing

Using an interpreter built from MicroPython git master with require("ffilib") added to the manifest, import ffilib; ffilib.libc() was called making sure the function returned a valid ffimod object.

This was done manually both on a current Arch Linux/x64 system and on a FreeBSD 15.0-RELEASE x64 VM.

Trade-offs and Alternatives

This comes with a 13 bytes increase, mostly to hold the freebsd string in the MPY file itself.

Generative AI

I did not use generative AI tools when creating this PR.

This commit extends the range of libc library versions that are looked
up when required by user code.

FreeBSD 14.1-RELEASE and later versions require an update to the range
since they bumped up their libc major version, from 6 to 7.  This has
the side-effect of guaranteeing at least one failed lookup on modern
Linux systems, where the libc is still at version 6.

With updated FreeBSD support in MicroPython core, now `sys.platform`
properly returns `freebsd`.  This required a minor change in the code
deciding whether to look for `.so`, `.dylib`, or `.dll` files, since
`linux` is no longer the default fallback for generic unix systems.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>

@dpgeorge dpgeorge 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.

Looks good, thanks!

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.

Unix port: ffilib.py: libc.so.6 is no longer the latest version

2 participants