diff mbox series

linuxloader: add -armhf on arm only for TARGET_FPU 'hard'

Message ID 20240605072629.115812-1-jonas.gorski@bisdn.de
State New
Headers show
Series linuxloader: add -armhf on arm only for TARGET_FPU 'hard' | expand

Commit Message

Jonas Gorski June 5, 2024, 7:26 a.m. UTC
There are two types of soft FPU options for arm, soft and softfp, and if
using the latter the wrong dynamic loader will be used.

E.g. go will link against ld-linux-armhf.so.3, but libc6 will only ship
a ld-linux.so.3, so go programs will fail to start.

Fix this by instead checking for TARGET_FPU being 'hard' and then
applying the suffix.

Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
---

I stumbled upon this on kirkstone after the Go linker changes were
backported to 4.0.19. Suddenly docker wasn't working anymore, being
linked against a non-existing ld-linux.

This is only tested on kirkstone since we are still on kirkstone and
going to master (or garthgap) is non-trivial (though planned).

 meta/classes-recipe/linuxloader.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Khem Raj June 5, 2024, 5:27 p.m. UTC | #1
On Wed, Jun 5, 2024 at 2:52 AM Jonas Gorski via lists.openembedded.org
<jonas.gorski=bisdn.de@lists.openembedded.org> wrote:
>
> There are two types of soft FPU options for arm, soft and softfp, and if
> using the latter the wrong dynamic loader will be used.
>
> E.g. go will link against ld-linux-armhf.so.3, but libc6 will only ship
> a ld-linux.so.3, so go programs will fail to start.
>
> Fix this by instead checking for TARGET_FPU being 'hard' and then
> applying the suffix.
>
> Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
> ---
>
> I stumbled upon this on kirkstone after the Go linker changes were
> backported to 4.0.19. Suddenly docker wasn't working anymore, being
> linked against a non-existing ld-linux.
>
> This is only tested on kirkstone since we are still on kirkstone and
> going to master (or garthgap) is non-trivial (though planned).
>
>  meta/classes-recipe/linuxloader.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/linuxloader.bbclass b/meta/classes-recipe/linuxloader.bbclass
> index 2ea1b62254c9..a2e8f9837bd4 100644
> --- a/meta/classes-recipe/linuxloader.bbclass
> +++ b/meta/classes-recipe/linuxloader.bbclass
> @@ -57,7 +57,7 @@ def get_glibc_loader(d):
>      elif re.search("i.86", targetarch):
>          dynamic_loader = "${base_libdir}/ld-linux.so.2"
>      elif targetarch == "arm":
> -        dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
> +        dynamic_loader = "${base_libdir}/ld-linux${@['', '-armhf'][d.getVar('TARGET_FPU') == 'hard']}.so.3"

looks fine.


>      elif targetarch.startswith("aarch64"):
>          dynamic_loader = "${base_libdir}/ld-linux-aarch64${ARMPKGSFX_ENDIAN_64}.so.1"
>      elif targetarch.startswith("riscv64"):
> --
> 2.45.1
>
>
> --
> BISDN GmbH
> Körnerstraße 7-10
> 10785 Berlin
> Germany
>
>
> Phone:
> +49-30-6108-1-6100
>
>
> Managing Directors:
> Dr.-Ing. Hagen Woesner, Andreas
> Köpsel
>
>
> Commercial register:
> Amtsgericht Berlin-Charlottenburg HRB 141569
> B
> VAT ID No: DE283257294
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#200359): https://lists.openembedded.org/g/openembedded-core/message/200359
> Mute This Topic: https://lists.openembedded.org/mt/106500218/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Ross Burton June 6, 2024, 10:56 a.m. UTC | #2
On 5 Jun 2024, at 08:26, Jonas Gorski via lists.openembedded.org <jonas.gorski=bisdn.de@lists.openembedded.org> wrote:
> -        dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
> +        dynamic_loader = "${base_libdir}/ld-linux${@['', '-armhf'][d.getVar('TARGET_FPU') == 'hard']}.so.3"

If we’re changing this line, can we stop using the obscure “implicitly treat a boolean as an index” idiom and just use a standard Python ternary expression?

Ross
diff mbox series

Patch

diff --git a/meta/classes-recipe/linuxloader.bbclass b/meta/classes-recipe/linuxloader.bbclass
index 2ea1b62254c9..a2e8f9837bd4 100644
--- a/meta/classes-recipe/linuxloader.bbclass
+++ b/meta/classes-recipe/linuxloader.bbclass
@@ -57,7 +57,7 @@  def get_glibc_loader(d):
     elif re.search("i.86", targetarch):
         dynamic_loader = "${base_libdir}/ld-linux.so.2"
     elif targetarch == "arm":
-        dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
+        dynamic_loader = "${base_libdir}/ld-linux${@['', '-armhf'][d.getVar('TARGET_FPU') == 'hard']}.so.3"
     elif targetarch.startswith("aarch64"):
         dynamic_loader = "${base_libdir}/ld-linux-aarch64${ARMPKGSFX_ENDIAN_64}.so.1"
     elif targetarch.startswith("riscv64"):