0005-compiler-gcc-integrate-the-various-compiler-gcc-345-.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. From 21be6b635320321216dde9201fa57a3aed60ee12 Mon Sep 17 00:00:00 2001
  2. From: Joe Perches <joe@perches.com>
  3. Date: Thu, 25 Jun 2015 15:01:02 -0700
  4. Subject: [PATCH] compiler-gcc: integrate the various compiler-gcc[345].h files
  5. As gcc major version numbers are going to advance rather rapidly in the
  6. future, there's no real value in separate files for each compiler
  7. version.
  8. Deduplicate some of the macros #defined in each file too.
  9. Neaten comments using normal kernel commenting style.
  10. Signed-off-by: Joe Perches <joe@perches.com>
  11. Cc: Andi Kleen <andi@firstfloor.org>
  12. Cc: Michal Marek <mmarek@suse.cz>
  13. Cc: Segher Boessenkool <segher@kernel.crashing.org>
  14. Cc: Sasha Levin <levinsasha928@gmail.com>
  15. Cc: Anton Blanchard <anton@samba.org>
  16. Cc: Alan Modra <amodra@gmail.com>
  17. Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  18. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  19. (cherry picked from commit cb984d101b30eb7478d32df56a0023e4603cba7f)
  20. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  21. ---
  22. include/linux/compiler-gcc.h | 120 ++++++++++++++++++++++++++++++++++++++++--
  23. include/linux/compiler-gcc3.h | 23 --------
  24. include/linux/compiler-gcc4.h | 88 -------------------------------
  25. include/linux/compiler-gcc5.h | 66 -----------------------
  26. 4 files changed, 116 insertions(+), 181 deletions(-)
  27. delete mode 100644 include/linux/compiler-gcc3.h
  28. delete mode 100644 include/linux/compiler-gcc4.h
  29. delete mode 100644 include/linux/compiler-gcc5.h
  30. diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
  31. index 24545cd90a25..0c5d746850c2 100644
  32. --- a/include/linux/compiler-gcc.h
  33. +++ b/include/linux/compiler-gcc.h
  34. @@ -97,10 +97,122 @@
  35. #define __maybe_unused __attribute__((unused))
  36. #define __always_unused __attribute__((unused))
  37. -#define __gcc_header(x) #x
  38. -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
  39. -#define gcc_header(x) _gcc_header(x)
  40. -#include gcc_header(__GNUC__)
  41. +/* gcc version specific checks */
  42. +
  43. +#if GCC_VERSION < 30200
  44. +# error Sorry, your compiler is too old - please upgrade it.
  45. +#endif
  46. +
  47. +#if GCC_VERSION < 30300
  48. +# define __used __attribute__((__unused__))
  49. +#else
  50. +# define __used __attribute__((__used__))
  51. +#endif
  52. +
  53. +#ifdef CONFIG_GCOV_KERNEL
  54. +# if GCC_VERSION < 30400
  55. +# error "GCOV profiling support for gcc versions below 3.4 not included"
  56. +# endif /* __GNUC_MINOR__ */
  57. +#endif /* CONFIG_GCOV_KERNEL */
  58. +
  59. +#if GCC_VERSION >= 30400
  60. +#define __must_check __attribute__((warn_unused_result))
  61. +#endif
  62. +
  63. +#if GCC_VERSION >= 40000
  64. +
  65. +/* GCC 4.1.[01] miscompiles __weak */
  66. +#ifdef __KERNEL__
  67. +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
  68. +# error Your version of gcc miscompiles the __weak directive
  69. +# endif
  70. +#endif
  71. +
  72. +#define __used __attribute__((__used__))
  73. +#define __compiler_offsetof(a, b) \
  74. + __builtin_offsetof(a, b)
  75. +
  76. +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
  77. +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  78. +#endif
  79. +
  80. +#if GCC_VERSION >= 40300
  81. +/* Mark functions as cold. gcc will assume any path leading to a call
  82. + * to them will be unlikely. This means a lot of manual unlikely()s
  83. + * are unnecessary now for any paths leading to the usual suspects
  84. + * like BUG(), printk(), panic() etc. [but let's keep them for now for
  85. + * older compilers]
  86. + *
  87. + * Early snapshots of gcc 4.3 don't support this and we can't detect this
  88. + * in the preprocessor, but we can live with this because they're unreleased.
  89. + * Maketime probing would be overkill here.
  90. + *
  91. + * gcc also has a __attribute__((__hot__)) to move hot functions into
  92. + * a special section, but I don't see any sense in this right now in
  93. + * the kernel context
  94. + */
  95. +#define __cold __attribute__((__cold__))
  96. +
  97. +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  98. +
  99. +#ifndef __CHECKER__
  100. +# define __compiletime_warning(message) __attribute__((warning(message)))
  101. +# define __compiletime_error(message) __attribute__((error(message)))
  102. +#endif /* __CHECKER__ */
  103. +#endif /* GCC_VERSION >= 40300 */
  104. +
  105. +#if GCC_VERSION >= 40500
  106. +/*
  107. + * Mark a position in code as unreachable. This can be used to
  108. + * suppress control flow warnings after asm blocks that transfer
  109. + * control elsewhere.
  110. + *
  111. + * Early snapshots of gcc 4.5 don't support this and we can't detect
  112. + * this in the preprocessor, but we can live with this because they're
  113. + * unreleased. Really, we need to have autoconf for the kernel.
  114. + */
  115. +#define unreachable() __builtin_unreachable()
  116. +
  117. +/* Mark a function definition as prohibited from being cloned. */
  118. +#define __noclone __attribute__((__noclone__))
  119. +
  120. +#endif /* GCC_VERSION >= 40500 */
  121. +
  122. +#if GCC_VERSION >= 40600
  123. +/*
  124. + * Tell the optimizer that something else uses this function or variable.
  125. + */
  126. +#define __visible __attribute__((externally_visible))
  127. +#endif
  128. +
  129. +/*
  130. + * GCC 'asm goto' miscompiles certain code sequences:
  131. + *
  132. + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  133. + *
  134. + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  135. + *
  136. + * (asm goto is automatically volatile - the naming reflects this.)
  137. + */
  138. +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  139. +
  140. +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  141. +#if GCC_VERSION >= 40400
  142. +#define __HAVE_BUILTIN_BSWAP32__
  143. +#define __HAVE_BUILTIN_BSWAP64__
  144. +#endif
  145. +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
  146. +#define __HAVE_BUILTIN_BSWAP16__
  147. +#endif
  148. +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
  149. +
  150. +#if GCC_VERSION >= 50000
  151. +#define KASAN_ABI_VERSION 4
  152. +#elif GCC_VERSION >= 40902
  153. +#define KASAN_ABI_VERSION 3
  154. +#endif
  155. +
  156. +#endif /* gcc version >= 40000 specific checks */
  157. #if !defined(__noclone)
  158. #define __noclone /* not needed */
  159. diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
  160. deleted file mode 100644
  161. index 7d89febe4d79..000000000000
  162. --- a/include/linux/compiler-gcc3.h
  163. +++ /dev/null
  164. @@ -1,23 +0,0 @@
  165. -#ifndef __LINUX_COMPILER_H
  166. -#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
  167. -#endif
  168. -
  169. -#if GCC_VERSION < 30200
  170. -# error Sorry, your compiler is too old - please upgrade it.
  171. -#endif
  172. -
  173. -#if GCC_VERSION >= 30300
  174. -# define __used __attribute__((__used__))
  175. -#else
  176. -# define __used __attribute__((__unused__))
  177. -#endif
  178. -
  179. -#if GCC_VERSION >= 30400
  180. -#define __must_check __attribute__((warn_unused_result))
  181. -#endif
  182. -
  183. -#ifdef CONFIG_GCOV_KERNEL
  184. -# if GCC_VERSION < 30400
  185. -# error "GCOV profiling support for gcc versions below 3.4 not included"
  186. -# endif /* __GNUC_MINOR__ */
  187. -#endif /* CONFIG_GCOV_KERNEL */
  188. diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
  189. deleted file mode 100644
  190. index 2507fd2a1eb4..000000000000
  191. --- a/include/linux/compiler-gcc4.h
  192. +++ /dev/null
  193. @@ -1,88 +0,0 @@
  194. -#ifndef __LINUX_COMPILER_H
  195. -#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
  196. -#endif
  197. -
  198. -/* GCC 4.1.[01] miscompiles __weak */
  199. -#ifdef __KERNEL__
  200. -# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
  201. -# error Your version of gcc miscompiles the __weak directive
  202. -# endif
  203. -#endif
  204. -
  205. -#define __used __attribute__((__used__))
  206. -#define __must_check __attribute__((warn_unused_result))
  207. -#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
  208. -
  209. -#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
  210. -# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  211. -#endif
  212. -
  213. -#if GCC_VERSION >= 40300
  214. -/* Mark functions as cold. gcc will assume any path leading to a call
  215. - to them will be unlikely. This means a lot of manual unlikely()s
  216. - are unnecessary now for any paths leading to the usual suspects
  217. - like BUG(), printk(), panic() etc. [but let's keep them for now for
  218. - older compilers]
  219. -
  220. - Early snapshots of gcc 4.3 don't support this and we can't detect this
  221. - in the preprocessor, but we can live with this because they're unreleased.
  222. - Maketime probing would be overkill here.
  223. -
  224. - gcc also has a __attribute__((__hot__)) to move hot functions into
  225. - a special section, but I don't see any sense in this right now in
  226. - the kernel context */
  227. -#define __cold __attribute__((__cold__))
  228. -
  229. -#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  230. -
  231. -#ifndef __CHECKER__
  232. -# define __compiletime_warning(message) __attribute__((warning(message)))
  233. -# define __compiletime_error(message) __attribute__((error(message)))
  234. -#endif /* __CHECKER__ */
  235. -#endif /* GCC_VERSION >= 40300 */
  236. -
  237. -#if GCC_VERSION >= 40500
  238. -/*
  239. - * Mark a position in code as unreachable. This can be used to
  240. - * suppress control flow warnings after asm blocks that transfer
  241. - * control elsewhere.
  242. - *
  243. - * Early snapshots of gcc 4.5 don't support this and we can't detect
  244. - * this in the preprocessor, but we can live with this because they're
  245. - * unreleased. Really, we need to have autoconf for the kernel.
  246. - */
  247. -#define unreachable() __builtin_unreachable()
  248. -
  249. -/* Mark a function definition as prohibited from being cloned. */
  250. -#define __noclone __attribute__((__noclone__))
  251. -
  252. -#endif /* GCC_VERSION >= 40500 */
  253. -
  254. -#if GCC_VERSION >= 40600
  255. -/*
  256. - * Tell the optimizer that something else uses this function or variable.
  257. - */
  258. -#define __visible __attribute__((externally_visible))
  259. -#endif
  260. -
  261. -/*
  262. - * GCC 'asm goto' miscompiles certain code sequences:
  263. - *
  264. - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  265. - *
  266. - * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  267. - * Fixed in GCC 4.8.2 and later versions.
  268. - *
  269. - * (asm goto is automatically volatile - the naming reflects this.)
  270. - */
  271. -#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  272. -
  273. -#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  274. -#if GCC_VERSION >= 40400
  275. -#define __HAVE_BUILTIN_BSWAP32__
  276. -#define __HAVE_BUILTIN_BSWAP64__
  277. -#endif
  278. -#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
  279. -#define __HAVE_BUILTIN_BSWAP16__
  280. -#endif
  281. -#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
  282. diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
  283. deleted file mode 100644
  284. index cdd1cc202d51..000000000000
  285. --- a/include/linux/compiler-gcc5.h
  286. +++ /dev/null
  287. @@ -1,66 +0,0 @@
  288. -#ifndef __LINUX_COMPILER_H
  289. -#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
  290. -#endif
  291. -
  292. -#define __used __attribute__((__used__))
  293. -#define __must_check __attribute__((warn_unused_result))
  294. -#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
  295. -
  296. -/* Mark functions as cold. gcc will assume any path leading to a call
  297. - to them will be unlikely. This means a lot of manual unlikely()s
  298. - are unnecessary now for any paths leading to the usual suspects
  299. - like BUG(), printk(), panic() etc. [but let's keep them for now for
  300. - older compilers]
  301. -
  302. - Early snapshots of gcc 4.3 don't support this and we can't detect this
  303. - in the preprocessor, but we can live with this because they're unreleased.
  304. - Maketime probing would be overkill here.
  305. -
  306. - gcc also has a __attribute__((__hot__)) to move hot functions into
  307. - a special section, but I don't see any sense in this right now in
  308. - the kernel context */
  309. -#define __cold __attribute__((__cold__))
  310. -
  311. -#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  312. -
  313. -#ifndef __CHECKER__
  314. -# define __compiletime_warning(message) __attribute__((warning(message)))
  315. -# define __compiletime_error(message) __attribute__((error(message)))
  316. -#endif /* __CHECKER__ */
  317. -
  318. -/*
  319. - * Mark a position in code as unreachable. This can be used to
  320. - * suppress control flow warnings after asm blocks that transfer
  321. - * control elsewhere.
  322. - *
  323. - * Early snapshots of gcc 4.5 don't support this and we can't detect
  324. - * this in the preprocessor, but we can live with this because they're
  325. - * unreleased. Really, we need to have autoconf for the kernel.
  326. - */
  327. -#define unreachable() __builtin_unreachable()
  328. -
  329. -/* Mark a function definition as prohibited from being cloned. */
  330. -#define __noclone __attribute__((__noclone__))
  331. -
  332. -/*
  333. - * Tell the optimizer that something else uses this function or variable.
  334. - */
  335. -#define __visible __attribute__((externally_visible))
  336. -
  337. -/*
  338. - * GCC 'asm goto' miscompiles certain code sequences:
  339. - *
  340. - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  341. - *
  342. - * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  343. - * Fixed in GCC 4.8.2 and later versions.
  344. - *
  345. - * (asm goto is automatically volatile - the naming reflects this.)
  346. - */
  347. -#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  348. -
  349. -#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  350. -#define __HAVE_BUILTIN_BSWAP32__
  351. -#define __HAVE_BUILTIN_BSWAP64__
  352. -#define __HAVE_BUILTIN_BSWAP16__
  353. -#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
  354. --
  355. 2.11.0