Subject: bug#58033: A bug in file-dynamic-info used by validate-runpath in gnu-build-system and others.

From: Lukasz Olszewski <[email-masked]>
Date: Sat, 24 Sep 2022 14:04:24 +0200

Also, to ensure all the information is provided. This is the code that
resulted in the binary header being transformed:

(add-after 'install 'fix-issue-with-libs
  (lambda* (#:key inputs outputs #:allow-other-keys)
    (chdir "..")
    (use-modules (ice-9 ftw)
(ice-9 regex)
(ice-9 rdelim)
(ice-9 popen)
(ice-9 textual-ports))
    (let* ((libdir (string-append #$output "/lib")))
      ;; ------------------------------
      ;; patchelf
      (define (get-rpaths file)
(format #t "Getting rpaths from ~a ...~%" file)
(let* ((port (open-input-pipe (string-append "patchelf --print-rpath " file)))
       (str  (read-line port))) ; from (ice-9 rdelim)
  (close-pipe port)
  str))
      (define (patch-elf file)
      (format #t "Patching ~a ...~%" file)
(define rpath (string-append (get-rpaths file) ":" #$extra-libs "/lib"))
(display (string-append "We're setting rpath:" rpath))
(invoke "patchelf" "--set-rpath" rpath file))
      (for-each (lambda (file)
  (when (elf-file? file)
    (patch-elf file)))
(find-files #$output  ".*")))))

I can run the patch-elf procedure in repl and it runs fine, but being
run during the build it results in the problematic elf header. The
build was run twice with the same result both times.

Regards,
Lukasz