From 9f3016443e1b5ed53e63e0ca684dba211123da22 Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Tue, 27 Aug 2013 22:14:49 +0200 Subject: [PATCH] musl: Added musl 0.9.12 - A lightweight implementation of a standard C library --- base/musl/musl.conf | 31 ++ base/musl/musl.desc | 37 ++ base/musl/parse-config-9 | 187 +++++++++ base/musl/parse-config-fixarch | 17 + base/musl/pkg/gcc/gcc-4.7.3-musl.patch | 548 +++++++++++++++++++++++++ 5 files changed, 820 insertions(+) create mode 100644 base/musl/musl.conf create mode 100644 base/musl/musl.desc create mode 100644 base/musl/parse-config-9 create mode 100644 base/musl/parse-config-fixarch create mode 100644 base/musl/pkg/gcc/gcc-4.7.3-musl.patch diff --git a/base/musl/musl.conf b/base/musl/musl.conf new file mode 100644 index 000000000..4e75a809f --- /dev/null +++ b/base/musl/musl.conf @@ -0,0 +1,31 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../musl/musl.conf +# Copyright (C) 2012 - 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +# translate $arch for being usable with musl +musl_arch="$( echo $arch | arch2uname )" + +if atstage toolchain; then + confopt="--prefix=$base/build/$SDECFG_ID/usr \$extraconfopt" + + makeopt="ARCH=$musl_arch" + var_append makeopt ' ' "include/bits" + + makeinstopt="ARCH=$musl_arch install-headers" +fi + +# if musl is default libc +if [ "$SDECFG_LIBC" == "musl" ]; then + # disable gcc wrapper script + var_append extraconfopt ' ' "--disable-gcc-wrapper" +fi diff --git a/base/musl/musl.desc b/base/musl/musl.desc new file mode 100644 index 000000000..e95a31950 --- /dev/null +++ b/base/musl/musl.desc @@ -0,0 +1,37 @@ +[COPY] --- SDE-COPYRIGHT-NOTE-BEGIN --- +[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch. +[COPY] +[COPY] Filename: package/.../musl/musl.desc +[COPY] Copyright (C) 2012 - 2013 The OpenSDE Project +[COPY] +[COPY] More information can be found in the files COPYING and README. +[COPY] +[COPY] This program is free software; you can redistribute it and/or modify +[COPY] it under the terms of the GNU General Public License as published by +[COPY] the Free Software Foundation; version 2 of the License. A copy of the +[COPY] GNU General Public License can be found in the file COPYING. +[COPY] --- SDE-COPYRIGHT-NOTE-END --- + +[I] A lightweight implementation of a standard C library + +[T] musl is a new general-purpose implementation of the C library. It is +[T] lightweight, fast, simple, free, and aims to be correct in the sense of +[T] standards-conformance and safety. +[T] It implements the standard library functionality described in the ISO C +[T] and POSIX standards, plus common extensions, intended for use on Linux +[T] based systems. + +[U] http://www.musl-libc.org/ + +[A] Rich Felker +[M] Christian Wiese + +[C] extra/base +[F] LIBC + +[L] MIT +[S] Beta +[V] 0.9.12 +[P] X 01-------9 101.700 + +[D] 2929595685 musl-0.9.12.tar.gz http://www.musl-libc.org/releases/ diff --git a/base/musl/parse-config-9 b/base/musl/parse-config-9 new file mode 100644 index 000000000..e29ac2e3b --- /dev/null +++ b/base/musl/parse-config-9 @@ -0,0 +1,187 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../musl/parse-config-9 +# Copyright (C) 2012 - 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +if [ "$SDECFG_LIBC" == "musl" ]; then + pkg_musl_dir=$base/package/base/musl + + if [ $pkg != "gettext" ]; then + var_append flistdel "|" "usr/share/locale/locale.alias" + fi + + # I don't know what this is for //morfoh + var_append flistdel "|" "$( echo $libdir | cut -d '/' -f2- )/charset.alias" + + # the most tipical fix is to config.sub + # + musl_fix_configsub() { + local x; for x; do + echo_warning "Adding linux-musl target support to $x" + echo "musl_fix_configsub: adding musl_arch_target support to $x" + cp -f $x $x.orig + sed -e 's,\([-]\?linux\)-gnu\*,\1-gnu\* | \1-musl\*,g' $x.orig > $x + diff -u $x.orig $x || true + done + } + musl_auto_fix_configsub() { + local f + for f in . ./build-aux ./config ./support; do + if [ -e $f/config.sub ] ; then + if ! grep -q '\-musl' $f/config.sub; then + musl_fix_configsub $f/config.sub + fi + fi + done + } + musl_findall_fix_configsub() { + local f + for f in `find . -name config.sub`; do + musl_fix_configsub $f + done + } + + + # FIXME: i forgot what makes musl_fix_addcases different than musl_fix_configsub //mnemoc + musl_fix_addcases() { + local file; for file; do + echo "musl_fix_addcases: adding *-linux-musl* support to $file" + cp -f $file $file.orig + sed -i -e 's,\([^ ]*\)linux-gnu\*\(.*\)\([\)\\]\),\1linux-gnu* | \1linux-musl*\2\3,g' $file + diff -u $file.orig $file || true + done + } + + musl_fix_addcases2() { + local file; for file; do + echo "musl_fix_addcases2: adding *-linux-musl* support to $file" + cp -f $file $file.orig + sed -i -e 's,\( *.*\)linux-gnu\*)\(.*\)\;\;$,\1linux-musl*)\2;;\n\1linux-gnu*)\2;;,g' \ + -e 's,\( *.*\)linux-gnu\*)\(.*[^;][^;]\)$,\1linux-musl* \| \\\n\1linux-gnu*)\2,g' \ + $file + diff -u $file.orig $file || true + done + } + # fix typical locations + hook_add postpatch 5 'musl_auto_fix_configsub' + + # fix issues with included gnulib + # http://openwall.com/lists/musl/2012/06/19/13 + musl_fix_gnulib() { + local dir="$1" + + gl_config_cache=" + gl_cv_func_isnanl_works=yes \ + gl_cv_header_working_stdint_h=yes \ + gl_cv_func_fpurge_works=yes \ + gl_cv_func_fcntl_f_dupfd_cloexec=yes \ + gl_cv_func_getcwd_path_max=yes \ + gl_cv_func_fprintf_posix=yes \ + gl_cv_func_printf_sizes_c99=yes \ + gl_cv_func_printf_long_double=yes \ + gl_cv_func_printf_infinite=yes \ + gl_cv_func_printf_infinite_long_double=yes \ + gl_cv_func_printf_directive_a=yes \ + gl_cv_func_printf_directive_f=yes \ + gl_cv_func_printf_directive_n=yes \ + gl_cv_func_printf_directive_ls=yes \ + gl_cv_func_printf_positions=yes \ + gl_cv_func_printf_flag_grouping=yes \ + gl_cv_func_printf_flag_leftadjust=yes \ + gl_cv_func_printf_flag_zero=yes \ + gl_cv_func_printf_precision=yes \ + gl_cv_func_printf_enomem=yes" + + for x in $gl_config_cache; do + var_append configcache ' ' "$x" + done + + empty_file() { + echo "gnulib fix: emptying file $1" + rm -f $1 + touch $1 + } + + for x in fseterr.c freadahead.c fseeko.c; do + empty_file "$dir/$x" + done + echo "void close_stdin(void) {}" > "$dir"/closein.c + + echo "#include " > "$dir"/fseterr.h + echo "#define fseterr(fp) __fseterr (fp)" >> "$dir"/fseterr.h + echo "#include "fseterr.h"" > "$dir"/fsetserr.c + + # fix stuff trying to reimplement libc + culprits="accept4 acosl alloca alphasort asinl asprintf atanl \ + atexit atoll bcopy btowc chown closedir cosl dirfd \ + dprintf dup2 dup3 _Exit expl fchdir fchown-stub \ + fdatasync fdopendir ffs flock fnmatch forkpty fpending \ + fprintf freeaddrinfo fsync ftell ftruncate futimens \ + gai_strerror getaddrinfo getdelim getdtablesize \ + getgroups gethostname getline getlogin getlogin_r \ + getnameinfo getpagesize getpass getsubopt gettimeofday \ + getusershell gmtime_r grantpt imaxabs imaxdiv inet_ntop \ + inet_pton isblank iswblank lchmod lchown ldexp ldexpl \ + link linkat logl mbrlen mbrtowc mbsinit memmove mempcpy \ + mkdtemp mkfifo mkfifoat mknod mknodat mkstemp mktime \ + nanosleep nl_langinfo open openat opendir openpty pclose \ + perror pipe pipe2 poll popen pread pselect ptsname \ + pwrite raise readdir readlink renameat rewinddir setenv \ + sigaction sigaddset sigdelset sigemptyset sigfillset \ + sigismember sigpending sigprocmask sinl snprintf \ + spawnattr_destroy spawnattr_getdefault spawnattr_getflags \ + spawnattr_getpgroup spawnattr_getsigmask spawnattr_init \ + spawnattr_setdefault.c spawnattr_setflags spawnattr_setpgroup \ + spawnattr_setsigmask spawn_faction_addclose \ + spawn_faction_adddup2 spawn_faction_addopen \ + spawn_faction_destroy spawn_faction_init \ + spawn_factions_addopen spawn_factions_destroy \ + spawn_factions_init sprintf sqrtl stdio-read stdio-write \ + strcasecmp strcasestr strchrnul strcspn strncasecmp \ + strndup strnlen strpbrk strsep strsignal strstr strtod \ + strtoimax strtol symlink symlinkat tanl tcgetsid timegm \ + time_r times tmpfile uname unlockpt unsetenv usleep \ + vasprintf vdprintf waitpid wcrtomb wctob" + + #for x in $culprits ; do empty_file "$dir/$x.c" ; done + } + + # and some others + case "$pkg" in + binutils) + hook_add postpatch 4 'musl_fix_addcases ./bfd/config.bfd ./bfd/configure \ + ./bfd/configure.in ./ld/configure.tgt' + hook_add postpatch 5 'musl_fix_addcases2 ./gas/configure ./gas/configure.in' + ;; + gmp) + hook_add postpatch 6 'musl_fix_configsub configfsf.sub' + ;; + esac + + # same package translations to look for patches + case "$pkg" in + linux*|linux-header) + pkg_musl_pkg=linux ;; + *) + pkg_musl_pkg=${pkg} ;; + esac + + pkg_musl_patches=$( ls -1 $pkg_musl_dir/pkg/$pkg_musl_pkg/*.patch 2> /dev/null | tr '\n' ' ' ) + if [ -n "$pkg_musl_patches" ]; then + echo_status "musl: appending patches ..." + var_append patchfiles ' ' "$pkg_musl_patches" + fi + + if [ -f $pkg_musl_dir/pkg/$pkg/$pkg.conf ]; then + . $pkg_musl_dir/pkg/$pkg/$pkg.conf + fi +fi diff --git a/base/musl/parse-config-fixarch b/base/musl/parse-config-fixarch new file mode 100644 index 000000000..c4ae94bf1 --- /dev/null +++ b/base/musl/parse-config-fixarch @@ -0,0 +1,17 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../musl/parse-config-fixarch +# Copyright (C) 2012 - 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +if [ "$SDECFG_LIBC" == "musl" -a "${arch_target%gnu}" != "$arch_target" ]; then + arch_target=${arch_target%gnu}musl +fi diff --git a/base/musl/pkg/gcc/gcc-4.7.3-musl.patch b/base/musl/pkg/gcc/gcc-4.7.3-musl.patch new file mode 100644 index 000000000..f87fd2c54 --- /dev/null +++ b/base/musl/pkg/gcc/gcc-4.7.3-musl.patch @@ -0,0 +1,548 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../musl/pkg/gcc/gcc-4.7.3-musl.patch +# Copyright (C) 2013 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +# HG changeset patch +# Parent 05e4cf5f033d266c8f8fe065f8c5752891c5bf7a +Adding musl to config.sub, so it's recognized as a target platform. + + +diff -r 05e4cf5f033d -r 04a6a82b8e06 config.sub +--- a/config.sub Wed Nov 21 21:16:07 2012 -0500 ++++ b/config.sub Wed Nov 21 21:16:58 2012 -0500 +@@ -125,6 +125,7 @@ + maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ ++ linux-musl* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ +@@ -1346,6 +1347,7 @@ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ ++ | -linux-musl* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ +# HG changeset patch +# Parent 04a6a82b8e06669a42181c96381b4fbc3ffa008c +Use the generic implementation of libstdc++ primitives when we're on musl, not the glibc one. + + +diff -r 04a6a82b8e06 -r 193f80e01b02 libstdc++-v3/configure.host +--- a/libstdc++-v3/configure.host Wed Nov 21 21:16:58 2012 -0500 ++++ b/libstdc++-v3/configure.host Wed Nov 21 21:17:38 2012 -0500 +@@ -243,6 +243,13 @@ + os_include_dir="os/bsd/freebsd" + ;; + gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) ++ # check for musl by target ++ case "${host_os}" in ++ *-musl*) ++ os_include_dir="os/generic" ++ ;; ++ *) ++ + if [ "$uclibc" = "yes" ]; then + os_include_dir="os/uclibc" + elif [ "$bionic" = "yes" ]; then +@@ -251,6 +258,9 @@ + os_include_dir="os/gnu-linux" + fi + ;; ++ ++ esac ++ ;; + hpux*) + os_include_dir="os/hpux" + ;; +# HG changeset patch +# Parent 193f80e01b026d8de7f53d467f2c59cd0b7927dc +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker. + + +diff -r 193f80e01b02 -r 45cd88d4fb7b gcc/config.gcc +--- a/gcc/config.gcc Wed Nov 21 21:17:38 2012 -0500 ++++ b/gcc/config.gcc Wed Nov 21 21:19:19 2012 -0500 +@@ -522,7 +522,7 @@ + esac + + # Common C libraries. +-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3" ++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" + + # Common parts for widely ported systems. + case ${target} in +@@ -625,6 +625,9 @@ + *-*-*uclibc*) + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" + ;; ++ *-*-*musl*) ++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" ++ ;; + *) + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" + ;; +diff -r 193f80e01b02 -r 45cd88d4fb7b gcc/config/linux.h +--- a/gcc/config/linux.h Wed Nov 21 21:17:38 2012 -0500 ++++ b/gcc/config/linux.h Wed Nov 21 21:19:19 2012 -0500 +@@ -33,10 +33,12 @@ + #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) ++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) + #else + #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) + #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) + #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) ++#define OPTION_MUSL (linux_libc == LIBC_MUSL) + #endif + + #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ +@@ -54,18 +56,21 @@ + uClibc or Bionic is the default C library and whether + -muclibc or -mglibc or -mbionic has been passed to change the default. */ + +-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ +- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" ++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ ++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" + + #if DEFAULT_LIBC == LIBC_GLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ +- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B) ++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ ++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) + #elif DEFAULT_LIBC == LIBC_UCLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ +- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B) ++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ ++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) + #elif DEFAULT_LIBC == LIBC_BIONIC +-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ +- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U) ++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ ++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) ++#elif DEFAULT_LIBC == LIBC_MUSL ++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ ++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) + #else + #error "Unsupported DEFAULT_LIBC" + #endif /* DEFAULT_LIBC */ +@@ -85,16 +90,16 @@ + + #define GNU_USER_DYNAMIC_LINKER \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ +- BIONIC_DYNAMIC_LINKER) ++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) + #define GNU_USER_DYNAMIC_LINKER32 \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ +- BIONIC_DYNAMIC_LINKER32) ++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) + #define GNU_USER_DYNAMIC_LINKER64 \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ +- BIONIC_DYNAMIC_LINKER64) ++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) + #define GNU_USER_DYNAMIC_LINKERX32 \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ +- BIONIC_DYNAMIC_LINKERX32) ++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) + + /* Determine whether the entire c99 runtime + is present in the runtime library. */ +diff -r 193f80e01b02 -r 45cd88d4fb7b gcc/config/linux.opt +--- a/gcc/config/linux.opt Wed Nov 21 21:17:38 2012 -0500 ++++ b/gcc/config/linux.opt Wed Nov 21 21:19:19 2012 -0500 +@@ -30,3 +30,7 @@ + muclibc + Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) + Use uClibc C library ++ ++mmusl ++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) ++Use musl C library +diff -r 193f80e01b02 -r 45cd88d4fb7b gcc/ginclude/stddef.h +--- a/gcc/ginclude/stddef.h Wed Nov 21 21:17:38 2012 -0500 ++++ b/gcc/ginclude/stddef.h Wed Nov 21 21:19:19 2012 -0500 +@@ -184,6 +184,7 @@ + #ifndef _GCC_SIZE_T + #ifndef _SIZET_ + #ifndef __size_t ++#ifndef __DEFINED_size_t /* musl */ + #define __size_t__ /* BeOS */ + #define __SIZE_T__ /* Cray Unicos/Mk */ + #define _SIZE_T +@@ -200,6 +201,7 @@ + #define ___int_size_t_h + #define _GCC_SIZE_T + #define _SIZET_ ++#define __DEFINED_size_t /* musl */ + #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ + || defined(__FreeBSD_kernel__) + /* __size_t is a typedef on FreeBSD 5, must not trash it. */ +@@ -215,6 +217,7 @@ + typedef long ssize_t; + #endif /* __BEOS__ */ + #endif /* !(defined (__GNUG__) && defined (size_t)) */ ++#endif /* __DEFINED_size_t */ + #endif /* __size_t */ + #endif /* _SIZET_ */ + #endif /* _GCC_SIZE_T */ +# HG changeset patch +# Parent 45cd88d4fb7b0e813578c296004eaab2c2d0bfb9 +A fix for libgomp to correctly request a POSIX version for time support. + + +diff -r 45cd88d4fb7b -r 0afd9d82498d libgomp/config/posix/time.c +--- a/libgomp/config/posix/time.c Wed Nov 21 21:19:19 2012 -0500 ++++ b/libgomp/config/posix/time.c Wed Nov 21 21:20:22 2012 -0500 +@@ -28,6 +28,8 @@ + The following implementation uses the most simple POSIX routines. + If present, POSIX 4 clocks should be used instead. */ + ++#define _POSIX_C_SOURCE 199309L /* for clocks */ ++ + #include "libgomp.h" + #include + #if TIME_WITH_SYS_TIME +diff -r 2ebb44d1e6f1 libgcc/unwind-dw2-fde-dip.c +--- a/libgcc/unwind-dw2-fde-dip.c Sun Jul 28 12:15:47 2013 -0400 ++++ b/libgcc/unwind-dw2-fde-dip.c Sun Jul 28 12:17:02 2013 -0400 +@@ -47,28 +47,13 @@ + #include "unwind-compat.h" + #include "gthr.h" + +-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ +- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ +- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR) + # define USE_PT_GNU_EH_FRAME +-#endif +- +-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ +- && defined(__FreeBSD__) && __FreeBSD__ >= 7 +-# define ElfW __ElfN +-# define USE_PT_GNU_EH_FRAME +-#endif +- +-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ +- && defined(__OpenBSD__) +-# define ElfW(type) Elf_##type +-# define USE_PT_GNU_EH_FRAME +-#endif +- +-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ +- && defined(TARGET_DL_ITERATE_PHDR) \ +- && defined(__sun__) && defined(__svr4__) +-# define USE_PT_GNU_EH_FRAME ++# ifdef __OpenBSD__ ++# define ElfW(type) Elf_##typ ++# elif defined(__FreeBSD__) && __FreeBSD__ >= 7 ++# define ElfW __ElfN ++# endif + #endif + + #if defined(USE_PT_GNU_EH_FRAME) +--- a/gcc/configure ++++ b/gcc/configure +@@ -26970,6 +26970,9 @@ + gcc_cv_target_dl_iterate_phdr=no + fi + ;; ++ *-linux-musl*) ++ gcc_cv_target_dl_iterate_phdr=yes ++ ;; + esac + + if test x$gcc_cv_target_dl_iterate_phdr = xyes; then + +# HG changeset patch +# Parent 94e435662aff38e86c9ca0dff4bbf451e0190b34 +Get rid of ever-broken fixincludes on musl. + + +diff -r 94e435662aff -r e27957848dc8 fixincludes/mkfixinc.sh +--- a/fixincludes/mkfixinc.sh Sat Jul 27 23:37:20 2013 -0400 ++++ b/fixincludes/mkfixinc.sh Sat Jul 27 23:43:03 2013 -0400 +@@ -19,7 +19,8 @@ + powerpc-*-eabi* | \ + powerpc-*-rtems* | \ + powerpcle-*-eabisim* | \ +- powerpcle-*-eabi* ) ++ powerpcle-*-eabi* | \ ++ *-musl* ) + # IF there is no include fixing, + # THEN create a no-op fixer and exit + (echo "#! /bin/sh" ; echo "exit 0" ) > ${target} +# HG changeset patch +# Parent 0afd9d82498d2cd30aa78529ff25f211bdc0c3b9 +Support for i386-linux-musl and x86_64-linux-musl. + + +diff -r 0afd9d82498d -r 53f3e21a7d14 gcc/config/i386/linux.h +--- a/gcc/config/i386/linux.h Wed Nov 21 21:20:22 2012 -0500 ++++ b/gcc/config/i386/linux.h Wed Nov 21 21:21:21 2012 -0500 +@@ -22,3 +22,4 @@ + + #define GNU_USER_LINK_EMULATION "elf_i386" + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" +diff -r 0afd9d82498d -r 53f3e21a7d14 gcc/config/i386/linux64.h +--- a/gcc/config/i386/linux64.h Wed Nov 21 21:20:22 2012 -0500 ++++ b/gcc/config/i386/linux64.h Wed Nov 21 21:21:21 2012 -0500 +@@ -31,3 +31,7 @@ + #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" + #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" + #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" ++ ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" ++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1" +diff -r 0afd9d82498d -r 53f3e21a7d14 libitm/config/linux/x86/tls.h +--- a/libitm/config/linux/x86/tls.h Wed Nov 21 21:20:22 2012 -0500 ++++ b/libitm/config/linux/x86/tls.h Wed Nov 21 21:21:21 2012 -0500 +@@ -25,16 +25,19 @@ + #ifndef LIBITM_X86_TLS_H + #define LIBITM_X86_TLS_H 1 + +-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) ++#if defined(__GLIBC_PREREQ) ++#if __GLIBC_PREREQ(2, 10) + /* Use slots in the TCB head rather than __thread lookups. + GLIBC has reserved words 10 through 13 for TM. */ + #define HAVE_ARCH_GTM_THREAD 1 + #define HAVE_ARCH_GTM_THREAD_DISP 1 + #endif ++#endif + + #include "config/generic/tls.h" + +-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) ++#if defined(__GLIBC_PREREQ) ++#if __GLIBC_PREREQ(2, 10) + namespace GTM HIDDEN { + + #ifdef __x86_64__ +@@ -101,5 +104,6 @@ + + } // namespace GTM + #endif /* >= GLIBC 2.10 */ ++#endif + + #endif // LIBITM_X86_TLS_H +# HG changeset patch +# Parent 53f3e21a7d14d0514ec7cb9ffb67b24dcf1f9fc9 +Support for arm-linux-musl. + + +diff -r 53f3e21a7d14 -r 0a4e297edad6 gcc/config/arm/linux-eabi.h +--- a/gcc/config/arm/linux-eabi.h Wed Nov 21 21:21:21 2012 -0500 ++++ b/gcc/config/arm/linux-eabi.h Wed Nov 21 21:21:54 2012 -0500 +@@ -64,6 +64,10 @@ + #undef GLIBC_DYNAMIC_LINKER + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3" + ++/* musl has no "classic" (i.e. broken) mode */ ++#undef MUSL_DYNAMIC_LINKER ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1" ++ + /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to + use the GNU/Linux version, not the generic BPABI version. */ + #undef LINK_SPEC +diff -r 53f3e21a7d14 -r 0a4e297edad6 libitm/config/arm/hwcap.cc +--- a/libitm/config/arm/hwcap.cc Wed Nov 21 21:21:21 2012 -0500 ++++ b/libitm/config/arm/hwcap.cc Wed Nov 21 21:21:54 2012 -0500 +@@ -40,7 +40,11 @@ + + #ifdef __linux__ + #include ++#ifdef __GLIBC__ + #include ++#else ++#include ++#endif + #include + + static void __attribute__((constructor)) +# HG changeset patch +# Parent 0a4e297edad6e46f4b66401b93b217aa3194af4e +Support for mips-linux-musl. + + +diff -r 0a4e297edad6 -r 78025c74c5c1 gcc/config/mips/linux.h +--- a/gcc/config/mips/linux.h Wed Nov 21 21:21:54 2012 -0500 ++++ b/gcc/config/mips/linux.h Wed Nov 21 21:23:49 2012 -0500 +@@ -19,3 +19,5 @@ + . */ + + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" ++ ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1" +# HG changeset patch +# Parent 78025c74c5c1705f16ce13f3645ecb86c10cc1c2 +Support for powerpc-linux-musl. + +diff -r 78025c74c5c1 gcc/config.gcc +--- a/gcc/config.gcc Wed Nov 21 21:23:49 2012 -0500 ++++ b/gcc/config.gcc Wed Nov 21 21:45:58 2012 -0500 +@@ -2078,6 +2078,10 @@ + powerpc*-*-linux*paired*) + tm_file="${tm_file} rs6000/750cl.h" ;; + esac ++ case ${target} in ++ *-linux*-musl*) ++ enable_secureplt=yes ;; ++ esac + if test x${enable_secureplt} = xyes; then + tm_file="rs6000/secureplt.h ${tm_file}" + fi +diff -r 78025c74c5c1 gcc/config/rs6000/linux64.h +--- a/gcc/config/rs6000/linux64.h Wed Nov 21 21:23:49 2012 -0500 ++++ b/gcc/config/rs6000/linux64.h Wed Nov 21 21:45:58 2012 -0500 +@@ -362,17 +362,21 @@ + #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1" + #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" + #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1" ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" + #elif DEFAULT_LIBC == LIBC_GLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" ++#elif DEFAULT_LIBC == LIBC_MUSL ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" + #else + #error "Unsupported DEFAULT_LIBC" + #endif + #define GNU_USER_DYNAMIC_LINKER32 \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) + #define GNU_USER_DYNAMIC_LINKER64 \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) + + + #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \ +diff -r 78025c74c5c1 gcc/config/rs6000/secureplt.h +--- a/gcc/config/rs6000/secureplt.h Wed Nov 21 21:23:49 2012 -0500 ++++ b/gcc/config/rs6000/secureplt.h Wed Nov 21 21:45:58 2012 -0500 +@@ -18,3 +18,4 @@ + . */ + + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" +diff -r 78025c74c5c1 gcc/config/rs6000/sysv4.h +--- a/gcc/config/rs6000/sysv4.h Wed Nov 21 21:23:49 2012 -0500 ++++ b/gcc/config/rs6000/sysv4.h Wed Nov 21 21:45:58 2012 -0500 +@@ -566,6 +566,9 @@ + #ifndef CC1_SECURE_PLT_DEFAULT_SPEC + #define CC1_SECURE_PLT_DEFAULT_SPEC "" + #endif ++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC ++#define LINK_SECURE_PLT_DEFAULT_SPEC "" ++#endif + + /* Pass -G xxx to the compiler and set correct endian mode. */ + #define CC1_SPEC "%{G*} %(cc1_cpu) \ +@@ -626,7 +629,8 @@ + %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \ + %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ + %{mcall-i960-old: --oformat elf32-powerpcle} \ +- }}}}" ++ }}}} \ ++%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" + + /* Any specific OS flags. */ + #define LINK_OS_SPEC "\ +@@ -804,15 +808,18 @@ + + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" + #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1" + #if DEFAULT_LIBC == LIBC_UCLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" ++#elif DEFAULT_LIBC == LIBC_MUSL ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" + #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC +-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" ++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" + #else + #error "Unsupported DEFAULT_LIBC" + #endif + #define GNU_USER_DYNAMIC_LINKER \ +- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) ++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) + + #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +@@ -938,6 +945,7 @@ + { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \ + { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \ + { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ ++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ + { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ + { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ + { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ +diff -r 78025c74c5c1 libgcc/config/rs6000/linux-unwind.h +--- a/libgcc/config/rs6000/linux-unwind.h Wed Nov 21 21:23:49 2012 -0500 ++++ b/libgcc/config/rs6000/linux-unwind.h Wed Nov 21 21:45:58 2012 -0500 +@@ -176,6 +176,7 @@ + } + #endif + ++#ifdef __GLIBC__ + /* Find an entry in the process auxiliary vector. The canonical way to + test for VMX is to look at AT_HWCAP. */ + +@@ -207,6 +208,7 @@ + return auxp->a_val; + return 0; + } ++#endif + + /* Do code reading to identify a signal frame, and set the frame + state data appropriately. See unwind-dw2.c for the structs. */ +@@ -253,7 +255,11 @@ + + if (hwcap == 0) + { ++#ifdef __GLIBC__ + hwcap = ppc_linux_aux_vector (16); ++#else ++ hwcap = -1; ++#endif + /* These will already be set if we found AT_HWCAP. A nonzero + value stops us looking again if for some reason we couldn't + find AT_HWCAP. */ +# HG changeset patch +# Parent 800ec1c37f610df2bfe75333ed6ec6caa905d630 +Support (partial) for microblaze-linux-musl. + +diff -r 800ec1c37f61 gcc/config.gcc +--- a/gcc/config.gcc Thu Apr 11 13:23:51 2013 -0400 ++++ b/gcc/config.gcc Thu Apr 11 13:24:17 2013 -0400 +@@ -1733,6 +1733,7 @@ + tm_file="${tm_file} dbxelf.h gnu-user.h linux.h microblaze/linux.h" + c_target_objs="${c_target_objs} microblaze-c.o" + cxx_target_objs="${cxx_target_objs} microblaze-c.o" ++ tmake_file="${tmake_file} microblaze/t-microblaze" + ;; + microblaze*-*-rtems*) + tm_file="${tm_file} dbxelf.h"