mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-26 07:51:06 +00:00
759e191c25
The following are experimental patches for gcc that add support for musl-libc. I haven't been able to test every combination, but please test and let me know on the mailing-list or on irc your results! Signed-off-by: Bryan Hundven <bryanhundven@gmail.com> [yann.morin.1998@free.fr: ditch the gcc-4.7 patches] Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
282 lines
11 KiB
Diff
282 lines
11 KiB
Diff
Index: gcc-4.9.1/gcc/config.gcc
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config.gcc
|
|
+++ gcc-4.9.1/gcc/config.gcc
|
|
@@ -2322,6 +2322,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
|
|
Index: gcc-4.9.1/gcc/config/aarch64/aarch64-linux.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/aarch64/aarch64-linux.h
|
|
+++ gcc-4.9.1/gcc/config/aarch64/aarch64-linux.h
|
|
@@ -23,6 +23,8 @@
|
|
|
|
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}.so.1"
|
|
|
|
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
|
|
+
|
|
#define CPP_SPEC "%{pthread:-D_REENTRANT}"
|
|
|
|
#define LINUX_TARGET_LINK_SPEC "%{h*} \
|
|
Index: gcc-4.9.1/gcc/config/arm/linux-eabi.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/arm/linux-eabi.h
|
|
+++ gcc-4.9.1/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
|
|
Index: gcc-4.9.1/gcc/config/i386/linux.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/i386/linux.h
|
|
+++ gcc-4.9.1/gcc/config/i386/linux.h
|
|
@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
|
|
|
|
#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"
|
|
Index: gcc-4.9.1/gcc/config/i386/linux64.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/i386/linux64.h
|
|
+++ gcc-4.9.1/gcc/config/i386/linux64.h
|
|
@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI
|
|
#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"
|
|
Index: gcc-4.9.1/gcc/config/microblaze/linux.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/microblaze/linux.h
|
|
+++ gcc-4.9.1/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 "%{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 }
|
|
Index: gcc-4.9.1/gcc/config/mips/linux.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/mips/linux.h
|
|
+++ gcc-4.9.1/gcc/config/mips/linux.h
|
|
@@ -23,3 +23,10 @@ along with GCC; see the file COPYING3.
|
|
#undef UCLIBC_DYNAMIC_LINKER
|
|
#define UCLIBC_DYNAMIC_LINKER \
|
|
"%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/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"
|
|
Index: gcc-4.9.1/gcc/config/rs6000/linux64.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/rs6000/linux64.h
|
|
+++ gcc-4.9.1/gcc/config/rs6000/linux64.h
|
|
@@ -375,17 +375,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)
|
|
Index: gcc-4.9.1/gcc/config/rs6000/secureplt.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/rs6000/secureplt.h
|
|
+++ gcc-4.9.1/gcc/config/rs6000/secureplt.h
|
|
@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
|
|
+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
|
|
Index: gcc-4.9.1/gcc/config/rs6000/sysv4.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/rs6000/sysv4.h
|
|
+++ gcc-4.9.1/gcc/config/rs6000/sysv4.h
|
|
@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
|
|
#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. */
|
|
#define CC1_SPEC "%{G*} %(cc1_cpu)" \
|
|
@@ -585,7 +588,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
|
|
|
|
/* 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 "\
|
|
@@ -763,15 +767,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
|
|
|
|
#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} \
|
|
@@ -894,6 +901,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 }, \
|
|
Index: gcc-4.9.1/gcc/config/sh/linux.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/gcc/config/sh/linux.h
|
|
+++ gcc-4.9.1/gcc/config/sh/linux.h
|
|
@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3.
|
|
|
|
#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"
|
|
Index: gcc-4.9.1/libitm/config/arm/hwcap.cc
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/libitm/config/arm/hwcap.cc
|
|
+++ gcc-4.9.1/libitm/config/arm/hwcap.cc
|
|
@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
|
|
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
+#ifdef __GLIBC__
|
|
#include <sys/fcntl.h>
|
|
+#else
|
|
+#include <fcntl.h>
|
|
+#endif
|
|
#include <elf.h>
|
|
|
|
static void __attribute__((constructor))
|
|
Index: gcc-4.9.1/libitm/config/linux/x86/tls.h
|
|
===================================================================
|
|
--- gcc-4.9.1.orig/libitm/config/linux/x86/tls.h
|
|
+++ gcc-4.9.1/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 a
|
|
|
|
} // namespace GTM
|
|
#endif /* >= GLIBC 2.10 */
|
|
+#endif
|
|
|
|
#endif // LIBITM_X86_TLS_H
|