diff mbox series

toolchain: follow symlinks in ld.*so.* install helper

Message ID 20241207203633.598905-1-geomatsi@gmail.com
State New
Headers show
Series toolchain: follow symlinks in ld.*so.* install helper | expand

Commit Message

Sergey Matyukevich Dec. 7, 2024, 8:36 p.m. UTC
Current toolchain install helper fails to setup external toolchains with
merged-usr sysroot. It does not follow lib symlinks when looking for
ld.*.so.* files. As a result builds fail with various linker errors.
Follow symlinks in find tool when installing ld*.so.* linker scripts
from external toolchain directory to staging and target directories.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
 toolchain/helpers.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni Dec. 7, 2024, 8:47 p.m. UTC | #1
Hello Sergey,

On Sat,  7 Dec 2024 23:36:26 +0300
Sergey Matyukevich <geomatsi@gmail.com> wrote:

> Current toolchain install helper fails to setup external toolchains with
> merged-usr sysroot. It does not follow lib symlinks when looking for
> ld.*.so.* files. As a result builds fail with various linker errors.
> Follow symlinks in find tool when installing ld*.so.* linker scripts
> from external toolchain directory to staging and target directories.
> 
> Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>

Thanks for the patch!

I need to get back to my backlog, but I believe I had investigated some
toolchain issue, and came back to the same patch/change as you.

This regression was introduced by commit
92207bc03f2358b28e0fd2cc3a41e40504b5d3d4 ("toolchain: handle toolchains
with multiple ld*.so.* files").

I am wondering how I got to debug this? Are there some autobuilder
issues?

Thomas
Sergey Matyukevich Dec. 8, 2024, 8:06 p.m. UTC | #2
Hi Thomas,

On Sat, Dec 07, 2024 at 09:47:32PM +0100, Thomas Petazzoni wrote:
> Hello Sergey,
> 
> On Sat,  7 Dec 2024 23:36:26 +0300
> Sergey Matyukevich <geomatsi@gmail.com> wrote:
> 
> > Current toolchain install helper fails to setup external toolchains with
> > merged-usr sysroot. It does not follow lib symlinks when looking for
> > ld.*.so.* files. As a result builds fail with various linker errors.
> > Follow symlinks in find tool when installing ld*.so.* linker scripts
> > from external toolchain directory to staging and target directories.
> > 
> > Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
> 
> Thanks for the patch!
> 
> I need to get back to my backlog, but I believe I had investigated some
> toolchain issue, and came back to the same patch/change as you.
> 
> This regression was introduced by commit
> 92207bc03f2358b28e0fd2cc3a41e40504b5d3d4 ("toolchain: handle toolchains
> with multiple ld*.so.* files").
> 
> I am wondering how I got to debug this? Are there some autobuilder
> issues?

I didn't see any autobuilder issues. Actually I was working with a 3rd
party vendor toolchain. Thanks for finding the commit that introduced
the regression. That commit enabled the use of multilib toolchains with
multiple ld*.so.* files. It turned out that my toolchain had both
properties:
- multilib with multiple ld*.so.* files
- merged-usr property

BTW, I did the following quick test. I baked a Buildroot merged-usr SDK
for aarch64 starting from qemu_aarch64_virt_defconfig. That SDK had a
single ld*.so.* file. Then I rebuilt qemu_aarch64_virt_defconfig image
using that SDK w/o my patch and w/o any issues. So indeed, we have to
use multilib _and_ merged-usr toolchain to trigger this symlink issue.

Should I resend v2 with 'Fixes' tag ?

Regards,
Sergey
diff mbox series

Patch

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index f3fdaaec07..92ad53d064 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -140,8 +140,8 @@  copy_toolchain_sysroot = \
 			$(call simplify_symlink,$$i,$(STAGING_DIR)) ; \
 		done ; \
 	fi ; \
-	if [[ ! $$(find $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \
-		find $${ARCH_SYSROOT_DIR}/lib -name 'ld*.so.*' -print0 | xargs -0 -I % cp % $(STAGING_DIR)/lib/; \
+	if [[ ! $$(find -L $(STAGING_DIR)/lib -name 'ld*.so.*' -print -quit) ]]; then \
+		find -L $${ARCH_SYSROOT_DIR}/lib -name 'ld*.so.*' -print0 | xargs -0 -I % cp % $(STAGING_DIR)/lib/; \
 	fi ; \
 	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \