unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 73979-done@debbugs.gnu.org
Subject: bug#73979: validate-runpath phases fails when binaries linked to package's own libraries
Date: Thu, 19 Dec 2024 14:10:21 +0900	[thread overview]
Message-ID: <87h670mf5u.fsf@gmail.com> (raw)
In-Reply-To: <87jzdbwbso.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sun, 10 Nov 2024 12:47:19 +0100")

Hi Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> There's a common pattern in packages where the validate-runpath phases
>> fail, which is when a binary is linked to libraries provided by the same
>> package.  In this case, our ld-wrapper script appears to not bake the
>> required runpath, which then fails the validate-runpath phase.
>>
>> When this happens, the common workaround is adding link directives such
>> as (string-append "-Wl,-rpath=" #$output "/lib/subdir") to LDFLAGS (see
>> for example the 'dmraid' package definition).
>
> I believe this is the exception, not the rule, and I see that as a bug
> in the build system of those packages.  (As a counterexample, any
> package built with Automake/Libtool is fine.)

Interesting.  I had not considered that point of view (that the build
system/usage of it could be at cause) enough; I think you are right.

[...]

>> One idea could be to allow creating rpaths to %BUILD-DIRECTORY prefixed
>> libraries, and have these entries refined in a phase that would run
>> after the package is installed, before the validate-runpath phase runs.
>> It could be called e.g. 'sanitize-runpath' and proceed along those
>> lines:
>>
>> Scan for RUNPATH entries being prefixed by %BUILD-DIRECTORY; attempt to
>> have them rewritten to libraries (.so) found under the package's own
>> libdir library prefix (at any depth), including a potential "lib"
>> output.  In case it couldn't, it would error.
>>
>> Does that sound feasible?
>
> It might be feasible, but I think it’s the wrong approach.  The problem
> here is in the build system itself; Guix is “not at fault”, so to speak.
>
> Nevertheless, from a practical viewpoint, whether or not Guix is at
> fault is largely irrelevant.  So the question becomes: how widespread is
> this issue?  If it’s widespread, can it be solved at a (guix
> build-system …) level?  (For instance, I think ‘cmake-build-system’ and
> ‘meson-build-system’ do the right things in that regard.)

I think CMake nowadays doesn't relink but uses some ELF-patching code to
patch the installed binaries in place (which is faster than relinking);
that would mean our ld-wrapper doesn't get involved in these case and we
depend on RPATH being enabled in the CMake build system, which it
normally is unless the package set CMAKE_SKIP_RPATH to false.  I guess
Meson is also patching binaries for speed.

> If it’s a per-package issue, which seems to be the case given what you
> describe, then I would fix it locally in this package, for instance by
> passing ‘-Wl,-rpath=$ORIGIN/../lib’ or whatever is convenient.

There doesn't seem to be so many occurrences; grepping for
'-Wl,-rpath.*output' I find 73 problematic packages.  I've found one
place where this happens is for Cythonized shared objects; this produced
shared objects linked to a library of the build directory, and is not
concerned with installing so nothing rewrites the runpath entries to
their correct installed location.  One such example is openpmix; the
issue was dismissed as "we expect people to set LD_LIBRARY_PATH" [0].

[0]  https://github.com/openpmix/openpmix/issues/3457

Anyway, sorry for the wall of text.  Closing!

-- 
Thanks,
Maxim




      reply	other threads:[~2024-12-19  5:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  6:01 bug#73979: validate-runpath phases fails when binaries linked to package's own libraries Maxim Cournoyer
2024-11-10 11:47 ` Ludovic Courtès
2024-12-19  5:10   ` Maxim Cournoyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h670mf5u.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=73979-done@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).