This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Build an old GCC with a newer version
Frank Juergen-R58616 wrote:
> Hi !!
>
> I need some hints how I can compile an old GCC (Version 3.3.2) with an
> new version. I try this under cygwin (3.4.4) and linux (4.x) and in both
> cases I get an compilation error.
>
> ../../gcc-3.3.2/gcc/gcc.c:1423: warning: string length `595' is greater
> than the length `509' ISO C89 compilers are requ
> ired to support
> ../../gcc-3.3.2/gcc/gcc.c: In function `process_command':
> ../../gcc-3.3.2/gcc/gcc.c:3555: error: assignment of read-only location
> ../../gcc-3.3.2/gcc/gcc.c:3557: error: assignment of read-only location
> ../../gcc-3.3.2/gcc/gcc.c: In function `fatal':
> ../../gcc-3.3.2/gcc/gcc.c:6463: warning: traditional C rejects ISO C
> style function definitions
> ../../gcc-3.3.2/gcc/gcc.c: In function `error':
> ../../gcc-3.3.2/gcc/gcc.c:6477: warning: traditional C rejects ISO C
> style function definitions
> ../../gcc-3.3.2/gcc/gcc.c: In function `notice':
> ../../gcc-3.3.2/gcc/gcc.c:6490: warning: traditional C rejects ISO C
> style function definitions
> make[1]: *** [gcc.o] Error 1
> make[1]: Leaving directory `/cygdrive/c/Download/GCC/obj_gcc/gcc'
> make: *** [all-gcc] Error 2
>
> Why I want this old version, unfortunately I receives an old project
> which was developed under GCC 3.3.2, and I could compile it with a new
> version of GCC. Could it help to play with the -std option ? How can I
> add this to the normal GCC makefile ?
>
> Exist an option which drives the compiler to behaves like in the older
> versions ?
No. You'll just have to fix the code in the compiler. Usually this isn't
too hard: for gcc 3.2.3 I had to make just a few changes, which I've
attached.
Andrew.
Index: gcc/read-rtl.c
===================================================================
--- gcc/read-rtl.c (revision 131336)
+++ gcc/read-rtl.c (working copy)
@@ -659,7 +659,7 @@
{
ungetc (c, infile);
list_counter++;
- obstack_ptr_grow (&vector_stack, (PTR) read_rtx (infile));
+ obstack_ptr_grow (&vector_stack, read_rtx (infile));
}
if (list_counter > 0)
{
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 131336)
+++ gcc/cp/decl.c (working copy)
@@ -454,9 +454,9 @@
/* The binding level currently in effect. */
#define current_binding_level \
- (cfun && cp_function_chain->bindings \
- ? cp_function_chain->bindings \
- : scope_chain->bindings)
+ (*(cfun && cp_function_chain->bindings \
+ ? &cp_function_chain->bindings \
+ : &scope_chain->bindings))
/* The binding level of the current class, if any. */
Index: gcc/system.h
===================================================================
--- gcc/system.h (revision 131336)
+++ gcc/system.h (working copy)
@@ -578,6 +578,7 @@
#define really_call_calloc calloc
#define really_call_realloc realloc
+
#if (GCC_VERSION >= 3000)
/* Note autoconf checks for prototype declarations and includes
@@ -589,7 +590,9 @@
#undef realloc
#undef calloc
#undef strdup
+#if ! (defined(FLEX_SCANNER) || defined(YYBISON) || defined(YYBYACC))
#pragma GCC poison malloc realloc calloc strdup
+#endif
/* Old target macros that have moved to the target hooks structure. */
#pragma GCC poison ASM_OPEN_PAREN ASM_CLOSE_PAREN \
@@ -628,4 +631,11 @@
#endif /* GCC >= 3.0 */
+#if defined(FLEX_SCANNER) || defined(YYBISON) || defined(YYBYACC)
+/* Flex and bison use malloc and realloc. Yuk. Note that this means
+ really_call_* cannot be used in a .l or .y file. */
+#define malloc xmalloc
+#define realloc xrealloc
+#endif
+
#endif /* ! GCC_SYSTEM_H */
Index: include/obstack.h
===================================================================
--- include/obstack.h (revision 131336)
+++ include/obstack.h (working copy)
@@ -349,7 +349,7 @@
#define obstack_memory_used(h) _obstack_memory_used (h)
-#if defined __GNUC__ && defined __STDC__ && __STDC__
+#if 0 && defined __GNUC__ && defined __STDC__ && __STDC__
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
does not implement __extension__. But that compiler doesn't define
__GNUC_MINOR__. */