Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 732482 - sys-libs/musl: does not support sysroot installation
Summary: sys-libs/musl: does not support sysroot installation
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2020-07-13 15:40 UTC by David Michael
Modified: 2021-06-21 08:22 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fix (relative_libc_symlink.patch,520 bytes, patch)
2020-07-29 18:04 UTC, Andrew Aladjev
Details | Diff
Patch for Makefile (file_732482.txt,880 bytes, patch)
2020-09-11 00:40 UTC, Michael 'veremitz' Everitt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Michael 2020-07-13 15:40:39 UTC
This line kills the build if it can't find the ld.so symlink's target when not building a crossdev version of the package:

https://github.com/gentoo/gentoo/blob/master/sys-libs/musl/musl-1.1.24.ebuild#L106

This prevents installing/updating musl in a sysroot because it uses an absolute symlink to /usr/lib/libc.so, which does not exist when the build system is amd64 using lib64.

Reproducible: Always

Steps to Reproduce:
1. emerge -v sys-libs/musl  # with a sysroot profile

Actual Results:  
 * ERROR: sys-libs/musl-1.1.24::gentoo failed (install phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line 125:  Called src_install
 *   environment, line 2295:  Called die
 * The specific snippet of code:
 *           [[ -e "${D}"/lib/ld-musl-${arch}.so.1 ]] || die;

Expected Results:  
It should build and install.

# ll /var/tmp/portage/sys-libs/musl-1.1.24/image/lib/ld-musl-x86_64.so.1 /usr/lib*/libc.so 
-rwxr-xr-x. 1 root root 253 Jul  6 09:17 /usr/lib64/libc.so
lrwxrwxrwx. 1 root root  16 Jul 13 11:38 /var/tmp/portage/sys-libs/musl-1.1.24/image/lib/ld-musl-x86_64.so.1 -> /usr/lib/libc.so
Comment 1 Jory A. Pratt gentoo-dev 2020-07-19 23:38:27 UTC
Your using an invalid profile for one, all musl profiles use /usr/lib/ they are not multilib profiles.
Comment 2 David Michael 2020-07-20 00:16:03 UTC
Nope.  Please leave the issue open for someone who is familiar with sysroots.
Comment 3 Andrew Aladjev 2020-07-29 18:04:08 UTC
Hello. I've mentioned this issue several times both on gentoo bugtracker and musl mailing lists. Everybody knows that this issue exists, but forget to fix it.

I am just using simple patch.
Comment 4 Andrew Aladjev 2020-07-29 18:04:49 UTC
Created attachment 651460 [details, diff]
fix
Comment 5 David Michael 2020-07-29 19:18:04 UTC
Thanks for that patch; using a relative symlink is the proper fix.  I've just been deleting the bad test line from the ebuild to make it work.
Comment 6 David Michael 2020-09-08 00:12:50 UTC
One note about the patch, when using split-usr (i.e. /lib and /usr/lib are separate directories), the symlink works:

/usr/x86_64-gentoo-linux-musl/lib/ld-musl-x86_64.so.1 -> ../usr/lib/libc.so

When /lib is a symlink to /usr/lib, there is a broken link:

/usr/x86_64-gentoo-linux-musl/usr/lib/ld-musl-x86_64.so.1 -> ../usr/lib/libc.so

This link works as /lib/ld-musl-x86_64.so.1 when the binpkg is installed in a real root, but testing the sysroot for broken links will find it.
Comment 7 Michael 'veremitz' Everitt 2020-09-11 00:40:51 UTC
Created attachment 659446 [details, diff]
Patch for Makefile

Suggested patch-file from upstream musl (credit to Rich Felkner, @dalias on IRC).

Please test.
Comment 8 David Michael 2020-09-11 01:21:12 UTC
It still makes a broken link when /lib is symlinked to /usr/lib:

    usr/lib/ld-musl-x86_64.so.1 -> ../usr/lib/libc.so

Maybe I can just put EXTRA_EMAKE='syslibdir=$(libdir)' in the environment when split-usr is disabled.
Comment 9 Rich Felker 2020-09-11 01:38:32 UTC
I don't entirely understand what you're trying to do, but --prefix etc. are usually not the right way to install in a sysroot. --syslibdir should be left alone (never changed from /lib) and DESTDIR= should be used at make install time to install to the sysroot so that the layout there will be appropriate for the target using it as /.
Comment 10 David Michael 2020-09-11 01:51:24 UTC
I am just trying to use a UsrMerge layout where /lib is a symlink to /usr/lib.  Testing the sysroot for broken links with this finds the link:

ls -l $(find /usr/x86_64-gentoo-linux-musl -xtype l)
lrwxrwxrwx. 1 root root 18 Sep 10 21:20 /usr/x86_64-gentoo-linux-musl/usr/lib/ld-musl-x86_64.so.1 -> ../usr/lib/libc.so