GCC 5.1 defaults to gnu11 which forbids redefinitions. This patch
comes from <https://gcc.gnu.org/ml/gcc-patches/2009-06/msg01249.html>
with adjustments for GCC 4.0.4.

diff -Naur gcc-4.0.4~/gcc/toplev.c gcc-4.0.4/gcc/toplev.c
--- gcc-4.0.4~/gcc/toplev.c	2018-12-28 13:46:31.125474524 +0100
+++ gcc-4.0.4/gcc/toplev.c	2018-12-28 13:47:27.217964446 +0100
@@ -540,6 +540,8 @@
   return atoi (p);
 }
 
+#if GCC_VERSION < 3004
+
 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
    If X is 0, return -1.  */
 
@@ -590,6 +592,8 @@
 #endif
 }
 
+#endif /*  GCC_VERSION < 3004 */
+
 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
    into ICE messages, which is much more user friendly.  In case the
    error printer crashes, reset the signal to prevent infinite recursion.  */
diff -Naur gcc-4.0.4~/gcc/toplev.h gcc-4.0.4/gcc/toplev.h
--- gcc-4.0.4~/gcc/toplev.h	2018-12-28 13:46:31.125474524 +0100
+++ gcc-4.0.4/gcc/toplev.h	2018-12-28 13:48:13.643582962 +0100
@@ -161,6 +161,7 @@
 /* Return true iff flags are set as if -ffast-math.  */
 extern bool fast_math_flags_set_p	(void);
 
+#if GCC_VERSION < 3004
 /* Return log2, or -1 if not exact.  */
 extern int exact_log2                  (unsigned HOST_WIDE_INT);
 
@@ -168,7 +169,7 @@
 extern int floor_log2                  (unsigned HOST_WIDE_INT);
 
 /* Inline versions of the above for speed.  */
-#if GCC_VERSION >= 3004
+#else /* GCC_VERSION >= 3004 */
 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
 #  define CLZ_HWI __builtin_clzl
 #  define CTZ_HWI __builtin_ctzl
@@ -180,13 +181,13 @@
 #  define CTZ_HWI __builtin_ctz
 # endif
 
-extern inline int
+static inline int
 floor_log2 (unsigned HOST_WIDE_INT x)
 {
   return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
 }
 
-extern inline int
+static inline int
 exact_log2 (unsigned HOST_WIDE_INT x)
 {
   return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
