Last active
May 10, 2022 09:11
-
-
Save kristerw/b854b6d285e678452a44a6bcbf7ef86f to your computer and use it in GitHub Desktop.
Patch for building gcc-1.27 as described in https://kristerw.blogspot.com/2019/01/building-gcc-127.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN gcc-1.27.orig/Makefile gcc-1.27/Makefile | |
--- gcc-1.27.orig/Makefile 1988-09-01 23:37:53.000000000 +0200 | |
+++ gcc-1.27/Makefile 2019-01-26 18:40:26.378486900 +0100 | |
@@ -19,7 +19,8 @@ | |
#and this notice must be preserved on all copies. | |
-CFLAGS = -g | |
+CCLIBFLAGS = -m32 | |
+CFLAGS = -g -m32 | |
CC = cc | |
# OLDCC should not be the GNU C compiler. | |
OLDCC = cc | |
@@ -345,6 +346,8 @@ | |
# Copy the files into directories where they will be run. | |
install: all | |
+ mkdir -p $(bindir) | |
+ mkdir -p $(libdir) | |
install cc1 $(libdir)/gcc-cc1 | |
install -c -m 755 gnulib $(libdir)/gcc-gnulib | |
if [ -f /usr/bin/ranlib ] ; then ranlib $(libdir)/gcc-gnulib ;fi | |
@@ -373,19 +376,19 @@ | |
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 -ruN gcc-1.27.orig/cccp.c gcc-1.27/cccp.c | |
--- gcc-1.27.orig/cccp.c 1988-08-20 21:56:27.000000000 +0200 | |
+++ gcc-1.27/cccp.c 2019-01-26 18:40:26.382486847 +0100 | |
@@ -129,6 +129,7 @@ | |
#include <sys/stat.h> | |
#include <ctype.h> | |
#include <stdio.h> | |
+#include <errno.h> | |
#ifndef VMS | |
#include <sys/file.h> | |
@@ -5009,9 +5010,6 @@ | |
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 -ruN gcc-1.27.orig/dbxout.c gcc-1.27/dbxout.c | |
--- gcc-1.27.orig/dbxout.c 1988-08-09 18:59:59.000000000 +0200 | |
+++ gcc-1.27/dbxout.c 2019-01-26 18:40:26.382486847 +0100 | |
@@ -1056,7 +1056,7 @@ | |
if (depth > 0) | |
{ | |
blocknum = next_block_number++; | |
- fprintf (asmfile, ".stabn %d,0,0,LBB%d\n", N_LBRAC, blocknum); | |
+ fprintf (asmfile, ".stabn %d,0,0,.LBB%d\n", N_LBRAC, blocknum); | |
} | |
/* Output the interior of the block. */ | |
@@ -1064,7 +1064,7 @@ | |
/* Refer to the marker for the end of the block. */ | |
if (depth > 0) | |
- fprintf (asmfile, ".stabn %d,0,0,LBE%d\n", N_RBRAC, blocknum); | |
+ fprintf (asmfile, ".stabn %d,0,0,.LBE%d\n", N_RBRAC, blocknum); | |
} | |
stmt = TREE_CHAIN (stmt); | |
} | |
diff -ruN gcc-1.27.orig/expr.c gcc-1.27/expr.c | |
--- gcc-1.27.orig/expr.c 1988-09-05 18:09:20.000000000 +0200 | |
+++ gcc-1.27/expr.c 2019-01-26 18:40:26.382486847 +0100 | |
@@ -3619,7 +3619,7 @@ | |
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 -ruN gcc-1.27.orig/gcc.c gcc-1.27/gcc.c | |
--- gcc-1.27.orig/gcc.c 1988-08-19 17:08:14.000000000 +0200 | |
+++ gcc-1.27/gcc.c 2019-01-26 18:40:26.382486847 +0100 | |
@@ -117,6 +117,7 @@ | |
#include <sys/types.h> | |
#include <signal.h> | |
#include <sys/file.h> | |
+#include <errno.h> | |
#include "config.h" | |
#include "obstack.h" | |
@@ -215,7 +216,7 @@ | |
%{g} %{O} %{W*} %{w} %{pedantic} %{ansi} %{traditional}\ | |
%{v:-version} %{gg:-symout %g.sym} %{pg:-p} %{p}\ | |
%{S:%{o*}%{!o*:-o %b.s}}%{!S:-o %g.s}\n\ | |
- %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %{gg:-G %g.sym}\ | |
+ %{!S:as --32 %{R} %{j} %{J} %{h} %{d2} %a %{gg:-G %g.sym}\ | |
%g.s %{c:%{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%b.o}\n }}}"}, | |
{".i", | |
"cc1 %i %1 %{!Q:-quiet} %{Y*} %{d*} %{m*} %{f*}\ | |
@@ -232,7 +233,7 @@ | |
}; | |
/* Here is the spec for running the linker, after compiling all files. */ | |
-char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld %{o*} %l\ | |
+char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld -m elf_i386 %{o*} %l\ | |
%{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\ | |
%{y*} %{!nostdlib:%S} \ | |
%{L*} %o %{!nostdlib:gnulib%s %{g:-lg} %L}\n }}}}"; | |
@@ -355,8 +356,8 @@ | |
char *standard_exec_prefix = STANDARD_EXEC_PREFIX; | |
char *standard_exec_prefix_1 = "/usr/lib/gcc-"; | |
-char *standard_startfile_prefix = "/lib/"; | |
-char *standard_startfile_prefix_1 = "/usr/lib/"; | |
+char *standard_startfile_prefix = "/lib32/"; | |
+char *standard_startfile_prefix_1 = "/usr/lib32/"; | |
/* Clear out the vector of arguments (after a command is executed). */ | |
@@ -1217,8 +1218,6 @@ | |
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 @@ | |
perror_with_name (name) | |
char *name; | |
{ | |
- extern int errno, sys_nerr; | |
- extern char *sys_errlist[]; | |
char *s; | |
if (errno < sys_nerr) | |
diff -ruN gcc-1.27.orig/include/ctype.h gcc-1.27/include/ctype.h | |
--- gcc-1.27.orig/include/ctype.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/ctype.h 2019-01-25 20:18:33.317567203 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _CTYPE_H | |
+#define _CTYPE_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/errno.h gcc-1.27/include/errno.h | |
--- gcc-1.27.orig/include/errno.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/errno.h 2019-01-25 20:19:04.589093218 +0100 | |
@@ -0,0 +1,9 @@ | |
+#ifndef _ERRNO_H | |
+#define _ERRNO_H | |
+ | |
+#define errno (*__errno_location()) | |
+extern int *__errno_location(void); | |
+extern int sys_nerr; | |
+extern const char *const sys_errlist[]; | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/fcntl.h gcc-1.27/include/fcntl.h | |
--- gcc-1.27.orig/include/fcntl.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/fcntl.h 2019-01-25 20:19:25.108782233 +0100 | |
@@ -0,0 +1,6 @@ | |
+#ifndef _FCNTL_H | |
+#define _GCNTL_H | |
+ | |
+#define O_RDONLY 0 | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/perror.h gcc-1.27/include/perror.h | |
--- gcc-1.27.orig/include/perror.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/perror.h 2019-01-25 20:19:47.476443267 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _PERROR_H | |
+#define _PERROR_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/setjmp.h gcc-1.27/include/setjmp.h | |
--- gcc-1.27.orig/include/setjmp.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/setjmp.h 2019-01-25 20:20:04.580184090 +0100 | |
@@ -0,0 +1,11 @@ | |
+#ifndef _SETJMP_H | |
+#define _SETJMP_H | |
+ | |
+struct __jmp_buf_tag | |
+{ | |
+ int _t[39]; | |
+}; | |
+ | |
+typedef struct __jmp_buf_tag jmp_buf[1]; | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/signal.h gcc-1.27/include/signal.h | |
--- gcc-1.27.orig/include/signal.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/signal.h 2019-01-25 22:15:49.967734626 +0100 | |
@@ -0,0 +1,12 @@ | |
+#ifndef _SIGNAL_H | |
+#define _SIGNAL_H | |
+ | |
+#define SIG_DFL 0 | |
+#define SIG_IGN 1 | |
+ | |
+#define SIGHUP 1 | |
+#define SIGINT 2 | |
+#define SIGSEGV 11 | |
+#define SIGTERM 15 | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/stdio.h gcc-1.27/include/stdio.h | |
--- gcc-1.27.orig/include/stdio.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/stdio.h 2019-01-25 20:26:59.863102621 +0100 | |
@@ -0,0 +1,12 @@ | |
+#ifndef _STDIO_H | |
+#define _STDIO_H | |
+ | |
+extern struct _IO_FILE *stderr; | |
+extern struct _IO_FILE *stdout; | |
+typedef struct _IO_FILE FILE; | |
+#define NULL 0 | |
+#define EOF (-1) | |
+ | |
+FILE *fopen(const char *, const char *); | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/file.h gcc-1.27/include/sys/file.h | |
--- gcc-1.27.orig/include/sys/file.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/file.h 2019-01-25 20:21:38.650759337 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _SYS_FILE_H | |
+#define _SYS_FILE_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/param.h gcc-1.27/include/sys/param.h | |
--- gcc-1.27.orig/include/sys/param.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/param.h 2019-01-25 20:22:02.786506014 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _SYS_PARAM_H | |
+#define _SYS_PARAM_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/resource.h gcc-1.27/include/sys/resource.h | |
--- gcc-1.27.orig/include/sys/resource.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/resource.h 2019-01-25 20:22:30.586210482 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _SYS_RESOURCE_H | |
+#define _SYS_RESOURCE_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/stat.h gcc-1.27/include/sys/stat.h | |
--- gcc-1.27.orig/include/sys/stat.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/stat.h 2019-01-25 20:58:18.132757639 +0100 | |
@@ -0,0 +1,32 @@ | |
+#ifndef _SYS_STAT_H | |
+#define _SYS_STAT_H | |
+ | |
+struct stat { | |
+ unsigned long st_dev; | |
+ unsigned long __st_dev; | |
+ unsigned int __pad1; | |
+ unsigned int st_ino; | |
+ unsigned int st_mode; | |
+ unsigned int st_nlink; | |
+ unsigned int st_uid; | |
+ unsigned int st_gid; | |
+ unsigned long st_rdev; | |
+ unsigned long __st_rdev; | |
+ unsigned long __pad2; | |
+ long st_size; | |
+ int st_blksize; | |
+ int st_blocks; | |
+ unsigned int st_atime; | |
+ unsigned int __st_atime; | |
+ unsigned int st_mtime; | |
+ unsigned int __st_mtime; | |
+ unsigned int st_ctime; | |
+ unsigned int __st_ctime; | |
+ int __pad3; | |
+ int __pad4; | |
+}; | |
+ | |
+#define S_IFREG 0x8000 | |
+#define S_IFMT 0xf000 | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/time.h gcc-1.27/include/sys/time.h | |
--- gcc-1.27.orig/include/sys/time.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/time.h 2019-01-25 20:24:00.313220536 +0100 | |
@@ -0,0 +1,4 @@ | |
+#include _SYS_TIME_H | |
+#define _SYS_TIME_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/times.h gcc-1.27/include/sys/times.h | |
--- gcc-1.27.orig/include/sys/times.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/times.h 2019-01-25 20:24:20.440991552 +0100 | |
@@ -0,0 +1,15 @@ | |
+#ifndef _SYS_TIMES | |
+#define _SYS_TIMES | |
+ | |
+#define HZ 100 | |
+ | |
+typedef long __kernel_clock_t; | |
+ | |
+struct tms { | |
+ __kernel_clock_t tms_utime; | |
+ __kernel_clock_t tms_stime; | |
+ __kernel_clock_t tms_cutime; | |
+ __kernel_clock_t tms_cstime; | |
+}; | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/sys/types.h gcc-1.27/include/sys/types.h | |
--- gcc-1.27.orig/include/sys/types.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/sys/types.h 2019-01-25 20:24:43.040731678 +0100 | |
@@ -0,0 +1,4 @@ | |
+#ifndef _SYS_TYPES_H | |
+#define _SYS_TYPES_H | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/include/time.h gcc-1.27/include/time.h | |
--- gcc-1.27.orig/include/time.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ gcc-1.27/include/time.h 2019-01-25 20:40:03.328705018 +0100 | |
@@ -0,0 +1,19 @@ | |
+#ifndef _TIME_H | |
+#define _TIME_H | |
+ | |
+struct tm | |
+{ | |
+ int tm_sec; | |
+ int tm_min; | |
+ int tm_hour; | |
+ int tm_mday; | |
+ int tm_mon; | |
+ int tm_year; | |
+ int tm_wday; | |
+ int tm_yday; | |
+ int tm_isdst; | |
+ long int tm_gmtoff; | |
+ const char *tm_zone; | |
+}; | |
+ | |
+#endif | |
diff -ruN gcc-1.27.orig/output-i386.c gcc-1.27/output-i386.c | |
--- gcc-1.27.orig/output-i386.c 1988-08-14 23:39:23.000000000 +0200 | |
+++ gcc-1.27/output-i386.c 2019-01-26 18:40:26.382486847 +0100 | |
@@ -339,7 +339,7 @@ | |
output_asm_insn ("fld%Q %0", &x); | |
} | |
-char *output_move_const_single (); | |
+static char *output_move_const_single (); | |
static char * | |
singlemove_string (operands) | |
diff -ruN gcc-1.27.orig/stdarg.h gcc-1.27/stdarg.h | |
--- gcc-1.27.orig/stdarg.h 1988-02-02 00:30:11.000000000 +0100 | |
+++ gcc-1.27/stdarg.h 2019-01-26 18:40:26.382486847 +0100 | |
@@ -19,4 +19,7 @@ | |
(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 -ruN gcc-1.27.orig/stddef.h gcc-1.27/stddef.h | |
--- gcc-1.27.orig/stddef.h 1988-05-14 07:05:30.000000000 +0200 | |
+++ gcc-1.27/stddef.h 2019-01-26 18:40:26.382486847 +0100 | |
@@ -7,7 +7,7 @@ | |
/* Unsigned type of `sizeof' something. */ | |
-typedef unsigned long size_t; | |
+typedef unsigned int size_t; | |
/* A null pointer constant. */ | |
diff -ruN gcc-1.27.orig/tm-i386v.h gcc-1.27/tm-i386v.h | |
--- gcc-1.27.orig/tm-i386v.h 1988-09-04 06:37:33.000000000 +0200 | |
+++ gcc-1.27/tm-i386v.h 2019-01-26 18:40:26.382486847 +0100 | |
@@ -32,9 +32,10 @@ | |
/* 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. */ | |
@@ -45,13 +46,13 @@ | |
#define IDENT_DIRECTIVE | |
#define SCCS_DIRECTIVE | |
-/* We want to output SDB debugging information. */ | |
+/* We don't want to output SDB debugging information. */ | |
-#define SDB_DEBUGGING_INFO | |
+#undef SDB_DEBUGGING_INFO | |
-/* We don't want to output DBX debugging information. */ | |
+/* We want to output DBX debugging information. */ | |
-#undef DBX_DEBUGGING_INFO | |
+#define DBX_DEBUGGING_INFO | |
/* Implicit library calls should use memcpy, not bcopy, etc. */ | |
@@ -59,6 +60,9 @@ | |
/* Don't write a `.optim' pseudo; this assembler doesn't handle them. */ | |
+#undef ASM_FILE_START | |
+#define ASM_FILE_START(FILE) | |
+ | |
#undef ASM_FILE_START_1 | |
#define ASM_FILE_START_1(FILE) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment