Bug 58446 - Support for musl libc
Summary: Support for musl libc
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 55807 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-09-17 17:10 UTC by Gregor Richards
Modified: 2019-06-14 18:23 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc/ arch-generic configuration and fixes for musl (2.01 KB, patch)
2013-09-17 17:10 UTC, Gregor Richards
Details | Diff
Fix for gomp to specify _POSIX_SOURCE requirements (380 bytes, patch)
2013-09-17 17:11 UTC, Gregor Richards
Details | Diff
gcc_cv_target_dl_iterate_phdr=yes on musl (note that due to a bug in making these .diffs, the configure.ac change is in libssp.diff ...) (149 bytes, patch)
2013-09-17 17:12 UTC, Gregor Richards
Details | Diff
libssp support for musl (2.32 KB, patch)
2013-09-17 17:13 UTC, Gregor Richards
Details | Diff
x86/x86_64 support for musl (680 bytes, patch)
2013-09-17 17:13 UTC, Gregor Richards
Details | Diff
arm support for musl (771 bytes, patch)
2013-09-17 17:13 UTC, Gregor Richards
Details | Diff
mips support for musl (277 bytes, patch)
2013-09-17 17:14 UTC, Gregor Richards
Details | Diff
powerpc support for musl (1.26 KB, patch)
2013-09-17 17:14 UTC, Gregor Richards
Details | Diff
aarch64 support for musl (329 bytes, patch)
2013-09-17 17:15 UTC, Gregor Richards
Details | Diff
Changes to gcc/configure.ac for musl (614 bytes, patch)
2013-09-19 13:58 UTC, Gregor Richards
Details | Diff
arm support for musl (754 bytes, patch)
2013-09-19 14:00 UTC, Gregor Richards
Details | Diff
mips support for musl (348 bytes, patch)
2013-09-19 14:01 UTC, Gregor Richards
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Richards 2013-09-17 17:10:43 UTC
Created attachment 30829 [details]
gcc/ arch-generic configuration and fixes for musl

The attached patches add support for targeting the musl C library for Linux, http://musl-libc.org/

The patches are:

gcc-config-musl.diff: Addition of -mmusl (akin to -mglibc, -muclibc, -mbionic) for musl libc support, as well as support for using the musl ld.so, patch to stddef.h for musl size_t support, etc. Most controversially, redefines the include dir ordering iff musl is the default target.

gomp-posix.diff: Not directly related to musl, a fix to libgomp to make it properly specify required POSIX version.

gcc-config-dliterate.diff: gcc_cv_target_dl_iterate_phdr=yes for musl

libssp.diff: Support for libcs which provide libssp functions in libc (of which musl is the only example at present)

x86.diff, arm.diff, mips.diff, powerpc.diff, aarch64.diff: ld.so specification for each target and related fixes.
Comment 1 Gregor Richards 2013-09-17 17:11:32 UTC
Created attachment 30830 [details]
Fix for gomp to specify _POSIX_SOURCE requirements
Comment 2 Gregor Richards 2013-09-17 17:12:26 UTC
Created attachment 30831 [details]
gcc_cv_target_dl_iterate_phdr=yes on musl (note that due to a bug in making these .diffs, the configure.ac change is in libssp.diff ...)
Comment 3 Gregor Richards 2013-09-17 17:13:05 UTC
Created attachment 30832 [details]
libssp support for musl
Comment 4 Gregor Richards 2013-09-17 17:13:30 UTC
Created attachment 30833 [details]
x86/x86_64 support for musl
Comment 5 Gregor Richards 2013-09-17 17:13:52 UTC
Created attachment 30834 [details]
arm support for musl
Comment 6 Gregor Richards 2013-09-17 17:14:09 UTC
Created attachment 30835 [details]
mips support for musl
Comment 7 Gregor Richards 2013-09-17 17:14:37 UTC
Created attachment 30836 [details]
powerpc support for musl
Comment 8 Gregor Richards 2013-09-17 17:15:04 UTC
Created attachment 30837 [details]
aarch64 support for musl
Comment 9 Rich Felker 2013-09-17 17:23:56 UTC
I don't know what the maintenance policy is for non-latest releases, but it would be wonderful if we could get these into the 4.7 series before it's closed, too. Bootstrapping new toolchains/systems with a different libc than the host system's libc, it's much easier to start with a GCC that doesn't need C++, and it would be a big help if our users could just start with GCC 4.7.x and have it work out of the box, rather than needing to apply third-party patches.

(Speaking from the standpoint of musl maintainer.)
Comment 10 joseph@codesourcery.com 2013-09-17 20:10:47 UTC
On Tue, 17 Sep 2013, gcc-bug-espfv4bhi9 at gregor dot im wrote:

> libssp.diff: Support for libcs which provide libssp functions in libc (of which
> musl is the only example at present)

glibc provides libssp functions since version 2.4.  Apparently some people 
have a use for building libssp anyway (see bug 58312), but I'd think the 
build / installation of libssp should be disabled by default for glibc 
targets.  (Though given this is a per-multilib matter, disabling may mean 
just avoiding building / installing anything rather than completely 
disabling the directory at toplevel.)

Likewise, according to gcc/configure.ac, Bionic, and uClibc configured 
with __UCLIBC_HAS_SSP__.
Comment 11 Gregor Richards 2013-09-17 20:13:42 UTC
Aha. I didn't realize such a setting already existed; I'll test and update my patch later today to use the existing mechanism. Thanks for the info.
Comment 12 Gregor Richards 2013-09-19 13:58:57 UTC
Created attachment 30864 [details]
Changes to gcc/configure.ac for musl

Making libssp use the same system as everything else. (I'll leave the whether-to-build-libssp debate to future generations :) )
Comment 13 Gregor Richards 2013-09-19 14:00:25 UTC
Created attachment 30865 [details]
arm support for musl

This change to arm.diff adds support for musl's -eb and -hf linkers (/lib/ld-musl-arm[eb][hf].so.1)
Comment 14 Gregor Richards 2013-09-19 14:01:18 UTC
Created attachment 30866 [details]
mips support for musl

And the equivalent change for MIPS (/lib/ld-musl-mips[el].so.1)
Comment 15 David Heidelberg (okias) 2014-03-09 00:41:16 UTC
in which state is musl patches integration?

btw. here is also old bug #55807
Comment 16 nsz 2015-07-14 09:07:57 UTC
*** Bug 55807 has been marked as a duplicate of this bug. ***
Comment 18 Andrew Pinski 2016-08-05 05:27:28 UTC
Fixed.