Bug 7562

Summary: musl buildroot-toolchain and BR2_MIPS_SOFT_FLOAT break
Product: buildroot Reporter: Alexander Clouter <alex+buildroot>
Component: OtherAssignee: Thomas Petazzoni <thomas.petazzoni>
Status: RESOLVED FIXED    
Severity: normal CC: buildroot
Priority: P5    
Version: 2014.08   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description Alexander Clouter 2014-10-26 18:19:10 UTC
I use the following settings:

BR2_mipsel=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_MIPS_SOFT_FLOAT=y

Even trying to run busybox fails as ld-musl-mipsel.so.1 does not exist.  Some digging around I found that ld-musl-mipsel-sf.so.1 does, I am guessing 'sf' stands for "soft float".

To workaround the problem, I slipped into my post-build.sh script the following:
----
ln -f -s /lib/libc.so "$1/lib/ld-musl-mipsel.so.1"
----

That gets things working again.  Not should how this should actually be fixed, otherwise I would submit a patch.

Let me know if you need anything from me to help get this fixed.
Comment 1 Thomas Petazzoni 2014-11-07 07:37:03 UTC
Thanks for the report. That's due to a lack of coherency between the musl installation code (which indeed installs the ld-musl-mipsel-sf symbolic link) and the gcc patch we have for musl support, which assumes the mips dynamic linker is always ld-musl-mipsel, regarding of whether it's hard-float or soft-float.

I'll have a look into this and if applicable report this up to the folks doing the gcc patches for musl.
Comment 2 Thomas Petazzoni 2014-11-09 10:33:56 UTC
Issue reported upstream at https://bitbucket.org/GregorR/musl-cross/issue/4/invalid-mips-soft-float-linker-path. I am not entirely sure what is the proper condition to add in gcc to determine if the -sf suffix should be added or not. I'll wait for upstream to give a hint about this before cooking a patch.
Comment 3 Peter Korsgaard 2016-03-10 22:20:24 UTC
Fixed in git by:

commit 348d5edd91abec1fc4cc27965220d54e58217dc3
Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date:   Tue Mar 8 22:20:55 2016 +0100

    gcc: fix dynamic linker path for mips soft-float
    
    This commit updates the gcc musl patches for gcc 4.7, 4.8 and 4.9 so
    that the path to the dynamic linker encoded as "program interpreter"
    in the generated binaries actually matches the symbolic link installed
    by musl when building for mips soft-float.
    
    Indeed, musl installs a symlink called ld-musl-mipsel-sf.so.1, but gcc
    currently generates binaries that use /lib/ld-musl-mips.so as program
    interpreter.
    
    The fix is simply the one from
    https://bitbucket.org/GregorR/musl-cross/commits/825219202365, i.e
    adjust MUSL_DYNAMIC_LINKER in our musl gcc patches.
    
    Thanks to these patches:
    
    $ ./host/usr/bin/mipsel-linux-readelf -a ./target/bin/busybox
    [...]
          [Requesting program interpreter: /lib/ld-musl-mipsel-sf.so.1]
    [...]
    
    gcc 5.x doesn't need any fix because the musl patches already use the
    right value.
    
    Fixes bug #7562.
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    Signed-off-by: Peter Korsgaard <peter@korsgaard.com>