Changes between Version 16 and Version 17 of UsingTheRightCompiler
- Timestamp:
- Feb 19, 2013, 1:52:31 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UsingTheRightCompiler
v16 v17 1 1 = Introduction = #introduction 2 2 3 Most software is built using a C compiler called gcc, 4 and the various versions of Xcode for Mac OS X come with different versions of gcc. 5 For example, with Xcode 2.5 on Mac OS X 10.4, gcc 3.3 and 4.0 are available, with 4.0 being the default. 6 With Xcode 3.1 on Mac OS X 10.5, gcc 4.2 is also available; 7 with Xcode 3.2 on Mac OS X 10.6, gcc 4.2 is the default compiler. 3 Much of the software in MacPorts is built using a C or C++ compiler, 4 and the various versions of Xcode for OS X come with different compiler suites and versions. 5 With Xcode 2.5 on OS X 10.4, gcc 3.3 and 4.0 are available, with 4.0 being the default. 6 With Xcode 3.1 on OS X 10.5, gcc 4.2 is also available. 7 With Xcode 3.2 on OS X 10.6, llvm-gcc-4.2 and clang are also available; gcc 4.2 is the default. 8 With Xcode 4.0 and 4.1 on OS X 10.6 or 10.7, llvm-gcc-4.2 is the default. 9 With Xcode 4.2 or later, clang is the default and gcc is no longer included. 10 The Xcode 4.6 release notes state that it is the last version of Xcode that will include llvm-gcc-4.2, which will leave only clang. 8 11 9 12 … … 11 14 12 15 The default version of gcc can be run simply as "`gcc`". 13 But this default can be changed using the "`gcc_select`" command. 16 There's also "`cc`" which points to the default compiler (which might not necessarily be gcc). 17 The default gcc can be changed using the "`gcc_select`" command. 14 18 Some users may have used this command to change their default gcc, 15 19 for example on Leopard to test new functionality in gcc 4.2, 16 20 or on Tiger to downgrade to gcc 3.3 to compile old software that is not compatible with gcc 4. 17 21 18 Software by default builds using "`gcc`" (or, equivalently, "`cc`")and this can be a problem if the user has changed what this is.19 On the one hand, gcc 4 may be too new to compile some very old software,22 If not instructed otherwise, software builds using "`gcc`" or "`cc`" and this can be a problem if the user has changed what this is. 23 For example, on the one hand, gcc 4 may be too new to compile some very old software, 20 24 but on the other hand gcc 3.3 is probably too old to compile a lot of modern software. 21 25 The problem is further complicated by the various gcc ports which can be installed using MacPorts, … … 23 27 For example, only the Apple versions can create universal binaries in a single step. 24 28 The gcc_select port can be used to make any of them the default compiler. 25 So we cannot rely on "`gcc`" being any particular version of gcc with any particular capabilities. 29 So we cannot rely on "`gcc`" being any particular version of gcc with any particular capabilities, 30 and "`cc`" varies by Xcode version as well. 26 31 27 32 Most port authors will not have used "`gcc_select`" … … 34 39 It does this by specifying the desired compiler's complete path in the CC environment variable 35 40 during the port's configure phase. 36 For example, on MacOS X 10.4 and 10.5, CC is set to the value "`/usr/bin/gcc-4.0`"41 For example, on OS X 10.4 and 10.5, CC is set to the value "`/usr/bin/gcc-4.0`" 37 42 so that there is no ambiguity. 38 43