[gnu.g++] Compiling g++ on SUN3 w/OS4

strick@osc.COM (henry strickland) (08/13/89)

In article <919@dialogic.UUCP> gerry@dialogic.UUCP (Gerry Lachac) writes:
>
>I'm having trouble getting g++1.35 to work on a Sun 3 running SUN OS
>4.0.3.  I have compiled the g++ compiler and the library (libg++.a).
>The problem is that when I attempt to compile tests (the tests
>programs that come with libg++1.35) I receive a 
>
>	Undefined symbol __DYNAMIC referenced from text
>
>The makefile hints at problems with SUNOS4 and the linker.  Is there
>some fix for my problems?
>
>-- 
>uunet!dialogic!gerry   | 			   |	Dialogic Corporation
>	OR	       |  			   |	129 Littleton Rd
>gerry@dialogic.UUCP    |			   |	Parsippany, NJ 07054 
>		       |  			   |	(201)334-8450

Here was my unofficial solution to your problem (I wrote this for a friend
a while ago).   Be sure crt0+.o is in /usr/local/lib/.

===============================
README:

APPLY THIS DIFF TO g++/config/tm-sun3.h ....

** BUT FIRST ** notice that it is a symbolic link!

SO -- copy g++/config/tm-sun3.h somewhere, remove the link, and copy it back.
BECAUSE you don't want these diffs in the "gcc" -- only in the "g++".   

WHAT THESE DO:  make g++ look for the c runtime "crt0+.o" rather than
the usual "crt0.o".   "crt0+.o" knows how to initialize global and static
objects with constructors,  using lists make by g++'s ld++ linker, which
has a built-in muncher (rather than using a separate munch program like
at&t does).   

If you use this on something besides a sun3, you may have to make similar
diffs to other dot-h files.

					strick

==========================

*** tm-sun3.h.orig	Wed Feb 22 09:27:23 1989
--- tm-sun3.h	Tue Jul  4 15:20:39 1989
***************
*** 77,84 ****
  
  #if TARGET_DEFAULT & 0100
  /* -mfpa is the default */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}	\
     %{m68881:Mcrt1.o%s}					\
     %{msoft-float:Fcrt1.o%s}				\
     %{!m68881:%{!msoft-float:Wcrt1.o%s}}"
--- 77,85 ----
  
  #if TARGET_DEFAULT & 0100
  /* -mfpa is the default */
+ /* ------> NOTA BENE: strick adds the "+" to  p:crt0.o%s.   4jul89 */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0+.o%s}}	\
     %{m68881:Mcrt1.o%s}					\
     %{msoft-float:Fcrt1.o%s}				\
     %{!m68881:%{!msoft-float:Wcrt1.o%s}}"
***************
*** 85,99 ****
  #else
  #if TARGET_DEFAULT & 2
  /* -m68881 is the default */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}	\
     %{mfpa:Wcrt1.o%s}					\
     %{msoft-float:Fcrt1.o%s}				\
     %{!mfpa:%{!msoft-float:Mcrt1.o%s}}"
  #else
  /* -msoft-float is the default */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}	\
     %{m68881:Mcrt1.o%s}					\
     %{mfpa:Wcrt1.o%s}					\
     %{!m68881:%{!mfpa:Fcrt1.o%s}}"
--- 86,102 ----
  #else
  #if TARGET_DEFAULT & 2
  /* -m68881 is the default */
+ /* ------> NOTA BENE: strick adds the "+" to  p:crt0.o%s.   4jul89 */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0+.o%s}}	\
     %{mfpa:Wcrt1.o%s}					\
     %{msoft-float:Fcrt1.o%s}				\
     %{!mfpa:%{!msoft-float:Mcrt1.o%s}}"
  #else
  /* -msoft-float is the default */
+ /* ------> NOTA BENE: strick adds the "+" to  p:crt0.o%s.   4jul89 */
  #define STARTFILE_SPEC					\
!   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0+.o%s}}	\
     %{m68881:Mcrt1.o%s}					\
     %{mfpa:Wcrt1.o%s}					\
     %{!m68881:%{!mfpa:Fcrt1.o%s}}"
-- 
					strick@osc.osc.com     415-325-2300
					uunet!lll-winken!pacbell!osc!strick
					( strick@gatech.edu )