Repository navigation
Description
Issue description
Libc and libstdc++ compatibility is a dominating factor in how severe is the effect of allowing impure dependencies such as OpenGL, OpenCL, Vulkan, or CUDA drivers. Ultimately, the heuristic is: build against the oldest library you can, load the most recent at runtime. This practice is widely followed in other distributions and is important e.g. for the "manywheel" standard in python packaging.
Currently, Nixpkgs pins a single fairly recent version of glibc and builds every package against that. A suggestion that has been at least occasionally voiced is to invest time in "making [OpenGL] binaries less demanding in regards to the glibc version"1.
Forgetting about maintenance costs for a moment, one can also see it would benefit downstream applications to start generally tracking each package's lowest compatible glibc - by building against it -, while ensuring that only one version - the newest - is ever referred to in runtime closures. For example, if such a mechanism were in place it would've been "trivial" to use Nix to create "manywheel" releases of python packages.
It would be (?) a reasonable starting point to implement an easy to use stdenvAdapters-like mechanism for separating the lib(std)c(++) used at build time from the one recorded in final RUNPATHs, LD_LIBRARY_PATHs, ld.so.cache-s, etc. We can test such mechanism by first applying it to our impure drivers
EDIT(2024-08-12): Apparently there's also the matter of which ld.so to use:
Details
❯ nix build github:NixOS/nixpkgs/nixos-23.05#hello -o hello2305
❯ nix build github:NixOS/nixpkgs/master#glibc.lib -o libc2411
❯ nix build github:NixOS/nixpkgs/master#glibc.out -o libc2411
❯ nix build github:NixOS/nixpkgs/master#hello -o hello2411
❯ nix build github:NixOS/nixpkgs/nixos-23.05#glibc.out -o libc2305
❯ LD_LIBRARY_PATH="$(readlink -f $PWD/libc2305/lib)" LD_DEBUG=libs ./hello2305/bin/hello # Expected success
...
Hello, world!
❯ LD_LIBRARY_PATH="$(readlink -f $PWD/libc2411/lib)" LD_DEBUG=libs ./hello2411/bin/hello # Expected success
...
Hello, world!
❯ LD_LIBRARY_PATH="$(readlink -f $PWD/libc2305/lib)" LD_DEBUG=libs ./hello2411/bin/hello # Expected failure
...
*** stack smashing detected ***: terminated
...
❯ LD_LIBRARY_PATH="$(readlink -f $PWD/libc2411/lib)" LD_DEBUG=libs ./hello2305/bin/hello # Unexpected failure
...
2943758: /nix/store/0wydilnf1c9vznywsvxqnaing4wraaxp-glibc-2.39-52/lib/libc.so.6: error: symbol lookup error: undefined symbol: __tunable_is_initialized, version GLIBC_PRIVATE (fatal)
./hello2305/bin/hello: symbol lookup error: /nix/store/0wydilnf1c9vznywsvxqnaing4wraaxp-glibc-2.39-52/lib/libc.so.6: undefined symbol: __tunable_is_initialized, version GLIBC_PRIVATE
❯ LD_LIBRARY_PATH="$(readlink -f $PWD/libc2411/lib)" LD_DEBUG=libs ./libc2411/lib/ld-linux-x86-64.so.2 "$(readlink -f ./hello2305/bin/hello)"
...
Hello, world!Footnotes
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNew
Activity
nixos-discourse commentedon Apr 11, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/help-understanding-the-libgl-abi-problem-and-possible-solutions/42022/26
[-]Provide a mechanism to build against an old glibc but link the newest in DT_RUNPATHs[/-][+]Build against an older libc, keep the newest in the runtime closure[/+]nixos-discourse commentedon Apr 23, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/libc-version-is-different-before-and-after-nix-shell-p/43946/3
nixos-discourse commentedon Aug 12, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/review-of-333575/50496/2
kjeremy commentedon Aug 21, 2024
kjeremy commentedon Aug 30, 2024
@SomeoneSerge Is there a plan to do this or an outline of the steps needed? I am running into this issue building software against 22.05 (that I cannot easily upgrade) and running on 24.04.
de11n commentedon Dec 28, 2025
One option would be to use Zig as the C/C++ compiler. Zig supports targeting specific glibc versions. Zicross has some prior art.
Atemu commentedon Dec 31, 2025
Honestly, this should just be some sort of config option when linking against glibc.
Just like Android's target and min SDK versions.
de11n commentedon Jan 2, 2026
glibcdoesn't support that, but Zig's toolchain has patches to glibc headers that enable it. It could be possible to use Zig's patched glibc headers directly without actually using Zig's toolchain. But that would be further off-the-beaten-path.