Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 589094 - Multilib support for musl libc based Gentoo
Summary: Multilib support for musl libc based Gentoo
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: AMD64 Linux
: Normal enhancement (vote)
Assignee: Gentoo musl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2016-07-18 16:04 UTC by Sebastian Doering
Modified: 2023-01-28 20:30 UTC (History)
2 users (show)

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


Attachments
patches and stuff (musl-multilib.tar.gz,1.55 KB, application/gzip)
2016-07-18 16:04 UTC, Sebastian Doering
Details
gcc patch (gcc-wchar_t.patch,286 bytes, patch)
2016-07-18 16:24 UTC, Sebastian Doering
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Doering 2016-07-18 16:04:25 UTC
Created attachment 441024 [details]
patches and stuff

Hello!

The last few weeks I've been working on turning my ARCH=amd64 hardened-musl Gentoo into a multilib Gentoo supporting the 32bit ABI. I don't exactly remember all the steps I underwent to make it work, but at least it doesn't seem to be impossible in principle and could maybe be supported by an official profile. Here's a rough list of what has to be done to make it work:

* Multilib musl ebuild (still missing, I did a manual install and bootstrapped the library from an i686 stage3. I'm not so good at ebuild writing). There's also a minor problem here with the musl configure. When using "--target=i686-gentoo-linux-musl it will at the end of make look for i686-gentoo-linux-musl-ar and *-ranlib. Fixed this with a symlink.

* A custom specs file (attached)

* I had to add an 'export GCC_SPECS=/path/to/specs to the gcc ebuild. It didn't seem to respect my env variable.

* Changes to multilib-minimal to support separate headers in /usr/include/i686-gentoo-linux-musl (attached)

* Basic multilib things for make.conf (should go into the profile; attached)

* /etc/ld-musl-i386.path needs to be added. Also currently env-update includes the 32 bit libraries to /etc/ld-musl-x86_64.path which can break things if the order is wrong (it added the 32 bit gcc libs before the 64 bit ones). Had to work around it by making it immutable (chattr +i)

I'm probably forgetting some minor things I did and I'm not sure that they way I did it is exactly the right/proper way to implement them. I'm kind of busy at the moment but will try to retread my steps in a stage3 ebuild, in order to reproduce the results.

Anyway, currently I'm running foobar2000 through 32bit wine in my amd64 musl Gentoo without a chroot and I couldn't be happier that it sort of works.

The only thing I can't get to work right now is GCC -fstack-protect for 32bit binaries (it's probably not supported?... Failing with unknown reference to __stack_chk_fail_local). My spec file takes care of disabling that flag for 32 bit stuff.

[Just noticed that I can only attach one file, so it's gotta be a tar.gz]

At the very least this bug report may help someone reproduce my work. Hope this helps.
Comment 1 Sebastian Doering 2016-07-18 16:24:16 UTC
Created attachment 441026 [details, diff]
gcc patch

Forgot to attach a gcc patch that was required.
Comment 2 Felix Janda 2016-07-19 08:45:49 UTC
Overall the approach of enabling multilib with musl looks sensible to me.

Instead of using a specfile it would be preferable to patch gcc's builtin specs.

The ldconfig script needs to be updated to be made multilib aware. I'm not quite sure how it should work. (Which directories go into ld-musl-i386.path, which into ld-musl-x86_64.path?)

Do you remember why you needed to add the gcc patch?

Although with bugzilla you cannot attach multiple files at once, you can attach them one after another.
Comment 3 Sebastian Doering 2016-07-19 09:43:39 UTC
>The ldconfig script needs to be updated to be made multilib aware. I'm not quite sure how it should work. (Which directories go into ld-musl-i386.path, which into ld-musl-x86_64.path?)

Could be pretty straight forward right? Multilib profile defines LIBDIR_x86, so we should add /$LIBDIR_x86 and /usr/$LIBDIR_x86 plus the 32 bit gcc libs of the current gcc profile? Other folders defined in env.d could be tricky though... grep for '32'? Meh...

>Do you remember why you needed to add the gcc patch?

I'm not sure why the #ifndef __cplusplus condition fired, but it did and caused a - afair - re-definition of wchar_t?

>Although with bugzilla you cannot attach multiple files at once, you can attach them one after another.

Yeah, kinda noticed that afterwards :/
Comment 4 Anthony Basile gentoo-dev 2016-07-21 16:31:03 UTC
(In reply to Sebastian Doering from comment #3)
> >The ldconfig script needs to be updated to be made multilib aware. I'm not quite sure how it should work. (Which directories go into ld-musl-i386.path, which into ld-musl-x86_64.path?)
> 
> Could be pretty straight forward right? Multilib profile defines LIBDIR_x86,
> so we should add /$LIBDIR_x86 and /usr/$LIBDIR_x86 plus the 32 bit gcc libs
> of the current gcc profile? Other folders defined in env.d could be tricky
> though... grep for '32'? Meh...
> 
> >Do you remember why you needed to add the gcc patch?
> 
> I'm not sure why the #ifndef __cplusplus condition fired, but it did and
> caused a - afair - re-definition of wchar_t?
> 
> >Although with bugzilla you cannot attach multiple files at once, you can attach them one after another.
> 
> Yeah, kinda noticed that afterwards :/

If you want to try, you can add all the profile components to the overlay and see if it works.  you'd have to have the musl profile inheriting from multilib.