← index #962Issue #795
Off-topic · high · value 0.504
QUERY · ISSUE

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

openby hiwayopened 2025-01-11updated 2026-03-23

While using os.popen() from unix-ffi libraries on FreeBSD 14.1-RELEASE-p5 amd64, I encountered this error:

...
  File "os/__init__.py", line 32, in <module>
  File "ffilib.py", line 43, in libc
  File "ffilib.py", line 39, in open
  File "ffilib.py", line 33, in open
OSError: [Errno 2] ENOENT

On further investigation, I found that libc major version has been upgraded to 7, and ffilib.py is only looking for versions up to 6.

$ ls /lib/libc.so*
/lib/libc.so.7

https://github.com/micropython/micropython-lib/blob/e4cf09527bce7569f5db742cf6ae9db68d50c6a9/unix-ffi/ffilib/ffilib.py#L42

Changing the 6 to 7 fixed the issue.

Only making a note here since the readme for unix-ffi says: "This directory is unmaintained." and I would like to have a reference come up in searches when someone encounters the error.

4 comments
agatti · 2026-03-22

Indeed (as this also applies to 15.0-RELEASE). That's also something that needs to be changed in MicroPython's own test suite, along with other minor things like moving part of the default sys.path from /usr/lib/micropython to /usr/local/lib/micropython, and recognising FreeBSD as its own thing rather than classify that as Linux.

I believe some of these changes are already part of the patches in the ports tree, but last time I checked they still package a relatively old version. It won't hurt to have them in the source tree themselves.

dpgeorge · 2026-03-23

This is fixed in _libc but still needs to be fixed in ffilib.

agatti · 2026-03-23

Right! I can fix that right now but then I'd have to fix it again if https://github.com/micropython/micropython/pull/18979 gets merged. In ffilib there's a check for sys.platform and that PR will make it return freebsd, invalidating any small-scale change I'd make. I can also make it look for either linux or freebsd for the lookup to occur but then it'll take up bytes for nothing if that PR won't make the cut.

I don't mind submitting multiple PRs over time, but maybe you may want to schedule the changes differently.

dpgeorge · 2026-03-23

I can fix that right now but then I'd have to fix it again if micropython/micropython#18979 gets merged.

Yes, I see that now.

We are on the cusp of a release so can't make big changes. I think all this can be postponed until after the release.

CANDIDATE · ISSUE

os-path causes build conflict with unix_ffi os

openby osresearchopened 2024-02-02updated 2024-02-08

Building fails for the unix port when adding the glob package to the variant manifest with:

require("glob", unix_ffi=True)

glob's manifest requires os-path, without unix_ffi, and that in turns requires os also without unix_ffi:

require("os", unix_ffi=True)
require("os-path")

os-path's manifest requires os:

require("os")
package("os")

This causes a conflict with the os that has already been required with unix_ffi:

build-standard/frozen_content.c:20526:27: error: redefinition of ‘const_qstr_table_data_os___init__’
20526 | static const qstr_short_t const_qstr_table_data_os___init__[158] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build-standard/frozen_content.c:17919:27: note: previous definition of ‘const_qstr_table_data_os___init__’ was here
17919 | static const qstr_short_t const_qstr_table_data_os___init__[158] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
....

If I add unix_ffi=True to lib/micropython-lib/python-stdlib/os-path/manifest.py, then it is able to compile the frozen content.

2 comments
dpgeorge · 2024-02-07

If I add unix_ffi=True to lib/micropython-lib/python-stdlib/os-path/manifest.py, then it is able to compile the frozen content.

I don't think that's the correct solution because it will most likely break targets (eg bare-metal ports) that can't use the unix-ffi code.

One solution would be to make it ignore subsequent packages if one is already require'd by the same name. So in this case the unix_ffi os will take precedence because it's require'd first.

dpgeorge · 2024-02-08

Should be fixed by https://github.com/micropython/micropython/pull/13620

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied