diff options
| author | Joe Perches <joe@perches.com> | 2018-08-20 16:15:26 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-20 17:12:38 -0400 |
| commit | cafa0010cd51fb711fdcb50fc55f394c5f167a0a (patch) | |
| tree | 59035cd5f8e7ea85abdd5ce278e820257f4a0663 | |
| parent | cc26ebbebde8548014d9329ac2f6cf0178181789 (diff) | |
Raise the minimum required gcc version to 4.6
Various architectures fail to build properly with older versions of the
gcc compiler.
An example from Guenter Roeck in thread [1]:
>
> In file included from ./include/linux/mm.h:17:0,
> from ./include/linux/pid_namespace.h:7,
> from ./include/linux/ptrace.h:10,
> from arch/openrisc/kernel/asm-offsets.c:32:
> ./include/linux/mm_types.h:497:16: error: flexible array member in otherwise empty struct
>
> This is just an example with gcc 4.5.1 for or32. I have seen the problem
> with gcc 4.4 (for unicore32) as well.
So update the minimum required version of gcc to 4.6.
[1] https://lore.kernel.org/lkml/20180814170904.GA12768@roeck-us.net/
Miscellanea:
- Update Documentation/process/changes.rst
- Remove and consolidate version test blocks in compiler-gcc.h for
versions lower than 4.6
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | Documentation/process/changes.rst | 2 | ||||
| -rw-r--r-- | include/linux/compiler-gcc.h | 86 |
2 files changed, 19 insertions, 69 deletions
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 7a92a06f90de..61f918b10a0c 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst | |||
| @@ -29,7 +29,7 @@ you probably needn't concern yourself with isdn4k-utils. | |||
| 29 | ====================== =============== ======================================== | 29 | ====================== =============== ======================================== |
| 30 | Program Minimal version Command to check the version | 30 | Program Minimal version Command to check the version |
| 31 | ====================== =============== ======================================== | 31 | ====================== =============== ======================================== |
| 32 | GNU C 3.2 gcc --version | 32 | GNU C 4.6 gcc --version |
| 33 | GNU make 3.81 make --version | 33 | GNU make 3.81 make --version |
| 34 | binutils 2.20 ld -v | 34 | binutils 2.20 ld -v |
| 35 | flex 2.5.35 flex --version | 35 | flex 2.5.35 flex --version |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 3e70b7d4e9ed..250b9b7cfd60 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | + __GNUC_MINOR__ * 100 \ | 10 | + __GNUC_MINOR__ * 100 \ |
| 11 | + __GNUC_PATCHLEVEL__) | 11 | + __GNUC_PATCHLEVEL__) |
| 12 | 12 | ||
| 13 | #if GCC_VERSION < 40600 | ||
| 14 | # error Sorry, your compiler is too old - please upgrade it. | ||
| 15 | #endif | ||
| 16 | |||
| 13 | /* Optimization barrier */ | 17 | /* Optimization barrier */ |
| 14 | 18 | ||
| 15 | /* The "volatile" is due to gcc bugs */ | 19 | /* The "volatile" is due to gcc bugs */ |
| @@ -58,6 +62,12 @@ | |||
| 58 | #define OPTIMIZER_HIDE_VAR(var) \ | 62 | #define OPTIMIZER_HIDE_VAR(var) \ |
| 59 | __asm__ ("" : "=r" (var) : "0" (var)) | 63 | __asm__ ("" : "=r" (var) : "0" (var)) |
| 60 | 64 | ||
| 65 | /* | ||
| 66 | * A trick to suppress uninitialized variable warning without generating any | ||
| 67 | * code | ||
| 68 | */ | ||
| 69 | #define uninitialized_var(x) x = x | ||
| 70 | |||
| 61 | #ifdef __CHECKER__ | 71 | #ifdef __CHECKER__ |
| 62 | #define __must_be_array(a) 0 | 72 | #define __must_be_array(a) 0 |
| 63 | #else | 73 | #else |
| @@ -91,7 +101,7 @@ | |||
| 91 | * A lot of inline functions can cause havoc with function tracing. | 101 | * A lot of inline functions can cause havoc with function tracing. |
| 92 | */ | 102 | */ |
| 93 | #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ | 103 | #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ |
| 94 | !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) | 104 | !defined(CONFIG_OPTIMIZE_INLINING) |
| 95 | #define inline \ | 105 | #define inline \ |
| 96 | inline __attribute__((always_inline, unused)) notrace __gnu_inline | 106 | inline __attribute__((always_inline, unused)) notrace __gnu_inline |
| 97 | #else | 107 | #else |
| @@ -147,47 +157,13 @@ | |||
| 147 | #define __always_unused __attribute__((unused)) | 157 | #define __always_unused __attribute__((unused)) |
| 148 | #define __mode(x) __attribute__((mode(x))) | 158 | #define __mode(x) __attribute__((mode(x))) |
| 149 | 159 | ||
| 150 | /* gcc version specific checks */ | ||
| 151 | |||
| 152 | #if GCC_VERSION < 30200 | ||
| 153 | # error Sorry, your compiler is too old - please upgrade it. | ||
| 154 | #endif | ||
| 155 | |||
| 156 | #if GCC_VERSION < 30300 | ||
| 157 | # define __used __attribute__((__unused__)) | ||
| 158 | #else | ||
| 159 | # define __used __attribute__((__used__)) | ||
| 160 | #endif | ||
| 161 | |||
| 162 | #ifdef CONFIG_GCOV_KERNEL | ||
| 163 | # if GCC_VERSION < 30400 | ||
| 164 | # error "GCOV profiling support for gcc versions below 3.4 not included" | ||
| 165 | # endif /* __GNUC_MINOR__ */ | ||
| 166 | #endif /* CONFIG_GCOV_KERNEL */ | ||
| 167 | |||
| 168 | #if GCC_VERSION >= 30400 | ||
| 169 | #define __must_check __attribute__((warn_unused_result)) | 160 | #define __must_check __attribute__((warn_unused_result)) |
| 170 | #define __malloc __attribute__((__malloc__)) | 161 | #define __malloc __attribute__((__malloc__)) |
| 171 | #endif | ||
| 172 | |||
| 173 | #if GCC_VERSION >= 40000 | ||
| 174 | |||
| 175 | /* GCC 4.1.[01] miscompiles __weak */ | ||
| 176 | #ifdef __KERNEL__ | ||
| 177 | # if GCC_VERSION >= 40100 && GCC_VERSION <= 40101 | ||
| 178 | # error Your version of gcc miscompiles the __weak directive | ||
| 179 | # endif | ||
| 180 | #endif | ||
| 181 | 162 | ||
| 182 | #define __used __attribute__((__used__)) | 163 | #define __used __attribute__((__used__)) |
| 183 | #define __compiler_offsetof(a, b) \ | 164 | #define __compiler_offsetof(a, b) \ |
| 184 | __builtin_offsetof(a, b) | 165 | __builtin_offsetof(a, b) |
| 185 | 166 | ||
| 186 | #if GCC_VERSION >= 40100 | ||
| 187 | # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) | ||
| 188 | #endif | ||
| 189 | |||
| 190 | #if GCC_VERSION >= 40300 | ||
| 191 | /* Mark functions as cold. gcc will assume any path leading to a call | 167 | /* Mark functions as cold. gcc will assume any path leading to a call |
| 192 | * to them will be unlikely. This means a lot of manual unlikely()s | 168 | * to them will be unlikely. This means a lot of manual unlikely()s |
| 193 | * are unnecessary now for any paths leading to the usual suspects | 169 | * are unnecessary now for any paths leading to the usual suspects |
| @@ -206,24 +182,19 @@ | |||
| 206 | 182 | ||
| 207 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | 183 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) |
| 208 | 184 | ||
| 209 | #ifndef __CHECKER__ | ||
| 210 | # define __compiletime_warning(message) __attribute__((warning(message))) | ||
| 211 | # define __compiletime_error(message) __attribute__((error(message))) | ||
| 212 | #endif /* __CHECKER__ */ | ||
| 213 | #endif /* GCC_VERSION >= 40300 */ | ||
| 214 | |||
| 215 | #if GCC_VERSION >= 40400 | ||
| 216 | #define __optimize(level) __attribute__((__optimize__(level))) | 185 | #define __optimize(level) __attribute__((__optimize__(level))) |
| 217 | #define __nostackprotector __optimize("no-stack-protector") | 186 | #define __nostackprotector __optimize("no-stack-protector") |
| 218 | #endif /* GCC_VERSION >= 40400 */ | ||
| 219 | 187 | ||
| 220 | #if GCC_VERSION >= 40500 | 188 | #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
| 221 | 189 | ||
| 222 | #ifndef __CHECKER__ | 190 | #ifndef __CHECKER__ |
| 191 | #define __compiletime_warning(message) __attribute__((warning(message))) | ||
| 192 | #define __compiletime_error(message) __attribute__((error(message))) | ||
| 193 | |||
| 223 | #ifdef LATENT_ENTROPY_PLUGIN | 194 | #ifdef LATENT_ENTROPY_PLUGIN |
| 224 | #define __latent_entropy __attribute__((latent_entropy)) | 195 | #define __latent_entropy __attribute__((latent_entropy)) |
| 225 | #endif | 196 | #endif |
| 226 | #endif | 197 | #endif /* __CHECKER__ */ |
| 227 | 198 | ||
| 228 | /* | 199 | /* |
| 229 | * calling noreturn functions, __builtin_unreachable() and __builtin_trap() | 200 | * calling noreturn functions, __builtin_unreachable() and __builtin_trap() |
| @@ -261,10 +232,6 @@ | |||
| 261 | #define randomized_struct_fields_end } __randomize_layout; | 232 | #define randomized_struct_fields_end } __randomize_layout; |
| 262 | #endif | 233 | #endif |
| 263 | 234 | ||
| 264 | #endif /* GCC_VERSION >= 40500 */ | ||
| 265 | |||
| 266 | #if GCC_VERSION >= 40600 | ||
| 267 | |||
| 268 | /* | 235 | /* |
| 269 | * When used with Link Time Optimization, gcc can optimize away C functions or | 236 | * When used with Link Time Optimization, gcc can optimize away C functions or |
| 270 | * variables which are referenced only from assembly code. __visible tells the | 237 | * variables which are referenced only from assembly code. __visible tells the |
| @@ -273,8 +240,7 @@ | |||
| 273 | */ | 240 | */ |
| 274 | #define __visible __attribute__((externally_visible)) | 241 | #define __visible __attribute__((externally_visible)) |
| 275 | 242 | ||
| 276 | #endif /* GCC_VERSION >= 40600 */ | 243 | /* gcc version specific checks */ |
| 277 | |||
| 278 | 244 | ||
| 279 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) | 245 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) |
| 280 | /* | 246 | /* |
| @@ -308,10 +274,8 @@ | |||
| 308 | * folding in __builtin_bswap*() (yet), so don't set these for it. | 274 | * folding in __builtin_bswap*() (yet), so don't set these for it. |
| 309 | */ | 275 | */ |
| 310 | #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__) | 276 | #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__) |
| 311 | #if GCC_VERSION >= 40400 | ||
| 312 | #define __HAVE_BUILTIN_BSWAP32__ | 277 | #define __HAVE_BUILTIN_BSWAP32__ |
| 313 | #define __HAVE_BUILTIN_BSWAP64__ | 278 | #define __HAVE_BUILTIN_BSWAP64__ |
| 314 | #endif | ||
| 315 | #if GCC_VERSION >= 40800 | 279 | #if GCC_VERSION >= 40800 |
| 316 | #define __HAVE_BUILTIN_BSWAP16__ | 280 | #define __HAVE_BUILTIN_BSWAP16__ |
| 317 | #endif | 281 | #endif |
| @@ -340,10 +304,9 @@ | |||
| 340 | * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html | 304 | * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html |
| 341 | */ | 305 | */ |
| 342 | #define __designated_init __attribute__((designated_init)) | 306 | #define __designated_init __attribute__((designated_init)) |
| 307 | #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 | ||
| 343 | #endif | 308 | #endif |
| 344 | 309 | ||
| 345 | #endif /* gcc version >= 40000 specific checks */ | ||
| 346 | |||
| 347 | #if !defined(__noclone) | 310 | #if !defined(__noclone) |
| 348 | #define __noclone /* not needed */ | 311 | #define __noclone /* not needed */ |
| 349 | #endif | 312 | |
