Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 544128 - sys-libs/musl: Issues with crossdev
Summary: sys-libs/musl: Issues with crossdev
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
: 544126 (view as bug list)
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2015-03-22 18:10 UTC by Felix Janda
Modified: 2015-05-14 21:49 UTC (History)
1 user (show)

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


Attachments
Proposed patch against musl ebuild (musl.patch,1.22 KB, patch)
2015-03-22 18:13 UTC, Felix Janda
Details | Diff
Proposed patch against musl ebuild (musl.patch,1.25 KB, patch)
2015-03-25 17:57 UTC, Felix Janda
Details | Diff
Patch against -r1 (musl.patch,431 bytes, patch)
2015-03-27 18:06 UTC, Felix Janda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Janda 2015-03-22 18:10:58 UTC
The musl ebuild now tries to create an ldd symlink. However this breaks
the build for crossdev targets. (The error message is something along
the line "dosym: requires two arguments".)

Another problem is that for crossdev targets the dynamic linker should
be installed into /lib/ld-musl-* instead of /usr/${CTARGET}/lib/ld-musl-*.
(Because the dynamic loader path is hardcoded.)

Thirdly, the make.profile symlink in /usr/${CTARGET}/etc/make.conf is
wrong. This seems to be an issue in crossdev, though.


Reproducible: Always
Comment 1 Felix Janda 2015-03-22 18:13:49 UTC
Created attachment 399484 [details, diff]
Proposed patch against musl ebuild

The patch should fix issues 1 & 2.

gcc does not seem to need the sys-include link anymore.

I've tested building musl natively and recreating a crossdev toolchain.
Comment 2 Felix Janda 2015-03-22 19:23:26 UTC
*** Bug 544126 has been marked as a duplicate of this bug. ***
Comment 3 Anthony Basile gentoo-dev 2015-03-25 12:56:26 UTC
(In reply to Felix Janda from comment #1)
> Created attachment 399484 [details, diff] [details, diff]
> Proposed patch against musl ebuild
> 
> The patch should fix issues 1 & 2.
> 
> gcc does not seem to need the sys-include link anymore.
> 
> I've tested building musl natively and recreating a crossdev toolchain.

Thanks, I don't have to cross compile, so I didn't notice this, but both points are legit.  I'll add that without a rev bump later.
Comment 4 Felix Janda 2015-03-25 17:57:51 UTC
Created attachment 399758 [details, diff]
Proposed patch against musl ebuild

The previous patch would have moved the dynamic linker of a
crosscompiler to /lib instead of /usr/$CTARGET/lib. Fix this by passing
--syslibdir to musl's configure script.
Comment 5 Anthony Basile gentoo-dev 2015-03-26 13:29:23 UTC
(In reply to Felix Janda from comment #4)
> Created attachment 399758 [details, diff] [details, diff]
> Proposed patch against musl ebuild
> 
> The previous patch would have moved the dynamic linker of a
> crosscompiler to /lib instead of /usr/$CTARGET/lib. Fix this by passing
> --syslibdir to musl's configure script.

I (In reply to Felix Janda from comment #4)
> Created attachment 399758 [details, diff] [details, diff]
> Proposed patch against musl ebuild
> 
> The previous patch would have moved the dynamic linker of a
> crosscompiler to /lib instead of /usr/$CTARGET/lib. Fix this by passing
> --syslibdir to musl's configure script.

I changed your first hunk to the following:

+	local sysroot=/
+	is_crosscompile && sysroot=/usr/${CTARGET}
 	./configure \
 		--target="${CTARGET}" \
-		--prefix="/usr" \
+		--prefix=${sysroot}/usr \
+		--syslibdir=${sysroot}/lib \
 		--disable-gcc-wrapper

Note: I initialized sysroot to / and I removed the quotes around ${sysroot} to avoid the double //, which probably doesn't matter anyhow when being passed to --prefix= or --syslibdir=.  This is what you do in the second hunk.  There you definitely want to avoid quotes around sysroot else you get 

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

I feel better about avoiding an non-explicitly initialized value for sysroot.

It works for native, please test for cross.  Its in as 1.1.7-r1 all ~arch.  Reopen if there is still a problem.
Comment 6 Anthony Basile gentoo-dev 2015-03-26 13:41:07 UTC
Actually, followup.  You need sysroot unset in order to avod the double //, so I checked and `local sysroot` does infact leave sysroot unset which is fine here.
Comment 7 Felix Janda 2015-03-27 18:06:25 UTC
Created attachment 399888 [details, diff]
Patch against -r1

musl-1.1.7-r1 does not yet work correctly for crossdev. (I didn't realise that changing --syslibdir would require more changes in the ebuild.) Have now updated native and several crossdev version of musl successfully.
Comment 8 Anthony Basile gentoo-dev 2015-03-27 23:23:38 UTC
Okay I'll give it a test natively and then commit.
Comment 9 Anthony Basile gentoo-dev 2015-03-28 12:31:22 UTC
(In reply to Anthony Basile from comment #8)
> Okay I'll give it a test natively and then commit.

Its in the tree now with 1.1.7-r2.  It works fine for native an looks okay for cross, but please test cross again and reopen if its still broken.
Comment 10 Felix Janda 2015-04-16 17:37:31 UTC
I'm still requesting the script not to fail when there are several
/lib/ld-musl-*.so.1 . Since it is now in the musl ebuild we can
find out the right name and modify ldconfig accordingly. Is this
undesirable?
Comment 11 Anthony Basile gentoo-dev 2015-04-16 21:35:35 UTC
(In reply to Felix Janda from comment #10)
> I'm still requesting the script not to fail when there are several
> /lib/ld-musl-*.so.1 . Since it is now in the musl ebuild we can
> find out the right name and modify ldconfig accordingly. Is this
> undesirable?

I assume you're referring to the ldconfig script?  So you would like this line changed:

  LDSO_PATH=$(ls /lib/ld-musl-*.so.1)

to something without the globbing and we should be able to do that in the ebuild because we know the arch?

The reason I went this way was because it makes the same script cross arch and you can just drop it in (without substitution) and it just works.  However, if this is breaking with crossdev, then I'm willing to write an ldconfig.in file and have some substitution in the ebuild which adds the correct arch where the glob is above.

Also it might be good to know under what conditions the glob gets confused?  ie when would you have several /lib/ld-musl-*.so.1?

I'll reopen for continued discussion.
Comment 12 Felix Janda 2015-04-17 18:37:28 UTC
Sorry, I commented on the wrong bug...

Yes, I'm refering to the ldconfig script and that line. It gets
confused when there are several /lib/ld-musl-*.so.1 .

With crossdev ld-musl-*.so.1 will be put into /usr/${CTARGET}/...
So this is really this wrong bug to comment on...

However when cross-compiling musl externally (say for an arch not
supported by crossdev) by default ld-musl-*.so.1 will be put
into /lib while the rest will be put into the prefix /usr/local/musl.
This makes it not very difficult to have several ld-musl-*.so.1 in
/lib. The intention of this design is that the resulting binaries
can be directly run (with qemu user emulation if the arch is
different) on the system (without a chroot).

Actually since we already (should?!) have an /etc/env.d/00musl we
could put some helpful environment variable inside and use that
to have an arch independent ldconfig script which does not fail
when there are several /lib/ld-musl-*.so.1.
Comment 13 Anthony Basile gentoo-dev 2015-04-18 11:30:54 UTC
(In reply to Felix Janda from comment #12)
> Sorry, I commented on the wrong bug...
> 
> Yes, I'm refering to the ldconfig script and that line. It gets
> confused when there are several /lib/ld-musl-*.so.1 .
> 
> With crossdev ld-musl-*.so.1 will be put into /usr/${CTARGET}/...
> So this is really this wrong bug to comment on...
> 
> However when cross-compiling musl externally (say for an arch not
> supported by crossdev) by default ld-musl-*.so.1 will be put
> into /lib while the rest will be put into the prefix /usr/local/musl.
> This makes it not very difficult to have several ld-musl-*.so.1 in
> /lib. The intention of this design is that the resulting binaries
> can be directly run (with qemu user emulation if the arch is
> different) on the system (without a chroot).

Understood.

> 
> Actually since we already (should?!) have an /etc/env.d/00musl we
> could put some helpful environment variable inside and use that
> to have an arch independent ldconfig script which does not fail
> when there are several /lib/ld-musl-*.so.1.

Thanks.  I forgot to add 00musl in 1.1.8-r1.  Its in 1.1.8-r2 and 9999.

I don't like the idea of *just* an environment variable since that can be fragile.  We need to also have a hardcoded fallback value especially on systems where musl is native.  Although I'd like ldconfig to be cross platform, i'm not against sed-ing it in the build for the particular arch in question.  We can do that *and* have an overriding env variable.  If set wrong, it would just screw up that shell (and children) and not the entire system.

Would that statisfy the cross compiling needs?
Comment 14 Felix Janda 2015-04-18 16:39:04 UTC
Thanks for adding 00musl.

For not getting confused about multiple /lib/ld-musl-*.so.1 certainly
any of the solutions you are proposing works.

Another way to make use of 00musl, would be to use LDPATH to insert
a (commented) line at the beginning of /etc/ld.so.conf with the name
of the dynamic linker name. We are already reading /etc/ld.so.conf
anyway and if there is some comment not to remove that line, the
user trying to remove that line has been warned...
Comment 15 Anthony Basile gentoo-dev 2015-05-13 16:46:53 UTC
(In reply to Felix Janda from comment #14)
> Thanks for adding 00musl.
> 
> For not getting confused about multiple /lib/ld-musl-*.so.1 certainly
> any of the solutions you are proposing works.
> 
> Another way to make use of 00musl, would be to use LDPATH to insert
> a (commented) line at the beginning of /etc/ld.so.conf with the name
> of the dynamic linker name. We are already reading /etc/ld.so.conf
> anyway and if there is some comment not to remove that line, the
> user trying to remove that line has been warned...

Please test musl-1.1.9.ebuild in a cross compiling env.  I've changed how the ldconfig script is built and it no longer does

   LDSO_PATH=$(ls /lib/ld-musl-*.so.1)

but rather check the target arch and adds the correct value for LDSO_PATH.
Comment 16 Felix Janda 2015-05-14 16:23:44 UTC
Thanks!

The new ldconfig works fine in my setup.

For crossdev no ldconfig is installed.