Skip to content

C compiled by with cc on Linux stays at the glibc floor: a build system's probe for a newer function no longer links - #3604

Merged
ehartford merged 2 commits into
mainfrom
glibc-floor-stubs
Nov 25, 2026
Merged

ehartford merged 2 commits into
mainfrom
glibc-floor-stubs

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #3603.

The bug. On Linux a C library that with get builds from source could need a newer glibc than the machine that built it. curl's configure asked whether memset_explicit (glibc 2.43) exists; the SDK's link stubs answered yes; curl called it; the program then did not start on glibc 2.39 (version GLIBC_2.43 not found).

Root cause. build/sdk.with, sdk_glibc_stub_sources: a symbol with no version at or below the 2.28 pin is made the default version (if default_ver < 0 and not floor_any: default_ver = newest), so that a prebuilt archive compiled against a newer glibc links. A probe is the same kind of reference, an unversioned one.

The fix. A second stub directory, usr/lib/floor, and with cc searches it first.

  • It is derived when the sysroot is packed (sdk_write_floor_stubs), from the stubs already there: each library is copied with the hidden bit set on every .gnu.version entry whose version is above the pin. Such a symbol is then present only by its versioned name. No SDK is regenerated or republished, and a sysroot copied out of an SDK built before this gets the directory too.
  • A few names stay default: the ones a compile against a newer glibc reaches without asking (stat, fstat, lstat, fstatat and their 64 forms, mknod, mknodat, __isoc23_*, __libc_single_threaded, _dl_find_object). An archive built there has no other spelling to offer.
  • A With program's own link reads usr/lib as before, so a prebuilt archive that names a newer function still links there.

One consequence to know: a with cc link of a prebuilt archive that calls a newer function by choice (not one of the kept names) now fails, naming the symbol, where it used to link and then need that glibc.

Tests. test/host_toolchain/cc_floor_probe.c (CMake's probe shape for memset_explicit) must not link; cc_floor_kept.c must. Both run in :no-host-toolchain on Linux.

Evidence (5e4d520 unless noted)

  • linux-aarch64 (container): build green; the probe fails with undefined symbol: memset_explicit; the kept names link and run; cc_hello.c builds and runs; with get c.zlib builds. At the first commit, the libcurl release scenario (a copy, with the recipe's TLS option set to mbedtls by a throwaway override that never left the container) passes all seven steps including the HTTPS run, and the rebuilt libcurl.a has no reference to memset_explicit. Before the fix that same run stopped at GLIBC_2.43 not found.
  • linux-x86_64 (eric-5090, fresh clone, first commit a6586be): build green from the SDK-copied sysroot; same three results; :no-host-toolchain green with both new lines in its verdict. The second commit changes spelling only (the ceremony census), and the seed checks build.with.
  • macOS: battery green.

:no-host-toolchain cannot run inside the Docker leg (its sandbox needs a namespace Docker refuses), which is why the aarch64 fixtures were run directly.

Eric Hartford added 2 commits November 24, 2026 22:33
…hold a function newer than the pin only by its versioned name, so a build system's probe for one does not link (#3603)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant