Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 430838

Summary: sys-libs/musl-0.9.3, virtual/libc-0: new ebuilds and profile support
Product: Gentoo Linux Reporter: Anthony Basile <blueness>
Component: [OLD] Core systemAssignee: Anthony Basile <blueness>
Status: RESOLVED FIXED    
Severity: normal CC: dev-embedded+disabled, embedded, mgorny, nikoli, toolchain
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 430702    
Attachments: Proposed musl ebuild

Description Anthony Basile gentoo-dev 2012-08-10 22:15:43 UTC
musl can be integrated with gentoo in three ways:

1) musl can be installed as an alternative libc which is linked against when building with gcc using a special spec file.  The musl build system itself provides a wrapper to gcc and the spec file.

This can safely be installed on current gentoo systems with nothing more than the just the ebuild.


2) musl can be installed as the main libc.  In this case, there is no gcc wrapper or spec file as /lib/libc.so points directly to musl.  Currently there is one daring linux distribution that builds everything against musl:

    https://github.com/chneukirchen/sabotage

This can break an unsuspecting users system so it cannot safely be installed unless you really know what your doing!  It also invovled adding musl to virtual/libc-0, masking it in profile/base and unmasking it in a musl specific profile, like we do with uclibc.


3) musl can be integrated with sys-devel/crossdev to build x-compiling toolchains.  This again requires the virtual and profile support among other hacks against crossdev.
Comment 1 Anthony Basile gentoo-dev 2012-08-10 22:29:46 UTC
Created attachment 320934 [details]
Proposed musl ebuild

Unlike uclibc, musl is not very configurable.  There's only two options, whether to install it as a native libc, or an alternative libc.

The logic in the ebuild is: 1) if CTARGET = CHOST, then decide based on the tuple wether we are installing as a native lib or alternative.  2) if CTARGET != CHOST then we are cross compiling.  While this is TODO, we would still be installing musl as the native libc.
Comment 2 Anthony Basile gentoo-dev 2012-08-10 22:33:40 UTC
The modification to virtual/libc-0 would be trivial:

diff -Naur libc-0.ebuild.orig libc-0.ebuild
--- libc-0.ebuild.orig	2012-08-10 18:31:34.000000000 -0400
+++ libc-0.ebuild	2012-08-10 18:32:29.000000000 -0400
@@ -19,5 +19,6 @@
 RDEPEND="!prefix? (
 		elibc_glibc? ( sys-libs/glibc:2.2 )
 		elibc_uclibc? ( sys-libs/uclibc )
+		elibc_musl? ( sys-libs/musl )
 		elibc_FreeBSD? ( sys-freebsd/freebsd-lib )
 	)"
Comment 3 Anthony Basile gentoo-dev 2012-08-10 22:52:19 UTC
The proposed change to profile/base would be:

diff -Naur /usr/portage/profiles/base/package.mask base/package.mask
--- /usr/portage/profiles/base/package.mask	2012-07-28 05:31:26.000000000 -0400
+++ base/package.mask	2012-08-10 18:46:33.000000000 -0400
@@ -10,6 +10,11 @@
 # still available on default profiles to be used with crossdev.
 sys-libs/uclibc
 
+# Make sure sys-libs/musl is only available on systems on musl profile
+# or on systems where the user explicitly unmasks musl as using it
+# incorrectly can break your system
+sys-libs/musl
+
 # Diego E. Pettenò <flameeyes@gentoo.org> (25 Apr 2010)
 #  on behalf of QA team <qa@gentoo.org
 #
diff -Naur /usr/portage/profiles/base/use.mask base/use.mask
--- /usr/portage/profiles/base/use.mask	2012-07-31 11:01:26.000000000 -0400
+++ base/use.mask	2012-08-10 18:47:23.000000000 -0400
@@ -44,6 +44,7 @@
 selinux
 uclibc
 multilib
+musl
 
 # amd64/x86 arch specific USE flags
 kqemu
@@ -150,6 +151,7 @@
 elibc_HPUX
 elibc_Interix
 elibc_mintlib
+elibc_musl
 elibc_NetBSD
 elibc_OpenBSD
 elibc_SunOS




The proposed change to desc/elibc.desc would be

--- /usr/portage/profiles/desc/elibc.desc	2011-12-18 04:04:46.000000000 -0500
+++ desc/elibc.desc	2012-08-09 22:16:56.000000000 -0400
@@ -14,6 +14,7 @@
 HPUX - ELIBC setting for systems that use the HP-UX C library
 Interix - ELIBC setting for systems that use the Interix C library
 mintlib - ELIBC setting for systems that use the FreeMiNT C library
+musl - ELIBC setting for systems that use the musl C library
 NetBSD - ELIBC setting for systems that use the NetBSD C library
 OpenBSD - ELIBC setting for systems that use the OpenBSD C library
 SunOS - ELIBC setting for systems that use the Sun Solaris C library




We would add a profile called profile/musl/linux which would have (among other possible details):

package.mask:
sys-libs/glibc
sys-libs/uclibc
-sys-libs/musl


use.force:
elibc_uclibc


use.mask:
emul-linux-x86
elibc_uclibc
elibc_glibc
Comment 4 SpanKY gentoo-dev 2012-08-11 03:07:08 UTC
i would forgo the USE=musl until something actually requests it.  and even then, it should most likely be elibc_musl and not musl.

as for the ebuild, i think you should look at how the uclibc/glibc/newlib ebuilds respect CHOST/CTARGET/etc... (newlib might be the simplest).

having every ebuild install "musl-gcc" is most likely just wrong.
Comment 5 Anthony Basile gentoo-dev 2013-06-16 00:05:00 UTC
Okay I added the following to profiles:

yellow profiles # cvs diff
X11 forwarding request failed on channel 0
Index: base/make.defaults
===================================================================
RCS file: /var/cvsroot/gentoo-x86/profiles/base/make.defaults,v
retrieving revision 1.99
diff -u -B -r1.99 make.defaults
--- base/make.defaults	30 May 2013 11:20:44 -0000	1.99
+++ base/make.defaults	16 Jun 2013 00:01:21 -0000
@@ -10,7 +10,7 @@
 USE_EXPAND_UNPREFIXED="ARCH"
 USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
 USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
-USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib NetBSD OpenBSD SunOS uclibc Winnt"
+USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
 USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
 USE_EXPAND_VALUES_USERLAND="BSD GNU"
 
Index: base/package.mask
===================================================================
RCS file: /var/cvsroot/gentoo-x86/profiles/base/package.mask,v
retrieving revision 1.56
diff -u -B -r1.56 package.mask
--- base/package.mask	6 Apr 2013 13:20:01 -0000	1.56
+++ base/package.mask	16 Jun 2013 00:01:21 -0000
@@ -10,6 +10,12 @@
 # still available on default profiles to be used with crossdev.
 sys-libs/uclibc
 
+# Anthony G. Basile <blueness@gentoo.org> (15 Jun 2013)
+# Make sure sys-libs/musl is only available for musl profiles or
+# where the user explicitly unmasks it as using it incorrectly
+# can break a system.  It is still available with crossdev.
+sys-libs/musl
+
 # Diego E. Pettenò <flameeyes@gentoo.org> (25 Apr 2010)
 #  on behalf of QA team <qa@gentoo.org
 #
Index: base/use.mask
===================================================================
RCS file: /var/cvsroot/gentoo-x86/profiles/base/use.mask,v
retrieving revision 1.172
diff -u -B -r1.172 use.mask
--- base/use.mask	13 Jun 2013 18:24:24 -0000	1.172
+++ base/use.mask	16 Jun 2013 00:01:21 -0000
@@ -157,6 +157,7 @@
 elibc_HPUX
 elibc_Interix
 elibc_mintlib
+elibc_musl
 elibc_NetBSD
 elibc_OpenBSD
 elibc_SunOS
Index: desc/elibc.desc
===================================================================
RCS file: /var/cvsroot/gentoo-x86/profiles/desc/elibc.desc,v
retrieving revision 1.5
diff -u -B -r1.5 elibc.desc
--- desc/elibc.desc	18 Dec 2011 09:04:46 -0000	1.5
+++ desc/elibc.desc	16 Jun 2013 00:01:21 -0000
@@ -14,6 +14,7 @@
 HPUX - ELIBC setting for systems that use the HP-UX C library
 Interix - ELIBC setting for systems that use the Interix C library
 mintlib - ELIBC setting for systems that use the FreeMiNT C library
+musl - ELIBC setting for systems that use the musl C library
 NetBSD - ELIBC setting for systems that use the NetBSD C library
 OpenBSD - ELIBC setting for systems that use the OpenBSD C library
 SunOS - ELIBC setting for systems that use the Sun Solaris C library
Comment 6 Anthony Basile gentoo-dev 2013-06-16 00:11:59 UTC
(In reply to Anthony Basile from comment #2)
> The modification to virtual/libc-0 would be trivial:
> 
> diff -Naur libc-0.ebuild.orig libc-0.ebuild
> --- libc-0.ebuild.orig	2012-08-10 18:31:34.000000000 -0400
> +++ libc-0.ebuild	2012-08-10 18:32:29.000000000 -0400
> @@ -19,5 +19,6 @@
>  RDEPEND="!prefix? (
>  		elibc_glibc? ( sys-libs/glibc:2.2 )
>  		elibc_uclibc? ( sys-libs/uclibc )
> +		elibc_musl? ( sys-libs/musl )
>  		elibc_FreeBSD? ( sys-freebsd/freebsd-lib )
>  	)"


This has now been added.  We can use $PORTDIR/profiles/embedded for now, but I may add one later specifically for musl.

This bug is done.