[cfe-commits] r149422 - in /cfe/trunk: lib/Driver/ToolChains.cpp test/Driver/darwin-ld.c test/Driver/rewrite-objc.m

Bob Wilson bob.wilson at apple.com
Tue Jan 31 14:04:57 PST 2012


Sure. I can do that.

On Jan 31, 2012, at 1:43 PM, Chandler Carruth <chandlerc at google.com> wrote:

> On Tue, Jan 31, 2012 at 1:30 PM, Bob Wilson <bob.wilson at apple.com> wrote:
> Author: bwilson
> Date: Tue Jan 31 15:30:03 2012
> New Revision: 149422
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=149422&view=rev
> Log:
> Fix more fallout from the introduction of "macosx" and "ios" triples.
> 
> The Darwin toolchain constructor was assuming that all Darwin triples would
> have an OS string starting with "darwin".  Triples starting with "macosx"
> would misinterpret the version number, and "ios" triples would completely
> miss the version number (or worse) because the OS name is not 6 characters
> long.  We lose some sanity checking of triple strings here, since the
> Triple.getOSVersion function doesn't do all the checking that the previous
> code did, but this still seems like a step in the right direction.
> 
> Could we sink this down into the llvm:Triple? It's quite possible that it doesn't belong there, but I don't see why not yet... If it doesn't belong there, it might be nice to add some comments about why the Driver has to have special handling of the OS versions here.
>  
> 
> Modified:
>    cfe/trunk/lib/Driver/ToolChains.cpp
>    cfe/trunk/test/Driver/darwin-ld.c
>    cfe/trunk/test/Driver/rewrite-objc.m
> 
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=149422&r1=149421&r2=149422&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 31 15:30:03 2012
> @@ -50,17 +50,44 @@
>     ARCRuntimeForSimulator(ARCSimulator_None),
>     LibCXXForSimulator(LibCXXSimulator_None)
>  {
> -  // Compute the initial Darwin version based on the host.
> -  bool HadExtra;
> -  std::string OSName = Triple.getOSName();
> -  if (!Driver::GetReleaseVersion(&OSName.c_str()[6],
> -                                 DarwinVersion[0], DarwinVersion[1],
> -                                 DarwinVersion[2], HadExtra))
> -    getDriver().Diag(diag::err_drv_invalid_darwin_version) << OSName;
> -
> +  // Compute the initial Darwin version from the triple
> +  unsigned Major, Minor, Micro;
> +  Triple.getOSVersion(Major, Minor, Micro);
> +  switch (Triple.getOS()) {
> +  default: assert(0 && "unexpected OS for Darwin triple");
> +  case llvm::Triple::Darwin:
> +    // Default to darwin4, i.e., MacOSX 10.0.0.
> +    if (Major == 0)
> +      Major = 4;
> +    if (Major < 4)
> +      getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
> +        Triple.getOSName();
> +    Micro = 0;
> +    Minor = Major - 4;
> +    Major = 10;
> 
> A comment about what the mapping is from 'darwin' versions to 'masox' versions would clarify this a lot.
>  
> +    break;
> +  case llvm::Triple::MacOSX:
> +    // Default to MacOSX 10.
> +    if (Major == 0)
> +      Major = 10;
> +    if (Major != 10)
> +      getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
> +        Triple.getOSName();
> +    break;
> +  case llvm::Triple::IOS:
> +    // Ignore the version from the triple.
> +    Major = 10;
> +    Minor = 0;
> +    Micro = 0;
> +    break;
> +  }
> +  // FIXME: DarwinVersion is only used to find GCC's libexec directory.
> +  // It should be removed when we stop supporting that.
> +  DarwinVersion[0] = Minor + 4;
> +  DarwinVersion[1] = Micro;
> +  DarwinVersion[2] = 0;
>   llvm::raw_string_ostream(MacosxVersionMin)
> -    << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
> -    << DarwinVersion[1];
> +    << Major << '.' << Minor << '.' << Micro;
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120131/1424bb0a/attachment.html>


More information about the cfe-commits mailing list