Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Misty_D_
Beginner
36 Views

version_info_macos.sh uses the wrong gcc switch to extract version information

The version_info_macos.sh script which extracts version information from the compiler on Mac OS X is using the wrong switch, introducing the possibility of retrieving a result the script can't use.

The script reads version information by using `gcc -v`, but this is actually the switch for verbose output; it only incidentally produces a version string. Because it produces verbose output, under some circumstances it will introduce extraneous information and may produce a string with an extra quotation mark, breaking parsing. See https://github.com/mxcl/homebrew/pull/22837 for an example of where this occurs.

The attached patch fixes this by using the first line of `gcc --version` instead. Presumably similar issues will occur on other platforms, but I haven't tested or altered their scripts.

This was tested on Mac OS X 10.7.5 using GCC and clang as provided by Xcode 4.6.3.

0 Kudos
4 Replies
RafSchietekat
Black Belt
36 Views

This "fix" becomes irrelevant but also selects the wrong information in an up-to-date environment (BTW, note the "Deprecation and Removal Notice" in that document):

[plain]

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
$ gcc -v </dev/null 2>&1 | grep 'version'
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
$ gcc --version </dev/null 2>&1 | head -1
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
$

[/plain]

Anton_M_Intel
Employee
36 Views

Thanks for the report and provided logs. Fixed (not '-v' however, since '--version' does not provide information in desired form as Raf showed).

Misty_D_
Beginner
36 Views

Thanks, Anton! Can you provide the fix you used? I'd like to provide a patch for my users. I had been using the --version patch earlier because it works with all compilers distributed by Apple in earlier Xcodes.

Raf, I am intimitely aware of the situation in Xcode 5. I work on a Mac OS X package manager, and I've been preparing for Apple's removal of the final GCC-based compiler in Xcode 5 for months.

RafSchietekat
Black Belt
36 Views

I would have understood if you hadn't looked at Xcode 5 yet, but...