new-gcc.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. diff -Nur linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72.orig/include/linux/compiler-gcc.h linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72/include/linux/compiler-gcc.h
  2. --- linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72.orig/include/linux/compiler-gcc.h 2017-09-27 03:56:44.000000000 +0200
  3. +++ linux-e7c8afc1dda7b7c18596d90ad6a17ae886650b72/include/linux/compiler-gcc.h 2017-09-27 04:18:30.590990967 +0200
  4. @@ -6,6 +6,10 @@
  5. * Common definitions for all gcc versions go here.
  6. */
  7. +#define GCC_VERSION (__GNUC__ * 10000 \
  8. + + __GNUC_MINOR__ * 100 \
  9. + + __GNUC_PATCHLEVEL__)
  10. +
  11. /* Optimization barrier */
  12. /* The "volatile" is due to gcc bugs */
  13. @@ -81,7 +85,164 @@
  14. #define __maybe_unused __attribute__((unused))
  15. #define __always_unused __attribute__((unused))
  16. -#define __gcc_header(x) #x
  17. -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
  18. -#define gcc_header(x) _gcc_header(x)
  19. -#include gcc_header(__GNUC__)
  20. +/* gcc version specific checks */
  21. +
  22. +#if GCC_VERSION < 30200
  23. +# error Sorry, your compiler is too old - please upgrade it.
  24. +#endif
  25. +
  26. +#if GCC_VERSION < 30300
  27. +# define __used __attribute__((__unused__))
  28. +#else
  29. +# define __used __attribute__((__used__))
  30. +#endif
  31. +
  32. +#ifdef CONFIG_GCOV_KERNEL
  33. +# if GCC_VERSION < 30400
  34. +# error "GCOV profiling support for gcc versions below 3.4 not included"
  35. +# endif /* __GNUC_MINOR__ */
  36. +#endif /* CONFIG_GCOV_KERNEL */
  37. +
  38. +#if GCC_VERSION >= 30400
  39. +#define __must_check __attribute__((warn_unused_result))
  40. +#endif
  41. +
  42. +#if GCC_VERSION >= 40000
  43. +
  44. +/* GCC 4.1.[01] miscompiles __weak */
  45. +#ifdef __KERNEL__
  46. +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
  47. +# error Your version of gcc miscompiles the __weak directive
  48. +# endif
  49. +#endif
  50. +
  51. +#define __used __attribute__((__used__))
  52. +#define __compiler_offsetof(a, b) \
  53. + __builtin_offsetof(a, b)
  54. +
  55. +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
  56. +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  57. +#endif
  58. +
  59. +#if GCC_VERSION >= 40300
  60. +/* Mark functions as cold. gcc will assume any path leading to a call
  61. + * to them will be unlikely. This means a lot of manual unlikely()s
  62. + * are unnecessary now for any paths leading to the usual suspects
  63. + * like BUG(), printk(), panic() etc. [but let's keep them for now for
  64. + * older compilers]
  65. + *
  66. + * Early snapshots of gcc 4.3 don't support this and we can't detect this
  67. + * in the preprocessor, but we can live with this because they're unreleased.
  68. + * Maketime probing would be overkill here.
  69. + *
  70. + * gcc also has a __attribute__((__hot__)) to move hot functions into
  71. + * a special section, but I don't see any sense in this right now in
  72. + * the kernel context
  73. + */
  74. +#define __cold __attribute__((__cold__))
  75. +
  76. +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  77. +
  78. +#ifndef __CHECKER__
  79. +# define __compiletime_warning(message) __attribute__((warning(message)))
  80. +# define __compiletime_error(message) __attribute__((error(message)))
  81. +#endif /* __CHECKER__ */
  82. +#endif /* GCC_VERSION >= 40300 */
  83. +
  84. +#if GCC_VERSION >= 40500
  85. +/*
  86. + * Mark a position in code as unreachable. This can be used to
  87. + * suppress control flow warnings after asm blocks that transfer
  88. + * control elsewhere.
  89. + *
  90. + * Early snapshots of gcc 4.5 don't support this and we can't detect
  91. + * this in the preprocessor, but we can live with this because they're
  92. + * unreleased. Really, we need to have autoconf for the kernel.
  93. + */
  94. +#define unreachable() __builtin_unreachable()
  95. +
  96. +/* Mark a function definition as prohibited from being cloned. */
  97. +#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
  98. +
  99. +#endif /* GCC_VERSION >= 40500 */
  100. +
  101. +#if GCC_VERSION >= 40600
  102. +/*
  103. + * When used with Link Time Optimization, gcc can optimize away C functions or
  104. + * variables which are referenced only from assembly code. __visible tells the
  105. + * optimizer that something else uses this function or variable, thus preventing
  106. + * this.
  107. + */
  108. +#define __visible __attribute__((externally_visible))
  109. +#endif
  110. +
  111. +
  112. +#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
  113. +/*
  114. + * __assume_aligned(n, k): Tell the optimizer that the returned
  115. + * pointer can be assumed to be k modulo n. The second argument is
  116. + * optional (default 0), so we use a variadic macro to make the
  117. + * shorthand.
  118. + *
  119. + * Beware: Do not apply this to functions which may return
  120. + * ERR_PTRs. Also, it is probably unwise to apply it to functions
  121. + * returning extra information in the low bits (but in that case the
  122. + * compiler should see some alignment anyway, when the return value is
  123. + * massaged by 'flags = ptr & 3; ptr &= ~3;').
  124. + */
  125. +#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
  126. +#endif
  127. +
  128. +/*
  129. + * GCC 'asm goto' miscompiles certain code sequences:
  130. + *
  131. + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  132. + *
  133. + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  134. + *
  135. + * (asm goto is automatically volatile - the naming reflects this.)
  136. + */
  137. +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  138. +
  139. +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  140. +#if GCC_VERSION >= 40400
  141. +#define __HAVE_BUILTIN_BSWAP32__
  142. +#define __HAVE_BUILTIN_BSWAP64__
  143. +#endif
  144. +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
  145. +#define __HAVE_BUILTIN_BSWAP16__
  146. +#endif
  147. +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
  148. +
  149. +#if GCC_VERSION >= 70000
  150. +#define KASAN_ABI_VERSION 5
  151. +#elif GCC_VERSION >= 50000
  152. +#define KASAN_ABI_VERSION 4
  153. +#elif GCC_VERSION >= 40902
  154. +#define KASAN_ABI_VERSION 3
  155. +#endif
  156. +
  157. +#if GCC_VERSION >= 40902
  158. +/*
  159. + * Tell the compiler that address safety instrumentation (KASAN)
  160. + * should not be applied to that function.
  161. + * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
  162. + */
  163. +#define __no_sanitize_address __attribute__((no_sanitize_address))
  164. +#endif
  165. +
  166. +#endif /* gcc version >= 40000 specific checks */
  167. +
  168. +#if !defined(__noclone)
  169. +#define __noclone /* not needed */
  170. +#endif
  171. +
  172. +#if !defined(__no_sanitize_address)
  173. +#define __no_sanitize_address
  174. +#endif
  175. +
  176. +/*
  177. + * A trick to suppress uninitialized variable warning without generating any
  178. + * code
  179. + */
  180. +#define uninitialized_var(x) x = x