Skip to content

Commit

Permalink
Work around build errors on MacOS 13.3 and XCode 14.3
Browse files Browse the repository at this point in the history
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] bazelbuild/bazel#17956

Release-Notes: skip
Change-Id: If1821b7bd3ec18e8c76c6d604018e11794c256ea
  • Loading branch information
msohn committed Apr 21, 2023
1 parent a6830e6 commit bda7eac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bda7eac

Please sign in to comment.