new-gcc.patch 6.2 KB

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