How to reliable detect a MacPorts-ported compiler?

Ryan Schmidt ryandesign at macports.org
Mon Sep 7 18:37:23 PDT 2015


On Sep 7, 2015, at 5:20 PM, Jeffrey Walton wrote:
> On Mon, Sep 7, 2015 at 5:04 PM, Rainer Müller wrote:
>> On 2015-09-07 02:46, Jeffrey Walton wrote:
>>> We have some users reporting issues under MacPort-ported compilers
>>> (specifically, Issue 37664, https://trac.macports.org/ticket/37664).
>>> 
>>> How do I reliably detect a MacPorts-ported compiler?
>> 
>> Wouldn't it be more correct to detect gcc on OS X as apparently this
>> feature is not supported no matter where the compiler comes from?
>> 
> Thanks.
> 
> For Apple, we can detect Apple ported gear with:
> 
>  $ clang++ -dM -E - < /dev/null | grep -i apple
>  #define __APPLE_CC__ 6000
>  #define __APPLE__ 1
>  #define __VERSION__ "4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)"
>  #define __apple_build_version__ 5030040

Well, that's clang, not gcc. 

> What strings or bits is MacPorts providing?

If you want to know if gcc is FSF GCC compiled by MacPOrts, you could inspect the version string:

$ gcc-mp-6 --version
gcc-mp-6 (MacPorts gcc6 6-20150830_0+universal) 6.0.0 20150830 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Note that this inclues the string "MacPorts".

However, I reiterate what Rainer said: the issue being discussed here is not (we believe) specific to MacPorts, but rather would occur anytime you compile FSF GCC on OS X.



More information about the macports-users mailing list