From bda7eace07057e552b059eed40c0fdefc41ecec8 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 21 Apr 2023 13:18:58 +0200 Subject: [PATCH] Work around build errors on MacOS 13.3 and XCode 14.3 After upgrading MacOS to 13.3.1 and XCode to 14.3 the gerrit build fails with the following errors apparently caused by zlib: $ bazelisk build release ... external/remote_java_tools/java_tools/zlib/gzwrite.c:89:20: error: call to undeclared function 'write'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] writ = write(state->fd, strm->next_in, put); ^ external/remote_java_tools/java_tools/zlib/gzwrite.c:89:20: note: did you mean 'fwrite'? /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:165:9: note: 'fwrite' declared here size_t fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite); ^ external/remote_java_tools/java_tools/zlib/gzwrite.c:110:24: error: call to undeclared function 'write'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] writ = write(state->fd, state->x.next, put); ^ external/remote_java_tools/java_tools/zlib/gzwrite.c:661:9: error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] if (close(state->fd) == -1) ^ To fix this follow the advise in [1] and set C standard to C90 globally. Setting this only for zlib sources as recommended in [1] seems not to work for the bazel version we are using. [1] https://github.com/bazelbuild/bazel/issues/17956 Release-Notes: skip Change-Id: If1821b7bd3ec18e8c76c6d604018e11794c256ea --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index 407b00568a31..e63d1b5b6632 100644 --- a/.bazelrc +++ b/.bazelrc @@ -27,6 +27,9 @@ build:remote17 --java_runtime_version=remotejdk_17 build:remote17 --tool_java_language_version=17 build:remote17 --tool_java_runtime_version=remotejdk_17 +# workaround for https://github.com/bazelbuild/bazel/issues/17956 on MacOS 13.3 and XCode 14.3 +build --host_conlyopt=-std=c90 + # Enable strict_action_env flag to. For more information on this feature see # https://groups.google.com/forum/#!topic/bazel-discuss/_VmRfMyyHBk. # This will be the new default behavior at some point (and the flag was flipped