Search code examples
xcodegcccommand-linehomebrewllvm-gcc

Why does Homebrew report "couldn't understand kern.osversion `14.0.0'"?


When I run brew -- config I get

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: bc071fb5448628aea8f066bbc0f37b0ecb4f11ee
Last commit: 16 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit haswell
OS X: 10.10.1-x86_64
Xcode: 6.1.1
CLT: 6.1.1.0.1.1416017670
couldn't understand kern.osversion `14.0.0'
GCC-4.2: build 5666
Clang: 6.0 build 600
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby

even though my Xcode (on Yosemite) command line tools seem to be current (to be sure I re-ran xcode-select --install) and in the right place

/Applications/Xcode.app/Contents/Developer 

according to xcode-select -print-path, my (only) gcc is

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

and the only issues according to brew doctor are

Unexpected static libraries:
    /usr/local/lib/libtclstub8.6.a
    /usr/local/lib/libtkstub8.6.a

However I have a couple suspicious things lying around, notably usr/bin/gcc-4.2, for which --version gives

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
...

and /usr/bin/i686-apple-darwin11-gcc-4.2.1, for which --version also gives

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)    
...

What does brew -- config's report of

couldn't understand kern.osversion `14.0.0'

mean? Is there something I should do about it?


Solution

  • Did you upgrade OS X on this machine some time ago? I guess they're from an older installation. Since gcc isn't installed by default, an OS upgrade probably didn't remove or replace gcc and other XCode command line tools. Whether you can really safely remove them, I don't know, but the obvious thing would be to rename them (or move them in a backup subdirectory), so that they are out of your PATH. That way, homebrew will not find them and use the newer compiler (clang). Very likely, your system (XCode, brew) will continue as usual, since they'll use the clang found on your system.

    The error you see, "couldn't understand kern.osversion '14.0.0'", is likely from the fact that this gcc was compiled against an older OS X kernel version, and the current one (Yosemite/14.0.0) is backwards incompatible with that.

    I don't know exactly which compiler tools all get installed, but for just the offending gcc, you can do something like:

    mv /usr/bin/gcc-4.2 /usr/bin/gcc-4.2-oldOSX10.9
    

    (assuming this was installed on 10.9; possibly on an earlier version).

    It's a bit unfortunate that an upgrade of XCode (or rather, a completely new version) doesn't check for older versions of the command line tools and removes those(*). Though understandably, Apple of course assumes that you don't use anything outside the normal XCode tools; they obviously won't support homebrew in such a way.

    (*) perhaps it does, but if you skipped a version or 2, it may not go back that far in time checking for older versions.