In CodeWarrior, you can choose from among several linkers in the Target Settings pane. The “Macintosh PowerPC linker” creates executables based on the format specified by the Code Fragment Manager (CFM) architecture. The “Apple Mach-O PowerPC linker” makes use of Apple’s ld linker and libtool command-line tool. The “Mac OS X PowerPC Mach-O linker” also creates Mach-O executables, but uses the Metrowerks Mac OS linker.
Xcode uses the ld linker, which is designed to work with Mach-O object files, and supports dynamic shared libraries, two-level and flat name spaces, and other features.
The ld linker supports the automatic stripping of unused (dead) code beginning with the June 2004 release of the Xcode tools. For more information, see “Dead Code Stripping.” Using the ld linker may also result in larger binary files than in your CodeWarrior project. You can display man page documentation for the linker in Xcode with Help > Open man page, or in a Terminal window by typing man ld.
The CodeWarrior linker supports dead code stripping (the removal of unused code). Beginning with version 1.5, Xcode also supports dead code stripping. To enable dead code stripping in your project, do the following:
Select a target in the project window.
Open an inspector window like the one shown in Figure 1-3 by clicking the Info button or choosing File > Get Info.
Select the Build pane.
If the Linking settings aren’t visible, select Linking from the Collection menu.
Click the checkbox in the Value column next to the Dead Code Stripping setting.
In versions of Xcode prior to Xcode 1.5, a project may generate errors at link time because it contains unused code that refers to undefined symbols. For more information on this issue, see “Resolve Undefined Symbols.”
You can of course take your own steps to eliminate code you know will never be called. Or, if you have reasons for not stripping certain unused code, you can take steps to avoid exporting symbols for that code. For example, if you create an order file, you can increase the likelihood that dead code in your application will never actually be loaded.
From a performance standpoint, it is always worthwhile to reduce both your code size and the number of exported symbols. For more information in this document, see “Exporting Symbols.” The document Code Size Performance Guidelines contains the following sections:
“Improving Locality of Reference” describes how to create an order file.
“Minimizing Your Exported Symbols” describes how to reduce the symbols exported by your application.
To learn more about support for dead code stripping in Xcode see “Dead Code Stripping” in the chapter “Linking” in Xcode User Guide.
Last updated: 2006-10-26