Skip to content

Instantly share code, notes, and snippets.

@bensuperpc
Forked from miyuki/gcc-1.27.patch
Last active June 11, 2021 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensuperpc/4224a85c761f8f3a40dc62c5a8bdccf4 to your computer and use it in GitHub Desktop.
Save bensuperpc/4224a85c761f8f3a40dc62c5a8bdccf4 to your computer and use it in GitHub Desktop.
A patch required to build GCC 1.27 on a modern system
diff --git a/Makefile b/Makefile
index ee02e0f..25a4aa5 100644
--- a/Makefile
+++ b/Makefile
@@ -373,19 +373,19 @@ maketest:
stage1: force
-mkdir stage1
mv $(STAGESTUFF) $(STAGE_GCC) stage1
- -rm stage1/gnulib
+ -rm -f stage1/gnulib
-ln gnulib stage1 || cp gnulib stage1
stage2: force
-mkdir stage2
mv $(STAGESTUFF) $(STAGE_GCC) stage2
- -rm stage2/gnulib
+ -rm -f stage2/gnulib
-ln gnulib stage2 || cp gnulib stage2
stage3: force
-mkdir stage3
mv $(STAGESTUFF) $(STAGE_GCC) stage3
- -rm stage3/gnulib
+ -rm -f stage3/gnulib
-ln gnulib stage3 || cp gnulib stage3
#In GNU Make, ignore whether `stage*' exists.
diff --git a/cccp.c b/cccp.c
index f53d438..c64f339 100644
--- a/cccp.c
+++ b/cccp.c
@@ -129,6 +129,7 @@ typedef unsigned char U_CHAR;
#include <sys/stat.h>
#include <ctype.h>
#include <stdio.h>
+#include <errno.h>
#ifndef VMS
#include <sys/file.h>
@@ -5009,9 +5010,6 @@ void
perror_with_name (name)
char *name;
{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
-
fprintf (stderr, "%s: ", progname);
if (errno < sys_nerr)
fprintf (stderr, "%s for `%s'\n", sys_errlist[errno], name);
diff --git a/expr.c b/expr.c
index f67db1a..01daa97 100644
--- a/expr.c
+++ b/expr.c
@@ -3619,7 +3619,7 @@ expand_call (exp, target, ignore)
INIT_CUMULATIVE_ARGS (args_so_far, funtype);
tem = FUNCTION_ARG (args_so_far, Pmode,
build_pointer_type (TREE_TYPE (funtype)), 1);
- if (GET_CODE (tem) == MEM)
+ if (tem != 0 && GET_CODE (tem) == MEM)
{
actparms = tree_cons (error_mark_node,
build (SAVE_EXPR,
diff --git a/gcc.c b/gcc.c
index 66e035c..c9fefc2 100644
--- a/gcc.c
+++ b/gcc.c
@@ -117,6 +117,7 @@ position among the other output files.
#include <sys/types.h>
#include <signal.h>
#include <sys/file.h>
+#include <errno.h>
#include "config.h"
#include "obstack.h"
@@ -1217,8 +1218,6 @@ save_string (s, len)
pfatal_with_name (name)
char *name;
{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
char *s;
if (errno < sys_nerr)
@@ -1231,8 +1230,6 @@ pfatal_with_name (name)
perror_with_name (name)
char *name;
{
- extern int errno, sys_nerr;
- extern char *sys_errlist[];
char *s;
if (errno < sys_nerr)
diff --git a/output-i386.c b/output-i386.c
index 748628d..0e29ca3 100644
--- a/output-i386.c
+++ b/output-i386.c
@@ -339,7 +339,7 @@ fp_push_df (x)
output_asm_insn ("fld%Q %0", &x);
}
-char *output_move_const_single ();
+static char *output_move_const_single ();
static char *
singlemove_string (operands)
diff --git a/sdbout.c b/sdbout.c
index 4e6cca5..2979ef0 100644
--- a/sdbout.c
+++ b/sdbout.c
@@ -27,7 +27,7 @@ and this notice must be preserved on all copies. */
#include "rtl.h"
#include "c-tree.h"
#include <stdio.h>
-#include <syms.h>
+#include "syms.h"
/* #include <storclass.h> used to be this instead of syms.h. */
/* Line number of beginning of current function, minus one. */
@@ -43,7 +43,7 @@ extern FILE *asm_out_file;
extern tree current_function_decl;
void sdbout_init ();
-void sdbout_syms ();
+static void sdbout_syms ();
void sdbout_symbol ();
void sdbout_tags();
void sdbout_types();
diff --git a/stdarg.h b/stdarg.h
index a5ef31a..50f3d48 100644
--- a/stdarg.h
+++ b/stdarg.h
@@ -19,4 +19,7 @@ void va_end (va_list); /* Defined in gnulib */
(AP += __va_rounded_size (TYPE), \
*((TYPE *) (AP - __va_rounded_size (TYPE))))
+typedef va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
+
#endif /* _STDARG_H */
diff --git a/stddef.h b/stddef.h
index 991b45d..f141d35 100644
--- a/stddef.h
+++ b/stddef.h
@@ -7,7 +7,7 @@ typedef long ptrdiff_t;
/* Unsigned type of `sizeof' something. */
-typedef unsigned long size_t;
+typedef unsigned int size_t;
/* A null pointer constant. */
diff --git a/tm-i386v.h b/tm-i386v.h
index 832caea..68dfe61 100644
--- a/tm-i386v.h
+++ b/tm-i386v.h
@@ -32,9 +32,10 @@ and this notice must be preserved on all copies. */
/* Use crt1.o as a startup file and crtn.o as a closing file. */
#define STARTFILE_SPEC \
- "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}"
+ "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crti.o%s"
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} crtn.o%s"
+#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} crtn.o%s" \
+ " -dynamic-linker ld-linux.so.2%s"
/* Specify predefined symbols in preprocessor. */
--- stddef.h
+++ stddef.h
@@ -7,7 +7,7 @@
/* Unsigned type of `sizeof' something. */
-typedef unsigned int size_t;
+//typedef unsigned int size_t;
/* A null pointer constant. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment