You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@SomeoneSerge Put this together a few days ago. Patchelf and replaceDependency a new glibc into place that will read $PREFIX/etc/ld.so.cache that is pre-populated using the contents of writeClosure.
withimport<nixpkgs>{};letwrap=drv:
let# Remove rpath from all binaries and set new interpreter with cachenew_drv=runCommand"${drv.name}-wrapped"{nativeBuildInputs=[pkgs.patchelfUnstable];}'' mkdir $out ln -st $out ${drv}/* rm -rf $out/bin mkdir -p $out/bin cp -r ${drv}/bin/* $out/bin/. chmod +w $out/bin/* for f in $out/bin/*; do patchelf --remove-rpath $f || true patchelf --set-interpreter ${new_glibc}/lib/${ifdrv.system=="x86_64-linux"then"ld-linux-x86-64.so.2"else"ld-linux-aarch64.so.1"} $f || true done '';# Replace self-references in glibcnew_glibc=replaceDependency{drv=new_glibc_pre;oldDependency=glibc.out;newDependency=new_glibc_pre;};# Create a new glibc derivation that has a targetet ld.so.cachenew_glibc_pre=buildEnv{name=pkgs.glibc.out.name;paths=[(pkgs.runCommand"something"{nativeBuildInputs=[pkgs.glibc.bin];}'' mkdir $out mkdir -p $out/etc mkdir -p $out/lib cp -R ${glibc.out}/* $out/ chmod +w $out/etc cat ${pkgs.writeClosuredrv} \ | xargs printf "%s\n" \ | xargs -I{} find {} -iname "lib*.so*" -execdir pwd \; \ | sort -u > $out/etc/ld.so.conf ldconfig -f $out/etc/ld.so.conf -C $out/etc/ld.so.cache '')];};innew_drv;inbuiltins.mapAttrs(name: drv: wrap(pkgs.lib.getBindrv))pkgs
AFAIU this implements a per-dso cache while reusing cache.nixos.org. How does this help with relocatability however?
P.S. Side note: I had struggled to figure out how to properly use replaceDependency and this is the first working example that I see. I expect transitive/propagated dependencies are still linking to the unwrapped interpreters?
Activity
tomberek commentedon Jun 26, 2024
@SomeoneSerge Put this together a few days ago. Patchelf and replaceDependency a new glibc into place that will read $PREFIX/etc/ld.so.cache that is pre-populated using the contents of writeClosure.
tomberek commentedon Jun 27, 2024
the loader supporting a "LD_CACHE_FILE" or similar would allow this to not require a such a wrapping
SomeoneSerge commentedon Jun 27, 2024
AFAIU this implements a per-dso cache while reusing cache.nixos.org. How does this help with relocatability however?
P.S. Side note: I had struggled to figure out how to properly use
replaceDependencyand this is the first working example that I see. I expect transitive/propagated dependencies are still linking to the unwrapped interpreters?