All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH next v6 07/10] core: implement per-package SDK and target
Date: Sun, 13 Jan 2019 23:10:53 +0100	[thread overview]
Message-ID: <7c0307f9-5370-215b-7230-0f83da461c82@mind.be> (raw)
In-Reply-To: <CAAXf6LVho4978cn=nkFMReanH4o5Z0D81OW5a-k_xWHRP77DQg@mail.gmail.com>



On 11/01/2019 21:09, Thomas De Schampheleire wrote:
> El jue., 10 ene. 2019 a las 22:25, Arnout Vandecappelle
> (<arnout@mind.be>) escribi?:
>>
>>
>>
>> On 26/12/2018 19:33, Thomas De Schampheleire wrote:
>>> In a similar context I once had following problem:
>>> http://lists.busybox.net/pipermail/buildroot/2018-August/226955.html
>>> This was for target binaries, rather than host, but for the below
>>> discussion it does not matter.
>>
>>  I don't think you ever replied to my question in that thread:
>>
>>  Let's first find out why it is cleared. patchelf should check for each
>> directory in rpath if it is actually needed, and only remove it if it is not
>> needed. So, what library do you have in /opt/foobar/lib, and is it really linked
>> with the program?
>>
>>  Hm, I realize that we never thought about dlopen()ed libraries. Could that be
>> the cause? I guess that hasn't been a problem up to now because usually programs
>> using dlopen() will use an absolute path (to a build-time or run-time configured
>> plugin directory) rather than relying on RPATH.
> 
> Sorry that I did not seem to have replied on that question.
> 
> The binary in question did in fact link with the library, there is no
> dlopen used.
> Some redacted output showing the initial rpath, which disappears after
> fix-rpath.
> 
> $ readelf -d output/target/opt/foobar/bin/fooprogram | rg 'NEEDED|RPATH'
> ...
>  0x00000001 (NEEDED)                     Shared library: [libfoo.so.1]
> ...
>  0x0000000f (RPATH)                      Library rpath:
> [/../lib:/opt/foobar/lib:/home/tdescham/repo/isam/buildroot/output/target/opt/foobar/lib]
> 
> $ find output/target/ -name libfoo.so.1
> output/target/opt/foobar/lib/libfoo.so.1
> 
> $ env HOST_DIR=output/host STAGING_DIR=output/staging
> TARGET_DIR=output/target support/scripts/fix-rpath target
> 
> $ readelf -d output/target/opt/foobar/bin/fooprogram | rg 'NEEDED|RPATH'
> ...
>  0x00000001 (NEEDED)                     Shared library: [libfoo.so.1]
> ...

 OK, so that's a bug in our patchelf modification... At least, if libfoo.so.1
doesn't exist in output/target/lib or output/target/usr/lib.

 If you run patchelf with --debug, it should tell you why the rpath got removed.


>>> Looking back at this problem, taking into account the above comment
>>> from the patchelf patch, I would say that my problem would have been
>>> fixed if case (4) above would not discard the path.
>>
>>  I think one motivation for removing redundant rpaths is to avoid having build
>> directories leaking into target binaries. Especially for reproducible builds
>> this is important.
> 
> Ok, I can understand that.
> But it should only remove directories which are not present in the
> target directory, e.g. if rpath contains /opt/foobar/lib then the
> script should check if output/target/opt/foobar/lib exists. If it
> does, then the rpath can remain, if it does not then it could be
> removed.

 Indeed, and that's what patchelf is supposed to do. Well, it also checks that
the library exists.


>>> If that change would be adopted, then it would also preserve the rpath
>>> '/home/thomas/projets/buildroot/output/per-package/host-e2fsprogs/host/lib'.
>>>
>>> Of course, in your case you might actually want a different final
>>> rpath, i.e. rewrite it to the consolidated host directory. I think
>>> that in this case it would be better to read the rpath via patchelf,
>>> calculate the transformed rpath from our own script, then writing it
>>> back via patchelf,  rather than adding more options into patchelf with
>>> e.g. transformation rules.
>>
>>  The problem is that patchelf is rather slow, so running it twice is even slower...
> 
> How so is it slow, can you clarify? Which times are you talking about?

 I don't remember, but someone did measurements in 2017 and it was slow.

 Regards,
 Arnout

  reply	other threads:[~2019-01-13 22:10 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23 14:58 [Buildroot] [PATCH next v6 00/10] Per-package host/target directory support Thomas Petazzoni
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 01/10] Makefile: evaluate CCACHE and HOST{CC, CXX} at time of use Thomas Petazzoni
2018-11-26 18:14   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 02/10] support/scripts/check-host-rpath: split condition on two statements Thomas Petazzoni
2018-11-26 18:14   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 03/10] Makefile: rework main directory creation logic Thomas Petazzoni
2018-11-23 18:07   ` Yann E. MORIN
2018-11-26 18:14   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 04/10] Makefile: move .NOTPARALLEL statement after including .config file Thomas Petazzoni
2018-11-26 18:15   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 05/10] Makefile: define TARGET_DIR_WARNING_FILE relative to TARGET_DIR Thomas Petazzoni
2018-11-26 18:15   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 06/10] package/pkg-generic: adjust config scripts tweaks for per-package directories Thomas Petazzoni
2018-11-23 18:09   ` Yann E. MORIN
2018-11-26 18:15   ` Peter Korsgaard
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 07/10] core: implement per-package SDK and target Thomas Petazzoni
2018-11-23 21:50   ` Yann E. MORIN
2018-12-04 22:24   ` Arnout Vandecappelle
2018-12-05  8:04     ` Thomas Petazzoni
2018-12-05  9:18       ` Arnout Vandecappelle
2018-12-05  9:44         ` Thomas Petazzoni
2018-12-05 10:41           ` Arnout Vandecappelle
2018-12-05 16:08   ` Andreas Naumann
2018-12-05 16:31     ` Thomas Petazzoni
2018-12-05 16:52       ` Andreas Naumann
2018-12-06 10:21         ` Andreas Naumann
2018-12-06 10:28           ` Thomas Petazzoni
2018-12-06 10:42             ` Andreas Naumann
2018-12-06 10:58               ` Thomas Petazzoni
2018-12-06 13:31                 ` Andreas Naumann
2018-12-26 17:34           ` Thomas Petazzoni
2018-12-26 18:33             ` Thomas De Schampheleire
2019-01-10 21:25               ` Arnout Vandecappelle
2019-01-11 20:09                 ` Thomas De Schampheleire
2019-01-13 22:10                   ` Arnout Vandecappelle [this message]
2019-01-14 16:01                     ` Thomas De Schampheleire
2019-01-14 16:33                       ` Thomas Petazzoni
2019-01-14 20:19                       ` Thomas De Schampheleire
2019-01-14 20:43                         ` Thomas De Schampheleire
2018-12-26 18:58             ` Yann E. MORIN
2018-12-27 16:17             ` Thomas Petazzoni
2019-01-10 21:14               ` Arnout Vandecappelle
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 08/10] Makefile: allow top-level parallel build with BR2_PER_PACKAGE_DIRECTORIES=y Thomas Petazzoni
2018-11-23 18:11   ` Yann E. MORIN
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 09/10] package/pkg-generic: make libtool .la files compatible with per-package directories Thomas Petazzoni
2018-11-25 17:57   ` Yann E. MORIN
2018-11-30 10:20     ` Thomas Petazzoni
2018-12-01 10:59       ` Yann E. MORIN
2018-11-23 14:58 ` [Buildroot] [PATCH next v6 10/10] package/pkg-kconfig: handle KCONFIG_DEPENDENCIES " Thomas Petazzoni
2018-11-25 17:57   ` Yann E. MORIN
2018-12-05 15:23   ` Andreas Naumann
2018-12-06 14:07     ` Andreas Naumann
2018-12-06 14:25       ` Thomas Petazzoni
2018-12-26 16:40       ` Thomas Petazzoni

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

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

  git send-email \
    --in-reply-to=7c0307f9-5370-215b-7230-0f83da461c82@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.