pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Bootstrap fails with Mavericks



On 11/18/13 7:35 AM, OBATA Akio wrote:
> On Mon, 18 Nov 2013 21:18:49 +0900, Jonathan Perkin
> <jperkin%joyent.com@localhost> wrote:
>
>>>> >Please only do this for 10.9, otherwise looks good.
>>>
>>> Is there any way to detect default compiler on Mac?
>>
>> What do you mean by default?  GCC and clang have co-existed for quite
>> a long time now, so it depends on what the user prefers.  The change
>> in 10.9 was that 'gcc' is now a link to clang, and there is no native
>> gcc any longer.
>
> I know co-existent. I want to know the default (preferred) compiler
> for the Xcode.  And isn't default compiler depend on Xcode version,
> not OS version?
>

Yes, I think the default depends on the Xcode version, not the OS
version.

MacPorts has a statement about the default compiler for some of the
Xcode versions at:

  https://trac.macports.org/wiki/UsingTheRightCompiler

Homebrew has a list of compilers available by Xcode version at:

  https://github.com/mxcl/homebrew/wiki/Xcode

But that doesn't say what the defaults are.

For Homebrew, some of the code for determining the default compiler
appears to be in the default_compiler method of the OS.Mac module at:

  https://github.com/mxcl/homebrew/blob/master/Library/Homebrew/os/mac.rb

It seems to try to find "cc" using the locate method defined in the
same file.  This locate method looks in /usr/bin, and if not there, it
looks in a Homebrew-specific path, and if not there, it uses xcrun with
the -find option to try to find it.  If that doesn't work, it does some
other things I'm not sure about.

Having obtained a path to "cc", it then converts that to a real path
(i.e. absolute path, no symlinks, and no dots), then gets the basename
of that, and then it performs the following tests on the basename: if
it starts with "gcc", the default is GCC; if it starts with "llvm", the
default is LLVM; if it is "clang", the default is clang.  If none of
those match, then it looks at the Xcode version and returns clang if the
Xcode version is >= 4.3, LLVM if >= 4.2, and GCC otherwise.

The Xcode version can be determined with the xcodebuild command on my
system, but I don't know if it will work on older systems or older
versions of Xcode.  Homebrew has lots of logic for this at:

  https://github.com/mxcl/homebrew/blob/master/Library/Homebrew/os/mac/xcode.rb

On my system, I can just run xcodebuild with the -version option:

  $ xcodebuild -version
  Xcode 5.0
  Build version 5A1413

Anyway, Homebrew has lots of logic for this and related things at:

  https://github.com/mxcl/homebrew/tree/master/Library/Homebrew/os/mac

Unfortunately, this all seems far from easy and general.

Lewis


Home | Main Index | Thread Index | Old Index