1 [This file contains two alternative recipes for compiling X11 with GCC.
2 The first alternative puts libgcc.a into the shared X library; the second
3 does not. Neither alternative works on all kinds of systems.
4 It may be that when using GCC 2.4, both alternatives work okay on
5 relatively recent Sparc systems. The first alternative is likely
6 not to work on a Sun 3 without hardware floating point.]
8 How to compile X11R5 (patch level 11) with GCC version 2:
10 The patches include support for building the shared libraries with GCC
11 2 on the Sparc and 68k machines. This version includes the necessary
12 parts of libgcc.a in the shared library for X, in case functions in
13 that library need it. Thus the default behavior is now to build
14 everything, including the libraries, with gcc.
16 If you build the shared library this way, it may not work with
17 executables made with older versions of GCC (2.3.3 and earlier).
18 If that happens, relink those executables with the latest GCC.
19 IF YOU THINK YOU MIGHT COMPILE X FOR SOLARIS 2, then you really don't
20 need this patch: get /contrib/R5.SunOS5.patch.tar.Z from
21 export.lcs.mit.edu instead. It has everything you need to do the
22 build for Solaris 2, sets you up to everything with GCC, and is
23 backward compatible with SunOS 4.*. Get the README
24 (/contrib/R5.SunOS5.patch.README at export) for more info.
26 If you see undefined symbols _dlopen, _dlsym, or _dlclose when linking
27 with -lX11, compile and link against the file mit/util/misc/dlsym.c in
28 the MIT X11R5 distribution. Alternatively, do dynamic linking
29 by using a non-GNU ld.
31 mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2.
32 If -fstrength-reduce (or any other -f option) is a major win, then it
33 will most likely be turned on by -O2 optimization.
35 mit/config/sunLib.rules -- If HasGcc and GccVersion > 1 are true, then
36 use gcc -fpic to generate PIC code. Make sure that gcc does not use
37 gas (the GNU assembler) when compiling PIC code; gas does not assemble
40 ***If you have gas installed where gcc uses it by default, you might have
41 to add -B/bin/ to the PositionIndependentCFlags.***
43 mit/config/site.def -- Define GccVersion to be 2.
45 mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
47 mit/config/sunLib.rules -- When compiling with GCC 2, use -fpic for
48 position independent code generation.
50 mit/rgb/Imakefile -- No longer need to compile some modules with
51 cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
53 mit/server/os/Imakefile -- Likewise.
55 mit/server/ddx/sun/Imakefile -- When compiling with GCC 2, some modules
56 should be compiled with -fvolatile.
58 mit/clients/twm/Imakefile -- Fix bad decls of malloc, realloc in gram.c.
60 mit/lib/X/Imakefile -- Make libgcc.a a required lib for libX11.so
62 *** mit/clients/twm/Imakefile Mon May 17 22:05:22 1993
63 --- new/clients/twm/Imakefile Mon May 17 22:28:46 1993
67 ComplexProgramTarget(twm)
68 InstallNonExecFile(system.twmrc,$(TWMDIR))
70 + #if HasGcc && GccVersion > 1 && defined (SunArchitecture)
73 + sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
74 + $(MV) y.tab.h gram.h
76 + gram.h gram.c: gram.y
77 + yacc $(YFLAGS) gram.y
83 $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c
84 *** mit/config/Imake.tmpl Mon May 17 22:02:57 1993
85 --- new/config/Imake.tmpl Mon May 17 22:15:06 1993
93 + #define CcCmd gcc -fpcc-struct-return
95 #define CcCmd gcc -fstrength-reduce -fpcc-struct-return
100 *** mit/config/site.def Mon May 17 22:02:44 1993
101 --- new/config/site.def Mon May 17 22:22:28 1993
105 #ifdef BeforeVendorCF
107 ! /* #define HasGcc YES */
109 #endif /* BeforeVendorCF */
113 #ifdef BeforeVendorCF
116 ! /* GccVersion > 1 implies building shared libraries with gcc */
117 ! #define GccVersion 2
119 #endif /* BeforeVendorCF */
121 *** mit/config/sun.cf Mon May 17 22:03:02 1993
122 --- new/config/sun.cf Mon May 17 22:24:55 1993
130 + #define OptimizedCDebugFlags -O2
132 + #define OptimizedCDebugFlags -O
133 #define SharedLibraryCcCmd cc
134 #define ExtraLoadFlags -B/usr/bin/
135 #define AllocateLocalDefines /**/
140 $(CC) -c $(CFLAGS) $*.c
141 *** mit/config/sunLib.rules Mon May 17 22:02:46 1993
142 --- new/config/sunLib.rules Mon May 17 22:19:06 1993
146 #define SharedLibraryLoadFlags -assert pure-text
148 #ifndef PositionIndependentCFlags
149 + #if defined(HasGcc) && GccVersion > 1
150 + #define PositionIndependentCFlags -fpic
152 #define PositionIndependentCFlags -pic
157 *** mit/lib/X/Imakefile Mon May 17 22:05:03 1993
158 --- new/lib/X/Imakefile Mon May 17 22:32:26 1993
165 + #if defined(SunArchitecture)
168 + REQUIREDLIBS= -lgcc -lc
173 + #if HasGcc && GccVersion > 1
174 + XCOMM Hack to fix gcc 2 ``-nostdlib'' deficiency on SunOS 4.x
175 + REQUIREDLIBS= `gcc -v 2>&1 | awk '{print $$4}' | sed -e 's/specs$$/libgcc.a/'`
185 *** mit/rgb/Imakefile Mon May 17 22:05:31 1993
186 --- new/rgb/Imakefile Mon May 17 22:25:30 1993
189 #if !(defined(SGIArchitecture) || SystemV4)
192 ! #if defined(SparcArchitecture) && HasGcc
195 EXTRA_LOAD_FLAGS = /**/
197 #if !(defined(SGIArchitecture) || SystemV4)
200 ! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
203 EXTRA_LOAD_FLAGS = /**/
204 *** mit/server/ddx/sun/Imakefile Mon May 17 22:05:57 1993
205 --- new/server/ddx/sun/Imakefile Mon May 17 22:27:23 1993
209 LinkFile(sunGX.o,sunGX.o.dist)
212 + #if HasGcc && GccVersion > 1
213 + SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
214 + SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
217 sunInitExtMono.o: $(ICONFIGFILES)
218 ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
219 ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
220 *** mit/server/os/Imakefile Mon May 17 22:05:46 1993
221 --- new/server/os/Imakefile Mon May 17 22:26:02 1993
224 SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
225 SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
226 SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
227 ! #if defined(SparcArchitecture) && HasGcc
228 oscolor.o: $(ICONFIGFILES)
230 cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
232 SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
233 SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
234 SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
235 ! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
236 oscolor.o: $(ICONFIGFILES)
238 cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
241 [This is the older version]
243 How to compile X11R5 (patch level 11) with GCC version 2:
245 The patches include support for building the shared libraries with GCC 2 on
246 the Sparc and 68k machines.
248 NOTE: Such shared libraries built with GCC version 2.3 DID NOT WORK
249 with executables previously linked using Sun CC! This is because
250 neither those executables nor the gcc-compiled shared libraries contain
251 libgcc.a. The shared libraries did work with executables linked using
252 GCC (running the Sun linker, of course) because GCC tells the linker to
253 link in libgcc.a. Because of these limitations the default behavior is
254 to NOT build the shared libraries with gcc.
256 Changes in GCC 2.4 seem to have eliminated the problem, and such a
257 shared library now seems work with all executables. If you want the
258 gcc-compiled shared libraries turn on "Gcc2BuildLibs" in site.def. If
259 you try this, please tell bug-gcc@prep.ai.mit.edu whether it works.
261 Sun forgot to include a static version of libdl.a with some versions
262 of SunOS (4.1 mainly). If you see undefined symbols _dlopen, _dlsym,
263 or _dlclose when linking with -lX11, compile and link against the file
264 mit/util/misc/dlsym.c in the MIT X11R5 distribution.
266 mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. If
267 -fstrength-reduce (or any other -f option) is a major win, then it will
268 most likely be turned on by -O2 optimization.
270 mit/config/sunLib.rules -- If HasGcc2 and Gcc2BuildLibs are defined, then
271 use gcc -fpic to generate PIC code. Make sure that gcc does not use gas (the
272 GNU assembler) when compiling PIC code; gas does not assemble it correctly.
273 If you have gas installed where gcc uses it by default, you might have to add
274 -B/bin/ to the PositionIndependentCFlags.
276 mit/config/site.def -- Define HasGcc2 to be YES.
278 mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
280 mit/rgb/Imakefile -- No longer need to compile some modules with
281 cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
283 mit/server/os/Imakefile -- Likewise.
285 mit/clients/twm/Imakefile -- fix bad decls of malloc, realloc in gram.c.
287 *** mit/config/Imake.tmpl.ORIG Tue Dec 31 11:07:56 1991
288 --- mit/config/Imake.tmpl Tue Dec 31 12:30:47 1991
296 + #define CcCmd gcc -fpcc-struct-return
299 #define CcCmd gcc -fstrength-reduce -fpcc-struct-return
306 *** mit/config/sunLib.rules.ORIG Tue Dec 31 11:11:24 1991
307 --- mit/config/sunLib.rules Tue May 5 12:26:12 1992
311 #define SharedLibraryLoadFlags -assert pure-text
313 #ifndef PositionIndependentCFlags
314 + #if defined(HasGcc2) && defined (Gcc2BuildLibs)
315 + #define PositionIndependentCFlags -fpic
317 #define PositionIndependentCFlags -pic
322 * InstallSharedLibrary - generate rules to install the shared library.
323 *** mit/config/site.def.ORIG Tue Dec 31 11:13:49 1991
324 --- mit/config/site.def Tue Dec 31 12:02:59 1991
328 #ifdef BeforeVendorCF
330 ! /* #define HasGcc YES */
332 #endif /* BeforeVendorCF */
336 #ifdef BeforeVendorCF
339 ! #define HasGcc2 YES
340 ! /* #define Gcc2BuildLibs YES */
342 #endif /* BeforeVendorCF */
344 *** mit/config/sun.cf.ORIG Tue Dec 31 11:13:57 1991
345 --- mit/config/sun.cf Tue May 5 12:29:50 1992
352 + #if defined(HasGcc2)
353 + #define OptimizedCDebugFlags -O2
354 + /* Leave Alone XXX */
356 + #define OptimizedCDebugFlags -O
357 #define SharedLibraryCcCmd cc
358 #define ExtraLoadFlags -B/usr/bin/
359 #define AllocateLocalDefines /**/
362 + #if !defined(Gcc2BuildLibs)
363 + #define SharedLibraryCcCmd cc
364 + #define ExtraLoadFlags -B/usr/bin/
365 + #define AllocateLocalDefines /**/
369 $(CC) -c $(CFLAGS) $*.c
370 *** mit/rgb/Imakefile.ORIG Wed Jan 15 16:43:18 1992
371 --- mit/rgb/Imakefile Thu Jan 2 13:34:09 1992
374 #if !(defined(SGIArchitecture) || SystemV4)
377 ! #if defined(SparcArchitecture) && HasGcc
380 EXTRA_LOAD_FLAGS = /**/
382 #if !(defined(SGIArchitecture) || SystemV4)
385 ! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
388 EXTRA_LOAD_FLAGS = /**/
389 *** mit/server/os/Imakefile.ORIG Wed Jan 15 16:46:23 1992
390 --- mit/server/os/Imakefile Wed Jan 15 16:46:48 1992
393 SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
394 SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
395 SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
396 ! #if defined(SparcArchitecture) && HasGcc
397 oscolor.o: $(ICONFIGFILES)
399 cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
401 SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
402 SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
403 SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
404 ! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
405 oscolor.o: $(ICONFIGFILES)
407 cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
408 *** 1.1 1992/09/08 19:52:07
409 --- mit/server/ddx/sun/Imakefile 1992/09/08 21:10:22
413 LinkFile(sunGX.o,sunGX.o.dist)
417 + SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
418 + SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
421 sunInitExtMono.o: $(ICONFIGFILES)
422 ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
423 ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
425 *** /tmp/RCSAa24446 Tue Sep 15 12:23:32 1992
426 --- mit/clients/twm/Imakefile Thu Aug 13 18:18:07 1992
430 ComplexProgramTarget(twm)
431 InstallNonExecFile(system.twmrc,$(TWMDIR))
433 + #if HasGcc2 && defined (SunArchitecture)
434 gram.h gram.c: gram.y
435 yacc $(YFLAGS) gram.y
436 + sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
437 + $(MV) y.tab.h gram.h
439 + gram.h gram.c: gram.y
440 + yacc $(YFLAGS) gram.y
446 $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c