123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- diff --git a/config.sub b/config.sub
- index fab0aa3..b83660a 100755
- --- a/config.sub
- +++ b/config.sub
- @@ -120,7 +120,7 @@ esac
- # Here we must recognize all the valid KERNEL-OS combinations.
- maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
- case $maybe_os in
- - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
- + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | linux-musl* | \
- uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- @@ -1211,7 +1211,7 @@ case $os in
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
- + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* | -linux-musl* \
- | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
- index ef048f7..f1cb8a5 100755
- --- a/fixincludes/mkfixinc.sh
- +++ b/fixincludes/mkfixinc.sh
- @@ -28,7 +28,8 @@ case $machine in
- 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}
- diff --git a/gcc/config.gcc b/gcc/config.gcc
- index 9a142e2..25136b7 100644
- --- a/gcc/config.gcc
- +++ b/gcc/config.gcc
- @@ -468,11 +468,14 @@ case ${target} in
- esac
- tmake_file="t-slibgcc-elf-ver t-linux"
- case ${target} in
- + *-*-*musl*)
- + tm_defines="${tm_defines} UCLIBC_DEFAULT=0 MUSL_DEFAULT=1"
- + ;;
- *-*-*uclibc*)
- - tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
- + tm_defines="${tm_defines} UCLIBC_DEFAULT=1 MUSL_DEFAULT=0"
- ;;
- *)
- - tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
- + tm_defines="${tm_defines} UCLIBC_DEFAULT=0 MUSL_DEFAULT=0"
- ;;
- esac
- # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
- diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
- index 6612f74..f2ce735 100644
- --- a/gcc/config/arm/linux-eabi.h
- +++ b/gcc/config/arm/linux-eabi.h
- @@ -55,6 +55,23 @@
- #undef GLIBC_DYNAMIC_LINKER
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
-
- +/* For ARM musl currently supports four dynamic linkers:
- + - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
- + - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
- + - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
- + - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
- + musl does not support the legacy OABI mode.
- + All the dynamic linkers live in /lib.
- + We default to soft-float, EL. */
- +#undef MUSL_DYNAMIC_LINKER
- +#if TARGET_BIG_ENDIAN_DEFAULT
- +#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
- +#else
- +#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
- +#endif
- +#define MUSL_DYNAMIC_LINKER \
- + "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.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 --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
- index 7eb2395..213b586 100644
- --- a/gcc/config/i386/linux.h
- +++ b/gcc/config/i386/linux.h
- @@ -103,6 +103,9 @@ Boston, MA 02110-1301, USA. */
- #define LINK_EMULATION "elf_i386"
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-
- +#undef MUSL_DYNAMIC_LINKER
- +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
- +
- #undef SUBTARGET_EXTRA_SPECS
- #define SUBTARGET_EXTRA_SPECS \
- { "link_emulation", LINK_EMULATION },\
- diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
- index cc8ed16..f0f025e 100644
- --- a/gcc/config/i386/linux64.h
- +++ b/gcc/config/i386/linux64.h
- @@ -52,6 +52,13 @@ Boston, MA 02110-1301, USA. */
- #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
- #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
-
- +#undef MUSL_DYNAMIC_LINKER32
- +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
- +#undef MUSL_DYNAMIC_LINKER64
- +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
- +#undef MUSL_DYNAMIC_LINKERX32
- +#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
- +
- #undef LINK_SPEC
- #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
- %{shared:-shared} \
- diff --git a/gcc/config/linux.h b/gcc/config/linux.h
- index 59e3e85..1967b46 100644
- --- a/gcc/config/linux.h
- +++ b/gcc/config/linux.h
- @@ -102,10 +102,12 @@ Boston, MA 02110-1301, USA. */
- /* Determine which dynamic linker to use depending on whether GLIBC or
- uClibc is the default C library and whether -muclibc or -mglibc has
- been passed to change the default. */
- -#if UCLIBC_DEFAULT
- -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
- +#if MUSL_DEFAULT
- +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";muclibc:" U ";:" M "}"
- +#elif UCLIBC_DEFAULT
- +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";mmusl:" M ";:" U "}"
- #else
- -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
- +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mmusl:" M ";muclibc:" U ";:" G "}"
- #endif
-
- /* For most targets the following definitions suffice;
- @@ -115,15 +117,89 @@ Boston, MA 02110-1301, USA. */
- #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
- #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
- #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
- +/* Should be redefined for each target that supports musl. */
- +#define MUSL_DYNAMIC_LINKER "/dev/null"
- +#define MUSL_DYNAMIC_LINKER32 "/dev/null"
- +#define MUSL_DYNAMIC_LINKER64 "/dev/null"
- +#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
- +
- #define LINUX_DYNAMIC_LINKER \
- - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
- + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
- #define LINUX_DYNAMIC_LINKER32 \
- - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
- + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
- #define LINUX_DYNAMIC_LINKER64 \
- - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
- + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
-
- /* Determine whether the entire c99 runtime
- is present in the runtime library. */
- #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
-
- #define TARGET_POSIX_IO
- +
- +/* musl avoids problematic includes by rearranging the include directories.
- + * Unfortunately, this is mostly duplicated from cppdefault.c */
- +#if MUSL_DEFAULT
- +#define INCLUDE_DEFAULTS_MUSL_GPP \
- + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, \
- + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 }, \
- + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
- +
- +#ifdef LOCAL_INCLUDE_DIR
- +#define INCLUDE_DEFAULTS_MUSL_LOCAL \
- + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
- + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
- +#else
- +#define INCLUDE_DEFAULTS_MUSL_LOCAL
- +#endif
- +
- +#ifdef PREFIX_INCLUDE_DIR
- +#define INCLUDE_DEFAULTS_MUSL_PREFIX \
- + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
- +#else
- +#define INCLUDE_DEFAULTS_MUSL_PREFIX
- +#endif
- +
- +#ifdef CROSS_INCLUDE_DIR
- +#define INCLUDE_DEFAULTS_MUSL_CROSS \
- + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
- +#else
- +#define INCLUDE_DEFAULTS_MUSL_CROSS
- +#endif
- +
- +#ifdef TOOL_INCLUDE_DIR
- +#define INCLUDE_DEFAULTS_MUSL_TOOL \
- + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
- +#else
- +#define INCLUDE_DEFAULTS_MUSL_TOOL
- +#endif
- +
- +#ifdef NATIVE_SYSTEM_HEADER_DIR
- +#define INCLUDE_DEFAULTS_MUSL_NATIVE \
- + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
- + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
- +#else
- +#define INCLUDE_DEFAULTS_MUSL_NATIVE
- +#endif
- +
- +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
- +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
- +# define INCLUDE_DEFAULTS_MUSL_LOCAL
- +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
- +# define INCLUDE_DEFAULTS_MUSL_NATIVE
- +#else
- +# undef INCLUDE_DEFAULTS_MUSL_CROSS
- +# define INCLUDE_DEFAULTS_MUSL_CROSS
- +#endif
- +
- +#undef INCLUDE_DEFAULTS
- +#define INCLUDE_DEFAULTS \
- + { \
- + INCLUDE_DEFAULTS_MUSL_GPP \
- + INCLUDE_DEFAULTS_MUSL_PREFIX \
- + INCLUDE_DEFAULTS_MUSL_CROSS \
- + INCLUDE_DEFAULTS_MUSL_TOOL \
- + INCLUDE_DEFAULTS_MUSL_NATIVE \
- + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
- + { 0, 0, 0, 0, 0, 0 } \
- + }
- +#endif
- diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
- index 3f615bb..31fb21b 100644
- --- a/gcc/config/linux.opt
- +++ b/gcc/config/linux.opt
- @@ -27,3 +27,7 @@ Use uClibc instead of GNU libc
- mglibc
- Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists
- Use GNU libc instead of uClibc
- +
- +mmusl
- +Target RejectNegative Report Var(linux_musl)
- +Use musl C library
- diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
- index ff268d4..97bfc38 100644
- --- a/gcc/config/mips/linux.h
- +++ b/gcc/config/mips/linux.h
- @@ -179,3 +179,9 @@ Boston, MA 02110-1301, USA. */
- %{profile:-lc_p} %{!profile: -lc}}"
-
- #define MD_UNWIND_SUPPORT "config/mips/linux-unwind.h"
- +
- +#undef MUSL_DYNAMIC_LINKER32
- +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips%{EL:el}%{msoft-float:-sf}.so.1"
- +#undef MUSL_DYNAMIC_LINKER64
- +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips64%{EL:el}%{msoft-float:-sf}.so.1"
- +#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mipsn32%{EL:el}%{msoft-float:-sf}.so.1"
- diff --git a/gcc/config/sh/linux-unwind.h b/gcc/config/sh/linux-unwind.h
- index de84a77..98d1661 100644
- --- a/gcc/config/sh/linux-unwind.h
- +++ b/gcc/config/sh/linux-unwind.h
- @@ -80,10 +80,10 @@ shmedia_fallback_frame_state (struct _Unwind_Context *context,
- && (*(unsigned long *) (pc+11) == 0x6ff0fff0))
- {
- struct rt_sigframe {
- - struct siginfo *pinfo;
- + siginfo_t *pinfo;
- void *puc;
- - struct siginfo info;
- - struct ucontext uc;
- + siginfo_t info;
- + ucontext_t uc;
- } *rt_ = context->cfa;
- /* The void * cast is necessary to avoid an aliasing warning.
- The aliasing warning is correct, but should not be a problem
- @@ -179,8 +179,8 @@ sh_fallback_frame_state (struct _Unwind_Context *context,
- && (*(unsigned short *) (pc+14) == 0x00ad))))
- {
- struct rt_sigframe {
- - struct siginfo info;
- - struct ucontext uc;
- + siginfo_t info;
- + ucontext_t uc;
- } *rt_ = context->cfa;
- /* The void * cast is necessary to avoid an aliasing warning.
- The aliasing warning is correct, but should not be a problem
- diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
- index 94c3166..306a08c 100644
- --- a/gcc/config/sh/linux.h
- +++ b/gcc/config/sh/linux.h
- @@ -48,6 +48,29 @@ Boston, MA 02110-1301, USA. */
-
- #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
- +#if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
- +#define MUSL_DYNAMIC_LINKER_E "%{mb:eb}"
- +#else
- +#define MUSL_DYNAMIC_LINKER_E "%{!ml:eb}"
- +#endif
- +
- +#if TARGET_CPU_DEFAULT & ( MASK_HARD_SH2A_DOUBLE | MASK_SH4 )
- +/* "-nofpu" if any nofpu option is specified */
- +#define MUSL_DYNAMIC_LINKER_FP \
- + "%{m1|m2|m2a-nofpu|m3|m4-nofpu|m4-100-nofpu|m4-200-nofpu|m4-300-nofpu|" \
- + "m4-340|m4-400|m4-500|m4al|m5-32media-nofpu|m5-64media-nofpu|" \
- + "m5-compact-nofpu:-nofpu}"
- +#else
- +/* "-nofpu" if none of the hard fpu options are specified */
- +#define MUSL_DYNAMIC_LINKER_FP \
- + "%{m2a|m4|m4-100|m4-200|m4-300|m4a|m5-32media|m5-64media|m5-compact:;:-nofpu}"
- +#endif
- +
- +#undef MUSL_DYNAMIC_LINKER
- +#define MUSL_DYNAMIC_LINKER \
- + "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
- + "%{mfdpic:-fdpic}.so.1"
- +
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-
- #undef SUBTARGET_LINK_EMUL_SUFFIX
- diff --git a/gcc/unwind-dw2-fde-glibc.c b/gcc/unwind-dw2-fde-glibc.c
- index 25bf2bb..59f7615 100644
- --- a/gcc/unwind-dw2-fde-glibc.c
- +++ b/gcc/unwind-dw2-fde-glibc.c
- @@ -49,7 +49,7 @@
- #include "gthr.h"
-
- #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
- - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
- + && (!defined(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
-
- #ifndef __RELOC_POINTER
- diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h
- index bcc533c..a9bfded 100644
- --- a/libstdc++-v3/config/os/generic/os_defines.h
- +++ b/libstdc++-v3/config/os/generic/os_defines.h
- @@ -38,4 +38,9 @@
- // System-specific #define, typedefs, corrections, etc, go here. This
- // file will come before all others.
-
- +// Disable the weak reference logic in gthr.h for os/generic because it
- +// is broken on every platform unless there is implementation specific
- +// workaround in gthr-posix.h and at link-time for static linking.
- +#define _GLIBCXX_GTHREAD_USE_WEAK 0
- +
- #endif
- diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
- index 441eb4c..37e80ab 100644
- --- a/libstdc++-v3/configure.host
- +++ b/libstdc++-v3/configure.host
- @@ -210,6 +210,9 @@ case "${host_os}" in
- freebsd*)
- os_include_dir="os/bsd/freebsd"
- ;;
- + linux-musl*)
- + os_include_dir="os/generic"
- + ;;
- gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
- if [ "$uclibc" = "yes" ]; then
- os_include_dir="os/uclibc"
|