How to reliable detect a MacPorts-ported compiler?

Rainer Müller raimue at
Wed Sep 9 09:30:34 PDT 2015

On 2015-09-09 16:02, Daniel J. Luke wrote:
>> On Sep 9, 2015, at 12:35 AM, Jeffrey Walton <noloader at> wrote:
>>> Again, I have to ask why you want to do this.
>> My apologies, I was not trying to be rude. I specifically avoided
>> addressing any of these questions because of the bikeshedding
>> involved.
>>> What problem are you seeing with FSF GCC compiled with MacPorts that you do not see with FSF GCC compiled on a Mac by some other means?
>> None that I am aware.
>> But that's not the problem I am trying to solve.
> the confusion here is that it seems to be that you would be better served in detecting FSF GCC (generally) rather than a macports build of FSF GCC (specifically).

I would have used something like this:

#if defined(__APPLE__) && \
  (defined(__GNUC__) || defined(__GNUG__)) && \
  !defined(__clang__) && !defined(__ICC)
    /* the compiler is gcc/g++ on OS X */

However, Fink ships a patched version of GCC enabling this feature on
Darwin [1], which would make an accurate detection a lot more complicated.

While looking into this, I noticed that even though clang accepts it,
the behavior is different compared to GCC, even on Linux. The reordering
might only happen in the current module, not globally, depending on the
version of clang [2]. The behavior will change once again if you use
-flto or pass multiple files at once to the compiler.



More information about the macports-users mailing list