Repository navigation
rootfs_script: on glibc, keep libstdc++ only when the image names it - #2867
Conversation
ssc338q_ultimate has failed on master since 4cc6476: rootfs.squashfs 8196/8192 KB (run 43742671078, job 132900013341). Its last pass was 8184 KB. Since this script was written (70c4ed5, 2023), every glibc board has kept libstdc++ whatever it links. On ssc338q_ultimate nothing does: no DT_NEEDED and no dlopen string anywhere in the image. zerotier-one, its only C++ program, carries its C++ runtime statically. Yet the image carries the 1.4 MB library, 427 KB of xz. A glibc board now keeps it only when some file on the image names libstdc++.so. That is a raw byte match, so it catches DT_NEEDED and dlopen()ed names and over-matches in the safe direction. As in prune-libnl.sh, the scan must first see libc.so somewhere before an empty result is trusted. musl/uClibc boards and the CONF keep-list are unchanged.
PR Summary by QodoPrune unreferenced libstdc++ from glibc root filesystems
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Libstdc++ removal lacks on-device proof
|
|
On the Qodo review:
|
|
CI: 150 firmware builds pass, among them every glibc board. |
`ssc338q_ultimate` has failed on master since 4cc6476 with `rootfs.squashfs: [8196KB/8192KB]` (run 43742671078, job 132900013341). Its last passing build was 8184 KB.
Dead weight. In the published `openipc.ssc338q-nor-ultimate` image (2026-11-14), `/usr/lib/libstdc++.so.6.0.32` is 1.4 MB, 427 KB of xz, and nothing on the image refers to it. No ELF has it as DT_NEEDED, and no file holds the string `libstdc++.so`. The only C++ program, zerotier-one, carries its C++ runtime statically (its NEEDED list is libatomic, libminiupnpc, libnatpmp, libm, libgcc_s, libc). It ships because `rootfs_script.sh` has kept libstdc++ on every glibc board unconditionally, since the script was first written in 70c4ed5 (2023), with no reason recorded.
Change. On a glibc board that matches none of the existing `CONF` keep-list entries, libstdc++ is now kept only if some file on the image names `libstdc++.so`. This is the same raw-byte test `prune-libnl.sh` uses: it catches DT_NEEDED and dlopen()ed names, and over-matches in the safe direction (a mere mention keeps it). It also requires the scan to see `libc.so` somewhere before it trusts an empty result. The `CONF` keep-list and the musl/uClibc behaviour are unchanged.
Checked locally against the extracted ssc338q_ultimate rootfs: it drops libstdc++. With a file added that names `libstdc++.so.6`, it keeps it.
The other glibc boards (av300, cv500, dv300, hi3536dv100, ssc30kq/kd, ssc338q_lite, rv11xx) keep libstdc++ where their vendor libraries link it, and lose it where nothing does. This PR touches the post-build script, so CI builds the full matrix and covers them.
Testing. This has not run on a camera; I have no glibc board here. What was checked: the extracted ssc338q_ultimate image, where no ELF lists libstdc++ in its dynamic section (readelf over every binary and library) and no file contains the string. DT_NEEDED entries are stored as plain strings, so a linked vendor library cannot slip past the byte scan. The only way to miss is a library name assembled at runtime from pieces. CI builds every glibc board, and any whose images reference libstdc++ will keep it.