Skip to content

Commit 6ec4476

Browse files
committed
Raise gcc version requirement to 4.9
I realize that we fairly recently raised it to 4.8, but the fact is, 4.9 is a much better minimum version to target. We have a number of workarounds for actual bugs in pre-4.9 gcc versions (including things like internal compiler errors on ARM), but we also have some syntactic workarounds for lacking features. In particular, raising the minimum to 4.9 means that we can now just assume _Generic() exists, which is likely the much better replacement for a lot of very convoluted built-time magic with conditionals on sizeof and/or __builtin_choose_expr() with same_type() etc. Using _Generic also means that you will need to have a very recent version of 'sparse', but thats easy to build yourself, and much less of a hassle than some old gcc version can be. The latest (in a long string) of reasons for minimum compiler version upgrades was commit 5435f73 ("efi/x86: Fix build with gcc 4"). Ard points out that RHEL 7 uses gcc-4.8, but the people who stay back on old RHEL versions persumably also don't build their own kernels anyway. And maybe they should cross-built or just have a little side affair with a newer compiler? Acked-by: Ard Biesheuvel <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dcde237 commit 6ec4476

File tree

7 files changed

+8
-56
lines changed

7 files changed

+8
-56
lines changed

arch/arm/kernel/asm-offsets.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131
#if defined(__APCS_26__)
3232
#error Sorry, your compiler targets APCS-26 but this kernel requires APCS-32
3333
#endif
34-
/*
35-
* GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854
36-
* miscompiles find_get_entry(), and can result in EXT3 and EXT4
37-
* filesystem corruption (possibly other FS too).
38-
*/
39-
#if defined(GCC_VERSION) && GCC_VERSION >= 40800 && GCC_VERSION < 40803
40-
#error Your compiler is too buggy; it is known to miscompile kernels
41-
#error and result in filesystem corruption and oopses.
42-
#endif
4334

4435
int main(void)
4536
{

arch/mips/include/asm/unroll.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
\
2020
/* \
2121
* We can't unroll if the number of iterations isn't \
22-
* compile-time constant. Unfortunately GCC versions \
23-
* up until 4.6 tend to miss obvious constants & cause \
22+
* compile-time constant. Unfortunately clang versions \
23+
* up until 8.0 tend to miss obvious constants & cause \
2424
* this check to fail, even though they go on to \
2525
* generate reasonable code for the switch statement, \
2626
* so we skip the sanity check for those compilers. \
2727
*/ \
28-
BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 || \
29-
CONFIG_CLANG_VERSION >= 80000) && \
28+
BUILD_BUG_ON((CONFIG_CLANG_VERSION >= 80000) && \
3029
!__builtin_constant_p(times)); \
3130
\
3231
switch (times) { \

include/linux/bits.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
* position @h. For example
1919
* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
2020
*/
21-
#if !defined(__ASSEMBLY__) && \
22-
(!defined(CONFIG_CC_IS_GCC) || CONFIG_GCC_VERSION >= 49000)
21+
#if !defined(__ASSEMBLY__)
2322
#include <linux/build_bug.h>
2423
#define GENMASK_INPUT_CHECK(h, l) \
2524
(BUILD_BUG_ON_ZERO(__builtin_choose_expr( \

include/linux/compiler-gcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
+ __GNUC_PATCHLEVEL__)
1212

1313
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */
14-
#if GCC_VERSION < 40800
14+
#if GCC_VERSION < 40900
1515
# error Sorry, your compiler is too old - please upgrade it.
1616
#endif
1717

include/linux/compiler_types.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -252,32 +252,8 @@ struct ftrace_likely_data {
252252
* __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving
253253
* non-scalar types unchanged.
254254
*/
255-
#if (defined(CONFIG_CC_IS_GCC) && CONFIG_GCC_VERSION < 40900) || defined(__CHECKER__)
256255
/*
257-
* We build this out of a couple of helper macros in a vain attempt to
258-
* help you keep your lunch down while reading it.
259-
*/
260-
#define __pick_scalar_type(x, type, otherwise) \
261-
__builtin_choose_expr(__same_type(x, type), (type)0, otherwise)
262-
263-
/*
264-
* 'char' is not type-compatible with either 'signed char' or 'unsigned char',
265-
* so we include the naked type here as well as the signed/unsigned variants.
266-
*/
267-
#define __pick_integer_type(x, type, otherwise) \
268-
__pick_scalar_type(x, type, \
269-
__pick_scalar_type(x, unsigned type, \
270-
__pick_scalar_type(x, signed type, otherwise)))
271-
272-
#define __unqual_scalar_typeof(x) typeof( \
273-
__pick_integer_type(x, char, \
274-
__pick_integer_type(x, short, \
275-
__pick_integer_type(x, int, \
276-
__pick_integer_type(x, long, \
277-
__pick_integer_type(x, long long, x))))))
278-
#else
279-
/*
280-
* If supported, prefer C11 _Generic for better compile-times. As above, 'char'
256+
* Prefer C11 _Generic for better compile-times and simpler code. Note: 'char'
281257
* is not type-compatible with 'signed char', and we define a separate case.
282258
*/
283259
#define __scalar_type_to_expr_cases(type) \
@@ -293,7 +269,6 @@ struct ftrace_likely_data {
293269
__scalar_type_to_expr_cases(long), \
294270
__scalar_type_to_expr_cases(long long), \
295271
default: (x)))
296-
#endif
297272

298273
/* Is this type a native word size -- useful for atomic operations */
299274
#define __native_word(t) \

mm/migrate.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,22 +1160,11 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
11601160
return rc;
11611161
}
11621162

1163-
/*
1164-
* gcc 4.7 and 4.8 on arm get an ICEs when inlining unmap_and_move(). Work
1165-
* around it.
1166-
*/
1167-
#if defined(CONFIG_ARM) && \
1168-
defined(GCC_VERSION) && GCC_VERSION < 40900 && GCC_VERSION >= 40700
1169-
#define ICE_noinline noinline
1170-
#else
1171-
#define ICE_noinline
1172-
#endif
1173-
11741163
/*
11751164
* Obtain the lock on page, remove all ptes and migrate the page
11761165
* to the newly allocated page in newpage.
11771166
*/
1178-
static ICE_noinline int unmap_and_move(new_page_t get_new_page,
1167+
static int unmap_and_move(new_page_t get_new_page,
11791168
free_page_t put_new_page,
11801169
unsigned long private, struct page *page,
11811170
int force, enum migrate_mode mode,

tools/include/linux/bits.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
* position @h. For example
1919
* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
2020
*/
21-
#if !defined(__ASSEMBLY__) && \
22-
(!defined(CONFIG_CC_IS_GCC) || CONFIG_GCC_VERSION >= 49000)
21+
#if !defined(__ASSEMBLY__)
2322
#include <linux/build_bug.h>
2423
#define GENMASK_INPUT_CHECK(h, l) \
2524
(BUILD_BUG_ON_ZERO(__builtin_choose_expr( \

0 commit comments

Comments
 (0)