Bump version to gcc-4055.
[official-gcc.git] / README.Apple
blobfc850b66c8712894aec8ec53063b3cffe63367a6
1 APPLE LOCAL file documentation
3 This file describes Apple's version of GCC 3.x modified for Darwin /
4 Mac OS X.  Although Apple's stated policy is to contribute all of its
5 GCC work to the FSF GCC mainstream, at any given moment there will be
6 changes that are permanently unacceptable for FSF GCC, in need of
7 rework before acceptance, or that we simply aren't ready to send in.
8 This version of GCC contains all those changes.
10 In keeping with provision 2a of the GPL, each Apple change is marked
11 with a comment saying "APPLE LOCAL", followed by optional words "begin",
12 "end", or "file", followed by a short phrase describing the change
13 generally ("AltiVec" for instance, if the change is related to AltiVec
14 support), followed by an optional date in the form yyyy-mm-dd,
15 optionally followed by the initials or email address of the person
16 making the change.  The words "begin" and "end" indicate that the
17 comments delimit a multi-line change, while the word "file" indicates
18 that the entire file is an Apple addition.  Additional explanatory
19 comments should be in a separate comment.
21 You may also isolate Apple's changes by diffing with the FSF mainline
22 sources as of the date mentioned in gcc/version.c; this date is
23 updated in the FSF repository daily, and is preserved when we import
24 FSF sources into Apple's repository (the tag for the imported source
25 is "fsf-cvs").
27 The primary purpose of this version of GCC is to be the main system
28 compiler for Darwin and Mac OS X.  However, since additions such as
29 PFE precompiled headers and Objective-C++ are of interest on other
30 platforms, we have generally conditionalized Mac-specific code so that
31 the compiler will build and run elsewhere.  You may however run into
32 mistakes; please let us know about them and we will
33 fix these if possible.
35 NOTE!  It's best to assume that this code has been updated from FSF
36 development sources recently, and has received very little testing
37 before being imported.  There is a good chance that your favorite
38 program will not compile or run when compiled with this program.  The
39 version of the compiler that ships with OS X is the standard for
40 correctness; any time something works with that compiler but fails
41 with this one is probably a bug, and should be reported to
42 darwin-development@lists.apple.com.
44 PREREQUISITES
46 Presumably if you're reading this, you've figured out how to get the
47 sources. :-) But just to be complete, these sources are available from
48 the Darwin repository at opensource.apple.com, CVS module "gcc",
49 branch "apple-ppc-branch".  See
50 http://www.opensource.apple.com/tools/cvs if this isn't enough info
51 yet.
53 If you want C++ exception handling to work, you will need a modified
54 crt1.o. (crt1.o is the bit of code that sets up for execution and
55 calls your program's main().) The modified crt1.o is standard in 10.2,
56 but 10.1, you will need to set it up yourself.
58 If you can't get a modified crt1.o from somebody else, you can patch a
59 copy of the sources to the "Csu" project and build it yourself.  The
60 patch is included in this directory, as "csu-patch".  The build is
61 easy, just say "make" in the Csu directory, and then copy the crt1.o
62 to /usr/lib/crt1.o (as usual, it's prudent to keep around a copy of
63 the original crt1.o, just in case).  You will need to have built the
64 "cctools" project as well, in order to get the helper tool "indr"
65 (which is expected to be installed as /usr/local/bin/indr).
67 BUILDING, THE APPLE WAY
69 To build things the Apple way, just say (in the source directory)
71         mkdir -p build/obj build/dst build/sym
72         gnumake install RC_OS=macos RC_ARCHS=ppc TARGETS=ppc \
73                 SRCROOT=`pwd` OBJROOT=`pwd`/build/obj \
74                 DSTROOT=`pwd`/build/dst SYMROOT=`pwd`/build/sym
76 This will configure and then do a full bootstrap build, with all the
77 results going into the subdirectory build/ that you created.  The
78 final results will be in the "dest root" directory build/dst, in the
79 form of an image of the installed directory structure.  The drivers
80 and other user-visible tools have a "3" suffixed, so for instance the
81 driver is /usr/bin/gcc3, and the demangler is /usr/bin/c++filt3.
83 To install the results, become root and do
85         ditto build/dst /
87 Various knobs and switches are available, but even so, the Apple
88 makefile machinery is mainly designed for mass builds of all the
89 projects that make up Darwin and/or Mac OS X, and is thus not as
90 flexible as the standard GCC build process.
92 To build for i386 Darwin, set TARGETS=i386.  To build fat, set
93 RC_ARCHS='i386 ppc' TARGETS='i386 ppc'.  Note that you must have a
94 complete set of fat libraries and i386-targeting cctools for this
95 all to work.
97 You can set the four *ROOT variables to point anywhere, but they must
98 always be absolute pathnames.
100 This way of building may or may not work on non-Macs, and if it
101 doesn't, you're on your own.
103 BUILDING, THE FSF WAY
105 In general, standard GCC procedures work for building this version.
106 We recommend that you build in a separate objdir; create a sibling
107 to the toplevel source dir, call it whatever you want, cd into it,
108 and say "../gcc/configure".  This way you can have more than one
109 build using the same set of sources.
111 If you insist on building in the source directory using "./configure",
112 the GNUmakefile that supports the Apple build process (see above) will
113 shadow your makefile, and you will need to override this behavior by
114 saying "make -f Makefile" (or by moving GNUmakefile out of the way).
116 For instance:
118         mkdir darwin
119         cd darwin
120         ../configure --prefix=/tmp/testplace
121         make bootstrap
122         make install
124 does a full build, plus two generations of self-compilation for
125 GCC proper, then an install.
127 To avoid building every language, use --enable-languages argument to
128 configure.  For instance, '--enable-languages=objc,c++,objc++' skips
129 the Fortran and Java compilers.  (The C compiler will always be
130 built.)
132 To build an x86 cross-compiler, add "--target=i386-darwin" to the
133 configure line.  The x86 compiler works, but to make it useful you
134 will need libraries and such from x86 Darwin.
136 There is a ProjectBuilder (PB) project also, but at the moment it's
137 only useful for browsing.  We expect to make it useful for building
138 eventually.  To keep it out of the way until then, it's in
139 "pbproj/gcc3.pbproj".
141 Tools built the FSF way are *not* usually going to be dropin
142 replacements for already-installed tools built the Apple way, because
143 search paths and other details will be different.
145 TESTING
147 This package includes a copy of the test framework of DejaGNU, for
148 convenience in running GCC's testsuite.  If you've done a make
149 from the top, DejaGNU will have been built already; otherwise at
150 the top of the objdir say "make all-dejagnu".
152 Once the DejaGNU is available, you can cd into the gcc objdir and type
153 "make check" to run all the tests.  This will take several hours.  You
154 can do things like "make check-gcc" just to run C tests, or "make
155 check-g77" for Fortran tests, which take less time.
157 USING
159 While this compiler can be used with 10.1, it is aimed at 10.2
160 (Jaguar) and later releases.  Built correctly, using the "Apple way",
161 it can be a dropin replacement for the 10.2 system compiler.
163 * Compatibility Issues
165 This section lists areas where this compiler behaves differently
166 from other versions of GCC.
168 Built-in functions are not automatically declared
170 GCC knows about some functions, such as memcpy, so it can generate
171 better code for them.  However, 2.95.2 let C++ programs refer to them
172 without ever declaring them.  The current C++ compiler now does the
173 right thing by requiring you to declare all functions.
175 alloca is a built-in function
177 Normally only __builtin_alloca is a built-in function, and user
178 code #defines alloca as __builtin_alloca.  This version of GCC
179 also recognizes alloca as built-in, and compiles it into a single
180 stack adjustment.
182 va_arg cannot take chars, shorts, or floats
184 You can no longer pass "char", "short", or "float" as the second
185 argument to va_arg() when using varargs.
187 #pragma once is silently accepted
189 GCC handles #pragma once correctly, but the standard compiler warns
190 that the pragma is obsolete.  This version of GCC is silent by
191 default.  Use -Wpragma-once to see the warnings again.
193 #import is silently accepted
195 GCC handles #import correctly, but the standard compiler warns that
196 the directive is obsolete.  This version of GCC is silent by default.
197 Use -Wimport to see the warnings again.
199 Extra tokens after #endif and friends are silently accepted
201 Standard GCC now warns about extra tokens after #endif and other
202 preprocessor directives.  This version of GCC is silent by default.
203 Use -Wextra-tokens to see these warnings.
205 Files with missing newlines are silently accepted
207 Standard GCC warns about files that do not end with a newline.
208 This seems to be common in Apple headers and sources, so this
209 version does not warn.  Use -Wnewline-eof to see these warnings.
211 -fpermissive by default
213 The C++ compiler is normally strict about adherence to the language
214 standard, but the -fpermissive flag is available to convert many
215 errors into warnings.  Apple's compiler is set to be permissive
216 by default.  This is temporary as of 1/27/02.
218 GNU stddef.h not installed
220 If built the Apple way, GCC's stddef.h is installed as "gnu-stddef.h",
221 and so by default you will get the /usr/include/stddef.h that comes
222 with Darwin.
224 libobjc not built
226 Since GNU libobjc and its headers would mask the system library
227 and headers, this version of GCC does not build or install them
228 if targeting Darwin.
230 Objective-C structure returns
232 When using the NeXT runtime, methods returning structures will work,
233 while they will fail when using FSF GCC.
235 All assembly files are preprocessed
237 FSF GCC only runs the C preprocessor on files with extension .S, and
238 does not run it on files ending in .s.  Apple GCC runs the
239 preprocessor on .s files also.
241 Bug reporting address different
243 If the compiler gets an internal error, it will ask you to report the
244 error to Apple, rather than to the FSF.
246 * Extensions
248 This section briefly describes Apple's extensions to GCC.  Further
249 details may be found in the GCC manual (usually).
251 __APPLE_CC__
253 The preprocessor symbol __APPLE_CC__ identifies a specific "build
254 number" of the compiler.  These numbers are finer-grained than the
255 generic GCC version numbers, and for gcc3 they range from 1000 up
256 (2.95.2 versions are in the 900s).
258 Framework includes
260 Headers may be found by pathname in the usual way, or as part of
261 "frameworks" which are assemblages of library/headers/resources.  For
262 instance, #include <IOKit/IOTypes.h> will be found as
263 /System/Library/Frameworks/IOKit.framework/Headers/IOTypes.h.  The
264 -F<pathname> adds <pathname> as a place to search for frameworks; by
265 default, the compiler will look in /System/Library/Frameworks,
266 /Library/Frameworks, and /Local/Library/Frameworks.
268 Frameworks may also have subframeworks, and the framework include
269 machinery will find headers in subframeworks if the outer framework
270 (known as an "umbrella framework) is being included.
272 Objective-C++
274 Objective-C++ is C++ extended to understand Objective-C constructs.
275 The two object models are separate and "mutually oblivious", so C++
276 code generally works unchanged, as well as Objective-C code that
277 conforms to C++ restrictions (similar to the restrictions placed on
278 plain C code by C++).  Objective-C++ files must have the extension .mm
279 or .M (but note that .M will conflict with .m files on HFS
280 filesystems, so .mm is preferred).
282 Pascal strings
284 The flag -fpascal-strings enables the use of "\p" to designate a
285 length byte, originally used for C-Pascal interoperation on Macs, but
286 now mostly a human-appendix-like compatibility option.
288 Macintosh alignment
290 The options -malign-mac68k, -malign-power, and -malign-natural are 
291 available to control whether the alignment of structure fields 
292 follows 68K, PowerPC, or "natural" rules.  These options are
293 useful to applications which need to be binary-compatible with
294 very old Mac applications, libraries, or resources.  The "natural"
295 alignment mode may be useful to applications whose performance is
296 sensitive to misaligned data accesses.
298 In addition, #pragma options align=<option> is available, where
299 <option> may be mac68k, native, natural, packed, power, or reset.
300 (native == power on a PowerPC.)  The pragma effectively pushes the
301 alignment onto a stack, while align=reset pops the alignment, thus
302 allowing nested pragmas to work.  #pragma pack is also available and
303 works with the same stack.
305 private extern symbols
307 You can declare symbols as "private extern", which means that they
308 behave as extern until linking, then they are made private, and are
309 not visible outside the library.  To declare something as private
310 extern, add "__private_extern__" where you might normally say
311 "extern".
313 Coalescing
315 Using "-fcoalesce", "-fcoalesce-templates" and "-fweak-coalesced"
316 flags can reduce the amount of duplicated code.  Coalescing and C++
317 template coalescing are enabled by default, at least if a
318 recent-enough cctools version (10.2 or later) has been installed.
320 -dynamiclib
322 You can build shared libraries (aka dylibs) by using -dynamiclib.
323 This invokes libtool (not to be confused with GNU libtool) instead of
324 ld.  See the libtool man page for more detail on options that can be
325 passed to libtool.
327 Linker flags
329 This version of GCC understands the plethora of linker-related flags,
330 such as -framework, -flat_namespace, etc.  The functionality should be
331 the same as for 2.95.2 and as documented in the linker man page; any
332 discrepancies are probably bugs.
334 AltiVec
336 The complete AltiVec programming interface, as defined in the PIM, is
337 available.  Use -faltivec to enable it.
339 Note that the PIM, section 2.1 mentions that AltiVec data types using
340 the 'long' keyword (i.e., vector [un]signed long) are deprecated and
341 that the 'int' should be used.  The compiler will thus issue a warning
342 for these cases.  The warning may be suppressed by specifying
343 -Wno-altivec-long-deprecated.
345 -mdynamic-no-pic
347 The option -mdynamic-no-pic generates code that make references to
348 PIC, but is not itself position-independent and thus more efficient.
349 This option is suitable for applications but not dylibs.
351 unavailable attribute
353 The attribute "unavailable" is available :-) to declare that a
354 symbol is not available.
356 weak_import attribute
358 The attribute weak_import is available to declare that a symbol
359 should be designated as a weak reference.
361 CALL_ON_LOAD and CALL_ON_UNLOAD pragmas
363 The pragmas CALL_ON_LOAD and CALL_ON_UNLOAD allow you to declare
364 that a given name is the name of a function to be called when
365 a module is loaded or unloaded by the system.
367 IOKit support
369 There are a number of changes to support the building of IOKit drivers.
371 The option -findirect-virtual-calls forces all virtual calls to go
372 through the vtable, while the option -fterminated-vtables adds a null
373 termination to vtables.  -fapple-kext turns on all of these, plus any
374 future options that may be needed to compile kexts.
376 There is a library libcc_kext.a that is libgcc.a compiled static and
377 including only routines that are allowed in the kernel.
379 The PowerPC-only option -mlong-branch is available to generate full
380 32-bit jumps, since kexts may not be loaded at addresses close to the
381 kernel.
383 Dependency file names
385 When you use -MD to output dependencies, you can also use
386 -dependency-file <name> to write the dependencies into the file named
387 <name>.  (By default, they go into <inputfilename>.d .)
389 Fat builds
391 You can compile for a specific target type by using -arch <archname>.
392 Multiple -arch options also work, and result in "fat binaries".  -arch
393 works with -c, -precomp (to make fat precomps), but not -S or
394 -save-temps.
396 At present, only "i386" and "ppc" may be used as architecture names.
397 Note that building for a specific arch will only work if you have
398 assembler and libraries for that arch.
400 -ObjC, -ObjC++
402 These options set the default language to be Objective-C and
403 Objective-C++, respectively.  Note that this behavior is slightly
404 different from the -x options, because -x affects only the files
405 appearing after it on the command line, while -ObjC and -ObjC++ affect
406 all input files.  Nevertheless, -x is standard and thus preferable.
407 (-fobjc works and is equivalent to -ObjC, but it's even more
408 deprecated.)
410 -Wmost
412 The option -Wmost is equivalent to -Wall -Wno-parentheses.  It is
413 present for compatibility with some existing Mac OS X projects.
415 -Wno-#warnings
417 The option -Wno-#warnings suppresses warnings issued by #warning.
419 -Wno-altivec-long-deprecated
421 The option -Wno-altivec-long-deprecated suppresses warnings about
422 'int' being preferred to 'long' in AltiVec vector types.
424 -Werror suppression
426 The environment variable QA_DISABLE_WERROR, if set (to any value),
427 disables the effect of -Werror on the command line; warnings will
428 not result in an error.
430 PB indexing
432 If the environment variable PB_INDEX_SOCKET_PORT is defined, then the
433 compiler will output PB indexing information to that port.  The option
434 -fdebug-gen-index will do the same port, but sending the information
435 to standard output, for debugging indexing.
437 Header mapfiles
439 This is the support for a PB feature where actual pathnames for
440 headers come from a given file rather than being searched for in the
441 various include paths.  It's not useful outside of the PB environment.
443 QA_OVERRIDE_GCC3_OPTIONS environment variable
445 Allows overriding, adding, or changing options sent to toplev.c.  This
446 allows you, for example, to override the -O setting that the driver
447 sends to the command line.  Documentation is in toplev.c.
449 * Miscellaneous Issues
451 GCC uses a syntax for rlwinm instructions that is only supported
452 by the assembler in 10.1 or later.  If you need to run 10.0, and
453 can't build cctools-364, then you can try to dig up the workaround;
454 versions of gcc3 before December 2001 have it, look for references
455 to rlwinm in gcc/config/rs6000/rs6000.md.
457 TO DO
459 This section lists specific features that we're still working on.
461 Make fat building work when the compiler is built the FSF way.
463 Implement floating point precision control (-ffppc) for i386.