bazel: `@remote_java_tools` fail to build on macOS 13.3 with Xcode 14.3
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: https://github.com/Blosc/c-blosc/pull/353/commits/ac72c2cf8248c6fdfb8b1ed97e1da95f8714870f
Any other information, logs, or outputs that you want to share?
This can be worked around with --host_conlyopt=-std=c90
(see https://github.com/bazelbuild/bazel/issues/17956#issuecomment-1494853070 for less intrusive workarounds).
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 33 (21 by maintainers)
Commits related to this issue
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 — committed to meteorcloudy/bazel by meteorcloudy a year ago
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Yun Peng <pcloud... — committed to ShreeM01/bazel by meteorcloudy a year ago
- Patch zlib to fix compatibility with latest Xcode (#17996) Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Y... — committed to bazelbuild/bazel by ShreeM01 a year ago
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Yun Peng <pcloud... — committed to ShreeM01/bazel by meteorcloudy a year ago
- Add compilation fix for zlib Later xcode toolchains fail to compile zlib under bazel. This change adds a workaround based on https://github.com/bazelbuild/bazel/issues/17956. Without this change, zl... — committed to cloudflare/workerd by ohodson a year ago
- Add compilation fix for zlib Later xcode toolchains fail to compile zlib under bazel. This change adds a workaround based on https://github.com/bazelbuild/bazel/issues/17956. Without this change, zl... — committed to cloudflare/workerd by ohodson a year ago
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Yun Peng <pcloud... — committed to ShreeM01/bazel by meteorcloudy a year ago
- Patch zlib to fix compatibility with latest Xcode (#18000) Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Y... — committed to bazelbuild/bazel by ShreeM01 a year ago
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Yun Peng <pcloud... — committed to ShreeM01/bazel by meteorcloudy a year ago
- Patch zlib to fix compatibility with latest Xcode (#18039) Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Y... — committed to bazelbuild/bazel by ShreeM01 a year ago
- Patch zlib to fix compatibility with latest Xcode (#18041) Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Y... — committed to bazelbuild/bazel by ShreeM01 a year ago
- 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 r... — committed to GerritCodeReview/gerrit by msohn a year ago
- Fix build on MacOS 13.3 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... — committed to GerritCodeReview/gerrit by msohn a year ago
- Patch zlib to fix compatibility with latest Xcode Fixes https://github.com/bazelbuild/bazel/issues/17956 Partial commit for third_party/*, see #17987. Closes #17987 Signed-off-by: Yun Peng <pcloud... — committed to fweikert/bazel by meteorcloudy a year ago
- 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 r... — committed to GerritCodeReview/gerrit by msohn a year ago
for anyone else who lands here, fixes are either adding
-std=c90
to the zlib BUILD file copts, or addingbuild --per_file_copt='external/zlib[~/].*\.c@-std=c90' --host_per_file_copt='external/zlib[~/].*\.c@-std=c90'
to their .bazelrcthe blanket
--host_conlyopt=-std=c90
flag can break a lot of other common/important things, like the go compileredit: changed regex to work with bzlmod as well
@bazel-io fork 4.2.4
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.
For fixing
remote_java_tools
itself, we’ll need a separate java_tools release. /cc @hvadehra can you do that?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.And I still get
@bazel-io fork 6.1.2
@bazel-io fork 6.2.0
@bazel-io fork 5.4.1
@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.
I got this building
bazel
with Xcode 14.3, but from macOS 13.1, not sure if related:@hvadehra Would applying a patch such as https://github.com/Blosc/c-blosc/commit/ac72c2cf8248c6fdfb8b1ed97e1da95f8714870f to
third_party/zlib
be an acceptable solution?