title: How to tell which specific compiler will be invoked for a Python C extension: GCC or Clang?
body: <p>I have a Python C++ extension that requires the following compilation flags when compiled using Clang on OS X:</p>
  <pre class="lang-sh prettyprint-override"><code>CPPFLAGS='-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.8'
  LDFLAGS='-lc++'
  </code></pre>
  <p>Detecting OS X in my <code>setup.py</code> is easy enough. I can do this:</p>
  <pre><code>if sys.prefix == 'darwin':
      compile_args.append(['-mmacosx-version-min=10.8', '-stdlib=libc++'])
      link_args.append('-lc++')
  </code></pre>
  <p>(See <a href="https://github.com/honnibal/spaCy/blob/ba1d3ddd7f527d2e6e41b86da0f2887cc4dec83a/setup.py#L70" rel="nofollow noreferrer">here</a> for full context)</p>
  <p>However, on GCC this compilation flag is invalid. So, compilation will fail if someone will try to use GCC on OS X if I write the <code>setup.py</code> this way.</p>
  <p>GCC and Clang support different compiler flags. So, I need to know which compiler will be invoked, so I can send different flags. What is the right way to detect the compiler in the <code>setup.py</code>?</p>
  <p><strong>Edit 1:</strong><br />
  Note that no Python exception is raised for compilation errors:</p>
  <pre class="lang-none prettyprint-override"><code>$ python setup.py build_ext --inplace
  running build_ext
  building 'spacy.strings' extension
  gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -c spacy/strings.cpp -o build/temp.linux-x86_64-2.7/spacy/strings.o -O3 -mmacosx-version-min=10.8 -stdlib=libc++
  gcc: error: unrecognized command line option ‘-mmacosx-version-min=10.8’
  gcc: error: unrecognized command line option ‘-stdlib=libc++’
  error: command 'gcc' failed with exit status 1
  $
  </code></pre>