macOS build failure (and fix)
On macOS, using the clang bundled with Xcode, the build fails:
clang -o build/opt/src/backends/regex.os -c -std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable -O3 -fPIC build/opt/src/backends/regex.c
build/opt/src/backends/regex.c:229:32: error: unknown warning group '-Wclobbered', ignored [-Werror,-Wunknown-warning-option]
#pragma GCC diagnostic ignored "-Wclobbered"
^
1 error generated.
scons: *** [build/opt/src/backends/regex.os] Error 1
scons: building terminated because of errors.
This is because we're using clang "in GCC mode" by specifying -std=gnu99
, but of course it's not the real McCoy, and thus the #pragma
makes clang barf.
The solution is to check whether the compiler is clang inside the #idef __GCC__
. This may seem counter-intuitive, but actually is logical (and works). The change felt a bit slim for a PR, so I'm including a patch with this issue.