38e012594e
From-SVN: r19601
448 lines
14 KiB
Plaintext
448 lines
14 KiB
Plaintext
[This file contains two alternative recipes for compiling X11 with GCC.
|
||
The first alternative puts libgcc.a into the shared X library; the second
|
||
does not. Neither alternative works on all kinds of systems.
|
||
It may be that when using GCC 2.4, both alternatives work okay on
|
||
relatively recent Sparc systems. The first alternative is likely
|
||
not to work on a Sun 3 without hardware floating point.]
|
||
|
||
How to compile X11R5 (patch level 11) with GCC version 2:
|
||
|
||
The patches include support for building the shared libraries with GCC
|
||
2 on the Sparc and 68k machines. This version includes the necessary
|
||
parts of libgcc.a in the shared library for X, in case functions in
|
||
that library need it. Thus the default behavior is now to build
|
||
everything, including the libraries, with gcc.
|
||
|
||
If you build the shared library this way, it may not work with
|
||
executables made with older versions of GCC (2.3.3 and earlier).
|
||
If that happens, relink those executables with the latest GCC.
|
||
IF YOU THINK YOU MIGHT COMPILE X FOR SOLARIS 2, then you really don't
|
||
need this patch: get /contrib/R5.SunOS5.patch.tar.Z from
|
||
export.lcs.mit.edu instead. It has everything you need to do the
|
||
build for Solaris 2, sets you up to everything with GCC, and is
|
||
backward compatible with SunOS 4.*. Get the README
|
||
(/contrib/R5.SunOS5.patch.README at export) for more info.
|
||
|
||
If you see undefined symbols _dlopen, _dlsym, or _dlclose when linking
|
||
with -lX11, compile and link against the file mit/util/misc/dlsym.c in
|
||
the MIT X11R5 distribution. Alternatively, do dynamic linking
|
||
by using a non-GNU ld.
|
||
|
||
mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2.
|
||
If -fstrength-reduce (or any other -f option) is a major win, then it
|
||
will most likely be turned on by -O2 optimization.
|
||
|
||
mit/config/sunLib.rules -- If HasGcc and GccVersion > 1 are true, then
|
||
use gcc -fpic to generate PIC code. Make sure that gcc does not use
|
||
gas (the GNU assembler) when compiling PIC code; gas does not assemble
|
||
it correctly.
|
||
|
||
***If you have gas installed where gcc uses it by default, you might have
|
||
to add -B/bin/ to the PositionIndependentCFlags.***
|
||
|
||
mit/config/site.def -- Define GccVersion to be 2.
|
||
|
||
mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
|
||
|
||
mit/config/sunLib.rules -- When compiling with GCC 2, use -fpic for
|
||
position independent code generation.
|
||
|
||
mit/rgb/Imakefile -- No longer need to compile some modules with
|
||
cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
|
||
|
||
mit/server/os/Imakefile -- Likewise.
|
||
|
||
mit/server/ddx/sun/Imakefile -- When compiling with GCC 2, some modules
|
||
should be compiled with -fvolatile.
|
||
|
||
mit/clients/twm/Imakefile -- Fix bad decls of malloc, realloc in gram.c.
|
||
|
||
mit/lib/X/Imakefile -- Make libgcc.a a required lib for libX11.so
|
||
|
||
*** mit/clients/twm/Imakefile Mon May 17 22:05:22 1993
|
||
--- new/clients/twm/Imakefile Mon May 17 22:28:46 1993
|
||
***************
|
||
*** 32,41 ****
|
||
--- 32,48 ----
|
||
ComplexProgramTarget(twm)
|
||
InstallNonExecFile(system.twmrc,$(TWMDIR))
|
||
|
||
+ #if HasGcc && GccVersion > 1 && defined (SunArchitecture)
|
||
gram.h gram.c: gram.y
|
||
yacc $(YFLAGS) gram.y
|
||
+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
|
||
+ $(MV) y.tab.h gram.h
|
||
+ #else
|
||
+ gram.h gram.c: gram.y
|
||
+ yacc $(YFLAGS) gram.y
|
||
$(MV) y.tab.c gram.c
|
||
$(MV) y.tab.h gram.h
|
||
+ #endif
|
||
|
||
clean::
|
||
$(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c
|
||
*** mit/config/Imake.tmpl Mon May 17 22:02:57 1993
|
||
--- new/config/Imake.tmpl Mon May 17 22:15:06 1993
|
||
***************
|
||
*** 500,506 ****
|
||
--- 500,510 ----
|
||
#endif
|
||
#ifndef CcCmd
|
||
#if HasGcc
|
||
+ #if GccVersion > 1
|
||
+ #define CcCmd gcc -fpcc-struct-return
|
||
+ #else
|
||
#define CcCmd gcc -fstrength-reduce -fpcc-struct-return
|
||
+ #endif
|
||
#else
|
||
#define CcCmd cc
|
||
#endif
|
||
*** mit/config/site.def Mon May 17 22:02:44 1993
|
||
--- new/config/site.def Mon May 17 22:22:28 1993
|
||
***************
|
||
*** 25,31 ****
|
||
|
||
#ifdef BeforeVendorCF
|
||
|
||
! /* #define HasGcc YES */
|
||
|
||
#endif /* BeforeVendorCF */
|
||
|
||
--- 25,33 ----
|
||
|
||
#ifdef BeforeVendorCF
|
||
|
||
! #define HasGcc YES
|
||
! /* GccVersion > 1 implies building shared libraries with gcc */
|
||
! #define GccVersion 2
|
||
|
||
#endif /* BeforeVendorCF */
|
||
|
||
*** mit/config/sun.cf Mon May 17 22:03:02 1993
|
||
--- new/config/sun.cf Mon May 17 22:24:55 1993
|
||
***************
|
||
*** 41,49 ****
|
||
--- 41,55 ----
|
||
|
||
#if HasGcc
|
||
|
||
+ #if GccVersion > 1
|
||
+ #define OptimizedCDebugFlags -O2
|
||
+ #else
|
||
+ #define OptimizedCDebugFlags -O
|
||
#define SharedLibraryCcCmd cc
|
||
#define ExtraLoadFlags -B/usr/bin/
|
||
#define AllocateLocalDefines /**/
|
||
+ #endif
|
||
+
|
||
|
||
.c.o:
|
||
$(CC) -c $(CFLAGS) $*.c
|
||
*** mit/config/sunLib.rules Mon May 17 22:02:46 1993
|
||
--- new/config/sunLib.rules Mon May 17 22:19:06 1993
|
||
***************
|
||
*** 23,29 ****
|
||
--- 23,33 ----
|
||
#define SharedLibraryLoadFlags -assert pure-text
|
||
#endif
|
||
#ifndef PositionIndependentCFlags
|
||
+ #if defined(HasGcc) && GccVersion > 1
|
||
+ #define PositionIndependentCFlags -fpic
|
||
+ #else
|
||
#define PositionIndependentCFlags -pic
|
||
+ #endif
|
||
#endif
|
||
|
||
/*
|
||
*** mit/lib/X/Imakefile Mon May 17 22:05:03 1993
|
||
--- new/lib/X/Imakefile Mon May 17 22:32:26 1993
|
||
***************
|
||
*** 9,14 ****
|
||
--- 9,31 ----
|
||
#define MotifBC NO
|
||
#endif
|
||
|
||
+ #if defined(SunArchitecture)
|
||
+ #if SystemV4
|
||
+ #if HasGcc
|
||
+ REQUIREDLIBS= -lgcc -lc
|
||
+ #else
|
||
+ REQUIREDLIBS= -lc
|
||
+ #endif
|
||
+ #else
|
||
+ #if HasGcc && GccVersion > 1
|
||
+ XCOMM Hack to fix gcc 2 ``-nostdlib'' deficiency on SunOS 4.x
|
||
+ REQUIREDLIBS= `gcc -v 2>&1 | awk '{print $$4}' | sed -e 's/specs$$/libgcc.a/'`
|
||
+ #else
|
||
+ REQUIREDLIBS=
|
||
+ #endif
|
||
+ #endif
|
||
+ #endif
|
||
+
|
||
#ifndef BuildXimp
|
||
#define BuildXimp NO
|
||
#endif
|
||
*** mit/rgb/Imakefile Mon May 17 22:05:31 1993
|
||
--- new/rgb/Imakefile Mon May 17 22:25:30 1993
|
||
***************
|
||
*** 17,23 ****
|
||
#if !(defined(SGIArchitecture) || SystemV4)
|
||
DBMLIB = -ldbm
|
||
#endif
|
||
! #if defined(SparcArchitecture) && HasGcc
|
||
CC = cc
|
||
CCOPTIONS = /**/
|
||
EXTRA_LOAD_FLAGS = /**/
|
||
--- 17,23 ----
|
||
#if !(defined(SGIArchitecture) || SystemV4)
|
||
DBMLIB = -ldbm
|
||
#endif
|
||
! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
|
||
CC = cc
|
||
CCOPTIONS = /**/
|
||
EXTRA_LOAD_FLAGS = /**/
|
||
*** mit/server/ddx/sun/Imakefile Mon May 17 22:05:57 1993
|
||
--- new/server/ddx/sun/Imakefile Mon May 17 22:27:23 1993
|
||
***************
|
||
*** 43,48 ****
|
||
--- 43,53 ----
|
||
LinkFile(sunGX.o,sunGX.o.dist)
|
||
#endif
|
||
|
||
+ #if HasGcc && GccVersion > 1
|
||
+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
|
||
+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
|
||
+ #endif
|
||
+
|
||
sunInitExtMono.o: $(ICONFIGFILES)
|
||
ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
|
||
ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
|
||
*** mit/server/os/Imakefile Mon May 17 22:05:46 1993
|
||
--- new/server/os/Imakefile Mon May 17 22:26:02 1993
|
||
***************
|
||
*** 132,138 ****
|
||
SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
|
||
SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
|
||
SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
|
||
! #if defined(SparcArchitecture) && HasGcc
|
||
oscolor.o: $(ICONFIGFILES)
|
||
$(RM) $@
|
||
cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
|
||
--- 132,138 ----
|
||
SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
|
||
SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
|
||
SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
|
||
! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
|
||
oscolor.o: $(ICONFIGFILES)
|
||
$(RM) $@
|
||
cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
|
||
|
||
|
||
[This is the older version]
|
||
|
||
How to compile X11R5 (patch level 11) with GCC version 2:
|
||
|
||
The patches include support for building the shared libraries with GCC 2 on
|
||
the Sparc and 68k machines.
|
||
|
||
NOTE: Such shared libraries built with GCC version 2.3 DID NOT WORK
|
||
with executables previously linked using Sun CC! This is because
|
||
neither those executables nor the gcc-compiled shared libraries contain
|
||
libgcc.a. The shared libraries did work with executables linked using
|
||
GCC (running the Sun linker, of course) because GCC tells the linker to
|
||
link in libgcc.a. Because of these limitations the default behavior is
|
||
to NOT build the shared libraries with gcc.
|
||
|
||
Changes in GCC 2.4 seem to have eliminated the problem, and such a
|
||
shared library now seems work with all executables. If you want the
|
||
gcc-compiled shared libraries turn on "Gcc2BuildLibs" in site.def. If
|
||
you try this, please tell bug-gcc@prep.ai.mit.edu whether it works.
|
||
|
||
Sun forgot to include a static version of libdl.a with some versions
|
||
of SunOS (4.1 mainly). If you see undefined symbols _dlopen, _dlsym,
|
||
or _dlclose when linking with -lX11, compile and link against the file
|
||
mit/util/misc/dlsym.c in the MIT X11R5 distribution.
|
||
|
||
mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. If
|
||
-fstrength-reduce (or any other -f option) is a major win, then it will
|
||
most likely be turned on by -O2 optimization.
|
||
|
||
mit/config/sunLib.rules -- If HasGcc2 and Gcc2BuildLibs are defined, then
|
||
use gcc -fpic to generate PIC code. Make sure that gcc does not use gas (the
|
||
GNU assembler) when compiling PIC code; gas does not assemble it correctly.
|
||
If you have gas installed where gcc uses it by default, you might have to add
|
||
-B/bin/ to the PositionIndependentCFlags.
|
||
|
||
mit/config/site.def -- Define HasGcc2 to be YES.
|
||
|
||
mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
|
||
|
||
mit/rgb/Imakefile -- No longer need to compile some modules with
|
||
cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
|
||
|
||
mit/server/os/Imakefile -- Likewise.
|
||
|
||
mit/clients/twm/Imakefile -- fix bad decls of malloc, realloc in gram.c.
|
||
|
||
*** mit/config/Imake.tmpl.ORIG Tue Dec 31 11:07:56 1991
|
||
--- mit/config/Imake.tmpl Tue Dec 31 12:30:47 1991
|
||
***************
|
||
*** 499,508 ****
|
||
--- 499,512 ----
|
||
#define HasGcc NO
|
||
#endif
|
||
#ifndef CcCmd
|
||
+ #if HasGcc2
|
||
+ #define CcCmd gcc -fpcc-struct-return
|
||
+ #else
|
||
#if HasGcc
|
||
#define CcCmd gcc -fstrength-reduce -fpcc-struct-return
|
||
#else
|
||
#define CcCmd cc
|
||
+ #endif
|
||
#endif
|
||
#endif
|
||
#if HasFortran
|
||
*** mit/config/sunLib.rules.ORIG Tue Dec 31 11:11:24 1991
|
||
--- mit/config/sunLib.rules Tue May 5 12:26:12 1992
|
||
***************
|
||
*** 23,30 ****
|
||
--- 23,34 ----
|
||
#define SharedLibraryLoadFlags -assert pure-text
|
||
#endif
|
||
#ifndef PositionIndependentCFlags
|
||
+ #if defined(HasGcc2) && defined (Gcc2BuildLibs)
|
||
+ #define PositionIndependentCFlags -fpic
|
||
+ #else
|
||
#define PositionIndependentCFlags -pic
|
||
#endif
|
||
+ #endif
|
||
|
||
/*
|
||
* InstallSharedLibrary - generate rules to install the shared library.
|
||
*** mit/config/site.def.ORIG Tue Dec 31 11:13:49 1991
|
||
--- mit/config/site.def Tue Dec 31 12:02:59 1991
|
||
***************
|
||
*** 25,31 ****
|
||
|
||
#ifdef BeforeVendorCF
|
||
|
||
! /* #define HasGcc YES */
|
||
|
||
#endif /* BeforeVendorCF */
|
||
|
||
--- 25,33 ----
|
||
|
||
#ifdef BeforeVendorCF
|
||
|
||
! #define HasGcc YES
|
||
! #define HasGcc2 YES
|
||
! /* #define Gcc2BuildLibs YES */
|
||
|
||
#endif /* BeforeVendorCF */
|
||
|
||
*** mit/config/sun.cf.ORIG Tue Dec 31 11:13:57 1991
|
||
--- mit/config/sun.cf Tue May 5 12:29:50 1992
|
||
***************
|
||
*** 34,42 ****
|
||
--- 41,61 ----
|
||
|
||
#if HasGcc
|
||
|
||
+ #if defined(HasGcc2)
|
||
+ #define OptimizedCDebugFlags -O2
|
||
+ /* Leave Alone XXX */
|
||
+ #else
|
||
+ #define OptimizedCDebugFlags -O
|
||
#define SharedLibraryCcCmd cc
|
||
#define ExtraLoadFlags -B/usr/bin/
|
||
#define AllocateLocalDefines /**/
|
||
+ #endif
|
||
+
|
||
+ #if !defined(Gcc2BuildLibs)
|
||
+ #define SharedLibraryCcCmd cc
|
||
+ #define ExtraLoadFlags -B/usr/bin/
|
||
+ #define AllocateLocalDefines /**/
|
||
+ #endif
|
||
|
||
.c.o:
|
||
$(CC) -c $(CFLAGS) $*.c
|
||
*** mit/rgb/Imakefile.ORIG Wed Jan 15 16:43:18 1992
|
||
--- mit/rgb/Imakefile Thu Jan 2 13:34:09 1992
|
||
***************
|
||
*** 17,23 ****
|
||
#if !(defined(SGIArchitecture) || SystemV4)
|
||
DBMLIB = -ldbm
|
||
#endif
|
||
! #if defined(SparcArchitecture) && HasGcc
|
||
CC = cc
|
||
CCOPTIONS = /**/
|
||
EXTRA_LOAD_FLAGS = /**/
|
||
--- 17,23 ----
|
||
#if !(defined(SGIArchitecture) || SystemV4)
|
||
DBMLIB = -ldbm
|
||
#endif
|
||
! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
|
||
CC = cc
|
||
CCOPTIONS = /**/
|
||
EXTRA_LOAD_FLAGS = /**/
|
||
*** mit/server/os/Imakefile.ORIG Wed Jan 15 16:46:23 1992
|
||
--- mit/server/os/Imakefile Wed Jan 15 16:46:48 1992
|
||
***************
|
||
*** 132,138 ****
|
||
SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
|
||
SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
|
||
SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
|
||
! #if defined(SparcArchitecture) && HasGcc
|
||
oscolor.o: $(ICONFIGFILES)
|
||
$(RM) $@
|
||
cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
|
||
--- 132,138 ----
|
||
SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
|
||
SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
|
||
SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
|
||
! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
|
||
oscolor.o: $(ICONFIGFILES)
|
||
$(RM) $@
|
||
cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
|
||
*** 1.1 1992/09/08 19:52:07
|
||
--- mit/server/ddx/sun/Imakefile 1992/09/08 21:10:22
|
||
***************
|
||
*** 43,48 ****
|
||
--- 43,53 ----
|
||
LinkFile(sunGX.o,sunGX.o.dist)
|
||
#endif
|
||
|
||
+ #if HasGcc2
|
||
+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
|
||
+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
|
||
+ #endif
|
||
+
|
||
sunInitExtMono.o: $(ICONFIGFILES)
|
||
ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
|
||
ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
|
||
|
||
*** /tmp/RCSAa24446 Tue Sep 15 12:23:32 1992
|
||
--- mit/clients/twm/Imakefile Thu Aug 13 18:18:07 1992
|
||
***************
|
||
*** 32,41 ****
|
||
--- 32,48 ----
|
||
ComplexProgramTarget(twm)
|
||
InstallNonExecFile(system.twmrc,$(TWMDIR))
|
||
|
||
+ #if HasGcc2 && defined (SunArchitecture)
|
||
gram.h gram.c: gram.y
|
||
yacc $(YFLAGS) gram.y
|
||
+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
|
||
+ $(MV) y.tab.h gram.h
|
||
+ #else
|
||
+ gram.h gram.c: gram.y
|
||
+ yacc $(YFLAGS) gram.y
|
||
$(MV) y.tab.c gram.c
|
||
$(MV) y.tab.h gram.h
|
||
+ #endif
|
||
|
||
clean::
|
||
$(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c
|
||
|