Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@remote_java_tools fail to build on macOS 13.3 with Xcode 14.3 #17956

Closed
fmeum opened this issue Apr 3, 2023 · 33 comments
Closed

@remote_java_tools fail to build on macOS 13.3 with Xcode 14.3 #17956

fmeum opened this issue Apr 3, 2023 · 33 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@fmeum
Copy link
Collaborator

fmeum commented Apr 3, 2023

Description of the bug:

Building @remote_java_tools from source on macOS 13.3 with Xcode 14.3 fails with:

external/remote_java_tools/java_tools/zlib/gzlib.c:254:9: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
        ^
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
external/remote_java_tools/java_tools/zlib/gzlib.c:254:9: note: did you mean 'fseek'?
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:162:6: note: 'fseek' declared here
int      fseek(FILE *, long, int);
         ^
external/remote_java_tools/java_tools/zlib/gzlib.c:260:24: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        state->start = LSEEK(state->fd, 0, SEEK_CUR);
                       ^
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
external/remote_java_tools/java_tools/zlib/gzlib.c:361:9: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
        ^
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
external/remote_java_tools/java_tools/zlib/gzlib.c:402:15: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
              ^
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
external/remote_java_tools/java_tools/zlib/gzlib.c:498:14: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    offset = LSEEK(state->fd, 0, SEEK_CUR);
             ^
external/remote_java_tools/java_tools/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
5 errors generated.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Try to build a Java target on macOS 13.3 with Xcode 14.3 using a non-prebuilt Java toolchain such as:

load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "NONPREBUILT_TOOLCHAIN_CONFIGURATION", "default_java_toolchain")
default_java_toolchain(
    name = "java_non_prebuilt",
    configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
)

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

6.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

This does appear to be an unfixed portability issue in zlib.

Other repos apply patches to resolve this: Blosc/c-blosc@ac72c2c

Any other information, logs, or outputs that you want to share?

This can be worked around with --host_conlyopt=-std=c90 (see #17956 (comment) for less intrusive workarounds).

@fmeum
Copy link
Collaborator Author

fmeum commented Apr 3, 2023

@hvadehra Would applying a patch such as Blosc/c-blosc@ac72c2c to third_party/zlib be an acceptable solution?

@ShreeM01 ShreeM01 added the team-Rules-Java Issues for Java rules label Apr 3, 2023
@adamjstewart
Copy link

I just encountered this issue as well. Is it possible to use an externally installed copy of zlib instead of relying on third_party?

@adamjstewart
Copy link

Confirmed that the above patch does indeed solve the issue. Still have the above question about using externally installed dependencies though.

@pjjw
Copy link

pjjw commented Apr 3, 2023

for anyone else who lands here, fixes are either adding -std=c90 to the zlib BUILD file copts, or adding build --per_file_copt='external/zlib[~/].*\.c@-std=c90' --host_per_file_copt='external/zlib[~/].*\.c@-std=c90' to their .bazelrc

the blanket --host_conlyopt=-std=c90 flag can break a lot of other common/important things, like the go compiler

edit: changed regex to work with bzlmod as well

@meteorcloudy
Copy link
Member

@fmeum Does this also break building Bazel with the latest Xcode toolchain? (I'll also try to test it)

@fmeum
Copy link
Collaborator Author

fmeum commented Apr 4, 2023

@meteorcloudy I am only relaying this information from our devs on Macs, I don't have the setup to test this myself right now. I would think so though.

@meteorcloudy meteorcloudy added P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website and removed team-Rules-Java Issues for Java rules untriaged labels Apr 4, 2023
@meteorcloudy
Copy link
Member

Yes, it broke bazel build as well.

$ bazel build //src:bazel
INFO: Invocation ID: 1a5a89d4-c183-49f4-bda0-6f569d4fb28f
INFO: Reading 'startup' options from /Users/pcloudy/.bazelrc: --host_jvm_args=-Djava.net.preferIPv6Addresses=true
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=331
INFO: Reading rc options for 'build' from /Users/pcloudy/workspace/bazel/.bazelrc:
  Inherited 'common' options: --enable_platform_specific_config
INFO: Reading rc options for 'build' from /Users/pcloudy/workspace/bazel/.bazelrc:
  'build' options: --java_language_version=11 --tool_java_language_version=11
INFO: Reading rc options for 'build' from /Users/pcloudy/.bazelrc:
  'build' options: --verbose_failures --announce_rc --disk_cache=/tmp/bazel_disk_cache --repository_cache=/tmp/bazel_repository_cache
INFO: Found applicable config definition build:macos in file /Users/pcloudy/workspace/bazel/.bazelrc: --macos_minimum_os=10.10
INFO: Analyzed target //src:bazel (335 packages loaded, 9877 targets configured).
INFO: Found 1 target...
ERROR: /Users/pcloudy/workspace/bazel/third_party/zlib/BUILD:39:19: Compiling third_party/zlib/gzwrite.c [for tool] failed: (Exit 1): wrapped_clang failed: error executing command (from target //third_party/zlib:zlib_checked_in)
  (cd /private/var/tmp/_bazel_pcloudy/829441223e9fec5a5a2e3d1dd743fdf0/sandbox/darwin-sandbox/15/execroot/io_bazel && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=13.3 \
    PATH=/Users/pcloudy/Library/Caches/bazelisk/downloads/bazelbuild/bazel-6.1.1-darwin-arm64/bin:/Users/pcloudy/bin/google-cloud-sdk/bin:/opt/homebrew/bin:/Users/pcloudy/bin:/usr/local/git/git-google/bin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin \
    XCODE_VERSION_OVERRIDE=14.3.0.14E222b \
    ZERO_AR_DATE=1 \
  external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' 'DEBUG_PREFIX_MAP_PWD=.' -iquote . -iquote bazel-out/darwin_arm64-opt-exec-EDC14992/bin -isystem third_party/zlib -isystem bazel-out/darwin_arm64-opt-exec-EDC14992/bin/third_party/zlib -MD -MF bazel-out/darwin_arm64-opt-exec-EDC14992/bin/third_party/zlib/_objs/zlib_checked_in/gzwrite.d '-DBAZEL_CURRENT_REPOSITORY=""' '-frandom-seed=bazel-out/darwin_arm64-opt-exec-EDC14992/bin/third_party/zlib/_objs/zlib_checked_in/gzwrite.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks -no-canonical-prefixes -pthread -g0 -w '-Dverbose=-1' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -target arm64-apple-macosx13.3 -c third_party/zlib/gzwrite.c -o bazel-out/darwin_arm64-opt-exec-EDC14992/bin/third_party/zlib/_objs/zlib_checked_in/gzwrite.o)
# Configuration: e8ff020b2b067b6b6ee8bdda4e7996c46b822986011eca4b767411efb47daa7f
# Execution platform: //:default_host_platform

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
third_party/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);
                   ^
third_party/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);
         ^
third_party/zlib/gzwrite.c:119: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);
                       ^
third_party/zlib/gzwrite.c:673: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)
        ^
3 errors generated.
Error in child process '/usr/bin/xcrun'. 1

@hvadehra I'll fix zlib in the Bazel repo first, then will hand it over to you to have a new java tools release.

@meteorcloudy meteorcloudy self-assigned this Apr 4, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Apr 4, 2023

@meteorcloudy If there will be a 5.4.1 release, maybe the fix for this should be included in that release as well?

@brentleyjones
Copy link
Contributor

I got this building bazel with Xcode 14.3, but from macOS 13.1, not sure if related:

ERROR: /Users/brentley/Developer/bazel/third_party/zlib/BUILD:39:19: Compiling third_party/zlib/gzlib.c [for tool] failed: (Exit 1): wrapped_clang failed: error executing command (from target //third_party/zlib:zlib_checked_in) external/local_config_cc/wrapped_clang ‘-D_FORTIFY_SOURCE=1’ -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG ‘-DNS_BLOCK_ASSERTIONS=1’ ... (remaining 34 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
third_party/zlib/gzlib.c:254:9: error: call to undeclared function ‘lseek’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
        ^
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
third_party/zlib/gzlib.c:254:9: note: did you mean ‘fseek’?
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
/Applications/Xcode-14.3.0-RC2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:162:6: note: ‘fseek’ declared here
int      fseek(FILE *, long, int);
         ^
third_party/zlib/gzlib.c:260:24: error: call to undeclared function ‘lseek’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        state->start = LSEEK(state->fd, 0, SEEK_CUR);
                       ^
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
third_party/zlib/gzlib.c:361:9: error: call to undeclared function ‘lseek’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
        ^
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
third_party/zlib/gzlib.c:402:15: error: call to undeclared function ‘lseek’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
              ^
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
third_party/zlib/gzlib.c:498:14: error: call to undeclared function ‘lseek’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    offset = LSEEK(state->fd, 0, SEEK_CUR);
             ^
third_party/zlib/gzlib.c:14:17: note: expanded from macro ‘LSEEK’
#  define LSEEK lseek
                ^
5 errors generated.

@meteorcloudy
Copy link
Member

@fmeum Oh, that makes sense, how confident are we that Blosc/c-blosc@ac72c2c is the correct fix, it's weird I don't see any upstream issue or PR mentioning this problem.

@brentleyjones Yes, looks like the same error.

@meteorcloudy
Copy link
Member

meteorcloudy commented Apr 4, 2023

@kshyanashree @keertk We should also cherry pick the fix for this issue into 5.4.1,, and 6.2.0

@meteorcloudy
Copy link
Member

@bazel-io fork 5.4.1

@meteorcloudy
Copy link
Member

@bazel-io fork 6.2.0

@fmeum
Copy link
Collaborator Author

fmeum commented Apr 4, 2023

@fmeum Oh, that makes sense, how confident are we that Blosc/c-blosc@ac72c2c is the correct fix, it's weird I don't see any upstream issue or PR mentioning this problem.

gzlib.c doesn't seem to transitively include unistd.h, but still uses either lseek or lseek64 here. I am also surprised that this hasn't come up in many more places though.

keertk pushed a commit that referenced this issue Apr 11, 2023
Fixes #17956

Partial commit for third_party/*, see #17987.

Closes #17987

Signed-off-by: Yun Peng <pcloudy@google.com>
Co-authored-by: Yun Peng <pcloudy@google.com>
@DanieleSassoli
Copy link

DanieleSassoli commented Apr 12, 2023

Is version 6.1.2rc1 supposed to fix this issue? Doesn't seem to be doing the trick for me. Still getting the same problem.

➜   bazel version
Bazelisk version: development
Build label: 6.1.2rc1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Apr 11 23:08:27 2023 (1681254507)
Build timestamp: 1681254507
Build timestamp as int: 1681254507
➜   pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // XCode version
version: 14.3.0.0.1.1679647830
➜   sw_vers // macOS version
ProductName:            macOS
ProductVersion:         13.3.1
BuildVersion:           22E261

And I still get

external/remote_java_tools/java_tools/zlib/gzlib.c:254:9: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */

@meteorcloudy
Copy link
Member

For fixing remote_java_tools itself, we'll need a separate java_tools release. /cc @hvadehra can you do that?

@meteorcloudy
Copy link
Member

@hvadehra After having the new release, do we need to upgrade the java_tools version embedded in Bazel?

keertk pushed a commit that referenced this issue Apr 12, 2023
Fixes #17956

Partial commit for third_party/*, see #17987.

Closes #17987

Signed-off-by: Yun Peng <pcloudy@google.com>
Co-authored-by: Yun Peng <pcloudy@google.com>
@hvadehra
Copy link
Member

@hvadehra After having the new release, do we need to upgrade the java_tools version embedded in Bazel?

I think only for the non-prebuilt java toolchain case.

@meteorcloudy
Copy link
Member

@hvadehra I see, can you follow up with a fix and some cherry picks?

@meteorcloudy meteorcloudy reopened this Apr 13, 2023
@hvadehra
Copy link
Member

I'm thinking we make a new java_tools release at HEAD and cherry-pick embedding that into 6.2. If waiting for 6.2 is not possible, one can override the java_tools version in WORKSPACE. @meteorcloudy WDYT?

@meteorcloudy
Copy link
Member

one can override the java_tools version in WORKSPACE

I guess that should be fine? Can you give some instruction here on how to do that?

Given the limited impact and the existing workaround with --host_conlyopt=-std=c90, probably no additional cherry pick for the patch releases are needed. /cc @keertk

@hvadehra
Copy link
Member

I guess that should be fine? Can you give some instruction here on how to do that?

The instructions are published with every java_tools release, eg: https://github.com/bazelbuild/java_tools/releases/tag/java_v12.0

@keertk @kshyanashree Would it be possible for you to make a regular release for java_tools? I'm going to be OOO soon and might not be able to finish the process.

@keertk
Copy link
Member

keertk commented Apr 13, 2023

Sure, we can do the release. Tracked here: bazelbuild/java_tools#69

@casian
Copy link

casian commented Apr 13, 2023

[4.2.4] @remote_java_tools fail to build on macOS 13.3 with Xcode 14.3 #18034

Thanks! Much appreciated!!

@keertk
Copy link
Member

keertk commented Apr 20, 2023

java_tools v12.1 + instructions: https://github.com/bazelbuild/java_tools/releases/tag/java_v12.1
Will cherry-pick into 6.2 as well.

cc @hvadehra @meteorcloudy @comius

@keertk keertk closed this as completed Apr 20, 2023
hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Apr 24, 2023
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
hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Apr 24, 2023
After upgrading MacOS to 13.3.1 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
- revert "Work around build errors on MacOS 13.3 and XCode 14.3"
- and follow the advise in [1]:
  - update bazel to 6.1.2
  - update remote_java_tools to 12.1
    https://github.com/bazelbuild/java_tools/releases/tag/java_v12.1

Set new errorprone bug patterns to WARN until we fixed occurrences.
Also demote the severity for these bug patterns to warning:

o LiteProtoToString
o MutableConstantField
o ProvidesMethodOutsideOfModule

Also suppress warnings for the following bug patterns: DoNotCall,
MathAbsoluteNegative and Unused using @SuppressWarnings annotation.

Also note that PreferredInterfaceType bug pattern is reported, but can
only be demoted to warning severity using the MutableConstantField bug
pattern, see also [2].

[1] bazelbuild/bazel#17956
[2] google/error-prone#3872

Release-Notes: Update bazel to 6.2.1 and remote_java_tools to 12.1 to fix build on MacOS 13.3
Change-Id: Ib9d8d8be44a58c470f712d297c39518498c43dc2
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
Fixes bazelbuild#17956

Partial commit for third_party/*, see bazelbuild#17987.

Closes bazelbuild#17987

Signed-off-by: Yun Peng <pcloudy@google.com>
hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Jun 8, 2023
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
(cherry picked from commit bda7eac)
This was referenced Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
13 participants