Solvedhomebrew core Upgrading to Xcode CLT 11.0 broke GCC 9

I just upgraded the Xcode Command Line Tools to 11.0. Now I can no longer compile with GCC 9. I get this error with any C++ file that includes cstdlib:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h:61,
                 from /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/cstdlib:75,
                 from /Users/cris/newdip/include/diplib/library/dimension_array.h:30,
                 from /Users/cris/newdip/include/diplib.h:26,
                 from /Users/cris/newdip/src/analysis/findshift.cpp:21:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/Availability.h:257:22: error: missing binary operator before token "("
  257 |     #if __has_builtin(__is_target_arch)
      |                      ^

It looks like cstdlib includes stdlib.h, but GCC finds it among Clang's header files, rather than the ones that come with GCC. This version of stdlib.h uses some compiler intrinsic that is unique to Clang.

This is the output of gcc --version:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.20.17)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Homebrew is up to date and I have the latest GCC installed through Homebrew.

I have uninstalled GCC and installed it anew, with no change in behavior.

Related issues: 1, 2


  • are reporting a bug others will be able to reproduce and not asking a question or requesting software. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh. To get software added or changed in Homebrew please file a Pull Request
  • have a problem with brew install (or upgrade, reinstall) a single, Homebrew/homebrew-core formula (not cask) on macOS? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new/choose. If it's a Linux problem please file this issue at https://github.com/Homebrew/linuxbrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
Error: No logs.
  • if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?
HOMEBREW_VERSION: 2.1.4-35-g06e0614
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 06e0614a939f3f78215974cba1fc1a0b01416e0a
Last commit: 10 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 30589214867d4bfbca10030cd265e68e382707e5
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: quad-core 64-bit broadwell
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.21.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_121
macOS: 10.14.5-x86_64
CLT: 11.0.0.0.1.1559496560
Xcode: N/A
CLT headers: 11.0.0.0.1.1559496560
XQuartz: 2.7.11 => /opt/X11
Warning: The following directories do not exist:
/usr/local/sbin

You should create these directories and change their ownership to your account.
  sudo mkdir -p /usr/local/sbin
  sudo chown -R $(whoami) /usr/local/sbin

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libics.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/libics.h
  /usr/local/include/libics_intern.h
  /usr/local/include/libics_ll.h
  /usr/local/include/libics_sensor.h
  /usr/local/include/libics_test.h
  /usr/local/include/uvcode.h
  /usr/local/include/valgrind/callgrind.h
  /usr/local/include/valgrind/config.h
  /usr/local/include/valgrind/drd.h
  /usr/local/include/valgrind/helgrind.h
  /usr/local/include/valgrind/libvex.h
  /usr/local/include/valgrind/libvex_basictypes.h
  /usr/local/include/valgrind/libvex_emnote.h
  /usr/local/include/valgrind/libvex_guest_amd64.h
  /usr/local/include/valgrind/libvex_guest_arm.h
  /usr/local/include/valgrind/libvex_guest_arm64.h
  /usr/local/include/valgrind/libvex_guest_mips32.h
  /usr/local/include/valgrind/libvex_guest_mips64.h
  /usr/local/include/valgrind/libvex_guest_offsets.h
  /usr/local/include/valgrind/libvex_guest_ppc32.h
  /usr/local/include/valgrind/libvex_guest_ppc64.h
  /usr/local/include/valgrind/libvex_guest_s390x.h
  /usr/local/include/valgrind/libvex_guest_x86.h
  /usr/local/include/valgrind/libvex_ir.h
  /usr/local/include/valgrind/libvex_s390x_common.h
  /usr/local/include/valgrind/libvex_trc_values.h
  /usr/local/include/valgrind/memcheck.h
  /usr/local/include/valgrind/pub_tool_addrinfo.h
  /usr/local/include/valgrind/pub_tool_aspacehl.h
  /usr/local/include/valgrind/pub_tool_aspacemgr.h
  /usr/local/include/valgrind/pub_tool_basics.h
  /usr/local/include/valgrind/pub_tool_basics_asm.h
  /usr/local/include/valgrind/pub_tool_clientstate.h
  /usr/local/include/valgrind/pub_tool_clreq.h
  /usr/local/include/valgrind/pub_tool_debuginfo.h
  /usr/local/include/valgrind/pub_tool_deduppoolalloc.h
  /usr/local/include/valgrind/pub_tool_errormgr.h
  /usr/local/include/valgrind/pub_tool_execontext.h
  /usr/local/include/valgrind/pub_tool_gdbserver.h
  /usr/local/include/valgrind/pub_tool_guest.h
  /usr/local/include/valgrind/pub_tool_hashtable.h
  /usr/local/include/valgrind/pub_tool_libcassert.h
  /usr/local/include/valgrind/pub_tool_libcbase.h
  /usr/local/include/valgrind/pub_tool_libcfile.h
  /usr/local/include/valgrind/pub_tool_libcprint.h
  /usr/local/include/valgrind/pub_tool_libcproc.h
  /usr/local/include/valgrind/pub_tool_libcsetjmp.h
  /usr/local/include/valgrind/pub_tool_libcsignal.h
  /usr/local/include/valgrind/pub_tool_machine.h
  /usr/local/include/valgrind/pub_tool_mallocfree.h
  /usr/local/include/valgrind/pub_tool_options.h
  /usr/local/include/valgrind/pub_tool_oset.h
  /usr/local/include/valgrind/pub_tool_poolalloc.h
  /usr/local/include/valgrind/pub_tool_rangemap.h
  /usr/local/include/valgrind/pub_tool_redir.h
  /usr/local/include/valgrind/pub_tool_replacemalloc.h
  /usr/local/include/valgrind/pub_tool_seqmatch.h
  /usr/local/include/valgrind/pub_tool_signals.h
  /usr/local/include/valgrind/pub_tool_sparsewa.h
  /usr/local/include/valgrind/pub_tool_stacktrace.h
  /usr/local/include/valgrind/pub_tool_threadstate.h
  /usr/local/include/valgrind/pub_tool_tooliface.h
  /usr/local/include/valgrind/pub_tool_transtab.h
  /usr/local/include/valgrind/pub_tool_vki.h
  /usr/local/include/valgrind/pub_tool_vkiscnums.h
  /usr/local/include/valgrind/pub_tool_vkiscnums_asm.h
  /usr/local/include/valgrind/pub_tool_wordfm.h
  /usr/local/include/valgrind/pub_tool_xarray.h
  /usr/local/include/valgrind/pub_tool_xtmemory.h
  /usr/local/include/valgrind/pub_tool_xtree.h
  /usr/local/include/valgrind/valgrind.h
  /usr/local/include/valgrind/vki/vki-amd64-linux.h
  /usr/local/include/valgrind/vki/vki-arm-linux.h
  /usr/local/include/valgrind/vki/vki-arm64-linux.h
  /usr/local/include/valgrind/vki/vki-darwin.h
  /usr/local/include/valgrind/vki/vki-linux-drm.h
  /usr/local/include/valgrind/vki/vki-linux.h
  /usr/local/include/valgrind/vki/vki-mips32-linux.h
  /usr/local/include/valgrind/vki/vki-mips64-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-amd64-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-arm-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-arm64-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-mips32-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-mips64-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-ppc32-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-ppc64-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-s390x-linux.h
  /usr/local/include/valgrind/vki/vki-posixtypes-x86-linux.h
  /usr/local/include/valgrind/vki/vki-ppc32-linux.h
  /usr/local/include/valgrind/vki/vki-ppc64-linux.h
  /usr/local/include/valgrind/vki/vki-s390x-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-amd64-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-arm-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-arm64-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-darwin.h
  /usr/local/include/valgrind/vki/vki-scnums-mips32-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-mips64-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-ppc32-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-ppc64-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-s390x-linux.h
  /usr/local/include/valgrind/vki/vki-scnums-solaris.h
  /usr/local/include/valgrind/vki/vki-scnums-x86-linux.h
  /usr/local/include/valgrind/vki/vki-solaris-repcache.h
  /usr/local/include/valgrind/vki/vki-solaris.h
  /usr/local/include/valgrind/vki/vki-x86-linux.h
  /usr/local/include/valgrind/vki/vki-xen-domctl.h
  /usr/local/include/valgrind/vki/vki-xen-evtchn.h
  /usr/local/include/valgrind/vki/vki-xen-gnttab.h
  /usr/local/include/valgrind/vki/vki-xen-hvm.h
  /usr/local/include/valgrind/vki/vki-xen-memory.h
  /usr/local/include/valgrind/vki/vki-xen-mmuext.h
  /usr/local/include/valgrind/vki/vki-xen-physdev.h
  /usr/local/include/valgrind/vki/vki-xen-schedop.h
  /usr/local/include/valgrind/vki/vki-xen-sysctl.h
  /usr/local/include/valgrind/vki/vki-xen-tmem.h
  /usr/local/include/valgrind/vki/vki-xen-version.h
  /usr/local/include/valgrind/vki/vki-xen-x86.h
  /usr/local/include/valgrind/vki/vki-xen-xsm.h
  /usr/local/include/valgrind/vki/vki-xen.h

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
  /usr/local/lib/pkgconfig/valgrind.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libics.a

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  unbound
18 Answers

✔️Accepted Answer

This is a bug in the C library that comes with the updated Xcode. To fix it, edit the file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/Availability.h (must be done as root). Near the point where the error is generated (line number 257), add the following two lines:

#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  #if defined(__has_builtin)   // <=== ADD THIS LINE
    #if __has_builtin(__is_target_arch)
     #if __has_builtin(__is_target_vendor)
      #if __has_builtin(__is_target_os)
       #if __has_builtin(__is_target_environment)
        #if __has_builtin(__is_target_variant_os)
         #if __has_builtin(__is_target_variant_environment)
          #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi))))
            #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx __AVAILABILITY_INTERNAL##_ios
            #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
                                                            __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep
            #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
                                                            __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg) __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg)
          #endif /* # if __is_target_arch... */
         #endif /* #if __has_builtin(__is_target_variant_environment) */
        #endif /* #if __has_builtin(__is_target_variant_os) */
       #endif /* #if __has_builtin(__is_target_environment) */
      #endif /* #if __has_builtin(__is_target_os) */
     #endif /* #if __has_builtin(__is_target_vendor) */
    #endif /* #if __has_builtin(__is_target_arch) */
  #endif   // <=== ADD THIS LINE

    #ifndef __OSX_AVAILABLE_STARTING
        #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx
        #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
                                                        __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep
        #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
                                                        __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg)
    #endif /* __OSX_AVAILABLE_STARTING */

#else

Needless to say, edit system files at your own risk! :)

Other Answers:

Thanks for the work but I'm just gonna repeat what fx said cause it's essential in this:

There are many such workarounds. The only real fix is to report the problem to Apple, so they can fix it. (Duplicate reports actually help them determine what is a pressing issue, too.)

More Issues: