Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build against an older libc, keep the newest in the runtime closure #303405

Open
SomeoneSerge opened this issue Apr 11, 2024 · 5 comments
Open

Build against an older libc, keep the newest in the runtime closure #303405

SomeoneSerge opened this issue Apr 11, 2024 · 5 comments
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs 6.topic: cuda Parallel computing platform and API

Comments

@SomeoneSerge
Copy link
Contributor

SomeoneSerge commented Apr 11, 2024

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:

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 libc2305LD_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_PRIVATELD_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

  1. https://discourse.nixos.org/t/help-understanding-the-libgl-abi-problem-and-possible-solutions/42022/21

@SomeoneSerge SomeoneSerge added the 6.topic: architecture Relating to code and API architecture of Nixpkgs label Apr 11, 2024
@nixos-discourse
Copy link

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

@SomeoneSerge SomeoneSerge changed the title 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 Apr 11, 2024
@SomeoneSerge SomeoneSerge added the 6.topic: cuda Parallel computing platform and API label Apr 11, 2024
@nixos-discourse
Copy link

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
Copy link

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

This comment was marked as duplicate.

@kjeremy
Copy link
Contributor

kjeremy commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: architecture Relating to code and API architecture of Nixpkgs 6.topic: cuda Parallel computing platform and API
Projects
Status: New
Development

No branches or pull requests

3 participants