diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch')
| -rw-r--r-- | meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch | 267 |
1 files changed, 267 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch b/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch new file mode 100644 index 0000000000..4d1ab872ae --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch | |||
| @@ -0,0 +1,267 @@ | |||
| 1 | # HG changeset patch | ||
| 2 | # Parent e5b4564f249f8634194bdabef4b3057d0e54ee97 | ||
| 3 | Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker. | ||
| 4 | |||
| 5 | Upstream-Status: Backport [partial] | ||
| 6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 7 | |||
| 8 | Index: gcc-4.9.0/gcc/config.gcc | ||
| 9 | =================================================================== | ||
| 10 | --- gcc-4.9.0.orig/gcc/config.gcc 2014-04-22 22:44:17.153567150 -0700 | ||
| 11 | +++ gcc-4.9.0/gcc/config.gcc 2014-04-23 23:54:31.427357051 -0700 | ||
| 12 | @@ -594,7 +594,7 @@ | ||
| 13 | esac | ||
| 14 | |||
| 15 | # Common C libraries. | ||
| 16 | -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3" | ||
| 17 | +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" | ||
| 18 | |||
| 19 | # 32-bit x86 processors supported by --with-arch=. Each processor | ||
| 20 | # MUST be separated by exactly one space. | ||
| 21 | @@ -719,6 +719,9 @@ | ||
| 22 | *-*-*uclibc*) | ||
| 23 | tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" | ||
| 24 | ;; | ||
| 25 | + *-*-*musl*) | ||
| 26 | + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" | ||
| 27 | + ;; | ||
| 28 | *) | ||
| 29 | tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" | ||
| 30 | ;; | ||
| 31 | @@ -2328,6 +2331,11 @@ | ||
| 32 | powerpc*-*-linux*paired*) | ||
| 33 | tm_file="${tm_file} rs6000/750cl.h" ;; | ||
| 34 | esac | ||
| 35 | + case ${target} in | ||
| 36 | + *-linux*-musl*) | ||
| 37 | + enable_secureplt=yes ;; | ||
| 38 | + esac | ||
| 39 | + | ||
| 40 | if test x${enable_secureplt} = xyes; then | ||
| 41 | tm_file="rs6000/secureplt.h ${tm_file}" | ||
| 42 | fi | ||
| 43 | Index: gcc-4.9.0/gcc/config/linux.h | ||
| 44 | =================================================================== | ||
| 45 | --- gcc-4.9.0.orig/gcc/config/linux.h 2014-01-02 14:23:26.000000000 -0800 | ||
| 46 | +++ gcc-4.9.0/gcc/config/linux.h 2014-04-24 00:11:29.034028895 -0700 | ||
| 47 | @@ -32,10 +32,12 @@ | ||
| 48 | #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) | ||
| 49 | #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) | ||
| 50 | #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) | ||
| 51 | +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) | ||
| 52 | #else | ||
| 53 | #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) | ||
| 54 | #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) | ||
| 55 | #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) | ||
| 56 | +#define OPTION_MUSL (linux_libc == LIBC_MUSL) | ||
| 57 | #endif | ||
| 58 | |||
| 59 | #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ | ||
| 60 | @@ -53,18 +55,21 @@ | ||
| 61 | uClibc or Bionic is the default C library and whether | ||
| 62 | -muclibc or -mglibc or -mbionic has been passed to change the default. */ | ||
| 63 | |||
| 64 | -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ | ||
| 65 | - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" | ||
| 66 | +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ | ||
| 67 | + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" | ||
| 68 | |||
| 69 | #if DEFAULT_LIBC == LIBC_GLIBC | ||
| 70 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
| 71 | - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B) | ||
| 72 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
| 73 | + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) | ||
| 74 | #elif DEFAULT_LIBC == LIBC_UCLIBC | ||
| 75 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
| 76 | - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B) | ||
| 77 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
| 78 | + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) | ||
| 79 | #elif DEFAULT_LIBC == LIBC_BIONIC | ||
| 80 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
| 81 | - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U) | ||
| 82 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
| 83 | + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) | ||
| 84 | +#elif DEFAULT_LIBC == LIBC_MUSL | ||
| 85 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
| 86 | + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) | ||
| 87 | #else | ||
| 88 | #error "Unsupported DEFAULT_LIBC" | ||
| 89 | #endif /* DEFAULT_LIBC */ | ||
| 90 | @@ -84,16 +89,16 @@ | ||
| 91 | |||
| 92 | #define GNU_USER_DYNAMIC_LINKER \ | ||
| 93 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ | ||
| 94 | - BIONIC_DYNAMIC_LINKER) | ||
| 95 | + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) | ||
| 96 | #define GNU_USER_DYNAMIC_LINKER32 \ | ||
| 97 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ | ||
| 98 | - BIONIC_DYNAMIC_LINKER32) | ||
| 99 | + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) | ||
| 100 | #define GNU_USER_DYNAMIC_LINKER64 \ | ||
| 101 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ | ||
| 102 | - BIONIC_DYNAMIC_LINKER64) | ||
| 103 | + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) | ||
| 104 | #define GNU_USER_DYNAMIC_LINKERX32 \ | ||
| 105 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ | ||
| 106 | - BIONIC_DYNAMIC_LINKERX32) | ||
| 107 | + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) | ||
| 108 | |||
| 109 | /* Whether we have Bionic libc runtime */ | ||
| 110 | #undef TARGET_HAS_BIONIC | ||
| 111 | @@ -127,3 +132,74 @@ | ||
| 112 | # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function | ||
| 113 | |||
| 114 | #endif | ||
| 115 | + | ||
| 116 | +/* musl avoids problematic includes by rearranging the include directories. | ||
| 117 | + * Unfortunately, this is mostly duplicated from cppdefault.c */ | ||
| 118 | +#if DEFAULT_LIBC == LIBC_MUSL | ||
| 119 | +#define INCLUDE_DEFAULTS_MUSL_GPP \ | ||
| 120 | + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ | ||
| 121 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ | ||
| 122 | + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ | ||
| 123 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ | ||
| 124 | + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ | ||
| 125 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, | ||
| 126 | + | ||
| 127 | +#ifdef LOCAL_INCLUDE_DIR | ||
| 128 | +#define INCLUDE_DEFAULTS_MUSL_LOCAL \ | ||
| 129 | + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ | ||
| 130 | + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, | ||
| 131 | +#else | ||
| 132 | +#define INCLUDE_DEFAULTS_MUSL_LOCAL | ||
| 133 | +#endif | ||
| 134 | + | ||
| 135 | +#ifdef PREFIX_INCLUDE_DIR | ||
| 136 | +#define INCLUDE_DEFAULTS_MUSL_PREFIX \ | ||
| 137 | + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, | ||
| 138 | +#else | ||
| 139 | +#define INCLUDE_DEFAULTS_MUSL_PREFIX | ||
| 140 | +#endif | ||
| 141 | + | ||
| 142 | +#ifdef CROSS_INCLUDE_DIR | ||
| 143 | +#define INCLUDE_DEFAULTS_MUSL_CROSS \ | ||
| 144 | + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, | ||
| 145 | +#else | ||
| 146 | +#define INCLUDE_DEFAULTS_MUSL_CROSS | ||
| 147 | +#endif | ||
| 148 | + | ||
| 149 | +#ifdef TOOL_INCLUDE_DIR | ||
| 150 | +#define INCLUDE_DEFAULTS_MUSL_TOOL \ | ||
| 151 | + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, | ||
| 152 | +#else | ||
| 153 | +#define INCLUDE_DEFAULTS_MUSL_TOOL | ||
| 154 | +#endif | ||
| 155 | + | ||
| 156 | +#ifdef NATIVE_SYSTEM_HEADER_DIR | ||
| 157 | +#define INCLUDE_DEFAULTS_MUSL_NATIVE \ | ||
| 158 | + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ | ||
| 159 | + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, | ||
| 160 | +#else | ||
| 161 | +#define INCLUDE_DEFAULTS_MUSL_NATIVE | ||
| 162 | +#endif | ||
| 163 | + | ||
| 164 | +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) | ||
| 165 | +# undef INCLUDE_DEFAULTS_MUSL_LOCAL | ||
| 166 | +# define INCLUDE_DEFAULTS_MUSL_LOCAL | ||
| 167 | +# undef INCLUDE_DEFAULTS_MUSL_NATIVE | ||
| 168 | +# define INCLUDE_DEFAULTS_MUSL_NATIVE | ||
| 169 | +#else | ||
| 170 | +# undef INCLUDE_DEFAULTS_MUSL_CROSS | ||
| 171 | +# define INCLUDE_DEFAULTS_MUSL_CROSS | ||
| 172 | +#endif | ||
| 173 | + | ||
| 174 | +#undef INCLUDE_DEFAULTS | ||
| 175 | +#define INCLUDE_DEFAULTS \ | ||
| 176 | + { \ | ||
| 177 | + INCLUDE_DEFAULTS_MUSL_GPP \ | ||
| 178 | + INCLUDE_DEFAULTS_MUSL_PREFIX \ | ||
| 179 | + INCLUDE_DEFAULTS_MUSL_CROSS \ | ||
| 180 | + INCLUDE_DEFAULTS_MUSL_TOOL \ | ||
| 181 | + INCLUDE_DEFAULTS_MUSL_NATIVE \ | ||
| 182 | + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | ||
| 183 | + { 0, 0, 0, 0, 0, 0 } \ | ||
| 184 | + } | ||
| 185 | +#endif | ||
| 186 | Index: gcc-4.9.0/gcc/config/linux.opt | ||
| 187 | =================================================================== | ||
| 188 | --- gcc-4.9.0.orig/gcc/config/linux.opt 2014-01-02 14:23:26.000000000 -0800 | ||
| 189 | +++ gcc-4.9.0/gcc/config/linux.opt 2014-04-22 22:44:17.280233817 -0700 | ||
| 190 | @@ -30,3 +30,7 @@ | ||
| 191 | muclibc | ||
| 192 | Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) | ||
| 193 | Use uClibc C library | ||
| 194 | + | ||
| 195 | +mmusl | ||
| 196 | +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) | ||
| 197 | +Use musl C library | ||
| 198 | Index: gcc-4.9.0/gcc/ginclude/stddef.h | ||
| 199 | =================================================================== | ||
| 200 | --- gcc-4.9.0.orig/gcc/ginclude/stddef.h 2014-01-02 14:23:26.000000000 -0800 | ||
| 201 | +++ gcc-4.9.0/gcc/ginclude/stddef.h 2014-04-22 22:44:17.280233817 -0700 | ||
| 202 | @@ -181,6 +181,7 @@ | ||
| 203 | #ifndef _GCC_SIZE_T | ||
| 204 | #ifndef _SIZET_ | ||
| 205 | #ifndef __size_t | ||
| 206 | +#ifndef __DEFINED_size_t /* musl */ | ||
| 207 | #define __size_t__ /* BeOS */ | ||
| 208 | #define __SIZE_T__ /* Cray Unicos/Mk */ | ||
| 209 | #define _SIZE_T | ||
| 210 | @@ -197,6 +198,7 @@ | ||
| 211 | #define ___int_size_t_h | ||
| 212 | #define _GCC_SIZE_T | ||
| 213 | #define _SIZET_ | ||
| 214 | +#define __DEFINED_size_t /* musl */ | ||
| 215 | #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ | ||
| 216 | || defined(__FreeBSD_kernel__) | ||
| 217 | /* __size_t is a typedef on FreeBSD 5, must not trash it. */ | ||
| 218 | @@ -214,6 +216,7 @@ | ||
| 219 | typedef long ssize_t; | ||
| 220 | #endif /* __BEOS__ */ | ||
| 221 | #endif /* !(defined (__GNUG__) && defined (size_t)) */ | ||
| 222 | +#endif /* __DEFINED_size_t */ | ||
| 223 | #endif /* __size_t */ | ||
| 224 | #endif /* _SIZET_ */ | ||
| 225 | #endif /* _GCC_SIZE_T */ | ||
| 226 | Index: gcc-4.9.0/gcc/config/rs6000/secureplt.h | ||
| 227 | =================================================================== | ||
| 228 | --- gcc-4.9.0.orig/gcc/config/rs6000/secureplt.h 2014-01-02 14:23:26.000000000 -0800 | ||
| 229 | +++ gcc-4.9.0/gcc/config/rs6000/secureplt.h 2014-04-23 23:55:15.114024175 -0700 | ||
| 230 | @@ -18,3 +18,4 @@ | ||
| 231 | <http://www.gnu.org/licenses/>. */ | ||
| 232 | |||
| 233 | #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" | ||
| 234 | +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" | ||
| 235 | Index: gcc-4.9.0/gcc/config/rs6000/sysv4.h | ||
| 236 | =================================================================== | ||
| 237 | --- gcc-4.9.0.orig/gcc/config/rs6000/sysv4.h 2014-04-23 23:52:13.854023015 -0700 | ||
| 238 | +++ gcc-4.9.0/gcc/config/rs6000/sysv4.h 2014-04-24 00:10:55.550695334 -0700 | ||
| 239 | @@ -538,6 +538,10 @@ | ||
| 240 | #define CC1_SECURE_PLT_DEFAULT_SPEC "" | ||
| 241 | #endif | ||
| 242 | |||
| 243 | +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC | ||
| 244 | +#define LINK_SECURE_PLT_DEFAULT_SPEC "" | ||
| 245 | +#endif | ||
| 246 | + | ||
| 247 | /* Pass -G xxx to the compiler. */ | ||
| 248 | #define CC1_SPEC "%{G*} %(cc1_cpu)" \ | ||
| 249 | "%{meabi: %{!mcall-*: -mcall-sysv }} \ | ||
| 250 | @@ -585,7 +589,8 @@ | ||
| 251 | |||
| 252 | /* Override the default target of the linker. */ | ||
| 253 | #define LINK_TARGET_SPEC \ | ||
| 254 | - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") | ||
| 255 | + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \ | ||
| 256 | + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" | ||
| 257 | |||
| 258 | /* Any specific OS flags. */ | ||
| 259 | #define LINK_OS_SPEC "\ | ||
| 260 | @@ -894,6 +899,7 @@ | ||
| 261 | { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ | ||
| 262 | { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ | ||
| 263 | { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ | ||
| 264 | + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ | ||
| 265 | { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ | ||
| 266 | { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ | ||
| 267 | { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ | ||
