public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/13] Add musl support to GCC
@ 2015-04-20 18:49 Szabolcs Nagy
  2015-04-20 18:51 ` [PATCH 1/13] libitm fixes for musl support Szabolcs Nagy
                   ` (13 more replies)
  0 siblings, 14 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

This patch set adds musl libc[0] support to GCC.

The patches were originally developed by Gregor Richards[1][2],
who I believe have already done the FSF copyright assignment and agrees
with the changes I made (please verify).  I only did minor cleanups
to make the patches better suited for upstream.

Issues I don't have patches for:

* On powerpc it seems the only configure option to choose the default
long-double abi is --with-long-double-128, but that's the default with
sufficiently new glibc. (musl gets 64bit long-double because the glibc
version check fails, this is ok, because there is no ibm128 support in
musl, but it would be better if --with-long-double-64 could be set
explicitly or even ieee128 abi if gcc supports that).

* libcilkrts uses pthread_yield on linux instead of sched_yield by
default, but musl does not have the non-standard pthread_yield symbol.

Tests:

I only tested the C and C++ languages.  GCJ needs further patching,
I haven't tested gfortran nor Ada.  libsanitizer has to be disabled
for musl.  I built cross compilers for various targets musl supports
and ran x86_64-linux-musl cross compiler (musl target glibc host)
and native musl make check.  There were several errors, some of the
causes:

* libcilkrts.so has undefined ref to pthread_yield
* ifunc is not supported by musl
* ifunc is used in x86 libatomic.so for __atomic_store_16
* gcc stdatomic.h has some incompatible typedefs with musl stdint.h
* musl does not support unwind across libc calls or signal handlers
* splitstacks does not work (undef refs to __morestack* in libgcc)
* musl does not yet have __memcpy_chk etc.
* -fshort-wchar is not supported
* i've seen x86 specific avx failures
* atexit during exit fails with musl (some c++ destructor tests)

This fixes BZ 58446 and 55807 which requested musl support.

[0] http://www.musl-libc.org/
[1] https://github.com/GregorR/musl-gcc-patches
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58446

--
Changes:
 fixincludes/mkfixinc.sh                     |    3 +-
 gcc/config.gcc                              |    9 ++-
 gcc/config/aarch64/aarch64-linux.h          |    8 ++
 gcc/config/arm/linux-eabi.h                 |   17 +++++
 gcc/config/i386/linux.h                     |    1 +
 gcc/config/i386/linux64.h                   |    4 +
 gcc/config/i386/pmm_malloc.h                |    9 ++-
 gcc/config/linux.h                          |  105 +++++++++++++++++++++++----
 gcc/config/linux.opt                        |    4 +
 gcc/config/microblaze/linux.h               |   16 +++-
 gcc/config/mips/linux.h                     |    7 ++
 gcc/config/rs6000/linux64.h                 |   12 ++-
 gcc/config/rs6000/secureplt.h               |    1 +
 gcc/config/rs6000/sysv4.h                   |   16 +++-
 gcc/config/sh/linux.h                       |    7 ++
 gcc/configure                               |    7 ++
 gcc/configure.ac                            |    7 ++
 libgcc/unwind-dw2-fde-dip.c                 |    6 ++
 libgfortran/acinclude.m4                    |    2 +-
 libgfortran/configure                       |    2 +-
 libitm/config/arm/hwcap.cc                  |    2 +-
 libitm/config/linux/x86/tls.h               |    8 +-
 libstdc++-v3/config/os/generic/os_defines.h |    5 ++
 libstdc++-v3/configure.host                 |    3 +
 24 files changed, 227 insertions(+), 34 deletions(-)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 1/13] libitm fixes for musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
@ 2015-04-20 18:51 ` Szabolcs Nagy
  2015-04-20 20:41   ` Jeff Law
  2015-04-20 18:52 ` [PATCH 2/13] musl libc config Szabolcs Nagy
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

This are minor correctness fixes required for musl.

(fcntl.h is the standard header and always available on Linux,
sys/fcntl.h is just a legacy alias, so use the standard one.)

libitm/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
	* config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 01-libitm.patch --]
[-- Type: text/x-patch; name=01-libitm.patch, Size: 1320 bytes --]

diff --git a/libitm/config/arm/hwcap.cc b/libitm/config/arm/hwcap.cc
index a1c2cfd..ea8f023 100644
--- a/libitm/config/arm/hwcap.cc
+++ b/libitm/config/arm/hwcap.cc
@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0
 
 #ifdef __linux__
 #include <unistd.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <elf.h>
 
 static void __attribute__((constructor))
diff --git a/libitm/config/linux/x86/tls.h b/libitm/config/linux/x86/tls.h
index e731ab7..54ad8b6 100644
--- a/libitm/config/linux/x86/tls.h
+++ b/libitm/config/linux/x86/tls.h
@@ -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 @@ static inline void set_abi_disp(struct abi_dispatch *x)
 
 } // namespace GTM
 #endif /* >= GLIBC 2.10 */
+#endif
 
 #endif // LIBITM_X86_TLS_H

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 2/13] musl libc config
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
  2015-04-20 18:51 ` [PATCH 1/13] libitm fixes for musl support Szabolcs Nagy
@ 2015-04-20 18:52 ` Szabolcs Nagy
  2015-04-22 13:16   ` Jeff Law
  2015-04-28 23:50   ` Joseph Myers
  2015-04-20 18:52 ` [PATCH 3/13] aarch64 musl support Szabolcs Nagy
                   ` (11 subsequent siblings)
  13 siblings, 2 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Add musl libc support to gcc and the command line option -mmusl following other
libc support code.

Note that -m<libc> cannot be entirely correct: there are build time decisions
based on the default libc.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config.gcc (LIBC_MUSL): New tm_defines macro.
	* config/linux.h (OPTION_MUSL): Define.
	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.

	* config/linux.opt (mmusl): New option.
	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.

	* gcc/configure: Regenerate.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-musl-config.patch --]
[-- Type: text/x-patch; name=02-musl-config.patch, Size: 9721 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index cb08a5c..8e59bb0 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -575,7 +575,7 @@ case ${target} in
 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"
 
 # 32-bit x86 processors supported by --with-arch=.  Each processor
 # MUST be separated by exactly one space.
@@ -720,6 +720,9 @@ case ${target} in
     *-*-*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 --git a/gcc/config/linux.h b/gcc/config/linux.h
index 857389a..cda87bf 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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()			\
@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     } while (0)
 
 /* Determine which dynamic linker to use depending on whether GLIBC or
-   uClibc or Bionic is the default C library and whether
-   -muclibc or -mglibc or -mbionic has been passed to change the default.  */
+   uClibc or Bionic or musl is the default C library and whether
+   -muclibc or -mglibc or -mbionic or -mmusl 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 */
@@ -84,21 +90,92 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #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)
 
 /* Whether we have Bionic libc runtime */
 #undef TARGET_HAS_BIONIC
 #define TARGET_HAS_BIONIC (OPTION_BIONIC)
 
+/* musl avoids problematic includes by rearranging the include directories.
+ * Unfortunately, this is mostly duplicated from cppdefault.c */
+#if DEFAULT_LIBC == LIBC_MUSL
+#define INCLUDE_DEFAULTS_MUSL_GPP			\
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },		\
+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },		\
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,	\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 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
+
 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
 /* This is a *uclinux* target.  We don't define below macros to normal linux
    versions, because doing so would require *uclinux* targets to include
diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
index c054338..9334f74 100644
--- a/gcc/config/linux.opt
+++ b/gcc/config/linux.opt
@@ -30,3 +30,7 @@ Use GNU C library
 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 --git a/gcc/configure b/gcc/configure
index 9523773..5345f69 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -27678,6 +27678,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
 else
   gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -27710,6 +27713,7 @@ fi
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
@@ -27806,6 +27810,9 @@ case "$target" in
       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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 68b0ee8..27ecdcd 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5199,6 +5199,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
       gcc_cv_libc_provides_ssp,
       [gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -5225,6 +5228,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
@@ -5298,6 +5302,9 @@ case "$target" in
       gcc_cv_target_dl_iterate_phdr=no
     fi
     ;;
+  *-linux-musl*)
+    gcc_cv_target_dl_iterate_phdr=yes
+    ;;
 esac
 GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 3/13] aarch64 musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
  2015-04-20 18:51 ` [PATCH 1/13] libitm fixes for musl support Szabolcs Nagy
  2015-04-20 18:52 ` [PATCH 2/13] musl libc config Szabolcs Nagy
@ 2015-04-20 18:52 ` Szabolcs Nagy
  2015-04-21 14:16   ` pinskia
  2015-04-20 18:53 ` [PATCH 4/13] arm " Szabolcs Nagy
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

Set up dynamic linker name for aarch64.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 03-aarch64.patch --]
[-- Type: text/x-patch; name=03-aarch64.patch, Size: 669 bytes --]

diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 9abb252..5ff83dd 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -23,6 +23,14 @@
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
 
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:_be}"
+#else
+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:_be}"
+#endif
+#define MUSL_DYNAMIC_LINKER \
+  "/lib/ld-musl-aarch64" MUSL_DYNAMIC_LINKER_E ".so.1"
+
 #undef  ASAN_CC1_SPEC
 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 4/13] arm musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (2 preceding siblings ...)
  2015-04-20 18:52 ` [PATCH 3/13] aarch64 musl support Szabolcs Nagy
@ 2015-04-20 18:53 ` Szabolcs Nagy
  2015-05-15 12:43   ` Szabolcs Nagy
  2015-05-27 13:49   ` Kyrill Tkachov
  2015-04-20 18:54 ` [PATCH 6/13] mips " Szabolcs Nagy
                   ` (9 subsequent siblings)
  13 siblings, 2 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

Set up dynamic linker name for arm.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 04-arm.patch --]
[-- Type: text/x-patch; name=04-arm.patch, Size: 1225 bytes --]

diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index e9d65dc..f12e6bd 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -77,6 +77,23 @@
     %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
     %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
 
+/* 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

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 6/13] mips musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (3 preceding siblings ...)
  2015-04-20 18:53 ` [PATCH 4/13] arm " Szabolcs Nagy
@ 2015-04-20 18:54 ` Szabolcs Nagy
  2015-04-21 13:58   ` Matthew Fortune
  2015-04-20 18:54 ` [PATCH 5/13] microblaze " Szabolcs Nagy
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

Set up dynamic linker name for mips.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/mips/linux.h (MUSL_DYNAMIC_LINKER): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 06-mips.patch --]
[-- Type: text/x-patch; name=06-mips.patch, Size: 746 bytes --]

diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
index 91df261..5057bc5 100644
--- a/gcc/config/mips/linux.h
+++ b/gcc/config/mips/linux.h
@@ -37,6 +37,13 @@ along with GCC; see the file COPYING3.  If not see
 #define UCLIBC_DYNAMIC_LINKERN32 \
   "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
 
+#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
+#else
+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
+#endif
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
+
 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
 #define GNU_USER_DYNAMIC_LINKERN32 \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 5/13] microblaze musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (4 preceding siblings ...)
  2015-04-20 18:54 ` [PATCH 6/13] mips " Szabolcs Nagy
@ 2015-04-20 18:54 ` Szabolcs Nagy
  2015-04-27 14:35   ` Szabolcs Nagy
  2015-04-20 18:55 ` [PATCH 7/13] powerpc " Szabolcs Nagy
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

Set up dynamic linker name for microblaze.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
	(DYNAMIC_LINKER): Change.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 05-microblaze.patch --]
[-- Type: text/x-patch; name=05-microblaze.patch, Size: 832 bytes --]

diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index a7faa7d..14fe41e 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -25,7 +25,21 @@
 #undef TLS_NEEDS_GOT
 #define TLS_NEEDS_GOT 1
 
-#define DYNAMIC_LINKER "/lib/ld.so.1"
+#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
+#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
+#else
+#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
+#endif
+
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+#if DEFAULT_LIBC == LIBC_MUSL
+#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
+#else
+#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
+#endif
+
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
   { "dynamic_linker", DYNAMIC_LINKER }

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 7/13] powerpc musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (5 preceding siblings ...)
  2015-04-20 18:54 ` [PATCH 5/13] microblaze " Szabolcs Nagy
@ 2015-04-20 18:55 ` Szabolcs Nagy
  2015-04-27 14:58   ` Szabolcs Nagy
  2015-04-20 18:56 ` [PATCH 8/13] sh " Szabolcs Nagy
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

Set up dynamic linker name for powerpc.  Musl only supports powerpc
with secure plt, so appropriate options are passed to the linker by
default.


gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config.gcc (secure_plt): Add *-linux*-musl*.
	* config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER): Define.
	(CHOOSE_DYNAMIC_LINKER): Update.

	* config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
	* config/rs6000/sysv4.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
	(CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 07-powerpc.patch --]
[-- Type: text/x-patch; name=07-powerpc.patch, Size: 4733 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 8e59bb0..34d4bd4 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2409,6 +2409,10 @@ powerpc*-*-linux*)
 	    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 --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0879e7e..f00c775 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -365,17 +365,21 @@ extern int dot_symbols;
 #endif
 #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)
 
 #undef  DEFAULT_ASM_ENDIAN
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h
index b463463..77edf2a 100644
--- a/gcc/config/rs6000/secureplt.h
+++ b/gcc/config/rs6000/secureplt.h
@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 9917c2f..e6ce1e1 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 #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.  */
 #undef CC1_SPEC
@@ -586,7 +589,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
 /* Override the default target of the linker.  */
 #define	LINK_TARGET_SPEC \
-  ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
+  ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
+  "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
 
 /* Any specific OS flags.  */
 #define LINK_OS_SPEC "\
@@ -764,15 +768,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
 #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} \
@@ -895,6 +902,7 @@ ncrtn.o%s"
   { "link_os_openbsd",		LINK_OS_OPENBSD_SPEC },			\
   { "link_os_default",		LINK_OS_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 },			\

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 8/13] sh musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (6 preceding siblings ...)
  2015-04-20 18:55 ` [PATCH 7/13] powerpc " Szabolcs Nagy
@ 2015-04-20 18:56 ` Szabolcs Nagy
  2015-04-20 20:29   ` Oleg Endo
  2015-04-20 18:57 ` [PATCH 9/13] x86 " Szabolcs Nagy
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

Set up dynamic linker name for sh.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 08-sh.patch --]
[-- Type: text/x-patch; name=08-sh.patch, Size: 630 bytes --]

diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
index 0f5d614..16524da 100644
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3.  If not see
 
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
+#if TARGET_BIG_ENDIAN_DEFAULT /* BE */
+#define MUSL_DYNAMIC_LINKER_E "eb"
+#else
+#define MUSL_DYNAMIC_LINKER_E
+#endif
+
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
 
 #undef SUBTARGET_LINK_EMUL_SUFFIX
 #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 9/13] x86 musl support
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (7 preceding siblings ...)
  2015-04-20 18:56 ` [PATCH 8/13] sh " Szabolcs Nagy
@ 2015-04-20 18:57 ` Szabolcs Nagy
  2015-04-27 14:52   ` Szabolcs Nagy
  2015-04-20 18:58 ` [PATCH 10/13] fixincludes Szabolcs Nagy
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

Set up dynamic linker name for x86.

gcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
	* config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 09-x86.patch --]
[-- Type: text/x-patch; name=09-x86.patch, Size: 991 bytes --]

diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index a100963..836a97a 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.  If not see
 
 #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 --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index a27d3be..cba322b 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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"

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 11/13] unwind fix for musl
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (9 preceding siblings ...)
  2015-04-20 18:58 ` [PATCH 10/13] fixincludes Szabolcs Nagy
@ 2015-04-20 18:58 ` Szabolcs Nagy
  2015-04-22 13:20   ` Jeff Law
  2015-04-20 18:59 ` [PATCH 12/13] libstdc++, libgfortran gthr workaround " Szabolcs Nagy
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

dl_iterate_phdr depends on USE_PT_GNU_EH_FRAME.

I think USE_PT_GNU_EH_FRAME could be enabled more generally (whenever
libc provides dl_iterate_phdr), but I only made a conservative change.


libgcc/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
	Linux if target provides dl_iterate_phdr.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 11-unwind.patch --]
[-- Type: text/x-patch; name=11-unwind.patch, Size: 593 bytes --]

diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index e1e566b..137dced 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -59,6 +59,12 @@
 
 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
     && defined(TARGET_DL_ITERATE_PHDR) \
+    && defined(__linux__)
+# define USE_PT_GNU_EH_FRAME
+#endif
+
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+    && defined(TARGET_DL_ITERATE_PHDR) \
     && (defined(__DragonFly__) || defined(__FreeBSD__))
 # define ElfW __ElfN
 # define USE_PT_GNU_EH_FRAME

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 10/13] fixincludes
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (8 preceding siblings ...)
  2015-04-20 18:57 ` [PATCH 9/13] x86 " Szabolcs Nagy
@ 2015-04-20 18:58 ` Szabolcs Nagy
  2015-04-20 20:38   ` Jeff Law
  2015-04-20 18:58 ` [PATCH 11/13] unwind fix for musl Szabolcs Nagy
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

No fixincludes are needed for musl.

fixincludes/Changelog:

2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* mkfixinc.sh: Add *-musl* with no fixes.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 10-fixincludes.patch --]
[-- Type: text/x-patch; name=10-fixincludes.patch, Size: 482 bytes --]

diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
index 6653fed..0d96c8c 100755
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
@@ -19,7 +19,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}

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (10 preceding siblings ...)
  2015-04-20 18:58 ` [PATCH 11/13] unwind fix for musl Szabolcs Nagy
@ 2015-04-20 18:59 ` Szabolcs Nagy
  2015-04-22 13:17   ` Jeff Law
  2015-04-20 19:00 ` [PATCH 13/13] fix incompatible posix_memalign declaration on x86 Szabolcs Nagy
  2015-04-28 23:50 ` [PATCH 0/13] Add musl support to GCC Joseph Myers
  13 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 18:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]

libgcc/gthr-posix.h uses weak reference logic to determine if libpthread
is linked into the application or not.  This is broken unless there is
special workaround with libc internal knowledge and even then static
linking needs further manual link time workaround, so this was disabled
for os/generic in libstdc++v3 and for musl in libgfortran.

The change minimizes the impact on other setups, but I think the weak
ref logic should be disabled by default, it is never entirely correct.
Conforming code can crash on a glibc setup too:

$ cat a.cpp
#include <pthread.h>
void(*f)(void) = (void(*)(void))pthread_key_create;
int main(){}
$ g++ -static a.cpp -lpthread
$ ./a.out
Segmentation fault

I reported this previously at
https://gcc.gnu.org/ml/gcc/2014-11/msg00246.html


libgfortran/Changelog:

2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
	* configure: Regenerate.

libstdc++v3/Changelog:

2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
	* configure.host (os_include_dir): Set to "os/generic" for linux-musl*.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 12-gthr.patch --]
[-- Type: text/x-patch; name=12-gthr.patch, Size: 2063 bytes --]

diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index ba890f9..30b8b1a6 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -100,7 +100,7 @@ void foo (void);
 	      [Define to 1 if the target supports #pragma weak])
   fi
   case "$host" in
-    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
+    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
       AC_DEFINE(GTHREAD_USE_WEAK, 0,
 		[Define to 0 if the target shouldn't use #pragma weak])
       ;;
diff --git a/libgfortran/configure b/libgfortran/configure
index e1592f7..07542e1 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -26447,7 +26447,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>confdefs.h
 
   fi
   case "$host" in
-    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
+    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
 
 $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
 
diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h
index 45bf52a..103ec0e 100644
--- a/libstdc++-v3/config/os/generic/os_defines.h
+++ b/libstdc++-v3/config/os/generic/os_defines.h
@@ -33,4 +33,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 82ddc52..a349ce3 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -271,6 +271,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"

^ permalink raw reply	[flat|nested] 83+ messages in thread

* [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (11 preceding siblings ...)
  2015-04-20 18:59 ` [PATCH 12/13] libstdc++, libgfortran gthr workaround " Szabolcs Nagy
@ 2015-04-20 19:00 ` Szabolcs Nagy
  2015-05-15 12:36   ` Szabolcs Nagy
  2015-05-15 15:18   ` H.J. Lu
  2015-04-28 23:50 ` [PATCH 0/13] Add musl support to GCC Joseph Myers
  13 siblings, 2 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-20 19:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

The posix_memalign declaration is incompatible with musl for C++,
because of the exception specification.  It also pollutes the
namespace and lacks protection against a potential macro definition
that is allowed by POSIX.  The fix avoids source level namespace
pollution but retains the dependency on the posix_memalign extern
libc symbol.

The fix is ugly, but it is not possible to correctly redeclare a
libc function in a public gcc header for C++.


gcc/Changelog:

2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
	(__gcc_posix_memalign): This.  Use posix_memalign as extern
	symbol only.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 13-posix_memalign.patch --]
[-- Type: text/x-patch; name=13-posix_memalign.patch, Size: 1144 bytes --]

diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
index 901001b..321fcd3 100644
--- a/gcc/config/i386/pmm_malloc.h
+++ b/gcc/config/i386/pmm_malloc.h
@@ -27,12 +27,13 @@
 #include <stdlib.h>
 
 /* We can't depend on <stdlib.h> since the prototype of posix_memalign
-   may not be visible.  */
+   may not be visible and we can't pollute the namespace either.  */
 #ifndef __cplusplus
-extern int posix_memalign (void **, size_t, size_t);
+extern int __gcc_posix_memalign (void **, size_t, size_t)
 #else
-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
+extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
 #endif
+__asm__("posix_memalign");
 
 static __inline void *
 _mm_malloc (size_t size, size_t alignment)
@@ -42,7 +43,7 @@ _mm_malloc (size_t size, size_t alignment)
     return malloc (size);
   if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
     alignment = sizeof (void *);
-  if (posix_memalign (&ptr, alignment, size) == 0)
+  if (__gcc_posix_memalign (&ptr, alignment, size) == 0)
     return ptr;
   else
     return NULL;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 8/13] sh musl support
  2015-04-20 18:56 ` [PATCH 8/13] sh " Szabolcs Nagy
@ 2015-04-20 20:29   ` Oleg Endo
  2015-04-27 14:50     ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Oleg Endo @ 2015-04-20 20:29 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Mon, 2015-04-20 at 19:56 +0100, Szabolcs Nagy wrote:
> Set up dynamic linker name for sh.
> 
> gcc/Changelog:
> 
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 
> 	* config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define.

The SH parts are OK for trunk.

Cheers,
Oleg

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 10/13] fixincludes
  2015-04-20 18:58 ` [PATCH 10/13] fixincludes Szabolcs Nagy
@ 2015-04-20 20:38   ` Jeff Law
  2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-04-20 20:38 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/20/2015 12:58 PM, Szabolcs Nagy wrote:
> No fixincludes are needed for musl.
>
> fixincludes/Changelog:
>
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>
> 	* mkfixinc.sh: Add *-musl* with no fixes.
OK.
jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 1/13] libitm fixes for musl support
  2015-04-20 18:51 ` [PATCH 1/13] libitm fixes for musl support Szabolcs Nagy
@ 2015-04-20 20:41   ` Jeff Law
  2015-04-22 14:34     ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-04-20 20:41 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/20/2015 12:51 PM, Szabolcs Nagy wrote:
> This are minor correctness fixes required for musl.
>
> (fcntl.h is the standard header and always available on Linux,
> sys/fcntl.h is just a legacy alias, so use the standard one.)
>
> libitm/Changelog:
>
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>
> 	* config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
> 	* config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.
>
OK.
jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 6/13] mips musl support
  2015-04-20 18:54 ` [PATCH 6/13] mips " Szabolcs Nagy
@ 2015-04-21 13:58   ` Matthew Fortune
  2015-04-21 14:43     ` Rich Felker
  0 siblings, 1 reply; 83+ messages in thread
From: Matthew Fortune @ 2015-04-21 13:58 UTC (permalink / raw)
  To: Szabolcs Nagy, Rich Felker, Gregor Richards; +Cc: Szabolcs Nagy, gcc-patches

Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> Set up dynamic linker name for mips.
> 
> gcc/Changelog:
> 
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 
> 	* config/mips/linux.h (MUSL_DYNAMIC_LINKER): Define.

I understand that mips musl is o32 only currently is that correct?
There does however appear to be both soft and hard float variants
listed in the musl docs. Do you plan on using the same dynamic linker
name for both float variants? No problem if so but someone must have
decided to have unique names for big and little endian so I thought
it worth checking.

Also, are you aware of the two nan encoding formats that MIPS has
and the support present in glibc's dynamic linker to deal with it?

I wonder if it would be wise to refuse to target musl unless the
ABI is known to be supported so that we can avoid compatibility
issues when different ABI variants are added in musl.

Thanks,
Matthew

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 3/13] aarch64 musl support
  2015-04-20 18:52 ` [PATCH 3/13] aarch64 musl support Szabolcs Nagy
@ 2015-04-21 14:16   ` pinskia
  2015-04-21 14:55     ` Szabolcs Nagy
  2015-04-27 14:33     ` Szabolcs Nagy
  0 siblings, 2 replies; 83+ messages in thread
From: pinskia @ 2015-04-21 14:16 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy





> On Apr 20, 2015, at 11:52 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> 
> Set up dynamic linker name for aarch64.
> 
> gcc/Changelog:
> 
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>        Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
>    * config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.


I don't think you need to check if defaulting to little or big-endian here are the specs always have one or the other passing through. 

Also if musl does not support ilp32, you might want to error out. Or even define the dynamic linker name even before support goes into musl. 

Thanks,
Andrew

> <03-aarch64.patch>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-04-21 13:58   ` Matthew Fortune
@ 2015-04-21 14:43     ` Rich Felker
  2015-04-21 15:00       ` Matthew Fortune
  0 siblings, 1 reply; 83+ messages in thread
From: Rich Felker @ 2015-04-21 14:43 UTC (permalink / raw)
  To: Matthew Fortune
  Cc: Szabolcs Nagy, Gregor Richards, Szabolcs Nagy, gcc-patches

On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> > Set up dynamic linker name for mips.
> > 
> > gcc/Changelog:
> > 
> > 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> > 
> > 	* config/mips/linux.h (MUSL_DYNAMIC_LINKER): Define.
> 
> I understand that mips musl is o32 only currently is that correct?

This is correct. Other ABIs if/when we support them will have
different names.

> There does however appear to be both soft and hard float variants
> listed in the musl docs. Do you plan on using the same dynamic linker
> name for both float variants? No problem if so but someone must have
> decided to have unique names for big and little endian so I thought
> it worth checking.

No, it's supposed to be different (-sf suffix for soft float; see
arch/mips/reloc.h in musl source). If this didn't make it into the
patches it's an omission, probably because we didn't officially
support the sf ABI at all for a long time.

> Also, are you aware of the two nan encoding formats that MIPS has
> and the support present in glibc's dynamic linker to deal with it?

I am aware but somewhat skeptical of treating it as yet another
dimension to ABI and the resulting ABI combinatorics. The vast
majority of programs couldn't care less which is which and whether a
NAN is quiet or signaling. Officially we just use the classic mips ABI
(with qnan/snan swapped vs other archs) but there's no harm in
somebody doing the opposite if they really know what they're doing.

> I wonder if it would be wise to refuse to target musl unless the
> ABI is known to be supported so that we can avoid compatibility
> issues when different ABI variants are added in musl.

Possibly, though this might make bootstrapping new ABIs harder.

Rich

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 3/13] aarch64 musl support
  2015-04-21 14:16   ` pinskia
@ 2015-04-21 14:55     ` Szabolcs Nagy
  2015-04-27 14:33     ` Szabolcs Nagy
  1 sibling, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-21 14:55 UTC (permalink / raw)
  To: pinskia; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy



On 21/04/15 15:16, pinskia@gmail.com wrote:
> 
> I don't think you need to check if defaulting to little or big-endian here are the specs always have one or the other passing through. 
> 

i was not aware of this

may be the ifdef is not necessary for other archs either
i will check

> Also if musl does not support ilp32, you might want to error out. Or even define the dynamic linker name even before support goes into musl. 
> 

ok, i guess adding %{mabi=ilp32:_ilp32} won't hurt us

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 6/13] mips musl support
  2015-04-21 14:43     ` Rich Felker
@ 2015-04-21 15:00       ` Matthew Fortune
  2015-04-27 14:40         ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Matthew Fortune @ 2015-04-21 15:00 UTC (permalink / raw)
  To: Rich Felker; +Cc: Szabolcs Nagy, Gregor Richards, Szabolcs Nagy, gcc-patches

Rich Felker <dalias@libc.org> writes:
> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
> > Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> > > Set up dynamic linker name for mips.
> > >
> > > gcc/Changelog:
> > >
> > > 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> > >
> > > 	* config/mips/linux.h (MUSL_DYNAMIC_LINKER): Define.
> >
> > I understand that mips musl is o32 only currently is that correct?
> 
> This is correct. Other ABIs if/when we support them will have different
> names.
> 
> > There does however appear to be both soft and hard float variants
> > listed in the musl docs. Do you plan on using the same dynamic linker
> > name for both float variants? No problem if so but someone must have
> > decided to have unique names for big and little endian so I thought
> it
> > worth checking.
> 
> No, it's supposed to be different (-sf suffix for soft float; see
> arch/mips/reloc.h in musl source). If this didn't make it into the
> patches it's an omission, probably because we didn't officially support
> the sf ABI at all for a long time.
> 
> > Also, are you aware of the two nan encoding formats that MIPS has and
> > the support present in glibc's dynamic linker to deal with it?
> 
> I am aware but somewhat skeptical of treating it as yet another
> dimension to ABI and the resulting ABI combinatorics. The vast majority
> of programs couldn't care less which is which and whether a NAN is
> quiet or signaling. Officially we just use the classic mips ABI (with
> qnan/snan swapped vs other archs) but there's no harm in somebody doing
> the opposite if they really know what they're doing.

Couldn't agree more here but I know some people have been concerned about
it so the strict rules were put in place. I will attempt to remember and
copy the musl list when putting out a plan for formally relaxing the nan
encoding rules. The proposal is probably less than 2 weeks away from being
ready to review, it does of course make certain assumptions originating
from glibc as reference but is an independent ABI proposal.
 
> > I wonder if it would be wise to refuse to target musl unless the ABI
> > is known to be supported so that we can avoid compatibility issues
> > when different ABI variants are added in musl.
> 
> Possibly, though this might make bootstrapping new ABIs harder.

Indeed. The other alternative would be to set the dynamic linker name
to something slightly silly for unsupported ABIs like /lib/fixme.so
which would make it possible to bootstrap via the addition of a symlink
but it is clearly not the approved name.

thanks,
Matthew

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-20 18:52 ` [PATCH 2/13] musl libc config Szabolcs Nagy
@ 2015-04-22 13:16   ` Jeff Law
  2015-04-22 14:34     ` Kyrill Tkachov
  2015-04-28 23:50   ` Joseph Myers
  1 sibling, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-04-22 13:16 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/20/2015 12:52 PM, Szabolcs Nagy wrote:
> Add musl libc support to gcc and the command line option -mmusl following other
> libc support code.
>
> Note that -m<libc> cannot be entirely correct: there are build time decisions
> based on the default libc.
>
> gcc/Changelog:
>
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>
> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
> 	* config/linux.h (OPTION_MUSL): Define.
> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>
> 	* config/linux.opt (mmusl): New option.
> 	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>
> 	* gcc/configure: Regenerate.
OK for the trunk.  Please install.

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl
  2015-04-20 18:59 ` [PATCH 12/13] libstdc++, libgfortran gthr workaround " Szabolcs Nagy
@ 2015-04-22 13:17   ` Jeff Law
  2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-04-22 13:17 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/20/2015 12:59 PM, Szabolcs Nagy wrote:
> libgcc/gthr-posix.h uses weak reference logic to determine if libpthread
> is linked into the application or not.  This is broken unless there is
> special workaround with libc internal knowledge and even then static
> linking needs further manual link time workaround, so this was disabled
> for os/generic in libstdc++v3 and for musl in libgfortran.
>
> The change minimizes the impact on other setups, but I think the weak
> ref logic should be disabled by default, it is never entirely correct.
> Conforming code can crash on a glibc setup too:
>
> $ cat a.cpp
> #include <pthread.h>
> void(*f)(void) = (void(*)(void))pthread_key_create;
> int main(){}
> $ g++ -static a.cpp -lpthread
> $ ./a.out
> Segmentation fault
>
> I reported this previously at
> https://gcc.gnu.org/ml/gcc/2014-11/msg00246.html
>
>
> libgfortran/Changelog:
>
> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
> 	* configure: Regenerate.
>
> libstdc++v3/Changelog:
>
> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
> 	* configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
OK.  Please install on the trunk.

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 11/13] unwind fix for musl
  2015-04-20 18:58 ` [PATCH 11/13] unwind fix for musl Szabolcs Nagy
@ 2015-04-22 13:20   ` Jeff Law
  2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-04-22 13:20 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/20/2015 12:58 PM, Szabolcs Nagy wrote:
> dl_iterate_phdr depends on USE_PT_GNU_EH_FRAME.
>
> I think USE_PT_GNU_EH_FRAME could be enabled more generally (whenever
> libc provides dl_iterate_phdr), but I only made a conservative change.
>
>
> libgcc/Changelog:
>
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
> 	Linux if target provides dl_iterate_phdr.
OK.  Please install on the trunk.

At this point I think everything but the target files have been 
approved, right?

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-22 13:16   ` Jeff Law
@ 2015-04-22 14:34     ` Kyrill Tkachov
  2015-04-22 15:27       ` Ilya Verbin
  0 siblings, 1 reply; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 14:34 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy


On 22/04/15 14:16, Jeff Law wrote:
> On 04/20/2015 12:52 PM, Szabolcs Nagy wrote:
>> Add musl libc support to gcc and the command line option -mmusl following other
>> libc support code.
>>
>> Note that -m<libc> cannot be entirely correct: there are build time decisions
>> based on the default libc.
>>
>> gcc/Changelog:
>>
>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
>> 	* config/linux.h (OPTION_MUSL): Define.
>> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>
>> 	* config/linux.opt (mmusl): New option.
>> 	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>
>> 	* gcc/configure: Regenerate.
> OK for the trunk.  Please install.

I've committed this on Szabolcs' behalf with r222326
with slightly adjusted ChangeLog paths:

2015-04-22  Gregor Richards  <gregor.richards@uwaterloo.ca>

     * config.gcc (LIBC_MUSL): New tm_defines macro.
     * config/linux.h (OPTION_MUSL): Define.
     (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
     (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
     (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.

     * config/linux.opt (mmusl): New option.
     * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
     (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.

     * configure: Regenerate.


Kyrill

>
> jeff
>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 1/13] libitm fixes for musl support
  2015-04-20 20:41   ` Jeff Law
@ 2015-04-22 14:34     ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 14:34 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy


On 20/04/15 21:41, Jeff Law wrote:
> On 04/20/2015 12:51 PM, Szabolcs Nagy wrote:
>> This are minor correctness fixes required for musl.
>>
>> (fcntl.h is the standard header and always available on Linux,
>> sys/fcntl.h is just a legacy alias, so use the standard one.)
>>
>> libitm/Changelog:
>>
>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>> 	* config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
>> 	* config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.
>>
> OK.
> jeff

I've committed this on Szabolcs' behalf with r222325.

Kyrill


^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 10/13] fixincludes
  2015-04-20 20:38   ` Jeff Law
@ 2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 14:35 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy


On 20/04/15 21:38, Jeff Law wrote:
> On 04/20/2015 12:58 PM, Szabolcs Nagy wrote:
>> No fixincludes are needed for musl.
>>
>> fixincludes/Changelog:
>>
>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>> 	* mkfixinc.sh: Add *-musl* with no fixes.
> OK.
> jeff
>

I've committed this on Szabolcs' behalf with r222327.

Kyrill

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 12/13] libstdc++, libgfortran gthr workaround for musl
  2015-04-22 13:17   ` Jeff Law
@ 2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 14:35 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy


On 22/04/15 14:17, Jeff Law wrote:
> On 04/20/2015 12:59 PM, Szabolcs Nagy wrote:
>> libgcc/gthr-posix.h uses weak reference logic to determine if libpthread
>> is linked into the application or not.  This is broken unless there is
>> special workaround with libc internal knowledge and even then static
>> linking needs further manual link time workaround, so this was disabled
>> for os/generic in libstdc++v3 and for musl in libgfortran.
>>
>> The change minimizes the impact on other setups, but I think the weak
>> ref logic should be disabled by default, it is never entirely correct.
>> Conforming code can crash on a glibc setup too:
>>
>> $ cat a.cpp
>> #include <pthread.h>
>> void(*f)(void) = (void(*)(void))pthread_key_create;
>> int main(){}
>> $ g++ -static a.cpp -lpthread
>> $ ./a.out
>> Segmentation fault
>>
>> I reported this previously at
>> https://gcc.gnu.org/ml/gcc/2014-11/msg00246.html
>>
>>
>> libgfortran/Changelog:
>>
>> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	* acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
>> 	* configure: Regenerate.
>>
>> libstdc++v3/Changelog:
>>
>> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	* config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
>> 	* configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
> OK.  Please install on the trunk.

I've committed this on Szabolcs' behalf with r222329.

Kyrill

>
> jeff
>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 11/13] unwind fix for musl
  2015-04-22 13:20   ` Jeff Law
@ 2015-04-22 14:35     ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 14:35 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy


On 22/04/15 14:20, Jeff Law wrote:
> On 04/20/2015 12:58 PM, Szabolcs Nagy wrote:
>> dl_iterate_phdr depends on USE_PT_GNU_EH_FRAME.
>>
>> I think USE_PT_GNU_EH_FRAME could be enabled more generally (whenever
>> libc provides dl_iterate_phdr), but I only made a conservative change.
>>
>>
>> libgcc/Changelog:
>>
>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	* unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
>> 	Linux if target provides dl_iterate_phdr.
> OK.  Please install on the trunk.

I've committed this on Szabolcs' behalf with r222328.

Kyrill

>
> At this point I think everything but the target files have been
> approved, right?
>
> jeff
>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-22 14:34     ` Kyrill Tkachov
@ 2015-04-22 15:27       ` Ilya Verbin
  2015-04-22 15:37         ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Ilya Verbin @ 2015-04-22 15:27 UTC (permalink / raw)
  To: Kyrill Tkachov
  Cc: Jeff Law, Szabolcs Nagy, gcc-patches, Gregor Richards,
	Rich Felker, Szabolcs Nagy

On Wed, Apr 22, 2015 at 15:34:51 +0100, Kyrill Tkachov wrote:
> 
> On 22/04/15 14:16, Jeff Law wrote:
> >On 04/20/2015 12:52 PM, Szabolcs Nagy wrote:
> >>Add musl libc support to gcc and the command line option -mmusl following other
> >>libc support code.
> >>
> >>Note that -m<libc> cannot be entirely correct: there are build time decisions
> >>based on the default libc.
> >>
> >>gcc/Changelog:
> >>
> >>2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> >>
> >>	* config.gcc (LIBC_MUSL): New tm_defines macro.
> >>	* config/linux.h (OPTION_MUSL): Define.
> >>	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
> >>	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
> >>	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
> >>
> >>	* config/linux.opt (mmusl): New option.
> >>	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
> >>	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
> >>
> >>	* gcc/configure: Regenerate.
> >OK for the trunk.  Please install.
> 
> I've committed this on Szabolcs' behalf with r222326
> with slightly adjusted ChangeLog paths:
> 
> 2015-04-22  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 
>     * config.gcc (LIBC_MUSL): New tm_defines macro.
>     * config/linux.h (OPTION_MUSL): Define.
>     (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>     (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>     (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
> 
>     * config/linux.opt (mmusl): New option.
>     * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>     (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
> 
>     * configure: Regenerate.

This caused:

https://gcc.gnu.org/ml/gcc-regression/2015-04/msg00262.html

  -- Ilya

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 2/13] musl libc config
  2015-04-22 15:27       ` Ilya Verbin
@ 2015-04-22 15:37         ` Kyrill Tkachov
  2015-04-22 15:42           ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Kyrill Tkachov @ 2015-04-22 15:37 UTC (permalink / raw)
  To: 'Ilya Verbin'
  Cc: Jeff Law, Szabolcs Nagy, gcc-patches, Gregor Richards,
	Rich Felker, Szabolcs Nagy


On 22/04/15 16:26, Ilya Verbin wrote:
> On Wed, Apr 22, 2015 at 15:34:51 +0100, Kyrill Tkachov wrote:
>> On 22/04/15 14:16, Jeff Law wrote:
>>> On 04/20/2015 12:52 PM, Szabolcs Nagy wrote:
>>>> Add musl libc support to gcc and the command line option -mmusl
following other
>>>> libc support code.
>>>>
>>>> Note that -m<libc> cannot be entirely correct: there are build time
decisions
>>>> based on the default libc.
>>>>
>>>> gcc/Changelog:
>>>>
>>>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>>
>>>> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
>>>> 	* config/linux.h (OPTION_MUSL): Define.
>>>> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>>>> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>>>> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>>>
>>>> 	* config/linux.opt (mmusl): New option.
>>>> 	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>>>> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>>>
>>>> 	* gcc/configure: Regenerate.
>>> OK for the trunk.  Please install.
>> I've committed this on Szabolcs' behalf with r222326
>> with slightly adjusted ChangeLog paths:
>>
>> 2015-04-22  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>>     * config.gcc (LIBC_MUSL): New tm_defines macro.
>>     * config/linux.h (OPTION_MUSL): Define.
>>     (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>>     (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>>     (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>
>>     * config/linux.opt (mmusl): New option.
>>     * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>>     (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>
>>     * configure: Regenerate.
> This caused:
>
> https://gcc.gnu.org/ml/gcc-regression/2015-04/msg00262.html

Sorry about that. I've reverted the patch.
Szabolcs, we should wait until the target-specific parts are
approved and install it all together? Or did you want to #ifdef
some parts out to make this patch more robust towards targets that
don't support musl?

Kyrill
>   -- Ilya
>


^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-22 15:37         ` Kyrill Tkachov
@ 2015-04-22 15:42           ` Szabolcs Nagy
  2015-04-27 14:30             ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-22 15:42 UTC (permalink / raw)
  To: Kyrylo Tkachov, 'Ilya Verbin'
  Cc: Jeff Law, gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy


On 22/04/15 16:36, Kyrylo Tkachov wrote:
> On 22/04/15 16:26, Ilya Verbin wrote:
>> On Wed, Apr 22, 2015 at 15:34:51 +0100, Kyrill Tkachov wrote:
>>> On 22/04/15 14:16, Jeff Law wrote:
>>>> On 04/20/2015 12:52 PM, Szabolcs Nagy wrote:
>>>>> Add musl libc support to gcc and the command line option -mmusl
> following other
>>>>> libc support code.
>>>>>
>>>>> Note that -m<libc> cannot be entirely correct: there are build time
> decisions
>>>>> based on the default libc.
>>>>>
>>>>> gcc/Changelog:
>>>>>
>>>>> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>>>
>>>>> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
>>>>> 	* config/linux.h (OPTION_MUSL): Define.
>>>>> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>>>>> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>>>>> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>>>>
>>>>> 	* config/linux.opt (mmusl): New option.
>>>>> 	* gcc/configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>>>>> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>>>>
>>>>> 	* gcc/configure: Regenerate.
>>>> OK for the trunk.  Please install.
>>> I've committed this on Szabolcs' behalf with r222326
>>> with slightly adjusted ChangeLog paths:
>>>
>>> 2015-04-22  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>
>>>     * config.gcc (LIBC_MUSL): New tm_defines macro.
>>>     * config/linux.h (OPTION_MUSL): Define.
>>>     (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>>>     (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>>>     (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>>
>>>     * config/linux.opt (mmusl): New option.
>>>     * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>>>     (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>>
>>>     * configure: Regenerate.
>> This caused:
>>
>> https://gcc.gnu.org/ml/gcc-regression/2015-04/msg00262.html
> 
> Sorry about that. I've reverted the patch.
> Szabolcs, we should wait until the target-specific parts are
> approved and install it all together? Or did you want to #ifdef
> some parts out to make this patch more robust towards targets that
> don't support musl?
> 

yes, i didn't realize that this depends on the target specific parts

i will prepare an updated patch that works if the target has no musl
dynamic linker name defined

sorry

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-22 15:42           ` Szabolcs Nagy
@ 2015-04-27 14:30             ` Szabolcs Nagy
  2015-04-27 19:27               ` Jeff Law
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:30 UTC (permalink / raw)
  To: Kyrylo Tkachov, 'Ilya Verbin'
  Cc: Jeff Law, gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]


On 22/04/15 16:42, Szabolcs Nagy wrote:
> yes, i didn't realize that this depends on the target specific parts
> 
> i will prepare an updated patch that works if the target has no musl
> dynamic linker name defined
> 

Updated the patch, this time I tested it separately.
(The test revealed that -mmusl was not wired up properly
in linux.opt through the "Negative" directive, now fixed).

A default dynamic linker name is defined for musl: "/dev/null".
(The arch specific headers have to be updated to undef the
MUSL_DYNAMIC_LINKER* macros).
(Other options were considered such as print an error with %e,
but then the user cannot override it with -Wl,-dynamic-linker)

The other parts of the patch (config, include path reordering)
are not changed.

gcc/Changelog

2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config.gcc (LIBC_MUSL): New tm_defines macro.
	* config/linux.h (OPTION_MUSL): Define.
	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.

	* config/linux.opt (mmusl): New option.
	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.

	* configure: Regenerate.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-musl-config-v2.diff --]
[-- Type: text/x-patch; name=02-musl-config-v2.diff, Size: 10288 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index a1df043..0176ca2 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -575,7 +575,7 @@ case ${target} in
 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"
 
 # 32-bit x86 processors supported by --with-arch=.  Each processor
 # MUST be separated by exactly one space.
@@ -725,6 +725,9 @@ case ${target} in
     *-*-*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 --git a/gcc/config/linux.h b/gcc/config/linux.h
index 857389a..b551c56 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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()			\
@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     } while (0)
 
 /* Determine which dynamic linker to use depending on whether GLIBC or
-   uClibc or Bionic is the default C library and whether
-   -muclibc or -mglibc or -mbionic has been passed to change the default.  */
+   uClibc or Bionic or musl is the default C library and whether
+   -muclibc or -mglibc or -mbionic or -mmusl 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 */
@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
 #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
+/* 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 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)
 
 /* Whether we have Bionic libc runtime */
 #undef TARGET_HAS_BIONIC
 #define TARGET_HAS_BIONIC (OPTION_BIONIC)
 
+/* musl avoids problematic includes by rearranging the include directories.
+ * Unfortunately, this is mostly duplicated from cppdefault.c */
+#if DEFAULT_LIBC == LIBC_MUSL
+#define INCLUDE_DEFAULTS_MUSL_GPP			\
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },		\
+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },		\
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,	\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 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
+
 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
 /* This is a *uclinux* target.  We don't define below macros to normal linux
    versions, because doing so would require *uclinux* targets to include
diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
index c054338..ef055a7 100644
--- a/gcc/config/linux.opt
+++ b/gcc/config/linux.opt
@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
 Use GNU C library
 
 muclibc
-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
 Use uClibc C library
+
+mmusl
+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
+Use musl C library
diff --git a/gcc/configure b/gcc/configure
index 9523773..5345f69 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -27678,6 +27678,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
 else
   gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -27710,6 +27713,7 @@ fi
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
@@ -27806,6 +27810,9 @@ case "$target" in
       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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 68b0ee8..27ecdcd 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5199,6 +5199,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
       gcc_cv_libc_provides_ssp,
       [gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -5225,6 +5228,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
@@ -5298,6 +5302,9 @@ case "$target" in
       gcc_cv_target_dl_iterate_phdr=no
     fi
     ;;
+  *-linux-musl*)
+    gcc_cv_target_dl_iterate_phdr=yes
+    ;;
 esac
 GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 3/13] aarch64 musl support
  2015-04-21 14:16   ` pinskia
  2015-04-21 14:55     ` Szabolcs Nagy
@ 2015-04-27 14:33     ` Szabolcs Nagy
  2015-05-15 12:33       ` Szabolcs Nagy
  2015-05-27 17:39       ` James Greenhalgh
  1 sibling, 2 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:33 UTC (permalink / raw)
  To: pinskia; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]


On 21/04/15 15:16, pinskia@gmail.com wrote:
> 
> I don't think you need to check if defaulting to little or big-endian here are the specs always have one or the other passing through. 
> 
> Also if musl does not support ilp32, you might want to error out. Or even define the dynamic linker name even before support goes into musl. 
> 

Patch v2.

(now _ilp32 abi variant is included too)

gcc/Changelog:

2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 03-aarch64-v2.diff --]
[-- Type: text/x-patch; name=03-aarch64-v2.diff, Size: 544 bytes --]

diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 9abb252..2d647c3 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -23,6 +23,9 @@
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
 
+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+
 #undef  ASAN_CC1_SPEC
 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 5/13] microblaze musl support
  2015-04-20 18:54 ` [PATCH 5/13] microblaze " Szabolcs Nagy
@ 2015-04-27 14:35   ` Szabolcs Nagy
  2015-04-29 13:23     ` Michael Eager
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]


On 20/04/15 19:54, Szabolcs Nagy wrote:
> Set up dynamic linker name for microblaze.
> 

Patch v2.
(undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)

gcc/Changelog:

2015-04-24  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
	(DYNAMIC_LINKER): Change.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 05-microblaze-v2.diff --]
[-- Type: text/x-patch; name=05-microblaze-v2.diff, Size: 882 bytes --]

diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index a7faa7d..3e08138 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -25,7 +25,22 @@
 #undef TLS_NEEDS_GOT
 #define TLS_NEEDS_GOT 1
 
-#define DYNAMIC_LINKER "/lib/ld.so.1"
+#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:;:el}"
+#else
+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:el}"
+#endif
+
+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+#if DEFAULT_LIBC == LIBC_MUSL
+#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
+#else
+#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
+#endif
+
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
   { "dynamic_linker", DYNAMIC_LINKER }

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-04-21 15:00       ` Matthew Fortune
@ 2015-04-27 14:40         ` Szabolcs Nagy
  2015-05-08 13:56           ` H.J. Lu
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:40 UTC (permalink / raw)
  To: Matthew Fortune, Rich Felker; +Cc: Gregor Richards, Szabolcs Nagy, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]



On 21/04/15 15:59, Matthew Fortune wrote:
> Rich Felker <dalias@libc.org> writes:
>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
>>> There does however appear to be both soft and hard float variants

Patch v2.

Now all the ABI variants musl plans to support are represented.

gcc/Changelog:

2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
	(GNU_USER_DYNAMIC_LINKERN32): Update.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 06-mips-v2.diff --]
[-- Type: text/x-patch; name=06-mips-v2.diff, Size: 930 bytes --]

diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
index 91df261..6038498 100644
--- a/gcc/config/mips/linux.h
+++ b/gcc/config/mips/linux.h
@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3.  If not see
 #define UCLIBC_DYNAMIC_LINKERN32 \
   "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
 
+#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}.so.1"
+#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mipsn32%{EL:el}.so.1"
+
 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
 #define GNU_USER_DYNAMIC_LINKERN32 \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
-                         BIONIC_DYNAMIC_LINKERN32)
+                         BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 8/13] sh musl support
  2015-04-20 20:29   ` Oleg Endo
@ 2015-04-27 14:50     ` Szabolcs Nagy
  0 siblings, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:50 UTC (permalink / raw)
  To: Oleg Endo; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 835 bytes --]



On 20/04/15 21:29, Oleg Endo wrote:
> On Mon, 2015-04-20 at 19:56 +0100, Szabolcs Nagy wrote:
>> Set up dynamic linker name for sh.
>>
> 
> The SH parts are OK for trunk.
> 

Patch v2

It turns out we have to distinguish between hard float and nofpu ABI.
I simply listed the options that turn on nofpu and hardfloat code
generation (the single precision modes are not relevant to musl,
currently musl only supports sh4 and up because it assumes either
gusa or llsc atomics is available and requires an mmu, but I listed
all the options for the nofpu check for completeness).

gcc/Changelog:

2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define.
	(MUSL_DYNAMIC_LINKER_E, MUSL_DYNAMIC_LINKER_FP): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 08-sh-v3.diff --]
[-- Type: text/x-patch; name=08-sh-v3.diff, Size: 1200 bytes --]

diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
index 0f5d614..4c167c6 100644
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -43,6 +43,28 @@ along with GCC; see the file COPYING3.  If not see
 
 #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 ".so.1"
+
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
 
 #undef SUBTARGET_LINK_EMUL_SUFFIX

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 9/13] x86 musl support
  2015-04-20 18:57 ` [PATCH 9/13] x86 " Szabolcs Nagy
@ 2015-04-27 14:52   ` Szabolcs Nagy
  2015-05-15 12:34     ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

On 20/04/15 19:57, Szabolcs Nagy wrote:
> Set up dynamic linker name for x86.
> 

Patch v2.

(undef MUSL_DYNAMIC_LINKER* before defining it).

gcc/Changelog:

2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>

	* config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
	* config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 09-x86-v2.diff --]
[-- Type: text/x-patch; name=09-x86-v2.diff, Size: 1115 bytes --]

diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index a100963..9c47fcb 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -21,3 +21,5 @@ along with GCC; see the file COPYING3.  If not see
 
 #define GNU_USER_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"
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index a27d3be..e300480 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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"
+
+#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"

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 7/13] powerpc musl support
  2015-04-20 18:55 ` [PATCH 7/13] powerpc " Szabolcs Nagy
@ 2015-04-27 14:58   ` Szabolcs Nagy
  0 siblings, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-27 14:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

On 20/04/15 19:55, Szabolcs Nagy wrote:
> Set up dynamic linker name for powerpc.  Musl only supports powerpc
> with secure plt, so appropriate options are passed to the linker by
> default.

Patch v2.

Powerpc does not include the top level linux.h, so I had to
repeat the include order fixes from there in rs6000/sysv4.h.

I corrected the endianness handling (the "le" suffix should
be added correctly now).

gcc/Changelog:

2015-04-24  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config.gcc (secure_plt): Add *-linux*-musl*.
	* config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
	(MUSL_DYNAMIC_LINKER64): Define.
	(GNU_USER_DYNAMIC_LINKER32): Update.
	(GNU_USER_DYNAMIC_LINKER64): Update.
	(CHOOSE_DYNAMIC_LINKER): Update.

	* config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
	* config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update.
	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,)
	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
	(LINK_SECURE_PLT_DEFAULT_SPEC): Define.
	(CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update.

	* config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 07-powerpc-v2.diff --]
[-- Type: text/x-patch; name=07-powerpc-v2.diff, Size: 7110 bytes --]

diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0879e7e..a6ad842 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -365,17 +365,21 @@ extern int dot_symbols;
 #endif
 #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" MUSL_DYNAMIC_LINKER_E ".so.1"
+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".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)
 
 #undef  DEFAULT_ASM_ENDIAN
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h
index b463463..77edf2a 100644
--- a/gcc/config/rs6000/secureplt.h
+++ b/gcc/config/rs6000/secureplt.h
@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 9917c2f..94c4263 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 #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.  */
 #undef CC1_SPEC
@@ -586,7 +589,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
 /* Override the default target of the linker.  */
 #define	LINK_TARGET_SPEC \
-  ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
+  ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
+  "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
 
 /* Any specific OS flags.  */
 #define LINK_OS_SPEC "\
@@ -762,17 +766,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
 
 #define LINK_START_LINUX_SPEC ""
 
+#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
+
 #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" MUSL_DYNAMIC_LINKER_E ".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} \
@@ -895,6 +904,7 @@ ncrtn.o%s"
   { "link_os_openbsd",		LINK_OS_OPENBSD_SPEC },			\
   { "link_os_default",		LINK_OS_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 },			\
@@ -949,3 +959,72 @@ ncrtn.o%s"
 /* This target uses the sysv4.opt file.  */
 #define TARGET_USES_SYSV4_OPT 1
 
+/* Include order changes for musl, same as in generic linux.h.  */
+#if DEFAULT_LIBC == LIBC_MUSL
+#define INCLUDE_DEFAULTS_MUSL_GPP			\
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },		\
+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },		\
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,	\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 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/rs6000/sysv4le.h b/gcc/config/rs6000/sysv4le.h
index 7b1d6a1..064323c 100644
--- a/gcc/config/rs6000/sysv4le.h
+++ b/gcc/config/rs6000/sysv4le.h
@@ -35,3 +35,5 @@
 /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default.  */
 #define LINUX64_DEFAULT_ABI_ELFv2
 
+#undef MUSL_DYNAMIC_LINKER_E
+#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le")

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-27 14:30             ` Szabolcs Nagy
@ 2015-04-27 19:27               ` Jeff Law
  0 siblings, 0 replies; 83+ messages in thread
From: Jeff Law @ 2015-04-27 19:27 UTC (permalink / raw)
  To: Szabolcs Nagy, Kyrylo Tkachov, 'Ilya Verbin'
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/27/2015 08:30 AM, Szabolcs Nagy wrote:
>
> On 22/04/15 16:42, Szabolcs Nagy wrote:
>> yes, i didn't realize that this depends on the target specific parts
>>
>> i will prepare an updated patch that works if the target has no musl
>> dynamic linker name defined
>>
>
> Updated the patch, this time I tested it separately.
> (The test revealed that -mmusl was not wired up properly
> in linux.opt through the "Negative" directive, now fixed).
>
> A default dynamic linker name is defined for musl: "/dev/null".
> (The arch specific headers have to be updated to undef the
> MUSL_DYNAMIC_LINKER* macros).
> (Other options were considered such as print an error with %e,
> but then the user cannot override it with -Wl,-dynamic-linker)
>
> The other parts of the patch (config, include path reordering)
> are not changed.
>
> gcc/Changelog
>
> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
> 	* config/linux.h (OPTION_MUSL): Define.
> 	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
> 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>
> 	* config/linux.opt (mmusl): New option.
> 	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>
> 	* configure: Regenerate.
Still OK :-)

I'm going to leave review of the target config changes to the target 
maintainers.

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-20 18:52 ` [PATCH 2/13] musl libc config Szabolcs Nagy
  2015-04-22 13:16   ` Jeff Law
@ 2015-04-28 23:50   ` Joseph Myers
  2015-05-06 11:24     ` Szabolcs Nagy
  1 sibling, 1 reply; 83+ messages in thread
From: Joseph Myers @ 2015-04-28 23:50 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Mon, 20 Apr 2015, Szabolcs Nagy wrote:

> 	* config/linux.opt (mmusl): New option.

New -m options need documenting in invoke.texi.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
                   ` (12 preceding siblings ...)
  2015-04-20 19:00 ` [PATCH 13/13] fix incompatible posix_memalign declaration on x86 Szabolcs Nagy
@ 2015-04-28 23:50 ` Joseph Myers
  2015-04-29 13:42   ` Szabolcs Nagy
  13 siblings, 1 reply; 83+ messages in thread
From: Joseph Myers @ 2015-04-28 23:50 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Mon, 20 Apr 2015, Szabolcs Nagy wrote:

> * On powerpc it seems the only configure option to choose the default
> long-double abi is --with-long-double-128, but that's the default with
> sufficiently new glibc. (musl gets 64bit long-double because the glibc
> version check fails, this is ok, because there is no ibm128 support in
> musl, but it would be better if --with-long-double-64 could be set
> explicitly or even ieee128 abi if gcc supports that).

It should be possible to use --without-long-double-128 (if not, that's a 
bug).

> * gcc stdatomic.h has some incompatible typedefs with musl stdint.h

If musl has chosen stdint.h types different from those in glibc, you need 
to make the *_TYPE macros appropriately conditional (possibly making 
glibc-stdint.h include conditionals to select the musl types when musl is 
in use).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 5/13] microblaze musl support
  2015-04-27 14:35   ` Szabolcs Nagy
@ 2015-04-29 13:23     ` Michael Eager
  2015-04-29 14:06       ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Michael Eager @ 2015-04-29 13:23 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 04/27/2015 07:35 AM, Szabolcs Nagy wrote:
>
> On 20/04/15 19:54, Szabolcs Nagy wrote:
>> Set up dynamic linker name for microblaze.
>>
>
> Patch v2.
> (undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)
>
> gcc/Changelog:
>
> 2015-04-24  Gregor Richards  <gregor.richards@uwaterloo.ca>
>
> 	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
> 	(DYNAMIC_LINKER): Change.
>

Are you building with both glibc and musl to verify these patches?

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-04-28 23:50 ` [PATCH 0/13] Add musl support to GCC Joseph Myers
@ 2015-04-29 13:42   ` Szabolcs Nagy
  2015-04-30  0:13     ` Joseph Myers
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-29 13:42 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy



On 29/04/15 00:27, Joseph Myers wrote:
> On Mon, 20 Apr 2015, Szabolcs Nagy wrote:
> 
>> * On powerpc it seems the only configure option to choose the default
>> long-double abi is --with-long-double-128, but that's the default with
>> sufficiently new glibc. (musl gets 64bit long-double because the glibc
>> version check fails, this is ok, because there is no ibm128 support in
>> musl, but it would be better if --with-long-double-64 could be set
>> explicitly or even ieee128 abi if gcc supports that).
> 
> It should be possible to use --without-long-double-128 (if not, that's a 
> bug).
> 

ok, --without-long-double-128 works, i thought i tested it

>> * gcc stdatomic.h has some incompatible typedefs with musl stdint.h
> 
> If musl has chosen stdint.h types different from those in glibc, you need 
> to make the *_TYPE macros appropriately conditional (possibly making 
> glibc-stdint.h include conditionals to select the musl types when musl is 
> in use).
> 

only affects [u]int_fastN_t types
(on 64bit systems for N=16,32 musl uses int but glibc uses long)

i can fix glibc-stdint.h, but it's yet another way in which the
compiler is tied to a particular libc.

(using musl-stdint.h would be nicer, but that would require more
changes i think, i have a fix now where the glibc-stdint.h types
depend on OPTION_MUSL, but i still have to make sure OPTION_MUSL
is always defined when this header is used).

(i'd prefer if the compiler did not know about these types, but
the standard requires them in stdatomic.h without including stdint.h
and in stdint.h in freestanding mode, i'm not sure if there is a
workaround without depending on libc)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 5/13] microblaze musl support
  2015-04-29 13:23     ` Michael Eager
@ 2015-04-29 14:06       ` Szabolcs Nagy
  2015-05-06 11:25         ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-04-29 14:06 UTC (permalink / raw)
  To: Michael Eager, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy



On 29/04/15 14:17, Michael Eager wrote:
> On 04/27/2015 07:35 AM, Szabolcs Nagy wrote:
>>
>> On 20/04/15 19:54, Szabolcs Nagy wrote:
>>> Set up dynamic linker name for microblaze.
>>>
>>
>> Patch v2.
>> (undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)
>>
>> gcc/Changelog:
>>
>> 2015-04-24  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>> 	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
>> 	(DYNAMIC_LINKER): Change.
>>
> 
> Are you building with both glibc and musl to verify these patches?
> 

i tested various aarch64 and x86 configurations with both glibc
and musl, but not everything was tested.

in particular microblaze (big and little endian) was only built
with musl.

note that microblaze does not use the GNU_USER_DYNAMIC_LINKER
macro so the -mglibc etc options don't work.
(that should be changed probably, assuming -muclibc and -mbionic
have no side effects when they are not supported)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-04-29 13:42   ` Szabolcs Nagy
@ 2015-04-30  0:13     ` Joseph Myers
  2015-05-06 11:36       ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Joseph Myers @ 2015-04-30  0:13 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Wed, 29 Apr 2015, Szabolcs Nagy wrote:

> only affects [u]int_fastN_t types
> (on 64bit systems for N=16,32 musl uses int but glibc uses long)
> 
> i can fix glibc-stdint.h, but it's yet another way in which the
> compiler is tied to a particular libc.
> 
> (using musl-stdint.h would be nicer, but that would require more
> changes i think, i have a fix now where the glibc-stdint.h types
> depend on OPTION_MUSL, but i still have to make sure OPTION_MUSL
> is always defined when this header is used).
> 
> (i'd prefer if the compiler did not know about these types, but
> the standard requires them in stdatomic.h without including stdint.h
> and in stdint.h in freestanding mode, i'm not sure if there is a
> workaround without depending on libc)

The compiler also needs to know these types for the Fortran C bindings.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-04-28 23:50   ` Joseph Myers
@ 2015-05-06 11:24     ` Szabolcs Nagy
  2015-05-07 18:02       ` Jeff Law
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-06 11:24 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]


On 29/04/15 00:30, Joseph Myers wrote:
> On Mon, 20 Apr 2015, Szabolcs Nagy wrote:
> 
>> 	* config/linux.opt (mmusl): New option.
> 
> New -m options need documenting in invoke.texi.
> 

Patch v3.

Now with documentation in invoke.texi.

Based on previous discussion I assume it is
OK to commit now.

gcc/Changelog

2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config.gcc (LIBC_MUSL): New tm_defines macro.
	* config/linux.h (OPTION_MUSL): Define.
	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.

	* config/linux.opt (mmusl): New option.
	* doc/invoke.texi (GNU/Linux Options): Document -mmusl.
	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.

	* configure: Regenerate.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-musl-config-v3.diff --]
[-- Type: text/x-patch; name=02-musl-config-v3.diff, Size: 11392 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 243e899..6634660 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -575,7 +575,7 @@ case ${target} in
 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"
 
 # 32-bit x86 processors supported by --with-arch=.  Each processor
 # MUST be separated by exactly one space.
@@ -728,6 +728,9 @@ case ${target} in
     *-*-*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 --git a/gcc/config/linux.h b/gcc/config/linux.h
index 857389a..b551c56 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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()			\
@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     } while (0)
 
 /* Determine which dynamic linker to use depending on whether GLIBC or
-   uClibc or Bionic is the default C library and whether
-   -muclibc or -mglibc or -mbionic has been passed to change the default.  */
+   uClibc or Bionic or musl is the default C library and whether
+   -muclibc or -mglibc or -mbionic or -mmusl 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 */
@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
 #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
+/* 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 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)
 
 /* Whether we have Bionic libc runtime */
 #undef TARGET_HAS_BIONIC
 #define TARGET_HAS_BIONIC (OPTION_BIONIC)
 
+/* musl avoids problematic includes by rearranging the include directories.
+ * Unfortunately, this is mostly duplicated from cppdefault.c */
+#if DEFAULT_LIBC == LIBC_MUSL
+#define INCLUDE_DEFAULTS_MUSL_GPP			\
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },		\
+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,		\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },		\
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,	\
+      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 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
+
 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
 /* This is a *uclinux* target.  We don't define below macros to normal linux
    versions, because doing so would require *uclinux* targets to include
diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
index c054338..ef055a7 100644
--- a/gcc/config/linux.opt
+++ b/gcc/config/linux.opt
@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
 Use GNU C library
 
 muclibc
-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
 Use uClibc C library
+
+mmusl
+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
+Use musl C library
diff --git a/gcc/configure b/gcc/configure
index e563e94..b99eb6d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -27740,6 +27740,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
 else
   gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -27772,6 +27775,7 @@ fi
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
@@ -27868,6 +27872,9 @@ case "$target" in
       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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 55fe633..810725c 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5247,6 +5247,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
       gcc_cv_libc_provides_ssp,
       [gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-*-musl*)
+	 # All versions of musl provide stack protector
+	 gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       # glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.
@@ -5273,6 +5276,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
 	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
 	 # simply assert that glibc does provide this, which is true for all
 	 # realistically usable GNU/Hurd configurations.
+	 # All supported versions of musl provide it as well
 	 gcc_cv_libc_provides_ssp=yes;;
        *-*-darwin* | *-*-freebsd*)
 	 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
@@ -5346,6 +5350,9 @@ case "$target" in
       gcc_cv_target_dl_iterate_phdr=no
     fi
     ;;
+  *-linux-musl*)
+    gcc_cv_target_dl_iterate_phdr=yes
+    ;;
 esac
 GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9c8aa99..c25d045 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -668,7 +668,7 @@ Objective-C and Objective-C++ Dialects}.
 -mcpu=@var{cpu}}
 
 @emph{GNU/Linux Options}
-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
+@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
 -tno-android-cc -tno-android-ld}
 
 @emph{H8/300 Options}
@@ -15362,13 +15362,19 @@ These @samp{-m} options are defined for GNU/Linux targets:
 @item -mglibc
 @opindex mglibc
 Use the GNU C library.  This is the default except
-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
+on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
+@samp{*-*-linux-*android*} targets.
 
 @item -muclibc
 @opindex muclibc
 Use uClibc C library.  This is the default on
 @samp{*-*-linux-*uclibc*} targets.
 
+@item -mmusl
+@opindex mmusl
+Use the musl C library.  This is the default on
+@samp{*-*-linux-*musl*} targets.
+
 @item -mbionic
 @opindex mbionic
 Use Bionic C library.  This is the default on

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 5/13] microblaze musl support
  2015-04-29 14:06       ` Szabolcs Nagy
@ 2015-05-06 11:25         ` Szabolcs Nagy
  2015-10-15 19:00           ` [PING][PATCH " Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-06 11:25 UTC (permalink / raw)
  To: Michael Eager, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]



On 29/04/15 14:51, Szabolcs Nagy wrote:
> On 29/04/15 14:17, Michael Eager wrote:
>> On 04/27/2015 07:35 AM, Szabolcs Nagy wrote:
>>> On 20/04/15 19:54, Szabolcs Nagy wrote:
>>>> Set up dynamic linker name for microblaze.
>>>>
>>>
>>> Patch v2.
>>> (undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)
>>>
>>
>> Are you building with both glibc and musl to verify these patches?
>>
...
> 
> note that microblaze does not use the GNU_USER_DYNAMIC_LINKER
> macro so the -mglibc etc options don't work.
> (that should be changed probably, assuming -muclibc and -mbionic
> have no side effects when they are not supported)
> 

Patch v3.

I changed the patch to use GNU_USER_DYNAMIC_LINKER like
other platforms do.

I built gcc with musl and glibc default libc as well and verified
that -mmusl and -mglibc sets the dynamic linker as expected.

gcc/Changelog:

2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
	(DYNAMIC_LINKER): Renamed to ...
	(GLIBC_DYNAMIC_LINKER): This.
	(SUBTARGET_EXTRA_SPECS): Use GNU_USER_DYNAMIC_LINKER.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 05-microblaze-v3.diff --]
[-- Type: text/x-patch; name=05-microblaze-v3.diff, Size: 856 bytes --]

diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index a7faa7d..95e2940 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -25,10 +25,20 @@
 #undef TLS_NEEDS_GOT
 #define TLS_NEEDS_GOT 1
 
-#define DYNAMIC_LINKER "/lib/ld.so.1"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:;:el}"
+#else
+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:el}"
+#endif
+
+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
+
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
-  { "dynamic_linker", DYNAMIC_LINKER }
+  { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
 
 #undef LINK_SPEC
 #define LINK_SPEC "%{shared:-shared} \

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-04-30  0:13     ` Joseph Myers
@ 2015-05-06 11:36       ` Szabolcs Nagy
  2015-05-07 18:07         ` Jeff Law
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-06 11:36 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]


On 30/04/15 00:18, Joseph Myers wrote:
> On Wed, 29 Apr 2015, Szabolcs Nagy wrote:
>> only affects [u]int_fastN_t types
>> (on 64bit systems for N=16,32 musl uses int but glibc uses long)
>>
>> i can fix glibc-stdint.h, but it's yet another way in which the
>> compiler is tied to a particular libc.
>>
...
>> (i'd prefer if the compiler did not know about these types, but
...
> 
> The compiler also needs to know these types for the Fortran C bindings.
> 

This is a work around patch so -mmusl or default musl libc
changes the [U]INT_FAST{16,32}_TYPE macro definitions.

The undef/define logic is needed because glibc-stdint.h is
used on non-linux targets where OPTION_MUSL would not be
defined and it is used both before and after config/linux.h on
various linux targets.

I did not find any cleaner workaround. (Separate musl-stdint.h
would need significant changes in config.gcc.)

gcc/Changelog:

2015-05-06  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/glibc-stdint.h (OPTION_MUSL): Define.
	(INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
	Change the definition based on OPTION_MUSL for 64 bit targets.

	* config/linux.h (OPTION_MUSL): Redefine.
	* config/alpha/linux.h (OPTION_MUSL): Redefine.
	* config/rs6000/linux.h (OPTION_MUSL): Redefine.
	* config/rs6000/linux64.h (OPTION_MUSL): Redefine.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: stdint-all.diff --]
[-- Type: text/x-patch; name=stdint-all.diff, Size: 4815 bytes --]

diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index c567f43..475ea06 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -61,10 +61,14 @@ along with GCC; see the file COPYING3.  If not see
 #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL
+#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)
+#undef OPTION_MUSL
+#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
 #endif
 
 /* Determine what functions are present at the runtime;
diff --git a/gcc/config/glibc-stdint.h b/gcc/config/glibc-stdint.h
index 3fc67dc..98f4f04 100644
--- a/gcc/config/glibc-stdint.h
+++ b/gcc/config/glibc-stdint.h
@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
+/* Systems using musl libc should use this header and make sure
+   OPTION_MUSL is defined correctly before using the TYPE macros. */
+#ifndef OPTION_MUSL
+#define OPTION_MUSL 0
+#endif
+
 #define SIG_ATOMIC_TYPE "int"
 
 #define INT8_TYPE "signed char"
@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
 
 #define INT_FAST8_TYPE "signed char"
-#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
-#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
+#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
+#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
 #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
 #define UINT_FAST8_TYPE "unsigned char"
-#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
-#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
+#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
+#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
 #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
 
 #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index b551c56..7bc87ab 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -32,11 +32,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL
 #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)
+#undef OPTION_MUSL
 #define OPTION_MUSL   (linux_libc == LIBC_MUSL)
 #endif
 
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index fe0ebd6..a68ff69 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -30,10 +30,14 @@
 #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL
+#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)
+#undef OPTION_MUSL
+#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
 #endif
 
 /* Determine what functions are present at the runtime;
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0879e7e..1b7f695 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -299,10 +299,14 @@ extern int dot_symbols;
 #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL
+#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)
+#undef OPTION_MUSL
+#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
 #endif
 
 /* Determine what functions are present at the runtime;

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-05-06 11:24     ` Szabolcs Nagy
@ 2015-05-07 18:02       ` Jeff Law
  2015-05-08  8:26         ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-05-07 18:02 UTC (permalink / raw)
  To: Szabolcs Nagy, Joseph Myers
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On 05/06/2015 05:24 AM, Szabolcs Nagy wrote:
>
> On 29/04/15 00:30, Joseph Myers wrote:
>> On Mon, 20 Apr 2015, Szabolcs Nagy wrote:
>>
>>> 	* config/linux.opt (mmusl): New option.
>>
>> New -m options need documenting in invoke.texi.
>>
>
> Patch v3.
>
> Now with documentation in invoke.texi.
>
> Based on previous discussion I assume it is
> OK to commit now.
>
> gcc/Changelog
>
> 2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
> 	* config/linux.h (OPTION_MUSL): Define.
> 	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
> 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>
> 	* config/linux.opt (mmusl): New option.
> 	* doc/invoke.texi (GNU/Linux Options): Document -mmusl.
> 	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>
> 	* configure: Regenerate.
OK.
Jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-05-06 11:36       ` Szabolcs Nagy
@ 2015-05-07 18:07         ` Jeff Law
  2015-05-08  8:31           ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-05-07 18:07 UTC (permalink / raw)
  To: Szabolcs Nagy, Joseph Myers
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On 05/06/2015 05:36 AM, Szabolcs Nagy wrote:
>
> On 30/04/15 00:18, Joseph Myers wrote:
>> On Wed, 29 Apr 2015, Szabolcs Nagy wrote:
>>> only affects [u]int_fastN_t types
>>> (on 64bit systems for N=16,32 musl uses int but glibc uses long)
>>>
>>> i can fix glibc-stdint.h, but it's yet another way in which the
>>> compiler is tied to a particular libc.
>>>
> ...
>>> (i'd prefer if the compiler did not know about these types, but
> ...
>>
>> The compiler also needs to know these types for the Fortran C bindings.
>>
>
> This is a work around patch so -mmusl or default musl libc
> changes the [U]INT_FAST{16,32}_TYPE macro definitions.
>
> The undef/define logic is needed because glibc-stdint.h is
> used on non-linux targets where OPTION_MUSL would not be
> defined and it is used both before and after config/linux.h on
> various linux targets.
>
> I did not find any cleaner workaround. (Separate musl-stdint.h
> would need significant changes in config.gcc.)
>
> gcc/Changelog:
>
> 2015-05-06  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config/glibc-stdint.h (OPTION_MUSL): Define.
> 	(INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
> 	Change the definition based on OPTION_MUSL for 64 bit targets.
>
> 	* config/linux.h (OPTION_MUSL): Redefine.
> 	* config/alpha/linux.h (OPTION_MUSL): Redefine.
> 	* config/rs6000/linux.h (OPTION_MUSL): Redefine.
> 	* config/rs6000/linux64.h (OPTION_MUSL): Redefine.
I really don't like the MUSL bits inside glibc-stdint.h.  But I don't 
see an easy way to avoid it.

OK for the trunk.

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 2/13] musl libc config
  2015-05-07 18:02       ` Jeff Law
@ 2015-05-08  8:26         ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-05-08  8:26 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, Joseph Myers
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy


On 07/05/15 19:02, Jeff Law wrote:
> On 05/06/2015 05:24 AM, Szabolcs Nagy wrote:
>> On 29/04/15 00:30, Joseph Myers wrote:
>>> On Mon, 20 Apr 2015, Szabolcs Nagy wrote:
>>>
>>>> 	* config/linux.opt (mmusl): New option.
>>> New -m options need documenting in invoke.texi.
>>>
>> Patch v3.
>>
>> Now with documentation in invoke.texi.
>>
>> Based on previous discussion I assume it is
>> OK to commit now.
>>
>> gcc/Changelog
>>
>> 2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
>> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	* config.gcc (LIBC_MUSL): New tm_defines macro.
>> 	* config/linux.h (OPTION_MUSL): Define.
>> 	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
>> 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
>> 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
>> 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
>> 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
>>
>> 	* config/linux.opt (mmusl): New option.
>> 	* doc/invoke.texi (GNU/Linux Options): Document -mmusl.
>> 	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
>> 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
>>
>> 	* configure: Regenerate.
> OK.
> Jeff
>

I've committed this on Szabolcs' behalf with r222904.

Kyrill

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 0/13] Add musl support to GCC
  2015-05-07 18:07         ` Jeff Law
@ 2015-05-08  8:31           ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-05-08  8:31 UTC (permalink / raw)
  To: Jeff Law, Szabolcs Nagy, Joseph Myers
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy


On 07/05/15 19:07, Jeff Law wrote:
> On 05/06/2015 05:36 AM, Szabolcs Nagy wrote:
>> On 30/04/15 00:18, Joseph Myers wrote:
>>> On Wed, 29 Apr 2015, Szabolcs Nagy wrote:
>>>> only affects [u]int_fastN_t types
>>>> (on 64bit systems for N=16,32 musl uses int but glibc uses long)
>>>>
>>>> i can fix glibc-stdint.h, but it's yet another way in which the
>>>> compiler is tied to a particular libc.
>>>>
>> ...
>>>> (i'd prefer if the compiler did not know about these types, but
>> ...
>>> The compiler also needs to know these types for the Fortran C bindings.
>>>
>> This is a work around patch so -mmusl or default musl libc
>> changes the [U]INT_FAST{16,32}_TYPE macro definitions.
>>
>> The undef/define logic is needed because glibc-stdint.h is
>> used on non-linux targets where OPTION_MUSL would not be
>> defined and it is used both before and after config/linux.h on
>> various linux targets.
>>
>> I did not find any cleaner workaround. (Separate musl-stdint.h
>> would need significant changes in config.gcc.)
>>
>> gcc/Changelog:
>>
>> 2015-05-06  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	* config/glibc-stdint.h (OPTION_MUSL): Define.
>> 	(INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
>> 	Change the definition based on OPTION_MUSL for 64 bit targets.
>>
>> 	* config/linux.h (OPTION_MUSL): Redefine.
>> 	* config/alpha/linux.h (OPTION_MUSL): Redefine.
>> 	* config/rs6000/linux.h (OPTION_MUSL): Redefine.
>> 	* config/rs6000/linux64.h (OPTION_MUSL): Redefine.
> I really don't like the MUSL bits inside glibc-stdint.h.  But I don't
> see an easy way to avoid it.
>
> OK for the trunk.

I've committed this on Szabolcs' behalf with r222905.

Kyrill

>
> jeff
>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-04-27 14:40         ` Szabolcs Nagy
@ 2015-05-08 13:56           ` H.J. Lu
  2015-05-08 14:27             ` Szabolcs Nagy
  2015-05-08 14:27             ` Matthew Fortune
  0 siblings, 2 replies; 83+ messages in thread
From: H.J. Lu @ 2015-05-08 13:56 UTC (permalink / raw)
  To: Szabolcs Nagy
  Cc: Matthew Fortune, Rich Felker, Gregor Richards, Szabolcs Nagy,
	gcc-patches

On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>
>
> On 21/04/15 15:59, Matthew Fortune wrote:
>> Rich Felker <dalias@libc.org> writes:
>>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
>>>> There does however appear to be both soft and hard float variants
>
> Patch v2.
>
> Now all the ABI variants musl plans to support are represented.
>
> gcc/Changelog:
>
> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
>             Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
>         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
>         (GNU_USER_DYNAMIC_LINKERN32): Update.

You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change
without config/mips/linux.h change.  Now linux-mips is broken.

-- 
H.J.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 6/13] mips musl support
  2015-05-08 13:56           ` H.J. Lu
  2015-05-08 14:27             ` Szabolcs Nagy
@ 2015-05-08 14:27             ` Matthew Fortune
  2015-05-08 14:40               ` Rich Felker
                                 ` (2 more replies)
  1 sibling, 3 replies; 83+ messages in thread
From: Matthew Fortune @ 2015-05-08 14:27 UTC (permalink / raw)
  To: H.J. Lu, Szabolcs Nagy
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches

H.J. Lu <hjl.tools@gmail.com> writes:
> On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy <szabolcs.nagy@arm.com>
> wrote:
> >
> >
> > On 21/04/15 15:59, Matthew Fortune wrote:
> >> Rich Felker <dalias@libc.org> writes:
> >>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
> >>>> There does however appear to be both soft and hard float variants
> >
> > Patch v2.
> >
> > Now all the ABI variants musl plans to support are represented.
> >
> > gcc/Changelog:
> >
> > 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> >             Szabolcs Nagy  <szabolcs.nagy@arm.com>
> >
> >         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
> >         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
> >         (GNU_USER_DYNAMIC_LINKERN32): Update.
> 
> You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change without
> config/mips/linux.h change.  Now linux-mips is broken.

The MIPS patch is OK. I am concerned that you are aiming for one
dynamic linker per ABI variant in musl but are not accounting for
soft-float up front in n32/n64. There is time to reconsider this
before any of this code gets to a versioned GCC release though.

I.e. as it stands this patch is not OK for backporting to GCC 5
without further discussion.

There is also the perspective that we should be able to aim for
an ABI variant agnostic dynamic linker at some point over the next
year by working towards a build that truly uses no float and is
hence compatible with all the ABI variants.

Thanks,
Matthew

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 13:56           ` H.J. Lu
@ 2015-05-08 14:27             ` Szabolcs Nagy
  2015-05-08 14:27             ` Matthew Fortune
  1 sibling, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-08 14:27 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Matthew Fortune, Rich Felker, Gregor Richards, Szabolcs Nagy,
	gcc-patches

On 08/05/15 14:56, H.J. Lu wrote:
> On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> On 21/04/15 15:59, Matthew Fortune wrote:
>>> Rich Felker <dalias@libc.org> writes:
>>>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
>>>>> There does however appear to be both soft and hard float variants
>>
>> Patch v2.
>>
>> Now all the ABI variants musl plans to support are represented.
>>
>> gcc/Changelog:
>>
>> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>             Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>>         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
>>         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
>>         (GNU_USER_DYNAMIC_LINKERN32): Update.
> 
> You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change
> without config/mips/linux.h change.  Now linux-mips is broken.
> 

sorry, i cannot roll back the change right now or
provide fix up patches.

i thought i did the tests without the target patches..
but not mips (only mips is affected).

while i'm waiting for the ppl with commit rights..
is it better to roll back the commit or do a single
line fix to config/mips/linux.h?

(the single line fix is to add a "/dev/null" fourth
argument to CHOOSE_DYNAMIC_LINKER macro in the definition
of GNU_USER_DYNAMIC_LINKERN32 in config/mips/linux.h)

i don't know why i got the mail with such a big delay :(

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:27             ` Matthew Fortune
@ 2015-05-08 14:40               ` Rich Felker
  2015-05-08 14:41               ` Szabolcs Nagy
  2015-05-08 18:20               ` Jeff Law
  2 siblings, 0 replies; 83+ messages in thread
From: Rich Felker @ 2015-05-08 14:40 UTC (permalink / raw)
  To: Matthew Fortune
  Cc: H.J. Lu, Szabolcs Nagy, Gregor Richards, Szabolcs Nagy, gcc-patches

On Fri, May 08, 2015 at 02:25:11PM +0000, Matthew Fortune wrote:
> H.J. Lu <hjl.tools@gmail.com> writes:
> > On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy <szabolcs.nagy@arm.com>
> > wrote:
> > >
> > >
> > > On 21/04/15 15:59, Matthew Fortune wrote:
> > >> Rich Felker <dalias@libc.org> writes:
> > >>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
> > >>>> There does however appear to be both soft and hard float variants
> > >
> > > Patch v2.
> > >
> > > Now all the ABI variants musl plans to support are represented.
> > >
> > > gcc/Changelog:
> > >
> > > 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> > >             Szabolcs Nagy  <szabolcs.nagy@arm.com>
> > >
> > >         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
> > >         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
> > >         (GNU_USER_DYNAMIC_LINKERN32): Update.
> > 
> > You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change without
> > config/mips/linux.h change.  Now linux-mips is broken.
> 
> The MIPS patch is OK. I am concerned that you are aiming for one
> dynamic linker per ABI variant in musl but are not accounting for
> soft-float up front in n32/n64. There is time to reconsider this
> before any of this code gets to a versioned GCC release though.

I'm not aware of whether there are mips64 chips for which softfloat
would be desirable, so I don't know if it's an ABI we'll ever have,
but I'm not opposed to adding it here just to be safe (in case we need
it).

> I.e. as it stands this patch is not OK for backporting to GCC 5
> without further discussion.
> 
> There is also the perspective that we should be able to aim for
> an ABI variant agnostic dynamic linker at some point over the next
> year by working towards a build that truly uses no float and is
> hence compatible with all the ABI variants.

For musl that's not going to happen. The dynamic linker and shared
libc are one file, which therefore has lots of public interfaces that
depend on the argument passing ABI.

Rich

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:27             ` Matthew Fortune
  2015-05-08 14:40               ` Rich Felker
@ 2015-05-08 14:41               ` Szabolcs Nagy
  2015-05-08 14:47                 ` Matthew Fortune
  2015-05-08 14:49                 ` Rich Felker
  2015-05-08 18:20               ` Jeff Law
  2 siblings, 2 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-08 14:41 UTC (permalink / raw)
  To: Matthew Fortune, H.J. Lu
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches



On 08/05/15 15:25, Matthew Fortune wrote:
> H.J. Lu <hjl.tools@gmail.com> writes:
>> On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy <szabolcs.nagy@arm.com>
>> wrote:
>>>
>>>
>>> On 21/04/15 15:59, Matthew Fortune wrote:
>>>> Rich Felker <dalias@libc.org> writes:
>>>>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
>>>>>> There does however appear to be both soft and hard float variants
>>>
>>> Patch v2.
>>>
>>> Now all the ABI variants musl plans to support are represented.
>>>
>>> gcc/Changelog:
>>>
>>> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>             Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>>
>>>         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
>>>         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
>>>         (GNU_USER_DYNAMIC_LINKERN32): Update.
>>
>> You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change without
>> config/mips/linux.h change.  Now linux-mips is broken.
> 
> The MIPS patch is OK. I am concerned that you are aiming for one
> dynamic linker per ABI variant in musl but are not accounting for
> soft-float up front in n32/n64. There is time to reconsider this
> before any of this code gets to a versioned GCC release though.
> 

i thought musl would not want to support soft float variants
of those abis, but now i think it does not hurt to add the -sf
there too.

if you think that's ok, i can now submit the patch with
%{msoft-float:-sf} added to all abi variants.

> I.e. as it stands this patch is not OK for backporting to GCC 5
> without further discussion.
> 
> There is also the perspective that we should be able to aim for
> an ABI variant agnostic dynamic linker at some point over the next
> year by working towards a build that truly uses no float and is
> hence compatible with all the ABI variants.

i'm not sure what you mean by 'a build that truly uses no float'

i thought the direction is to have a potentially hard float abi
with kernel emulation when the fpu is not present.

> 
> Thanks,
> Matthew
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 6/13] mips musl support
  2015-05-08 14:41               ` Szabolcs Nagy
@ 2015-05-08 14:47                 ` Matthew Fortune
  2015-05-08 15:13                   ` Szabolcs Nagy
  2015-05-08 14:49                 ` Rich Felker
  1 sibling, 1 reply; 83+ messages in thread
From: Matthew Fortune @ 2015-05-08 14:47 UTC (permalink / raw)
  To: Szabolcs Nagy, H.J. Lu
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches

Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> On 08/05/15 15:25, Matthew Fortune wrote:
> > H.J. Lu <hjl.tools@gmail.com> writes:
> >> On Mon, Apr 27, 2015 at 7:40 AM, Szabolcs Nagy
> >> <szabolcs.nagy@arm.com>
> >> wrote:
> >>>
> >>>
> >>> On 21/04/15 15:59, Matthew Fortune wrote:
> >>>> Rich Felker <dalias@libc.org> writes:
> >>>>> On Tue, Apr 21, 2015 at 01:58:02PM +0000, Matthew Fortune wrote:
> >>>>>> There does however appear to be both soft and hard float variants
> >>>
> >>> Patch v2.
> >>>
> >>> Now all the ABI variants musl plans to support are represented.
> >>>
> >>> gcc/Changelog:
> >>>
> >>> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> >>>             Szabolcs Nagy  <szabolcs.nagy@arm.com>
> >>>
> >>>         * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
> >>>         (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
> >>>         (GNU_USER_DYNAMIC_LINKERN32): Update.
> >>
> >> You checked in config/linux.h CHOOSE_DYNAMIC_LINKER change without
> >> config/mips/linux.h change.  Now linux-mips is broken.
> >
> > The MIPS patch is OK. I am concerned that you are aiming for one
> > dynamic linker per ABI variant in musl but are not accounting for
> > soft-float up front in n32/n64. There is time to reconsider this
> > before any of this code gets to a versioned GCC release though.
> >
> 
> i thought musl would not want to support soft float variants of those
> abis, but now i think it does not hurt to add the -sf there too.
> 
> if you think that's ok, i can now submit the patch with %{msoft-float:-
> sf} added to all abi variants.

That's fine. Go ahead.

> > I.e. as it stands this patch is not OK for backporting to GCC 5
> > without further discussion.
> >
> > There is also the perspective that we should be able to aim for an ABI
> > variant agnostic dynamic linker at some point over the next year by
> > working towards a build that truly uses no float and is hence
> > compatible with all the ABI variants.
> 
> i'm not sure what you mean by 'a build that truly uses no float'
> 
> i thought the direction is to have a potentially hard float abi with
> kernel emulation when the fpu is not present.

With MIPS having such a rich matrix of ABI variants the need to build code
to target all variants is quite costly. We currently have to do this
regardless of whether the code in it is affected by the differences. We are
looking at ways to create more generic objects so that some libraries can
get away with fewer build variations. The major variation for MIPS is the
set of floating-point extensions so knowing that a module has no interest
in floating point code is quite valuable.

Since Rich has just pointed out that the dynamic linker and C library are
one and the same for musl then this will not be of as much value to musl.

Thanks,
Matthew

> 
> >
> > Thanks,
> > Matthew
> >


^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:41               ` Szabolcs Nagy
  2015-05-08 14:47                 ` Matthew Fortune
@ 2015-05-08 14:49                 ` Rich Felker
  2015-05-08 16:50                   ` Joseph Myers
  1 sibling, 1 reply; 83+ messages in thread
From: Rich Felker @ 2015-05-08 14:49 UTC (permalink / raw)
  To: Szabolcs Nagy
  Cc: Matthew Fortune, H.J. Lu, Gregor Richards, Szabolcs Nagy, gcc-patches

On Fri, May 08, 2015 at 03:41:31PM +0100, Szabolcs Nagy wrote:
> > I.e. as it stands this patch is not OK for backporting to GCC 5
> > without further discussion.
> > 
> > There is also the perspective that we should be able to aim for
> > an ABI variant agnostic dynamic linker at some point over the next
> > year by working towards a build that truly uses no float and is
> > hence compatible with all the ABI variants.
> 
> i'm not sure what you mean by 'a build that truly uses no float'
> 
> i thought the direction is to have a potentially hard float abi
> with kernel emulation when the fpu is not present.

I think Matthew's idea was that the dynamic linker could be agnostic
since it doesn't need floating point arithmetic itself, then load
appropriate libraries depending on the ABI of the application
(presumably determined by some flags in _DYNAMIC or perhaps the main
ELF header). Of course with some familiarity with musl it becomes
clear why this is not an option, but to answer things like this we
need to think from a standpoint of non-familiarity with musl. :-)

Rich

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:47                 ` Matthew Fortune
@ 2015-05-08 15:13                   ` Szabolcs Nagy
  2015-05-08 15:17                     ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-08 15:13 UTC (permalink / raw)
  To: Matthew Fortune, H.J. Lu
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

On 08/05/15 15:46, Matthew Fortune wrote:
> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
>> if you think that's ok, i can now submit the patch with %{msoft-float:-
>> sf} added to all abi variants.
> 
> That's fine. Go ahead.
> 

the patch for the record.

Changelog:

2015-05-08  Gregor Richards  <gregor.richards@uwaterloo.ca>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
	(GNU_USER_DYNAMIC_LINKERN32): Update.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 06-mips-v3.diff --]
[-- Type: text/x-patch; name=06-mips-v3.diff, Size: 966 bytes --]

diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
index 91df261..fb358e2 100644
--- a/gcc/config/mips/linux.h
+++ b/gcc/config/mips/linux.h
@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3.  If not see
 #define UCLIBC_DYNAMIC_LINKERN32 \
   "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
 
+#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"
+
 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
 #define GNU_USER_DYNAMIC_LINKERN32 \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
-                         BIONIC_DYNAMIC_LINKERN32)
+                         BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 15:13                   ` Szabolcs Nagy
@ 2015-05-08 15:17                     ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-05-08 15:17 UTC (permalink / raw)
  To: Szabolcs Nagy, Matthew Fortune, H.J. Lu
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches


On 08/05/15 16:13, Szabolcs Nagy wrote:
> On 08/05/15 15:46, Matthew Fortune wrote:
>> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
>>> if you think that's ok, i can now submit the patch with %{msoft-float:-
>>> sf} added to all abi variants.
>> That's fine. Go ahead.
>>
> the patch for the record.

I've committed this on Szabolcs' behalf with r222915.

Kyrill
>
> Changelog:
>
> 2015-05-08  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
> 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
> 	(GNU_USER_DYNAMIC_LINKERN32): Update.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:49                 ` Rich Felker
@ 2015-05-08 16:50                   ` Joseph Myers
  2015-05-08 17:03                     ` Rich Felker
  2015-05-08 18:27                     ` Jeff Law
  0 siblings, 2 replies; 83+ messages in thread
From: Joseph Myers @ 2015-05-08 16:50 UTC (permalink / raw)
  To: Rich Felker
  Cc: Szabolcs Nagy, Matthew Fortune, H.J. Lu, Gregor Richards,
	Szabolcs Nagy, gcc-patches

On Fri, 8 May 2015, Rich Felker wrote:

> On Fri, May 08, 2015 at 03:41:31PM +0100, Szabolcs Nagy wrote:
> > > I.e. as it stands this patch is not OK for backporting to GCC 5
> > > without further discussion.
> > > 
> > > There is also the perspective that we should be able to aim for
> > > an ABI variant agnostic dynamic linker at some point over the next
> > > year by working towards a build that truly uses no float and is
> > > hence compatible with all the ABI variants.
> > 
> > i'm not sure what you mean by 'a build that truly uses no float'
> > 
> > i thought the direction is to have a potentially hard float abi
> > with kernel emulation when the fpu is not present.
> 
> I think Matthew's idea was that the dynamic linker could be agnostic
> since it doesn't need floating point arithmetic itself, then load

Note that however the dynamic linker does properly need to save and 
restore call-clobbered registers used for argument passing (because of 
IFUNCs, user-provided malloc, audit hooks etc. that might affect them even 
if the dynamic linker itself doesn't); see 
<https://sourceware.org/ml/libc-alpha/2014-01/msg00673.html>.  So any 
floating-point-agnostic dynamic linker would, if fixing the bugs around 
not saving / restoring such registers, need to have runtime-conditional 
code to save and restore them rather than simple compile-time 
conditionals.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 16:50                   ` Joseph Myers
@ 2015-05-08 17:03                     ` Rich Felker
  2015-05-08 18:27                     ` Jeff Law
  1 sibling, 0 replies; 83+ messages in thread
From: Rich Felker @ 2015-05-08 17:03 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Szabolcs Nagy, Matthew Fortune, H.J. Lu, Gregor Richards,
	Szabolcs Nagy, gcc-patches

On Fri, May 08, 2015 at 04:50:28PM +0000, Joseph Myers wrote:
> On Fri, 8 May 2015, Rich Felker wrote:
> 
> > On Fri, May 08, 2015 at 03:41:31PM +0100, Szabolcs Nagy wrote:
> > > > I.e. as it stands this patch is not OK for backporting to GCC 5
> > > > without further discussion.
> > > > 
> > > > There is also the perspective that we should be able to aim for
> > > > an ABI variant agnostic dynamic linker at some point over the next
> > > > year by working towards a build that truly uses no float and is
> > > > hence compatible with all the ABI variants.
> > > 
> > > i'm not sure what you mean by 'a build that truly uses no float'
> > > 
> > > i thought the direction is to have a potentially hard float abi
> > > with kernel emulation when the fpu is not present.
> > 
> > I think Matthew's idea was that the dynamic linker could be agnostic
> > since it doesn't need floating point arithmetic itself, then load
> 
> Note that however the dynamic linker does properly need to save and 
> restore call-clobbered registers used for argument passing (because of 
> IFUNCs, user-provided malloc, audit hooks etc. that might affect them even 
> if the dynamic linker itself doesn't); see 
> <https://sourceware.org/ml/libc-alpha/2014-01/msg00673.html>.  So any 
> floating-point-agnostic dynamic linker would, if fixing the bugs around 
> not saving / restoring such registers, need to have runtime-conditional 
> code to save and restore them rather than simple compile-time 
> conditionals.

FWIW, this also doesn't apply to musl; we don't do lazy binding and
there's no resolver function. The dynamic linker never calls into code
provided by the application except for executing init/fini functions.
IFUNC may be provided at some point but it wouldn't be lazy, so
call-clobbered registers aren't relevant; right now the lack of any
specification for what an IFUNC callback is permitted to do (in the
form of "if you do anything else, the behavior is undefined") is
what's blocking support.

Rich

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 14:27             ` Matthew Fortune
  2015-05-08 14:40               ` Rich Felker
  2015-05-08 14:41               ` Szabolcs Nagy
@ 2015-05-08 18:20               ` Jeff Law
  2 siblings, 0 replies; 83+ messages in thread
From: Jeff Law @ 2015-05-08 18:20 UTC (permalink / raw)
  To: Matthew Fortune, H.J. Lu, Szabolcs Nagy
  Cc: Rich Felker, Gregor Richards, Szabolcs Nagy, gcc-patches

On 05/08/2015 08:25 AM, Matthew Fortune wrote:
>
> There is also the perspective that we should be able to aim for
> an ABI variant agnostic dynamic linker at some point over the next
> year by working towards a build that truly uses no float and is
> hence compatible with all the ABI variants.
Having seen the pain around this for ARM up close and personal, if you 
can see a path to that goal, I'd suggest running as fast as you can to 
that goal.

jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 6/13] mips musl support
  2015-05-08 16:50                   ` Joseph Myers
  2015-05-08 17:03                     ` Rich Felker
@ 2015-05-08 18:27                     ` Jeff Law
  2015-05-08 18:56                       ` Matthew Fortune
  1 sibling, 1 reply; 83+ messages in thread
From: Jeff Law @ 2015-05-08 18:27 UTC (permalink / raw)
  To: Joseph Myers, Rich Felker
  Cc: Szabolcs Nagy, Matthew Fortune, H.J. Lu, Gregor Richards,
	Szabolcs Nagy, gcc-patches

On 05/08/2015 10:50 AM, Joseph Myers wrote:
>
> Note that however the dynamic linker does properly need to save and
> restore call-clobbered registers used for argument passing (because of
> IFUNCs, user-provided malloc, audit hooks etc. that might affect them even
> if the dynamic linker itself doesn't); see
> <https://sourceware.org/ml/libc-alpha/2014-01/msg00673.html>.  So any
> floating-point-agnostic dynamic linker would, if fixing the bugs around
> not saving / restoring such registers, need to have runtime-conditional
> code to save and restore them rather than simple compile-time
> conditionals.
Right.  So there has to be some reasonable cost way to find out if you 
have FPU registers at runtime, then select between the code paths at 
runtime.


Jeff

^ permalink raw reply	[flat|nested] 83+ messages in thread

* RE: [PATCH 6/13] mips musl support
  2015-05-08 18:27                     ` Jeff Law
@ 2015-05-08 18:56                       ` Matthew Fortune
  0 siblings, 0 replies; 83+ messages in thread
From: Matthew Fortune @ 2015-05-08 18:56 UTC (permalink / raw)
  To: Jeff Law, Joseph Myers, Rich Felker
  Cc: Szabolcs Nagy, H.J. Lu, Gregor Richards, Szabolcs Nagy, gcc-patches

Jeff Law <law@redhat.com> writes:
> On 05/08/2015 10:50 AM, Joseph Myers wrote:
> >
> > Note that however the dynamic linker does properly need to save and
> > restore call-clobbered registers used for argument passing (because of
> > IFUNCs, user-provided malloc, audit hooks etc. that might affect them
> > even if the dynamic linker itself doesn't); see
> > <https://sourceware.org/ml/libc-alpha/2014-01/msg00673.html>.  So any
> > floating-point-agnostic dynamic linker would, if fixing the bugs
> > around not saving / restoring such registers, need to have
> > runtime-conditional code to save and restore them rather than simple
> > compile-time conditionals.
> Right.  So there has to be some reasonable cost way to find out if you
> have FPU registers at runtime, then select between the code paths at
> runtime.

Indeed and I think there are many ways to achieve that without hardware
support as the cost of loading a global variable in the dynamic linker
wouldn't be significant. I think MIPS ABIs are the only ones with enough
information available at runtime to achieve this currently but the
principles should apply to any arch.

The work we are investigating as part of PR65862 will help all this
as the intention is to avoid FPR usage unless floating point is actually
used. There is then some thinking involved in figuring out what no-float
should really mean: i.e. no floating point types used, no FPU insns used
and/or no floating point in any of the calls/global functions. I haven't
spent enough time thinking about which ones are the most important from
above yet.

Matthew

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 3/13] aarch64 musl support
  2015-04-27 14:33     ` Szabolcs Nagy
@ 2015-05-15 12:33       ` Szabolcs Nagy
  2015-05-27 17:39       ` James Greenhalgh
  1 sibling, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-15 12:33 UTC (permalink / raw)
  To: pinskia
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy,
	Marcus Shawcroft

On 27/04/15 15:33, Szabolcs Nagy wrote:
> 
> On 21/04/15 15:16, pinskia@gmail.com wrote:
>>
>> I don't think you need to check if defaulting to little or big-endian here are the specs always have one or the other passing through. 
>>
>> Also if musl does not support ilp32, you might want to error out. Or even define the dynamic linker name even before support goes into musl. 
>>
> 
> Patch v2.
> 
> (now _ilp32 abi variant is included too)
> 

ping

(now with maintainer in cc)

> gcc/Changelog:
> 
> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	* config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 9/13] x86 musl support
  2015-04-27 14:52   ` Szabolcs Nagy
@ 2015-05-15 12:34     ` Szabolcs Nagy
  2015-05-15 12:45       ` Uros Bizjak
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-15 12:34 UTC (permalink / raw)
  To: gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy, Jan Hubicka, Uros Bizjak

On 27/04/15 15:52, Szabolcs Nagy wrote:
> On 20/04/15 19:57, Szabolcs Nagy wrote:
>> Set up dynamic linker name for x86.
>>
> Patch v2.
> 
> (undef MUSL_DYNAMIC_LINKER* before defining it).

ping

(now with maintainers in cc)

> gcc/Changelog:
> 
> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 
> 	* config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
> 	* config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
> 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-04-20 19:00 ` [PATCH 13/13] fix incompatible posix_memalign declaration on x86 Szabolcs Nagy
@ 2015-05-15 12:36   ` Szabolcs Nagy
  2015-05-15 13:04     ` Uros Bizjak
  2015-05-15 15:18   ` H.J. Lu
  1 sibling, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-15 12:36 UTC (permalink / raw)
  To: gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy, Jan Hubicka, Uros Bizjak

On 20/04/15 20:00, Szabolcs Nagy wrote:
> The posix_memalign declaration is incompatible with musl for C++,
> because of the exception specification.  It also pollutes the
> namespace and lacks protection against a potential macro definition
> that is allowed by POSIX.  The fix avoids source level namespace
> pollution but retains the dependency on the posix_memalign extern
> libc symbol.
> 
> The fix is ugly, but it is not possible to correctly redeclare a
> libc function in a public gcc header for C++.
> 

ping

(now with maintainers in cc)

> 
> gcc/Changelog:
> 
> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	* config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
> 	(__gcc_posix_memalign): This.  Use posix_memalign as extern
> 	symbol only.
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 4/13] arm musl support
  2015-04-20 18:53 ` [PATCH 4/13] arm " Szabolcs Nagy
@ 2015-05-15 12:43   ` Szabolcs Nagy
  2015-05-27 13:49   ` Kyrill Tkachov
  1 sibling, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-15 12:43 UTC (permalink / raw)
  To: gcc-patches
  Cc: Gregor Richards, Rich Felker, Szabolcs Nagy, Ramana Radhakrishnan

On 20/04/15 19:53, Szabolcs Nagy wrote:
> Set up dynamic linker name for arm.
> 

ping

(now with maintainer in cc)

> gcc/Changelog:
> 
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 
> 	* config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define.
> 

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 9/13] x86 musl support
  2015-05-15 12:34     ` Szabolcs Nagy
@ 2015-05-15 12:45       ` Uros Bizjak
  2015-05-15 13:39         ` Kyrill Tkachov
  0 siblings, 1 reply; 83+ messages in thread
From: Uros Bizjak @ 2015-05-15 12:45 UTC (permalink / raw)
  To: Szabolcs Nagy
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy, Jan Hubicka

On Fri, May 15, 2015 at 2:33 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> On 27/04/15 15:52, Szabolcs Nagy wrote:
>> On 20/04/15 19:57, Szabolcs Nagy wrote:
>>> Set up dynamic linker name for x86.
>>>
>> Patch v2.
>>
>> (undef MUSL_DYNAMIC_LINKER* before defining it).
>
> ping
>
> (now with maintainers in cc)
>
>> gcc/Changelog:
>>
>> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>
>>       * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
>>       * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
>>       (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.

OK with a small nit below.

diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index a100963..9c47fcb 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -21,3 +21,5 @@ along with GCC; see the file COPYING3.  If not see

 #define GNU_USER_LINK_EMULATION "elf_i386"
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"

Please add vertical space here.

+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-05-15 12:36   ` Szabolcs Nagy
@ 2015-05-15 13:04     ` Uros Bizjak
  0 siblings, 0 replies; 83+ messages in thread
From: Uros Bizjak @ 2015-05-15 13:04 UTC (permalink / raw)
  To: Szabolcs Nagy
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy,
	Jan Hubicka, H.J. Lu, Kirill Yukhin

On Fri, May 15, 2015 at 2:34 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> On 20/04/15 20:00, Szabolcs Nagy wrote:
>> The posix_memalign declaration is incompatible with musl for C++,
>> because of the exception specification.  It also pollutes the
>> namespace and lacks protection against a potential macro definition
>> that is allowed by POSIX.  The fix avoids source level namespace
>> pollution but retains the dependency on the posix_memalign extern
>> libc symbol.
>>
>> The fix is ugly, but it is not possible to correctly redeclare a
>> libc function in a public gcc header for C++.
>>
>
> ping
>
> (now with maintainers in cc)
>
>>
>> gcc/Changelog:
>>
>> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>>       * config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
>>       (__gcc_posix_memalign): This.  Use posix_memalign as extern
>>       symbol only.

This changes Intel's header - adding relevant people to OK the change.

Uros.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 9/13] x86 musl support
  2015-05-15 12:45       ` Uros Bizjak
@ 2015-05-15 13:39         ` Kyrill Tkachov
  0 siblings, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-05-15 13:39 UTC (permalink / raw)
  To: Uros Bizjak, Szabolcs Nagy
  Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]


On 15/05/15 13:43, Uros Bizjak wrote:
> On Fri, May 15, 2015 at 2:33 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> On 27/04/15 15:52, Szabolcs Nagy wrote:
>>> On 20/04/15 19:57, Szabolcs Nagy wrote:
>>>> Set up dynamic linker name for x86.
>>>>
>>> Patch v2.
>>>
>>> (undef MUSL_DYNAMIC_LINKER* before defining it).
>> ping
>>
>> (now with maintainers in cc)
>>
>>> gcc/Changelog:
>>>
>>> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>
>>>        * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
>>>        * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
>>>        (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
> OK with a small nit below.
>
> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
> index a100963..9c47fcb 100644
> --- a/gcc/config/i386/linux.h
> +++ b/gcc/config/i386/linux.h
> @@ -21,3 +21,5 @@ along with GCC; see the file COPYING3.  If not see
>
>   #define GNU_USER_LINK_EMULATION "elf_i386"
>   #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>
> Please add vertical space here.
>
> +#undef MUSL_DYNAMIC_LINKER
> +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"

Hi all,
I've committed the patch for Szabolcs with r223218.
I'm attaching the committed patch with the whitespace
change that he provided.

Cheers,
Kyrill

>
> Thanks,
> Uros.
>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 09-x86-v3.diff --]
[-- Type: text/x-patch; name=09-x86-v3.diff, Size: 1118 bytes --]

diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index a100963..385aefd 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -21,3 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #define GNU_USER_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"
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index a27d3be..e300480 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #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"
+
+#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"

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-04-20 19:00 ` [PATCH 13/13] fix incompatible posix_memalign declaration on x86 Szabolcs Nagy
  2015-05-15 12:36   ` Szabolcs Nagy
@ 2015-05-15 15:18   ` H.J. Lu
  2015-05-15 16:12     ` Szabolcs Nagy
  1 sibling, 1 reply; 83+ messages in thread
From: H.J. Lu @ 2015-05-15 15:18 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Mon, Apr 20, 2015 at 12:00 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> The posix_memalign declaration is incompatible with musl for C++,
> because of the exception specification.  It also pollutes the
> namespace and lacks protection against a potential macro definition
> that is allowed by POSIX.  The fix avoids source level namespace
> pollution but retains the dependency on the posix_memalign extern
> libc symbol.
>
> The fix is ugly, but it is not possible to correctly redeclare a
> libc function in a public gcc header for C++.
>
>
> gcc/Changelog:
>
> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         * config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
>         (__gcc_posix_memalign): This.  Use posix_memalign as extern
>         symbol only.

What does this try to achieve?  Do you have a testcase which
fails before and passes with this patch?

-- 
H.J.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-05-15 15:18   ` H.J. Lu
@ 2015-05-15 16:12     ` Szabolcs Nagy
  2015-05-15 17:22       ` H.J. Lu
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-05-15 16:12 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy



On 15/05/15 16:05, H.J. Lu wrote:
> On Mon, Apr 20, 2015 at 12:00 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> The posix_memalign declaration is incompatible with musl for C++,
>> because of the exception specification.  It also pollutes the
>> namespace and lacks protection against a potential macro definition
>> that is allowed by POSIX.  The fix avoids source level namespace
>> pollution but retains the dependency on the posix_memalign extern
>> libc symbol.
>>
>> The fix is ugly, but it is not possible to correctly redeclare a
>> libc function in a public gcc header for C++.
>>
>>
>> gcc/Changelog:
>>
>> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>>         * config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
>>         (__gcc_posix_memalign): This.  Use posix_memalign as extern
>>         symbol only.
> 
> What does this try to achieve?  Do you have a testcase which
> fails before and passes with this patch?

if posix_memalign is defined in stdlib.h according to posix then
the exception specifier used in mm_malloc.h is incompatible:

$ echo "#include <mm_malloc.h>" | ./x86_64-linux-musl-g++ -pedantic -c -xc++ -D_POSIX_C_SOURCE=200809L -
In file included from <stdin>:1:0:
/data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:34:64: error: declaration of 'int posix_memalign(void**, size_t,
size_t) throw ()' has a different exception specifier
 extern "C" int posix_memalign (void **, size_t, size_t) throw ()
                                                                ^
In file included from /data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:27:0,
                 from <stdin>:1:
/data/cross/x86_64-linux-musl/x86_64-linux-musl/include/stdlib.h:98:5: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
 int posix_memalign (void **, size_t, size_t);
     ^

however it seems without -pedantic there is no error anymore,
the code is accepted even in standard conforming mode.
(it used to be an error that could not be silenced).

this means the patch is no longer critical for musl support.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
  2015-05-15 16:12     ` Szabolcs Nagy
@ 2015-05-15 17:22       ` H.J. Lu
  0 siblings, 0 replies; 83+ messages in thread
From: H.J. Lu @ 2015-05-15 17:22 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Fri, May 15, 2015 at 9:09 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>
>
> On 15/05/15 16:05, H.J. Lu wrote:
>> On Mon, Apr 20, 2015 at 12:00 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>> The posix_memalign declaration is incompatible with musl for C++,
>>> because of the exception specification.  It also pollutes the
>>> namespace and lacks protection against a potential macro definition
>>> that is allowed by POSIX.  The fix avoids source level namespace
>>> pollution but retains the dependency on the posix_memalign extern
>>> libc symbol.
>>>
>>> The fix is ugly, but it is not possible to correctly redeclare a
>>> libc function in a public gcc header for C++.
>>>
>>>
>>> gcc/Changelog:
>>>
>>> 2015-04-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>>
>>>         * config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
>>>         (__gcc_posix_memalign): This.  Use posix_memalign as extern
>>>         symbol only.
>>
>> What does this try to achieve?  Do you have a testcase which
>> fails before and passes with this patch?
>
> if posix_memalign is defined in stdlib.h according to posix then
> the exception specifier used in mm_malloc.h is incompatible:
>
> $ echo "#include <mm_malloc.h>" | ./x86_64-linux-musl-g++ -pedantic -c -xc++ -D_POSIX_C_SOURCE=200809L -
> In file included from <stdin>:1:0:
> /data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:34:64: error: declaration of 'int posix_memalign(void**, size_t,
> size_t) throw ()' has a different exception specifier
>  extern "C" int posix_memalign (void **, size_t, size_t) throw ()
>                                                                 ^
> In file included from /data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:27:0,
>                  from <stdin>:1:
> /data/cross/x86_64-linux-musl/x86_64-linux-musl/include/stdlib.h:98:5: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
>  int posix_memalign (void **, size_t, size_t);
>      ^
>
> however it seems without -pedantic there is no error anymore,
> the code is accepted even in standard conforming mode.
> (it used to be an error that could not be silenced).
>
> this means the patch is no longer critical for musl support.
>

2 more comments:

1. You need a tecase, independent of MUSL.
2. Please replace __gcc_posix_memalign with _mm_posix_memalign.


-- 
H.J.

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 4/13] arm musl support
  2015-04-20 18:53 ` [PATCH 4/13] arm " Szabolcs Nagy
  2015-05-15 12:43   ` Szabolcs Nagy
@ 2015-05-27 13:49   ` Kyrill Tkachov
  1 sibling, 0 replies; 83+ messages in thread
From: Kyrill Tkachov @ 2015-05-27 13:49 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

Hi Szabolcs,

On 20/04/15 19:53, Szabolcs Nagy wrote:
> Set up dynamic linker name for arm.
>
> gcc/Changelog:
>
> 2015-04-16  Gregor Richards  <gregor.richards@uwaterloo.ca>
>
> 	* config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define.

This is ok.
The #if TARGET_BIG_ENDIAN_DEFAULT logic looks ok to me.

I've committed this as r223749.

Thanks,
Kyrill

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PATCH 3/13] aarch64 musl support
  2015-04-27 14:33     ` Szabolcs Nagy
  2015-05-15 12:33       ` Szabolcs Nagy
@ 2015-05-27 17:39       ` James Greenhalgh
  1 sibling, 0 replies; 83+ messages in thread
From: James Greenhalgh @ 2015-05-27 17:39 UTC (permalink / raw)
  To: Szabolcs Nagy
  Cc: pinskia, gcc-patches, Gregor Richards, Rich Felker, Szabolcs Nagy

On Mon, Apr 27, 2015 at 03:33:05PM +0100, Szabolcs Nagy wrote:
> 
> On 21/04/15 15:16, pinskia@gmail.com wrote:
> > 
> > I don't think you need to check if defaulting to little or big-endian here
> > are the specs always have one or the other passing through. 
> > 
> > Also if musl does not support ilp32, you might want to error out. Or even
> > define the dynamic linker name even before support goes into musl. 
> > 
> 
> Patch v2.
> 
> (now _ilp32 abi variant is included too)
> 
> gcc/Changelog:
> 
> 2015-04-27  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	* config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.

OK, I've committed this on your behalf as revision 223766.

Thanks,
James


> diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
> index 9abb252..2d647c3 100644
> --- a/gcc/config/aarch64/aarch64-linux.h
> +++ b/gcc/config/aarch64/aarch64-linux.h
> @@ -23,6 +23,9 @@
>  
>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
>  
> +#undef MUSL_DYNAMIC_LINKER
> +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
> +
>  #undef  ASAN_CC1_SPEC
>  #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
>  

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PING][PATCH 5/13] microblaze musl support
  2015-05-06 11:25         ` Szabolcs Nagy
@ 2015-10-15 19:00           ` Szabolcs Nagy
  2015-10-15 19:04             ` Michael Eager
  0 siblings, 1 reply; 83+ messages in thread
From: Szabolcs Nagy @ 2015-10-15 19:00 UTC (permalink / raw)
  To: Michael Eager, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 06/05/15 12:25, Szabolcs Nagy wrote:
> On 29/04/15 14:51, Szabolcs Nagy wrote:
>> On 29/04/15 14:17, Michael Eager wrote:
>>> On 04/27/2015 07:35 AM, Szabolcs Nagy wrote:
>>>> On 20/04/15 19:54, Szabolcs Nagy wrote:
>>>>> Set up dynamic linker name for microblaze.
>>>>>
>>>>
>>>> Patch v2.
>>>> (undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)
>>>>
>>>
>>> Are you building with both glibc and musl to verify these patches?
>>>
> ...
>>
>> note that microblaze does not use the GNU_USER_DYNAMIC_LINKER
>> macro so the -mglibc etc options don't work.
>> (that should be changed probably, assuming -muclibc and -mbionic
>> have no side effects when they are not supported)
>>
>
> Patch v3.
>
> I changed the patch to use GNU_USER_DYNAMIC_LINKER like
> other platforms do.
>
> I built gcc with musl and glibc default libc as well and verified
> that -mmusl and -mglibc sets the dynamic linker as expected.
>

Ping,
patch still works.
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00437.html

> gcc/Changelog:
>
> 2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
> 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
> 	* config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
> 	(DYNAMIC_LINKER): Renamed to ...
> 	(GLIBC_DYNAMIC_LINKER): This.
> 	(SUBTARGET_EXTRA_SPECS): Use GNU_USER_DYNAMIC_LINKER.
>

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PING][PATCH 5/13] microblaze musl support
  2015-10-15 19:00           ` [PING][PATCH " Szabolcs Nagy
@ 2015-10-15 19:04             ` Michael Eager
  2015-10-15 19:06               ` Szabolcs Nagy
  0 siblings, 1 reply; 83+ messages in thread
From: Michael Eager @ 2015-10-15 19:04 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 10/15/2015 12:00 PM, Szabolcs Nagy wrote:
> On 06/05/15 12:25, Szabolcs Nagy wrote:
>> On 29/04/15 14:51, Szabolcs Nagy wrote:
>>> On 29/04/15 14:17, Michael Eager wrote:
>>>> On 04/27/2015 07:35 AM, Szabolcs Nagy wrote:
>>>>> On 20/04/15 19:54, Szabolcs Nagy wrote:
>>>>>> Set up dynamic linker name for microblaze.
>>>>>>
>>>>>
>>>>> Patch v2.
>>>>> (undef MUSL_DYNAMIC_LINKER that comes from config/linux.h)
>>>>>
>>>>
>>>> Are you building with both glibc and musl to verify these patches?
>>>>
>> ...
>>>
>>> note that microblaze does not use the GNU_USER_DYNAMIC_LINKER
>>> macro so the -mglibc etc options don't work.
>>> (that should be changed probably, assuming -muclibc and -mbionic
>>> have no side effects when they are not supported)
>>>
>>
>> Patch v3.
>>
>> I changed the patch to use GNU_USER_DYNAMIC_LINKER like
>> other platforms do.
>>
>> I built gcc with musl and glibc default libc as well and verified
>> that -mmusl and -mglibc sets the dynamic linker as expected.
>>
>
> Ping,
> patch still works.
> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00437.html
>
>> gcc/Changelog:
>>
>> 2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>         Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>>     * config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
>>     (DYNAMIC_LINKER): Renamed to ...
>>     (GLIBC_DYNAMIC_LINKER): This.
>>     (SUBTARGET_EXTRA_SPECS): Use GNU_USER_DYNAMIC_LINKER.


OK.  Do you have commit privileges?


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 83+ messages in thread

* Re: [PING][PATCH 5/13] microblaze musl support
  2015-10-15 19:04             ` Michael Eager
@ 2015-10-15 19:06               ` Szabolcs Nagy
  0 siblings, 0 replies; 83+ messages in thread
From: Szabolcs Nagy @ 2015-10-15 19:06 UTC (permalink / raw)
  To: Michael Eager, gcc-patches; +Cc: Gregor Richards, Rich Felker, Szabolcs Nagy

On 15/10/15 20:04, Michael Eager wrote:
> On 10/15/2015 12:00 PM, Szabolcs Nagy wrote:
>> Ping,
>> patch still works.
>> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00437.html
>>
>>> gcc/Changelog:
>>>
>>> 2015-05-06  Gregor Richards  <gregor.richards@uwaterloo.ca>
>>>         Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>>
>>>     * config/microblaze/linux.h (MUSL_DYNAMIC_LINKER): Define.
>>>     (DYNAMIC_LINKER): Renamed to ...
>>>     (GLIBC_DYNAMIC_LINKER): This.
>>>     (SUBTARGET_EXTRA_SPECS): Use GNU_USER_DYNAMIC_LINKER.
>
>
> OK.  Do you have commit privileges?
>

yes,
will commit it with updated date.


^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2015-10-15 19:06 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 18:49 [PATCH 0/13] Add musl support to GCC Szabolcs Nagy
2015-04-20 18:51 ` [PATCH 1/13] libitm fixes for musl support Szabolcs Nagy
2015-04-20 20:41   ` Jeff Law
2015-04-22 14:34     ` Kyrill Tkachov
2015-04-20 18:52 ` [PATCH 2/13] musl libc config Szabolcs Nagy
2015-04-22 13:16   ` Jeff Law
2015-04-22 14:34     ` Kyrill Tkachov
2015-04-22 15:27       ` Ilya Verbin
2015-04-22 15:37         ` Kyrill Tkachov
2015-04-22 15:42           ` Szabolcs Nagy
2015-04-27 14:30             ` Szabolcs Nagy
2015-04-27 19:27               ` Jeff Law
2015-04-28 23:50   ` Joseph Myers
2015-05-06 11:24     ` Szabolcs Nagy
2015-05-07 18:02       ` Jeff Law
2015-05-08  8:26         ` Kyrill Tkachov
2015-04-20 18:52 ` [PATCH 3/13] aarch64 musl support Szabolcs Nagy
2015-04-21 14:16   ` pinskia
2015-04-21 14:55     ` Szabolcs Nagy
2015-04-27 14:33     ` Szabolcs Nagy
2015-05-15 12:33       ` Szabolcs Nagy
2015-05-27 17:39       ` James Greenhalgh
2015-04-20 18:53 ` [PATCH 4/13] arm " Szabolcs Nagy
2015-05-15 12:43   ` Szabolcs Nagy
2015-05-27 13:49   ` Kyrill Tkachov
2015-04-20 18:54 ` [PATCH 6/13] mips " Szabolcs Nagy
2015-04-21 13:58   ` Matthew Fortune
2015-04-21 14:43     ` Rich Felker
2015-04-21 15:00       ` Matthew Fortune
2015-04-27 14:40         ` Szabolcs Nagy
2015-05-08 13:56           ` H.J. Lu
2015-05-08 14:27             ` Szabolcs Nagy
2015-05-08 14:27             ` Matthew Fortune
2015-05-08 14:40               ` Rich Felker
2015-05-08 14:41               ` Szabolcs Nagy
2015-05-08 14:47                 ` Matthew Fortune
2015-05-08 15:13                   ` Szabolcs Nagy
2015-05-08 15:17                     ` Kyrill Tkachov
2015-05-08 14:49                 ` Rich Felker
2015-05-08 16:50                   ` Joseph Myers
2015-05-08 17:03                     ` Rich Felker
2015-05-08 18:27                     ` Jeff Law
2015-05-08 18:56                       ` Matthew Fortune
2015-05-08 18:20               ` Jeff Law
2015-04-20 18:54 ` [PATCH 5/13] microblaze " Szabolcs Nagy
2015-04-27 14:35   ` Szabolcs Nagy
2015-04-29 13:23     ` Michael Eager
2015-04-29 14:06       ` Szabolcs Nagy
2015-05-06 11:25         ` Szabolcs Nagy
2015-10-15 19:00           ` [PING][PATCH " Szabolcs Nagy
2015-10-15 19:04             ` Michael Eager
2015-10-15 19:06               ` Szabolcs Nagy
2015-04-20 18:55 ` [PATCH 7/13] powerpc " Szabolcs Nagy
2015-04-27 14:58   ` Szabolcs Nagy
2015-04-20 18:56 ` [PATCH 8/13] sh " Szabolcs Nagy
2015-04-20 20:29   ` Oleg Endo
2015-04-27 14:50     ` Szabolcs Nagy
2015-04-20 18:57 ` [PATCH 9/13] x86 " Szabolcs Nagy
2015-04-27 14:52   ` Szabolcs Nagy
2015-05-15 12:34     ` Szabolcs Nagy
2015-05-15 12:45       ` Uros Bizjak
2015-05-15 13:39         ` Kyrill Tkachov
2015-04-20 18:58 ` [PATCH 10/13] fixincludes Szabolcs Nagy
2015-04-20 20:38   ` Jeff Law
2015-04-22 14:35     ` Kyrill Tkachov
2015-04-20 18:58 ` [PATCH 11/13] unwind fix for musl Szabolcs Nagy
2015-04-22 13:20   ` Jeff Law
2015-04-22 14:35     ` Kyrill Tkachov
2015-04-20 18:59 ` [PATCH 12/13] libstdc++, libgfortran gthr workaround " Szabolcs Nagy
2015-04-22 13:17   ` Jeff Law
2015-04-22 14:35     ` Kyrill Tkachov
2015-04-20 19:00 ` [PATCH 13/13] fix incompatible posix_memalign declaration on x86 Szabolcs Nagy
2015-05-15 12:36   ` Szabolcs Nagy
2015-05-15 13:04     ` Uros Bizjak
2015-05-15 15:18   ` H.J. Lu
2015-05-15 16:12     ` Szabolcs Nagy
2015-05-15 17:22       ` H.J. Lu
2015-04-28 23:50 ` [PATCH 0/13] Add musl support to GCC Joseph Myers
2015-04-29 13:42   ` Szabolcs Nagy
2015-04-30  0:13     ` Joseph Myers
2015-05-06 11:36       ` Szabolcs Nagy
2015-05-07 18:07         ` Jeff Law
2015-05-08  8:31           ` Kyrill Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).