Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: hello.skyclo@gmail.com, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] package/musl: fixup the dynamic loader symlink
Date: Sun, 30 Oct 2022 20:38:23 +0100	[thread overview]
Message-ID: <20221030193822.GE1058960@scaer> (raw)
In-Reply-To: <20221026125836.3910730-1-thomas.petazzoni@bootlin.com>

Thomas, All,

On 2022-10-26 14:58 +0200, Thomas Petazzoni via buildroot spake thusly:
> The musl Makefile installs the dynamic loader as a symlink to libc.so
> with the following rule:
> 
> $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
>         $(INSTALL) -D -l $(libdir)/libc.so $@ || true
> 
> While it works, the drawback is that ld-musl-<arch>.so ends up being a
> symlink to /lib/libc.so. While it works on the target, it means we
> have a broken symlink in $(STAGING_DIR) and $(TARGET_DIR) as
> /lib/libc.so doesn't make sense on the build machine. This generally
> doesn't cause any problem *except* when we tell Qemu to use
> $(STAGING_DIR) as the library directory when running target programs
> through the Qemu user emulation mode. This is for example node inside
> the NodeJS build. Due to this broken symlink, Qemu can't find libc.so
> that is pointed to be the dynamic loader symlink causing this build
> error:
> 
> qemu-arm: Could not open '/lib/ld-musl-armhf.so.1': No such file or directory
> 
> Since this is not really a bug in the musl build system, we address
> this issue by overriding the symlink to be a relative path. The
> dynamic loader is always installed in /lib, and libc.so is also always
> installed in /lib because we pass libdir=/lib when configuring
> musl. So we can simply have a ld-musl* -> libc.so symbolic link. We
> use ld-musl* as a wildcard so that we don't need to have extra logic
> to determine the exact name of the dynamic loader symlink, and simply
> override the one that exists.
> 
> Fixes:
> 
>   http://autobuild.buildroot.net/results/9ff23f2e3c97e9af410617de3e7376f9d45a7d63/
>   https://bugs.busybox.net/show_bug.cgi?id=15061
> 
> Cc: hello.skyclo@gmail.com
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Applied to master, after adding a summary of the explanations you
provided Yann about the external toolchain case. Thanks.

Regards,
Yann E. MORIN.

> ---
>  package/musl/musl.mk | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/package/musl/musl.mk b/package/musl/musl.mk
> index 44c79da6f7..30c3c2fbc0 100644
> --- a/package/musl/musl.mk
> +++ b/package/musl/musl.mk
> @@ -60,12 +60,14 @@ endef
>  define MUSL_INSTALL_STAGING_CMDS
>  	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
>  		DESTDIR=$(STAGING_DIR) install-libs install-tools install-headers
> +	ln -sf libc.so $(STAGING_DIR)/lib/ld-musl*
>  endef
>  
>  define MUSL_INSTALL_TARGET_CMDS
>  	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
>  		DESTDIR=$(TARGET_DIR) install-libs
>  	$(RM) $(addprefix $(TARGET_DIR)/lib/,crt1.o crtn.o crti.o rcrt1.o Scrt1.o)
> +	ln -sf libc.so $(TARGET_DIR)/lib/ld-musl*
>  endef
>  
>  $(eval $(generic-package))
> -- 
> 2.37.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2022-10-30 19:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 12:58 [Buildroot] [PATCH] package/musl: fixup the dynamic loader symlink Thomas Petazzoni via buildroot
2022-10-26 13:31 ` yann.morin
2022-10-26 18:53   ` Thomas Petazzoni via buildroot
2022-10-27  5:50     ` yann.morin
2022-10-30 19:38 ` Yann E. MORIN [this message]
2022-11-13 15:10 ` Peter Korsgaard

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=20221030193822.GE1058960@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=hello.skyclo@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox