Skip to content

[staging-next] patchelf: revert to previous version temporarily in notable cases - #574271

Merged
zowoq merged 2 commits into
NixOS:staging-nextfrom
vcunat:p/patchelf-hacks
Oct 15, 2026
Merged

zowoq merged 2 commits into
NixOS:staging-nextfrom
vcunat:p/patchelf-hacks

Conversation

@vcunat

@vcunat vcunat commented Oct 15, 2026

Copy link
Copy Markdown
Member

Things done

@vcunat

vcunat commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

I was tempted to add a top-level attribute for a different patchelf, but the version override is relatively simple.

@vcunat vcunat mentioned this pull request Oct 15, 2026
13 tasks
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: stdenv Standard environment labels Oct 15, 2026
@zowoq
zowoq added this pull request to the merge queue Oct 15, 2026
Merged via the queue into NixOS:staging-next with commit 0825629 Oct 15, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Stdenv Oct 15, 2026
@magneticflux-

magneticflux- commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The bump to 0.19.2 also broke cudaPackages_12_9.cuda_nvcc, I added a similar patch to these to fix it temporarily.

NIXPKGS_ALLOW_UNFREE=1 nix build --impure nixpkgs#cudaPackages_12_9.cuda_nvcc
Build log for nixpkgs#cudaPackages_12_9.cuda_nvcc
got build log for '/nix/store/75jzrcn149zqv3ap1af9svl9hxzgmhr2-cuda12.9-cuda_nvcc-12.9.86.drv' from 'daemon'
structuredAttrs is enabled
source: sourcing buildRedistHook.bash (hostOffset=-1) (targetOffset=0)
buildRedistHookRegistration: added unpackCudaLibSubdir to postUnpackHooks
buildRedistHookRegistration: added unpackCudaPkgConfigDirs to postUnpackHooks
buildRedistHookRegistration: added patchCudaPkgConfig to prePatchHooks
buildRedistHookRegistration: added checkCudaNonEmptyOutputs to postInstallCheckHooks
buildRedistHookRegistration: added fixupCudaPropagatedBuildOutputsToOut to postFixupHooks
buildRedistHookRegistration: added checkCudaHasStubsIffIncludeRemoveStubsFromRunpathHook to postFixupHooks
Sourcing auto-add-driver-runpath-hook
Using autoAddDriverRunpath
Sourcing fix-elf-files.sh
Sourcing mark-for-cudatoolkit-root-hook
Running phase: unpackPhase
@nix {"action":"setPhase","phase":"unpackPhase"}
unpacking source archive /nix/store/1m2f4x6wri3iqfr3y7m9disidvjwlzz7-cuda_nvcc-12.9.86-source
source root is cuda_nvcc-12.9.86-source
Running phase: patchPhase
@nix {"action":"setPhase","phase":"patchPhase"}
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix {"action":"setPhase","phase":"updateAutotoolsGnuConfigScriptsPhase"}
Running phase: configurePhase
@nix {"action":"setPhase","phase":"configurePhase"}
no configure script, doing nothing
Running phase: installPhase
@nix {"action":"setPhase","phase":"installPhase"}
runPhase: moving tree to output out
postInstall: moving /build/cuda_nvcc-12.9.86-source/nvvm to /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86 and renaming lib64 to lib
renamed '/nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/lib64' -> '/nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/lib'
postInstall: removing $(_TARGET_SIZE_) from nvcc.profile
postInstall: patching nvcc.profile to use the correct include paths
postInstall: patching nvcc.profile to use the correct NVVM paths
postInstall: adding /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm to nvcc.profile
postInstall: setting compiler-bindir to backendStdenv.cc in nvcc.profile
postInstall: wrapping nvcc to add backendStdenv.cc to its PATH
postInstall: Patching math_functions.h signatures to match glibc's ones
postInstall: Patching math_functions.hpp signatures to match glibc's ones
postInstall: Patching host_defines.h to skip __noinline__ macro under clang
Running phase: fixupPhase
@nix {"action":"setPhase","phase":"fixupPhase"}
shrinking RPATHs of ELF executables and libraries in /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/lib/libnvvm.so.4.0.0
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/bin/cicc
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/cudafe++
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/ptxas
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/.nvcc-wrapped
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvlink
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/fatbinary
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/bin2c
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/__nvcc_device_query
shrinking /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvcc
checking for references to /build/ in /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86...
patching script interpreter paths in /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86
stripping (with command strip and flags -S -p) in /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/lib /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin
automatically fixing dependencies for ELF files
{'add_existing': True,
 'append_rpaths': [PosixPath('$ORIGIN')],
 'extra_args': [],
 'ignore_missing': [],
 'keep_libc': False,
 'libs': [PosixPath('/nix/store/7a2cjhcgzyym5zaz6m4fksw47qvm150w-gcc-16.2.0-lib/lib'),
          PosixPath('/nix/store/h4g9r791fa9dc0fsa3csw84p8yky3krw-setup-cuda-hook/lib')],
 'paths': [PosixPath('/nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86')],
 'preserve_origin': False,
 'recursive': True,
 'relativize_rpath': False,
 'runtime_dependencies': [],
 'structured_logs': False}
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/cudafe++
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/cudafe++
    libgcc_s.so.1 -> found: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib
setting RPATH to: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib:$ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/ptxas
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/ptxas
setting RPATH to: $ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/.nvcc-wrapped
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/.nvcc-wrapped
    libgcc_s.so.1 -> found: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib
setting RPATH to: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib:$ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvlink
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvlink
    libgcc_s.so.1 -> found: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib
setting RPATH to: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib:$ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/fatbinary
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/fatbinary
    libgcc_s.so.1 -> found: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib
setting RPATH to: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib:$ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/bin2c
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/bin2c
setting RPATH to: $ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/__nvcc_device_query
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/__nvcc_device_query
    libstdc++.so.6 -> found: /nix/store/7a2cjhcgzyym5zaz6m4fksw47qvm150w-gcc-16.2.0-lib/lib
    libgcc_s.so.1 -> found: /nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib
setting RPATH to: /nix/store/7a2cjhcgzyym5zaz6m4fksw47qvm150w-gcc-16.2.0-lib/lib:/nix/store/3sj8msrsym648f35mk3gb3pp385hhk8r-gcc-16.2.0-libgcc/lib:$ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvcc
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/bin/nvcc
setting RPATH to: $ORIGIN
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/lib/libnvvm.so.4.0.0
setting RPATH to: $ORIGIN
setting interpreter of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/bin/cicc
searching for dependencies of /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/bin/cicc
setting RPATH to: $ORIGIN
auto-patchelf: 0 dependencies could not be satisfied
autoFixElfFiles: using addDriverRunpath to fix /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/lib/libnvvm.so.4.0.0
autoFixElfFiles: using addDriverRunpath to fix /nix/store/0s1rkd7jxbhf2zr61hygh9xn72a71j6w-cuda12.9-cuda_nvcc-12.9.86/nvvm/bin/cicc
patchelf: patchelf.cc:547: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Nhdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym, Elf_Versym, Elf_Verdef, Elf_Verdaux, Elf_Verneed, Elf_Vernaux, Elf_Rel, Elf_Rela, ElfClass>::shiftFile(unsigned int, size_t, size_t) [with Elf_Ehdr = Elf64_Ehdr; Elf_Phdr = Elf64_Phdr; Elf_Shdr = Elf64_Shdr; Elf_Nhdr = Elf64_Nhdr; Elf_Addr = long unsigned int; Elf_Off = long unsigned int; Elf_Dyn = Elf64_Dyn; Elf_Sym = Elf64_Sym; Elf_Versym = short unsigned int; Elf_Verdef = Elf64_Verdef; Elf_Verdaux = Elf64_Verdaux; Elf_Verneed = Elf64_Verneed; Elf_Vernaux = Elf64_Vernaux; Elf_Rel = Elf64_Rel; Elf_Rela = Elf64_Rela; unsigned int ElfClass = 64; size_t = long unsigned int]: Assertion `splitIndex == -1' failed.
/nix/store/c9fggk6arh8c1x8fbama99crqng8wcmx-add-driver-runpath-hook/nix-support/setup-hook: line 23:   265 Aborted                    (core dumped) patchelf --set-rpath "/run/opengl-driver/lib:$origRpath" ${forceRpath:+--force-rpath} "$file"

The patch:

diff --git c/pkgs/development/cuda-modules/buildRedist/default.nix w/pkgs/development/cuda-modules/buildRedist/default.nix
index bdf8a75494a1..9011ea8b5537 100644
--- c/pkgs/development/cuda-modules/buildRedist/default.nix
+++ w/pkgs/development/cuda-modules/buildRedist/default.nix
@@ -1,6 +1,7 @@
 # NOTE: buildRedist should never take manifests or fixups as callPackage-provided arguments,
 # since we want to provide the flexibility to call it directly with a different fixup or manifest.
 {
+  pkgs,
   _cuda,
   autoAddCudaCompatRunpath,
   autoAddDriverRunpath,
@@ -277,6 +278,16 @@ extendMkDerivation {
 
       nativeBuildInputs = [
         ./buildRedistHook.bash
+        #FIXME: avoid pulling explicit patchelf after resolving https://github.com/NixOS/nixpkgs/pull/569010
+        (pkgs.patchelf.overrideAttrs (
+          finalAttrs: previousAttrs: {
+            version = "0.15.2";
+            src = fetchurl {
+              url = "https://github.com/NixOS/patchelf/releases/download/${finalAttrs.version}/patchelf-${finalAttrs.version}.tar.bz2";
+              hash = "sha256-F3RfVkFZyOIo/EEtplogSLhGxLa0Igt3y/IkFuAvLXw=";
+            };
+          }
+        ))
         autoPatchelfHook
         # This hook will make sure libcuda can be found
         # in typically /lib/opengl-driver by adding that
diff --git c/pkgs/development/cuda-modules/default.nix w/pkgs/development/cuda-modules/default.nix
index e8ab8e91c28f..f7c1a2b87329 100644
--- c/pkgs/development/cuda-modules/default.nix
+++ w/pkgs/development/cuda-modules/default.nix
@@ -131,6 +131,7 @@ let
       # Must be constructed without `callPackage` to avoid replacing the `override` attribute with that of
       # `callPackage`'s.
       buildRedist = import ./buildRedist {
+        inherit pkgs;
         inherit
           _cuda
           lib

The new patch NixOS/patchelf#672 does not fix this particular issue!

Edit: Apparently it does fix it? Not sure why it failed the first time I tried...

@corngood

Copy link
Copy Markdown
Contributor

I was tempted to add a top-level attribute for a different patchelf, but the version override is relatively simple.

@vcunat I wonder if this might still be a good idea to help with cleanup? There's at least one other use of this (#576879), and I'll need to add another one for patch-nupkgs.

I could do that if you think it's a good idea, or maybe we should make an issue to track them?

corngood added a commit to corngood/nixpkgs that referenced this pull request Oct 22, 2026
@vcunat

vcunat commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Perhaps. It will take a couple weeks to get the default patchelf fixed in nixpkgs master.

@corngood

Copy link
Copy Markdown
Contributor

I just made a tracking issue for now: #577387

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants