jon@nucleus.mi.org (Jon Block) (02/13/91)
These patches will let you build g++ for ISC 2.0.2. They are based
on the excellent previous postings of Ronald Cole and Michael Bloom.
the only additional change you need is to ln cplus-cadillac.c to
cplus-edsel.c (otherwise the assembler has problems with .filename).
I have compiled libg++-1.37.0, groff-1.00, and InterViews 2.6 with
these patches, and the only thing that seemed odd is that one file
in idraw wouldn't compile with -g and without -O. With both, it
compiled fine, but you may want to make sure you optimize when
you generate debugging info.
---------- cut here ----------
diff -rc2 g++old/Makefile g++-1.39.0/Makefile
*** g++old/Makefile Tue Feb 12 20:48:04 1991
--- g++-1.39.0/Makefile Tue Feb 12 20:46:09 1991
***************
*** 42,47 ****
--- 42,51 ----
# On COFF systems, use one of the definitions below. (see collect.c)
+ # Use one of these for coff systems with a broken loader:
# COFFLAGS = -DUSE_COLLECT -DCOFF
# COFFLAGS = -DUSE_COLLECT -DEXTENDED_COFF
+ # use this with for coff systems with properly working coff loaders:
+ # (this does not include sun386)
+ COFFLAGS = -DCOFF -DUSE_GPLUS_IFILE
# On some BSD systems (like Vax, unlike Sun), there is no file
***************
*** 60,64 ****
INSTALL = install -c
# on sysV, define this as ln.
! LINK = ln -s
# Compiler to use for compiling gnulib.
--- 64,68 ----
INSTALL = install -c
# on sysV, define this as ln.
! LINK = ln# -s
# Compiler to use for compiling gnulib.
***************
*** 78,82 ****
# USG_STDIO = -DUSG_STDIO
! prefix=/tools/gnu
# Directory where sources are, from where we are.
--- 82,86 ----
# USG_STDIO = -DUSG_STDIO
! prefix=/usr/local
# Directory where sources are, from where we are.
***************
*** 210,217 ****
# gnulib is not a target because a proper installation of GNU CC
# will place it where g++ can find it. Same with cpp
! all: crt1+.o g++ cc1plus ld++ g++filt # collect crt0+.o
! # On COFF systems, use the target below.
! # all: g++ cc1plus collect # crt0+.o crt1+.o
doc: $(srcdir)/cpp.info $(srcdir)/g++.info
--- 214,226 ----
# gnulib is not a target because a proper installation of GNU CC
# will place it where g++ can find it. Same with cpp
! # all: crt1+.o g++ cc1plus ld++ g++filt # collect crt0+.o
+ # On COFF systems with a properly working coff loader, use the target below.
+ all: g++ cc1plus gnulib3.o g++.ifile
+
+ # On COFF systems without a properly working coff loader (such as sun386),
+ # use the target below.
+ # all: g++ cc1plus gnulib3.o collect
+
doc: $(srcdir)/cpp.info $(srcdir)/g++.info
***************
*** 297,300 ****
--- 306,315 ----
$(CC) -o collect2 collect2.c $(PROFILE) $$COLLECT_OPTIONS $(CFLAGS) $(INCLUDES) -lc
+ make_ifile: make_ifile.o
+ $(CC) -o make_ifile make_ifile.o
+
+ g++.ifile: make_ifile
+ make_ifile >g++.ifile
+
g++filt: g++filt.o cplus-dem.o
$(CC) -o g++filt g++filt.o cplus-dem.o
***************
*** 357,362 ****
cplus-cadillac.o : cplus-cadillac.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h
$(CC) -c -DCADILLAC $(CFLAGS) $(INCLUDES) -I../cadillac/code/comp-dep -I../cadillac/code/connection $<
! cplus-edsel.o : cplus-cadillac.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h
! $(CC) -c $(CFLAGS) $(INCLUDES) -o cplus-edsel.o cplus-cadillac.c
cplus-tab.o : $(srcdir)/cplus-tab.c $(CONFIG_H) $(CPLUS_TREE_H) \
--- 372,377 ----
cplus-cadillac.o : cplus-cadillac.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h
$(CC) -c -DCADILLAC $(CFLAGS) $(INCLUDES) -I../cadillac/code/comp-dep -I../cadillac/code/connection $<
! cplus-edsel.o : cplus-edsel.c $(CONFIG_H) $(CPLUS_TREE_H) stack.h
! $(CC) -c $(CFLAGS) $(INCLUDES) -o cplus-edsel.o cplus-edsel.c
cplus-tab.o : $(srcdir)/cplus-tab.c $(CONFIG_H) $(CPLUS_TREE_H) \
***************
*** 611,614 ****
--- 626,630 ----
-if [ -f cc1plus ] ; then $(INSTALL) cc1plus $(libdir)/gcc-cc1plus ;fi
-if [ -f collect ] ; then $(INSTALL) collect $(libdir)/gcc-collect ;fi
+ -if [ -f g++.ifile ] ; then $(INSTALL) g++.ifile $(libdir)/g++.ifile ;fi
-if [ -f collect2 ] ; then $(INSTALL) collect2 $(libdir)/gcc-ld ;fi
$(INSTALL) g++ $(bindir)
diff -rc2 g++old/config/tm-att386.h g++-1.39.0/config/tm-att386.h
*** g++old/config/tm-att386.h Tue Feb 12 20:47:28 1991
--- g++-1.39.0/config/tm-att386.h Tue Feb 12 21:05:13 1991
***************
*** 150,153 ****
--- 150,193 ----
#define BSS_SECTION_ASM_OP ".bss"
+ #ifdef USE_GPLUS_IFILE
+
+ /* section defs for [con,de]structors */
+
+ #define CTORS_SECTION_ASM_OP ".section\t.ctor,\"w\""
+ #define DTORS_SECTION_ASM_OP ".section\t.dtor,\"w\""
+
+ #define EXTRA_SECTIONS in_bss, in_ctors, in_dtors
+
+ #define EXTRA_SECTION_FUNCTIONS \
+ void \
+ bss_section () \
+ { \
+ if (in_section != in_bss) \
+ { \
+ fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); \
+ in_section = in_bss; \
+ } \
+ } \
+ \
+ void \
+ ctors_section () \
+ { \
+ if (in_section != in_ctors) \
+ { \
+ fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
+ in_section = in_ctors; \
+ } \
+ } \
+ \
+ void \
+ dtors_section () \
+ { \
+ if (in_section != in_dtors) \
+ { \
+ fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
+ in_section = in_dtors; \
+ } \
+ }
+ #else
#define EXTRA_SECTIONS in_bss
***************
*** 162,165 ****
--- 202,207 ----
} \
}
+ #endif
+
/* Define the syntax of labels and symbol definitions/declarations. */
diff -rc2 g++old/config/tm-i386v.h g++-1.39.0/config/tm-i386v.h
*** g++old/config/tm-i386v.h Tue Feb 12 20:47:35 1991
--- g++-1.39.0/config/tm-i386v.h Tue Feb 12 21:05:13 1991
***************
*** 30,37 ****
--- 30,46 ----
/* Use crt1.o as a startup file and crtn.o as a closing file. */
+ #ifdef USE_GPLUS_IFILE
+ /* ATT assembler can't handle $ in label */
+ #define NO_DOLLAR_IN_LABEL
+
+ #define STARTFILE_SPEC \
+ "g++.ifile%s %{pg:gcrt1.o%s}%{!pg:%{posix:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}%{!posix:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}\
+ %{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}"
+ #else
#define STARTFILE_SPEC \
"%{pg:gcrt1.o%s}%{!pg:%{posix:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}%{!posix:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}\
%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}"
+ #endif
#define LIB_SPEC "%{posix:-lcposix} %{shlib:-lc_s} -lc crtn.o%s"
diff -rc2 g++old/cplus-field.c g++-1.39.0/cplus-field.c
*** g++old/cplus-field.c Tue Feb 12 20:48:05 1991
--- g++-1.39.0/cplus-field.c Tue Feb 12 20:46:09 1991
***************
*** 19,23 ****
#include <strings.h>
!
--- 19,25 ----
#include <strings.h>
! #ifdef USG
! #define rindex strrchr
! #endif
***************
*** 247,251 ****
--- 249,261 ----
if (wd_name == NULL) {
+ #ifdef USG
+ {
+ extern char *getcwd();
+ if (getcwd (wdbuf, 1024) == 0)
+ strcpy (wdbuf, ".");
+ }
+ #else
getwd(wdbuf);
+ #endif
wd_name = SALLOC(wdbuf);
};
diff -rc2 g++old/cplus-lex.c g++-1.39.0/cplus-lex.c
*** g++old/cplus-lex.c Tue Feb 12 20:48:05 1991
--- g++-1.39.0/cplus-lex.c Tue Feb 12 20:46:09 1991
***************
*** 51,54 ****
--- 51,58 ----
#define obstack_chunk_free free
+ #ifdef USG
+ #include "getpagesize.h"
+ #endif
+
extern int xmalloc ();
extern void free ();
diff -rc2 g++old/gnulib3.c g++-1.39.0/gnulib3.c
*** g++old/gnulib3.c Tue Feb 12 20:48:05 1991
--- g++-1.39.0/gnulib3.c Tue Feb 12 20:46:10 1991
***************
*** 1,2 ****
--- 1,6 ----
+ #ifdef USE_GPLUS_IFILE
+ extern int __CTOR_LEN__;
+ extern int __DTOR_LEN__;
+ #endif
typedef struct set_vector
{
***************
*** 47,50 ****
--- 51,62 ----
#endif
+
+ #ifdef USE_GPLUS_IFILE
+ __CTOR_LIST__.length = (int) &__CTOR_LEN__;
+
+ __DTOR_LIST__.length = (int) &__DTOR_LEN__;
+
+ #endif
+
__dli = __DTOR_LIST__.length;
__dlp = &__DTOR_LIST__;
diff -rc2 g++old/make_ifile.c g++-1.39.0/make_ifile.c
*** g++old/make_ifile.c Tue Feb 12 20:48:35 1991
--- g++-1.39.0/make_ifile.c Tue Feb 12 20:50:24 1991
***************
*** 0 ****
--- 1,102 ----
+ /* Output a loader directive file to be used for merging constructor
+ and destructor coff sections.
+
+ This file is part of GNU CC.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY. No author or distributor
+ accepts responsibility to anyone for the consequences of using it
+ or for whether it serves any particular purpose or works at all,
+ unless he says so in writing. Refer to the GNU CC General Public
+ License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute
+ GNU CC, but only under the conditions described in the
+ GNU CC General Public License. A copy of this license is
+ supposed to have been given to you along with GNU CC so you
+ can know your rights and responsibilities. It should be in a
+ file named COPYING. Among other things, the copyright notice
+ and this notice must be preserved on all copies. */
+
+ /* This file attempts to generate a loader directive file for use
+ with ld when called from g++ on your system. On System V Systems,
+ the data segment must be bound to an address in a region whose
+ starting address is in a different hardware segment than the last
+ hardware segment containing text. On many (most?) System V systems,
+ the value to use for this is defined as NBPS in <sys/param.h>. Some
+ System V systems apparently do not have this definition, however.
+ For these systems, we guess at a 0x400000 size boundary. This happens
+ to be correct for at least one Sysem V/386 system. I am curious
+ to hear of any changes needed that might be needed for other systems.
+
+ Michael Bloom
+ - mb@ttidca.tti.com
+ */
+
+
+ #include <sys/param.h>
+
+ #define TEXT_OFFSET 0x200
+ #define TEXT_START 0x400000
+ #define TEXT_ADDRESS (TEXT_START+TEXT_OFFSET)
+
+ #ifdef NBPS
+ #define SEGSIZE NBPS
+ #else
+ #define SEGSIZE 0x400000 /* overkill, but should work. */
+ #endif
+ main()
+ {
+ printf("\n\
+ /*\n\
+ *\tBLOCK to an offset that leaves room for many headers ( the value\n\
+ *\there allows for a file header, an outheader, and up to 11 section \n\
+ *\theaders on most systems.\n\
+ *\tBIND to an address that excludes page 0 from being mapped. The value\n\
+ *\tused for BLOCK should be or'd into this value. Here I'm setting BLOCK\n\
+ *\tto 0x200 and BIND to ( 0x400000 | value_used_for(BLOCK) )\n\
+ *\tIf you are using shared libraries, watch that you don't overlap the\n\
+ *\taddress ranges assigned for shared libs.\n\
+ *\n\
+ *\tGROUP BIND to a location in the next segment. Here, the only value\n\
+ *\tthat you should change (I think) is that within NEXT, which I've set\n\
+ *\tto my hardware segment size. You can always use a larger size, but not\n\
+ *\ta smaller one.\n\
+ *\t\n\
+ *\tNote the items marked \"placeholder for count\". These will be filled in\n\
+ *\twithin gnulib3.\n\
+ */");
+
+ printf("\n\
+ SECTIONS\n\
+ {\n\
+ .text BIND(0x%x) BLOCK (0x%x) :\n\
+ {\n\
+ /* plenty for room for headers */\n\
+ *(.init)\n\
+ *(.text)\n\
+ vfork = fork; /* I got tired of editing peoples sloppy code */\n\
+ *(.fini)\n\
+ }\n\
+ GROUP BIND( NEXT(0x%x) + ADDR(.text) + SIZEOF(.text)):",
+ TEXT_ADDRESS, TEXT_OFFSET, SEGSIZE);
+ printf("\n\
+ {\n\
+ .data : {\n\
+ __CTOR_LIST__ = . ; \n\
+ . += 4; /* placeholder for count*/\n\
+ *(.ctor) \n\
+ __CTOR_LEN__ = (. - (__CTOR_LIST__ + 4 )) / 4 ;\n\
+ . += 4 ; /* trailing NULL */\n\
+ __DTOR_LIST__ = . ;\n\
+ . += 4; /* placeholder for count*/\n\
+ *(.dtor) \n\
+ __DTOR_LEN__ = ( . - (__DTOR_LIST__ + 4 ) )/4 ;\n\
+ . += 4 ; /* trailing NULL */\n\
+ }\n\
+ .bss : { }\n\
+ }\n\
+ }\n");
+
+ exit(0);
+ }
diff -rc2 g++old/stmt.c g++-1.39.0/stmt.c
*** g++old/stmt.c Tue Feb 12 20:48:06 1991
--- g++-1.39.0/stmt.c Tue Feb 12 20:46:10 1991
***************
*** 1731,1734 ****
--- 1731,1739 ----
block = block->next;
+ /* Only use `last_insn' if there are cleanups which must be run. */
+
+ if (block || cleanup_label != 0)
+ last_insn = get_last_insn ();
+
/* If yes, use a goto to return, since that runs cleanups. */
diff -rc2 g++old/symout.c g++-1.39.0/symout.c
*** g++old/symout.c Tue Feb 12 20:48:07 1991
--- g++-1.39.0/symout.c Tue Feb 12 20:46:11 1991
***************
*** 1243,1247 ****
buffer.filedir = (char *) next_address;
#ifdef USG
! strcpy (dir, getcwd (dir, MAXNAMLEN));
#else
#ifndef VMS
--- 1243,1251 ----
buffer.filedir = (char *) next_address;
#ifdef USG
! {
! extern char *getcwd();
! if (getcwd (dir, MAXNAMLEN) == 0)
! strcpy (dir, ".");
! }
#else
#ifndef VMS
diff -rc2 g++old/toplev.c g++-1.39.0/toplev.c
*** g++old/toplev.c Tue Feb 12 20:48:08 1991
--- g++-1.39.0/toplev.c Tue Feb 12 20:46:12 1991
***************
*** 42,45 ****
--- 42,46 ----
#ifdef USG
+ #include "getpagesize.h"
#include <sys/fcntl.h>
#undef FLOAT
diff -rc2 g++old/varasm.c g++-1.39.0/varasm.c
*** g++old/varasm.c Tue Feb 12 20:48:08 1991
--- g++-1.39.0/varasm.c Tue Feb 12 21:01:06 1991
***************
*** 38,41 ****
--- 38,45 ----
#include "obstack.h"
+ #ifdef USE_GPLUS_IFILE
+ #include "cplus-tree.h"
+ #endif
+
#define MIN(a, b) ((a) < (b) ? (a) : (b))
***************
*** 315,318 ****
--- 319,325 ----
char *fnname;
int align;
+ #ifdef USE_GPLUS_IFILE
+ int is_file_ctor_or_dtor = 0;
+ #endif
/* Get the function's name, as described by its RTL.
***************
*** 331,334 ****
--- 338,360 ----
app_disable ();
+ #ifdef USE_GPLUS_IFILE
+ if (is_file_ctor_or_dtor = !strncmp (FILE_FUNCTION_FORMAT, fnname, FILE_FUNCTION_PREFIX_LEN)) {
+ switch (fnname[FILE_FUNCTION_PREFIX_LEN]) {
+ case 'I':
+ ctors_section();
+ ASM_OUTPUT_INT(asm_out_file, n);
+ break;
+ case 'D':
+ dtors_section();
+ ASM_OUTPUT_INT(asm_out_file, n);
+ break;
+ case 'Z':
+ break;
+ default:
+ abort();
+ }
+ }
+ #endif
+
output_constant_pool (fnname, decl);
***************
*** 354,364 ****
/* Make function name accessible from other files, if appropriate. */
!
! if (TREE_PUBLIC (decl))
! {
! if (!first_global_object_name)
! first_global_object_name = fnname;
! ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
! }
/* Do any machine/system dependent processing of the function name */
--- 380,392 ----
/* Make function name accessible from other files, if appropriate. */
! #ifdef USE_GPLUS_IFILE
! if (!is_file_ctor_or_dtor) /* don't globalize ctor's, dtor's */
! #endif
! if (TREE_PUBLIC (decl))
! {
! if (!first_global_object_name)
! first_global_object_name = fnname;
! ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
! }
/* Do any machine/system dependent processing of the function name */