Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Bug in RPATH fixing logic
@ 2017-11-12 16:40 Thomas Petazzoni
  2017-11-12 16:49 ` Thomas Petazzoni
  0 siblings, 1 reply; 19+ messages in thread
From: Thomas Petazzoni @ 2017-11-12 16:40 UTC (permalink / raw)
  To: buildroot

Hello,

I found a bug in the RPATH fixing logic. On ARC, some of the binutils
programs (ar and ranlib at least) are linked with libfl.so.2, which
is provided by Buildroot in $(HOST_DIR)/lib.

However, after "make sdk" has been called, ar and ranlib don't have any
RPATH encoded. I debugged this and here is what happens:

First, fix-rpath fixes the RPATH of $(HOST_DIR)/bin/<tuple>-ar:

/opt/br-arcle-hs38-full-2017.11-rc1/bin/patchelf --debug --make-rpath-relative /opt/br-arcle-hs38-full-2017.11-rc1 --relative-to-file /opt/br-arcle-hs38-full-2017.11-rc1/bin/arc-buildroot-linux-uclibc-ar
patching ELF file `/opt/br-arcle-hs38-full-2017.11-rc1/bin/arc-buildroot-linux-uclibc-ar'
Kernel page size is 4096 bytes
keeping relative path of /opt/br-arcle-hs38-full-2017.11-rc1/lib
new rpath is `$ORIGIN/../lib'

Here, everything is fine, the rpath is $ORIGIN/../lib.

However, fix-rpath moves on and fixes $(HOST_DIR)/<tuple>/bin/ar:

/opt/br-arcle-hs38-full-2017.11-rc1/bin/patchelf --debug --make-rpath-relative /opt/br-arcle-hs38-full-2017.11-rc1 --relative-to-file /opt/br-arcle-hs38-full-2017.11-rc1/arc-buildroot-linux-uclibc/bin/ar
patching ELF file `/opt/br-arcle-hs38-full-2017.11-rc1/arc-buildroot-linux-uclibc/bin/ar'
Kernel page size is 4096 bytes
removing directory '$ORIGIN/../lib' from RPATH because it does not contain needed libs
new rpath is `'

The gotcha is that $(HOST_DIR)/<tuple>/bin/ar and
$(HOST_DIR)/bin/<tuple>-ar are the same files: they are hard links!

So, when $(HOST_DIR)/bin/<tuple>-ar is fixed, everything is fine
because the library we depend on is indeed located
in /opt/br-arcle-hs38-full-2017.11-rc1/lib/, which is the hardcoded
RPATH. It gets fixed to $ORIGIN/../lib, as should be the case.

However, when we get to $(HOST_DIR)/<tuple>/bin/ar, libfl.so.2 is not
found in $ORIGIN/../lib (because it should be $ORIGIN/../../lib), and
patchelf decides to remove the rpath entirely.

So, we have two things that are a bit weird here:

 - Why are the binutils linked to libfl ? This happens only on the ARC
   architecture, where we use a special version of binutils that gets
   autoreconf'ed.

 - The absolute rpath in $(HOST_DIR)/<tuple>/bin/ar is wrong in the
   first place, but I'm not sure how to fix this.

Wolfgang, Arnout, do you have any idea?

You can reproduce this by building an ARC toolchain, and look at the
(absence of) rpath on bin/<tuple>-ar.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-11-14 10:39 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-12 16:40 [Buildroot] Bug in RPATH fixing logic Thomas Petazzoni
2017-11-12 16:49 ` Thomas Petazzoni
2017-11-12 17:15   ` Peter Korsgaard
2017-11-12 17:24     ` Thomas Petazzoni
2017-11-12 17:42       ` Yann E. MORIN
2017-11-13  7:17         ` Wolfgang Grandegger
2017-11-13 13:50           ` Peter Korsgaard
2017-11-13 15:19             ` Wolfgang Grandegger
2017-11-13 17:36             ` Yann E. MORIN
2017-11-13 18:04               ` Wolfgang Grandegger
2017-11-13 20:23                 ` Peter Korsgaard
2017-11-13 20:33                 ` Yann E. MORIN
2017-11-14  8:00                   ` Wolfgang Grandegger
2017-11-14  9:05                     ` Wolfgang Grandegger
2017-11-14 10:39                       ` Peter Korsgaard
2017-11-12 18:03       ` Peter Korsgaard
2017-11-12 19:04         ` Wolfgang Grandegger
2017-11-12 19:35           ` Wolfgang Grandegger
2017-11-12 20:37             ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox