← index #17399PR #17695
Related · high · value 0.930
QUERY · ISSUE

docs: pots/unix (standalone) has no instructions to build static linked micropython instance

openby o-murphyopened 2025-05-30updated 2025-07-07
docsport-unix

Documentation URL

https://github.com/micropython/micropython/blob/master/ports/unix/README.md

Description

The ports/unix instructions not provide a way to build micropython with LDFLAGS -static to link ld statically. So even if you trying to build standalone binary it still build dynamic linked instance (e.g. ld.so.1). Dynamic linking to system ld.so.1 makes impossible to run binary on systems like Buildroot Linux

For make fully standalone static linked build you should directly modify Makefile cause make not handle LDFLAGS and docs not give instructions for this case.

Relative to issue: https://github.com/micropython/micropython/issues/17353

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

unix/make: Fix 32bit libffi path.

openby yf13opened 2025-07-17updated 2025-08-01
port-unix

<!-- Thanks for submitting a Pull Request! We appreciate you spending the
time to improve MicroPython. Please provide enough information so that
others can review your Pull Request.

 Before submitting, please read:
 https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md
 https://github.com/micropython/micropython/wiki/ContributorGuidelines

 Please check any CI failures that appear after your Pull Request is opened.

-->

Summary

<!-- Explain the reason for making this change. What problem does the pull request
solve, or what improvement does it add? Add links if relevant. -->

This fixes libffi.a link error when building 32bit standalone UNIX port on Ubuntu 22.04:

$ make -C ports/unix MICROPY_STANDALONE=1 MICROPY_FORCE_32BIT=1 CC=i686-linux-gnu-gcc CXX=i686-linux-gnu-g++ deplibs
$ make -C ports/unix MICROPY_STANDALONE=1 MICROPY_FORCE_32BIT=1 CC=i686-linux-gnu-gcc CXX=i686-linux-gnu-g++
...
LINK build-standard/micropython
/usr/lib/gcc-cross/i686-linux-gnu/11/../../../../i686-linux-gnu/bin/ld: cannot find build-standard/lib/libffi/out/lib32/libffi.a: No such file or directory
collect2: error: ld returned 1 exit status

Testing

<!-- Explain what testing you did, and on which boards/ports. If there are
boards or ports that you couldn't test, please mention this here as well.

 If you leave this empty then your Pull Request may be closed. -->

Checked on Ubuntu 22.04 like:

$ make -C ports/unix MICROPY_STANDALONE=1 MICROPY_FORCE_32BIT=1 CC=i686-linux-gnu-gcc CXX=i686-linux-gnu-g++ deplibs
$ make -C ports/unix MICROPY_STANDALONE=1 MICROPY_FORCE_32BIT=1 CC=i686-linux-gnu-gcc CXX=i686-linux-gnu-g++
...
LINK build-standard/micropython
   text      data       bss       dec       hex   filename
 743657     35968      2788    782413     bf04d   build-standard/micropython
$ file ports/unix/build-standard/micropython
ports/unix/build-standard/micropython: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=3c107769fefd7b467ca0b095ad1c6d28b1702826, for GNU/Linux 3.2.0, stripped
$ ldd ports/unix/build-standard/micropython
     linux-gate.so.1 (0xf7f7b000)
     libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7d8f000)
     libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7a00000)
     /lib/ld-linux.so.2 (0xf7f7d000)

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