lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

200-musl_config.patch (11542B)


      1 From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
      2 Date: Fri, 8 May 2015 08:25:47 +0000 (+0000)
      3 Subject: [PATCH 2/13] musl libc config
      4 X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29c16f8ef226fbf98af373a4b2ceb
      5 
      6 [PATCH 2/13] musl libc config
      7 
      8 2015-05-08  Gregor Richards  <gregor.richards@uwaterloo.ca>
      9 	    Szabolcs Nagy  <szabolcs.nagy@arm.com>
     10 
     11 	* config.gcc (LIBC_MUSL): New tm_defines macro.
     12 	* config/linux.h (OPTION_MUSL): Define.
     13 	(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
     14 	(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
     15 	(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
     16 	(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
     17 	(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
     18 	* config/linux.opt (mmusl): New option.
     19 	* doc/invoke.texi (GNU/Linux Options): Document -mmusl.
     20 	* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
     21 	(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
     22 	* configure: Regenerate.
     23 
     24 
     25 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4
     26 ---
     27 
     28 --- a/gcc/config.gcc
     29 +++ b/gcc/config.gcc
     30 @@ -575,7 +575,7 @@ case ${target} in
     31  esac
     32  
     33  # Common C libraries.
     34 -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
     35 +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
     36  
     37  # 32-bit x86 processors supported by --with-arch=.  Each processor
     38  # MUST be separated by exactly one space.
     39 @@ -720,6 +720,9 @@ case ${target} in
     40      *-*-*uclibc*)
     41        tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
     42        ;;
     43 +    *-*-*musl*)
     44 +      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
     45 +      ;;
     46      *)
     47        tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
     48        ;;
     49 --- a/gcc/config/linux.h
     50 +++ b/gcc/config/linux.h
     51 @@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
     52  #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
     53  #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
     54  #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
     55 +#define OPTION_MUSL   (DEFAULT_LIBC == LIBC_MUSL)
     56  #else
     57  #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
     58  #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
     59  #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
     60 +#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
     61  #endif
     62  
     63  #define GNU_USER_TARGET_OS_CPP_BUILTINS()			\
     64 @@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTI
     65      } while (0)
     66  
     67  /* Determine which dynamic linker to use depending on whether GLIBC or
     68 -   uClibc or Bionic is the default C library and whether
     69 -   -muclibc or -mglibc or -mbionic has been passed to change the default.  */
     70 +   uClibc or Bionic or musl is the default C library and whether
     71 +   -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
     72 +   the default.  */
     73  
     74 -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3)	\
     75 -  "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
     76 +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4)	\
     77 +  "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
     78  
     79  #if DEFAULT_LIBC == LIBC_GLIBC
     80 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
     81 -  CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
     82 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
     83 +  CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
     84  #elif DEFAULT_LIBC == LIBC_UCLIBC
     85 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
     86 -  CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
     87 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
     88 +  CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
     89  #elif DEFAULT_LIBC == LIBC_BIONIC
     90 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
     91 -  CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
     92 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
     93 +  CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
     94 +#elif DEFAULT_LIBC == LIBC_MUSL
     95 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
     96 +  CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
     97  #else
     98  #error "Unsupported DEFAULT_LIBC"
     99  #endif /* DEFAULT_LIBC */
    100 @@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTI
    101  #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
    102  #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
    103  #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
    104 +/* Should be redefined for each target that supports musl.  */
    105 +#define MUSL_DYNAMIC_LINKER "/dev/null"
    106 +#define MUSL_DYNAMIC_LINKER32 "/dev/null"
    107 +#define MUSL_DYNAMIC_LINKER64 "/dev/null"
    108 +#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
    109  
    110  #define GNU_USER_DYNAMIC_LINKER						\
    111    CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER,	\
    112 -			 BIONIC_DYNAMIC_LINKER)
    113 +			 BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
    114  #define GNU_USER_DYNAMIC_LINKER32					\
    115    CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
    116 -			 BIONIC_DYNAMIC_LINKER32)
    117 +			 BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
    118  #define GNU_USER_DYNAMIC_LINKER64					\
    119    CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
    120 -			 BIONIC_DYNAMIC_LINKER64)
    121 +			 BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
    122  #define GNU_USER_DYNAMIC_LINKERX32					\
    123    CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
    124 -			 BIONIC_DYNAMIC_LINKERX32)
    125 +			 BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
    126  
    127  /* Whether we have Bionic libc runtime */
    128  #undef TARGET_HAS_BIONIC
    129  #define TARGET_HAS_BIONIC (OPTION_BIONIC)
    130  
    131 +/* musl avoids problematic includes by rearranging the include directories.
    132 + * Unfortunately, this is mostly duplicated from cppdefault.c */
    133 +#if DEFAULT_LIBC == LIBC_MUSL
    134 +#define INCLUDE_DEFAULTS_MUSL_GPP			\
    135 +    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
    136 +      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },		\
    137 +    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,		\
    138 +      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },		\
    139 +    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,	\
    140 +      GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
    141 +
    142 +#ifdef LOCAL_INCLUDE_DIR
    143 +#define INCLUDE_DEFAULTS_MUSL_LOCAL			\
    144 +    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },		\
    145 +    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
    146 +#else
    147 +#define INCLUDE_DEFAULTS_MUSL_LOCAL
    148 +#endif
    149 +
    150 +#ifdef PREFIX_INCLUDE_DIR
    151 +#define INCLUDE_DEFAULTS_MUSL_PREFIX			\
    152 +    { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
    153 +#else
    154 +#define INCLUDE_DEFAULTS_MUSL_PREFIX
    155 +#endif
    156 +
    157 +#ifdef CROSS_INCLUDE_DIR
    158 +#define INCLUDE_DEFAULTS_MUSL_CROSS			\
    159 +    { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
    160 +#else
    161 +#define INCLUDE_DEFAULTS_MUSL_CROSS
    162 +#endif
    163 +
    164 +#ifdef TOOL_INCLUDE_DIR
    165 +#define INCLUDE_DEFAULTS_MUSL_TOOL			\
    166 +    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
    167 +#else
    168 +#define INCLUDE_DEFAULTS_MUSL_TOOL
    169 +#endif
    170 +
    171 +#ifdef NATIVE_SYSTEM_HEADER_DIR
    172 +#define INCLUDE_DEFAULTS_MUSL_NATIVE			\
    173 +    { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 },	\
    174 +    { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
    175 +#else
    176 +#define INCLUDE_DEFAULTS_MUSL_NATIVE
    177 +#endif
    178 +
    179 +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
    180 +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
    181 +# define INCLUDE_DEFAULTS_MUSL_LOCAL
    182 +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
    183 +# define INCLUDE_DEFAULTS_MUSL_NATIVE
    184 +#else
    185 +# undef INCLUDE_DEFAULTS_MUSL_CROSS
    186 +# define INCLUDE_DEFAULTS_MUSL_CROSS
    187 +#endif
    188 +
    189 +#undef INCLUDE_DEFAULTS
    190 +#define INCLUDE_DEFAULTS				\
    191 +  {							\
    192 +    INCLUDE_DEFAULTS_MUSL_GPP				\
    193 +    INCLUDE_DEFAULTS_MUSL_PREFIX			\
    194 +    INCLUDE_DEFAULTS_MUSL_CROSS				\
    195 +    INCLUDE_DEFAULTS_MUSL_TOOL				\
    196 +    INCLUDE_DEFAULTS_MUSL_NATIVE			\
    197 +    { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 },		\
    198 +    { 0, 0, 0, 0, 0, 0 }				\
    199 +  }
    200 +#endif
    201 +
    202  #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
    203  /* This is a *uclinux* target.  We don't define below macros to normal linux
    204     versions, because doing so would require *uclinux* targets to include
    205 --- a/gcc/config/linux.opt
    206 +++ b/gcc/config/linux.opt
    207 @@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_l
    208  Use GNU C library
    209  
    210  muclibc
    211 -Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
    212 +Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
    213  Use uClibc C library
    214 +
    215 +mmusl
    216 +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
    217 +Use musl C library
    218 --- a/gcc/configure
    219 +++ b/gcc/configure
    220 @@ -27833,6 +27833,9 @@ if test "${gcc_cv_libc_provides_ssp+set}
    221  else
    222    gcc_cv_libc_provides_ssp=no
    223      case "$target" in
    224 +       *-*-musl*)
    225 +	 # All versions of musl provide stack protector
    226 +	 gcc_cv_libc_provides_ssp=yes;;
    227         *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
    228        # glibc 2.4 and later provides __stack_chk_fail and
    229        # either __stack_chk_guard, or TLS access to stack guard canary.
    230 @@ -27865,6 +27868,7 @@ fi
    231  	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
    232  	 # simply assert that glibc does provide this, which is true for all
    233  	 # realistically usable GNU/Hurd configurations.
    234 +	 # All supported versions of musl provide it as well
    235  	 gcc_cv_libc_provides_ssp=yes;;
    236         *-*-darwin* | *-*-freebsd*)
    237  	 ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
    238 @@ -27961,6 +27965,9 @@ case "$target" in
    239        gcc_cv_target_dl_iterate_phdr=no
    240      fi
    241      ;;
    242 +  *-linux-musl*)
    243 +    gcc_cv_target_dl_iterate_phdr=yes
    244 +    ;;
    245  esac
    246  
    247  if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
    248 --- a/gcc/configure.ac
    249 +++ b/gcc/configure.ac
    250 @@ -5287,6 +5287,9 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
    251        gcc_cv_libc_provides_ssp,
    252        [gcc_cv_libc_provides_ssp=no
    253      case "$target" in
    254 +       *-*-musl*)
    255 +	 # All versions of musl provide stack protector
    256 +	 gcc_cv_libc_provides_ssp=yes;;
    257         *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
    258        # glibc 2.4 and later provides __stack_chk_fail and
    259        # either __stack_chk_guard, or TLS access to stack guard canary.
    260 @@ -5313,6 +5316,7 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
    261  	 # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
    262  	 # simply assert that glibc does provide this, which is true for all
    263  	 # realistically usable GNU/Hurd configurations.
    264 +	 # All supported versions of musl provide it as well
    265  	 gcc_cv_libc_provides_ssp=yes;;
    266         *-*-darwin* | *-*-freebsd*)
    267  	 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
    268 @@ -5386,6 +5390,9 @@ case "$target" in
    269        gcc_cv_target_dl_iterate_phdr=no
    270      fi
    271      ;;
    272 +  *-linux-musl*)
    273 +    gcc_cv_target_dl_iterate_phdr=yes
    274 +    ;;
    275  esac
    276  GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
    277  if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
    278 --- a/gcc/doc/invoke.texi
    279 +++ b/gcc/doc/invoke.texi
    280 @@ -667,7 +667,7 @@ Objective-C and Objective-C++ Dialects}.
    281  -mcpu=@var{cpu}}
    282  
    283  @emph{GNU/Linux Options}
    284 -@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
    285 +@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
    286  -tno-android-cc -tno-android-ld}
    287  
    288  @emph{H8/300 Options}
    289 @@ -15340,13 +15340,19 @@ These @samp{-m} options are defined for
    290  @item -mglibc
    291  @opindex mglibc
    292  Use the GNU C library.  This is the default except
    293 -on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
    294 +on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
    295 +@samp{*-*-linux-*android*} targets.
    296  
    297  @item -muclibc
    298  @opindex muclibc
    299  Use uClibc C library.  This is the default on
    300  @samp{*-*-linux-*uclibc*} targets.
    301  
    302 +@item -mmusl
    303 +@opindex mmusl
    304 +Use the musl C library.  This is the default on
    305 +@samp{*-*-linux-*musl*} targets.
    306 +
    307  @item -mbionic
    308  @opindex mbionic
    309  Use Bionic C library.  This is the default on