Skip to contentSkip to conversation

Bump gcc minimum version to 3.4, 4.1 for x86

RFC PATCH In review H. Peter Anvin 4 participants 9 messages Sep 13, 2010 – Sep 15, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Bump gcc minimum version to 3.4, 4.1 for x86

This patchset bumps the minimum supported gcc version to 3.4 for the general kernel, and to 4.1 for x86.

We have had a rash of bug reports related to these really old compilers and their associated binutils version lately, and it is clear that the support burden of these older compilers is getting to be excessive. If you really want to build a kernel on a system that old you can build or obtain an updated gcc/binutils as well.

 Documentation/Changes             |    2 +-
 arch/x86/include/asm/bitops.h     |    7 -------
 arch/x86/include/asm/cpufeature.h |    7 -------
 arch/x86/include/asm/string_32.h  |   21 ---------------------
 arch/x86/kernel/Makefile          |    3 ++-
 arch/x86/kernel/compiler.c        |    5 +++++
 include/linux/compiler-gcc3.h     |   15 +--------------
 7 files changed, 9 insertions(+), 51 deletions(-)
#1 lore raw

PATCH 1/5 Disallow building with gcc < 3.4

Disallow building the generic kernel code with gcc < 3.4. Earlier versions of gcc have known problems, and it appears that anyone who genuinely needs gcc 3.x can use gcc 3.4 at this point.

---
 Documentation/Changes         |    2 +-
 include/linux/compiler-gcc3.h |   15 +--------------
 2 files changed, 2 insertions(+), 15 deletions(-)
Documentation/Changes +1 -1
index 4fb88f1..0ea8040 100644
@@ -28,7 +28,7 @@ necessary on all systems; obviously, if you don't have any ISDN
 hardware, for example, you probably needn't concern yourself with
 isdn4k-utils.
 
-o  Gnu C                  3.2                     # gcc --version
+o  Gnu C                  3.4                     # gcc --version
 o  Gnu make               3.80                    # make --version
 o  binutils               2.12                    # ld -v
 o  util-linux             2.10o                   # fdformat --version
include/linux/compiler-gcc3.h +1 -14
index b721129..c11d443 100644
@@ -2,25 +2,12 @@
 #error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
 #endif
 
-#if __GNUC_MINOR__ < 2
+#if __GNUC_MINOR__ < 4
 # error Sorry, your compiler is too old - please upgrade it.
 #endif
 
-#if __GNUC_MINOR__ >= 3
 # define __used			__attribute__((__used__))
-#else
-# define __used			__attribute__((__unused__))
-#endif
-
-#if __GNUC_MINOR__ >= 4
 #define __must_check		__attribute__((warn_unused_result))
-#endif
-
-#ifdef CONFIG_GCOV_KERNEL
-# if __GNUC_MINOR__ < 4
-#   error "GCOV profiling support for gcc versions below 3.4 not included"
-# endif /* __GNUC_MINOR__ */
-#endif /* CONFIG_GCOV_KERNEL */
 
 /*
  * A trick to suppress uninitialized variable warning without generating any
Signature · 1 line
1.7.2.1
#3 lore raw

PATCH 2/5 x86, gcc: Disallow building Linux/x86 with gcc 3.x/4.0

In reply to H. Peter Anvin

We are starting to get "straggler problems" with people compiling current Linux kernels with now-ancient versions of gcc. All the development is being done against gcc 4.x; this simply disallows gcc 4.0 or earlier.

We disallow 4.0 as well as 3.x because 4.0 had a fair share of bugs especially around asm() statements; this allows us to remove those workarounds.

---
 arch/x86/kernel/Makefile   |    3 ++-
 arch/x86/kernel/compiler.c |    5 +++++
 2 files changed, 7 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/kernel/compiler.c
arch/x86/kernel/Makefile +2 -1
index 0925676..a6459b7 100644
@@ -29,7 +29,8 @@ GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
 GCOV_PROFILE_paravirt.o		:= n
 
-obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
+obj-y			:= compiler.o
+obj-y			+= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
 obj-y			+= setup.o x86_init.o i8259.o irqinit.o
arch/x86/kernel/compiler.c new file +5 -0
new file mode 100644
index 0000000..8914974
@@ -0,0 +1,5 @@
+#if __GNUC__ < 4
+#error "Compiling Linux/x86 with gcc 3.x is no longer supported"
+#elif __GNUC__ == 4 && __GNUC_MINOR__ < 1
+#error "Compiling Linux/x86 with gcc 4.0 is not supported"
+#endif
Signature · 1 line
1.7.2.1
#4 lore raw

PATCH 3/5 x86, cpu: Remove gcc 3.x workarounds in <asm/cpufeature.h>

In reply to H. Peter Anvin

We no longer support gcc 3.x, so remove the workaround for it.

---
 arch/x86/include/asm/cpufeature.h |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/x86/include/asm/cpufeature.h +0 -7
index 781a50b..830a94f 100644
@@ -345,7 +345,6 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 #endif
 }
 
-#if __GNUC__ >= 4
 #define static_cpu_has(bit)					\
 (								\
 	__builtin_constant_p(boot_cpu_has(bit)) ?		\
@@ -354,12 +353,6 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 		__static_cpu_has(bit) :				\
 		boot_cpu_has(bit)				\
 )
-#else
-/*
- * gcc 3.x is too stupid to do the static test; fall back to dynamic.
- */
-#define static_cpu_has(bit) boot_cpu_has(bit)
-#endif
 
 #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
 
Signature · 1 line
1.7.2.1
#5 lore raw

PATCH 4/5 x86, mem: Remove gcc < 4.1 support code for memcpy()

In reply to H. Peter Anvin

We require gcc 4.1 or later, so remove support code for previous versions of gcc.

---
 arch/x86/include/asm/string_32.h |   21 ---------------------
 1 files changed, 0 insertions(+), 21 deletions(-)
arch/x86/include/asm/string_32.h +0 -21
index 3d3e835..fde4eb2 100644
@@ -177,16 +177,8 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)
  */
 
 #ifndef CONFIG_KMEMCHECK
-
-#if (__GNUC__ >= 4)
 #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
 #else
-#define memcpy(t, f, n)				\
-	(__builtin_constant_p((n))		\
-	 ? __constant_memcpy((t), (f), (n))	\
-	 : __memcpy((t), (f), (n)))
-#endif
-#else
 /*
  * kmemcheck becomes very happy if we use the REP instructions unconditionally,
  * because it means that we know both memory operands in advance.
@@ -284,12 +276,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
 
 	{
 		int d0, d1;
-#if __GNUC__ == 4 && __GNUC_MINOR__ == 0
-		/* Workaround for broken gcc 4.0 */
-		register unsigned long eax asm("%eax") = pattern;
-#else
 		unsigned long eax = pattern;
-#endif
 
 		switch (count % 4) {
 		case 0:
@@ -321,15 +308,7 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
 	 : __memset_generic((s), (c), (count)))
 
 #define __HAVE_ARCH_MEMSET
-#if (__GNUC__ >= 4)
 #define memset(s, c, count) __builtin_memset(s, c, count)
-#else
-#define memset(s, c, count)						\
-	(__builtin_constant_p(c)					\
-	 ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \
-				 (count))				\
-	 : __memset((s), (c), (count)))
-#endif
 
 /*
  * find the first occurrence of byte 'c', or 1 past the area if none
Signature · 1 line
1.7.2.1
#6 lore raw

PATCH 5/5 x86, bitops: Remove gcc < 4.1 workaround

In reply to H. Peter Anvin

Remove workaround for gcc older than 4.1.

---
 arch/x86/include/asm/bitops.h |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/x86/include/asm/bitops.h +0 -7
index 545776e..1532109 100644
@@ -22,14 +22,7 @@
  *
  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  */
-
-#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
-/* Technically wrong, but this avoids compilation errors on some gcc
-   versions. */
-#define BITOP_ADDR(x) "=m" (*(volatile long *) (x))
-#else
 #define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
-#endif
 
 #define ADDR				BITOP_ADDR(addr)
 
Signature · 1 line
1.7.2.1
#7 lore raw
In reply to H. Peter Anvin
Quoted 8 lines · H. Peter Anvin

This patchset bumps the minimum supported gcc version to 3.4 for the general kernel, and to 4.1 for x86.

We have had a rash of bug reports related to these really old compilers and their associated binutils version lately, and it is clear that the support burden of these older compilers is getting to be excessive.  If you really want to build a kernel on a system that old you can build or obtain an updated gcc/binutils as well.

What version of binutils does this correspond to? It would be nice to clean up some of the hacks for ancient binutils as well.

--
Brian Gerst

#8 lore raw
Quoted 4 lines · Brian Gerst
Quoted 3 lines · H. Peter Anvin

This patchset bumps the minimum supported gcc version to 3.4 for the general kernel, and to 4.1 for x86.

Quoted 9 lines
Quoted 5 lines

We have had a rash of bug reports related to these really old compilers and their associated binutils version lately, and it is clear that the support burden of these older compilers is getting to be excessive. If you really want to build a kernel on a system that old you can build or obtain an updated gcc/binutils as well.

What version of binutils does this correspond to? It would be nice to clean up some of the hacks for ancient binutils as well.

4.1 -> 2.16
3.4 -> 2.14/2.15 (gcc 3.4.0 beat binutils 2.15 by a mere 29 days)

This is somewhat unfortunate, since neither of these brackets eliminate the Binutils Version From Hell, a.k.a. 2.16.

-hpa