Changes between Version 26 and Version 27 of UsingTheRightCompiler


Ignore:
Timestamp:
Sep 19, 2013, 5:03:22 AM (11 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

edit default-compiler section

Legend:

Unmodified
Added
Removed
Modified
  • UsingTheRightCompiler

    v26 v27  
    1515== The problem with the default compiler == #default-compiler
    1616
    17 The default version of gcc can be run simply as "`gcc`".
    18 There's also "`cc`" which points to the default compiler (which might not necessarily be gcc).
    19 The default gcc can be changed using the "`port select`" mechanism.
    20 Some users may have used this command to change their default gcc,
    21 for example on Leopard to test new functionality in gcc 4.2,
    22 or on Tiger to downgrade to gcc 3.3 to compile old software that is not compatible with gcc 4.
    23 
    24 If not instructed otherwise, software builds using "`gcc`" or "`cc`" and this can be a problem if the user has changed what this is.
    25 For example, on the one hand, gcc 4 may be too new to compile some very old software,
    26 but on the other hand gcc 3.3 is probably too old to compile a lot of modern software.
    27 The problem is further complicated by the various gcc ports which can be installed using MacPorts,
    28 which have different capabilities than the Apple versions of gcc.
    29 For example, only the Apple versions can create universal binaries in a single step.
    30 The port select mechanism can be used to make any of them the default compiler.
    31 So we cannot rely on "`gcc`" being any particular version of gcc with any particular capabilities,
    32 and "`cc`" varies by Xcode version as well.
     17If not instructed otherwise, most software builds C code using "`cc`" or "`gcc`".
     18But "`/usr/bin/cc`" and "`/usr/bin/gcc`" are not specific compilers; they're symlinks to some suitable default compiler, but it varies based on Xcode version.
     19Users might also have created a "`/opt/local/bin/gcc`" symlink, pointing to any installed compiler, by using "`port select --set gcc`".
     20So we cannot rely on "`cc`" oc "`gcc`" being any particular compiler.
    3321
    3422Most port authors will not have used "`port select --set gcc $value`"
     
    3725To remove this testing burden from maintainers,
    3826and to prevent users from running into unanticipated problems,
    39 MacPorts arranges for ports to always compile using the correct default version for the current operating system,
    40 and does not use the unpredictable "`gcc`".
     27MacPorts arranges for ports to compile by default using the same compiler that the installed version of Xcode would use,
     28and does not use the unpredictable "`cc`" or "`gcc`" symlinks.
    4129It does this by specifying the desired compiler's complete path in the CC environment variable
    4230during the port's configure phase.
    43 For example, on OS X 10.8, CC is set to the value "`/usr/bin/clang`"
     31For example, with Xcode 4.2 and later, CC is set to "`/usr/bin/clang`"
    4432so that there is no ambiguity.
    4533
     
    4735there's also CXX for the C++ compiler and CPP for the C pre-processor.
    4836During the configure phase,
    49 MacPorts sets each of these variables to the right value for the user's OS.
     37MacPorts sets each of these variables to the right value for the user's Xcode version.
    5038It does this through the use of a number of similarly-named Tcl variables:
    5139${configure.cc}, ${configure.cxx} and ${configure.cpp}.