powerpc musl libc support
authorGregor Richards <gregor.richards@uwaterloo.ca>
Fri, 23 Oct 2015 19:07:05 +0000 (19:07 +0000)
committerSzabolcs Nagy <nsz@gcc.gnu.org>
Fri, 23 Oct 2015 19:07:05 +0000 (19:07 +0000)
gcc/
* 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/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.
(CHOOSE_DYNAMIC_LINKER): Update.
(INCLUDE_DEFAULTS): Redefine.

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

Co-Authored-By: Szabolcs Nagy <szabolcs.nagy@arm.com>
From-SVN: r229266

gcc/ChangeLog
gcc/config/rs6000/linux64.h
gcc/config/rs6000/sysv4.h
gcc/config/rs6000/sysv4le.h

index 716b6320e42dba1af1c6a2a94ae605975b27041a..5aef5b72cd16b791022d5b5e277dd8f97d3fb148 100644 (file)
@@ -1,3 +1,22 @@
+2015-10-23  Gregor Richards  <gregor.richards@uwaterloo.ca>
+           Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+       * 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/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.
+       (CHOOSE_DYNAMIC_LINKER): Update.
+       (INCLUDE_DEFAULTS): Redefine.
+
+       * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define.
+
 2015-10-23  Jan Hubicka  <hubicka@ucw.cz>
 
        * fold-const.c (operand_equal_p): Do not compare TYPE_MODE when
index 41472f4930fab412e45dbd443bce813d5dd71b68..810d2f8b0d826dbb3a99d4cf959e76b7de79aa99 100644 (file)
@@ -421,19 +421,31 @@ extern int dot_symbols;
 ":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
 #endif
 
+#define MUSL_DYNAMIC_LINKER32 \
+  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+#define MUSL_DYNAMIC_LINKER64 \
+  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+
 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
 #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)
index adb4333965a554716e3b2b3530e8c2385e41cac9..20fa3eb07c52ea374c8a65bbf767c420bd025504 100644 (file)
@@ -762,17 +762,27 @@ 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 "%{msoft-float:-sf}.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} \
@@ -949,3 +959,73 @@ 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_LOCAL                                \
+    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
index 66ee7cadfe414217652195dc3764e2c91041c2a5..f00e8b0b8320571f400c18751603c04876170023 100644 (file)
@@ -31,3 +31,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")