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

Problems building release-6.1.1 on osx 13.3.1 (22E261) / Xcode 14.3 (14E222b) #18278

Closed
adam-singer opened this issue May 1, 2023 · 15 comments
Closed
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

@adam-singer
Copy link
Contributor

Description of the bug:

Seems to be a few different failures when trying to build bazel for osx locally using OSX 13.3.1 (22E261) / Xcode 14.3 (14E222b).

The following seems to have resolved the build issue for me, but it just highlights what I removed to get things working, does not resolve the potential issue of version/breaking situations with latest Xcode and bazel osx build setup:

release-6.1.1...adam-singer:bazel:adam-singer/release-6.1.1-arc-removed-min-os-13.3

Main things added / removed

  • Adding unistd.h for osx in third_party/zlib headers.
  • Bumped macos_minimum_os to 13.3
  • Removed -fobjc-arc flag.

zlib failure message

[bazel (release-6.1.1)]$ bazel build //src:bazel-dev
Starting local Bazel server and connecting to it...
(10:05:33) INFO: Current date is 2023-05-01
(10:05:36) DEBUG: /private/var/tmp/_bazel_adams/e3e571441a21119b807d452c0b95bb9b/external/build_bazel_rules_nodejs/index.bzl:122:10: WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.
(10:06:13) INFO: Analyzed target //src:bazel-dev (380 packages loaded, 10178 targets configured).
(10:06:13) INFO: Found 1 target...
(10:06:16) ERROR: /Users/adams/workspace/bazel/third_party/zlib/BUILD:39:19: Compiling third_party/zlib/gzwrite.c 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 -O0 -DDEBUG 'DEBUG_PREFIX_MAP_PWD=.' ... (remaining 32 arguments skipped)

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
(10:06:16) ERROR: /Users/adams/workspace/bazel/third_party/zlib/BUILD:39:19: Compiling third_party/zlib/gzlib.c 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 -O0 -DDEBUG 'DEBUG_PREFIX_MAP_PWD=.' ... (remaining 32 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.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.
Error in child process '/usr/bin/xcrun'. 1
Target //src:bazel-dev failed to build
Use --verbose_failures to see the command lines of failed build steps.
(10:06:16) INFO: Elapsed time: 46.388s, Critical Path: 0.88s
(10:06:16) INFO: 32 processes: 28 internal, 4 darwin-sandbox.
(10:06:16) FAILED: Build did NOT complete successfully

ARC failure messages

[bazel (release-6.1.1)]$ bazel build //src:bazel-dev
(10:19:14) INFO: Current date is 2023-05-01
(10:19:15) INFO: Analyzed target //src:bazel-dev (1 packages loaded, 43 targets configured).
(10:19:15) INFO: Found 1 target...
(10:19:19) INFO: From Compiling src/google/protobuf/stubs/strutil.cc [for tool]:
external/com_google_protobuf/src/google/protobuf/stubs/strutil.cc:506:11: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
          sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"),
          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
1 warning generated.
(10:20:05) INFO: From Generating proto_library //src/main/protobuf:execution_statistics_proto:
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:244] The optimize_for = LITE_RUNTIME option is no longer supported by protobuf Java code generator and is ignored--protoc will always generate full runtime code for Java. To use Java Lite runtime, users should use the Java Lite plugin instead. See:
  https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
(10:20:06) INFO: From Generating proto_library @googleapis//:google_bytestream_bytestream_proto:
google/bytestream/bytestream.proto:19:1: warning: Import google/api/annotations.proto is unused.
(10:20:06) INFO: From Action external/googleapis/google_bytestream_bytestream_java_grpc_srcs.jar:
google/bytestream/bytestream.proto:19:1: warning: Import google/api/annotations.proto is unused.
(10:20:06) INFO: From Generating proto_library @googleapis//:google_api_auth_proto:
google/api/auth.proto:19:1: warning: Import google/api/annotations.proto is unused.
(10:20:10) ERROR: /Users/adams/workspace/bazel/src/main/java/net/starlark/java/eval/BUILD:96:10: Linking src/main/java/net/starlark/java/eval/libcpu_profiler.so failed: (Exit 1): cc_wrapper.sh failed: error executing command (from target //src/main/java/net/starlark/java/eval:libcpu_profiler.so) external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-fastbuild/bin/src/main/java/net/starlark/java/eval/libcpu_profiler.so-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in child process '/usr/bin/xcrun'. 1
Target //src:bazel-dev failed to build
Use --verbose_failures to see the command lines of failed build steps.
(10:20:10) INFO: Elapsed time: 56.681s, Critical Path: 25.19s
(10:20:10) INFO: 448 processes: 48 internal, 389 darwin-sandbox, 11 worker.
(10:20:10) FAILED: Build did NOT complete successfully
[tw-mbp-adams-4 bazel (adams/test)]$ ls -al /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/
total 245784
drwxr-xr-x  18 root  wheel        576 Mar 24 04:19 .
drwxr-xr-x   8 root  wheel        256 Mar 24 04:09 ..
drwxr-xr-x   6 root  wheel        192 Apr  3 09:57 SwiftSourceKitClientPlugin.framework
drwxr-xr-x   6 root  wheel        192 Apr  3 09:57 SwiftSourceKitPlugin.framework
drwxr-xr-x   3 root  wheel         96 Mar 11 15:19 clang
-rwxr-xr-x   1 root  wheel     702704 Mar 24 04:19 libIndexStore.dylib
-rwxr-xr-x   1 root  wheel  121630112 Mar 24 04:18 libLTO.dylib
-rwxr-xr-x   1 root  wheel   22838240 Mar 24 04:19 libSwiftDriver.dylib
-rwxr-xr-x   1 root  wheel  226265216 Mar 24 04:19 libclang.dylib
-rwxr-xr-x   1 root  wheel     171856 Mar 24 04:18 libcodedirectory.dylib
-rwxr-xr-x   1 root  wheel    1132768 Mar 24 04:19 libswiftDemangle.dylib
-rwxr-xr-x   1 root  wheel     523280 Mar 24 04:18 libtapi.dylib
drwxr-xr-x   6 root  wheel        192 Apr  3 09:57 sourcekitd.framework
drwxr-xr-x   6 root  wheel        192 Apr  3 09:57 sourcekitdInProc.framework
drwxr-xr-x  17 root  wheel        544 Apr  3 09:57 swift
drwxr-xr-x   9 root  wheel        288 Dec  4 08:14 swift-5.0
drwxr-xr-x   9 root  wheel        288 Dec  4 08:14 swift-5.5
drwxr-xr-x   3 root  wheel         96 Feb 25 01:18 tapi

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

Using OSX 13.3.1 (22E261) / Xcode 14.3 (14E222b) on release-6.1.1

bazel build //src:bazel-dev

Which operating system are you running Bazel on?

OSX 13.3.1 (22E261)

What is the output of bazel info release?

release 6.1.2

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 ?

https://github.com/bazelbuild/bazel.git
6b3bae26c10bf1a72d1dcfdae64c6cf83eddd513
e7fd4cf42e3e320dfac0400464a604c0d8b71a1d

Have you found anything relevant by searching the web?

No response

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

No response

@Pavank1992
Copy link
Contributor

This is a duplicate of #17956. In particular the discussion starting from #17956 (comment).

@Pavank1992 Pavank1992 added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label May 2, 2023
@adam-singer
Copy link
Contributor Author

This is a duplicate of #17956. In particular the discussion starting from #17956 (comment).

That issue is similar, but eventually leads to libarclite_macosx.a not being available once getting past the unistd.h header inclusion. I think there are two issues here but the first one needs to be fixed before hitting the second one on osx 13.3.1 (22E261) / Xcode 14.3 (14E222b)

@meteorcloudy meteorcloudy self-assigned this May 2, 2023
@meteorcloudy meteorcloudy added P1 I'll work on this now. (Assignee required) and removed untriaged labels May 2, 2023
@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) P1 I'll work on this now. (Assignee required) and removed P1 I'll work on this now. (Assignee required) P2 We'll consider working on this in future. (Assignee optional) labels May 17, 2023
@meteorcloudy
Copy link
Member

Now seeing the same error on Bazel CI: https://buildkite.com/bazel/bazel-bazel/builds/23347#0188282d-5359-496a-8f03-d004561adf2e

@meteorcloudy
Copy link
Member

ld: file not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in child process '/usr/bin/xcrun'. 1
Target //src:bazel-dev failed to build

@keith @googlewalt Is this an issue we should fix in the apple cc toolchain?

@meteorcloudy
Copy link
Member

Looks like it's a common problem with Xcode 14.3: https://stackoverflow.com/questions/75574268/missing-file-libarclite-iphoneos-a-xcode-14-3

@keith
Copy link
Member

keith commented May 17, 2023

The fix at least on rules_apple was to bump the minimum OS for the affected targets. Is that ok to do for the case failing here too? I think this is just a bad error for Xcode dropping support for old platforms, but I didn't dig since bumping the version was fine for our cases that failed

@keith
Copy link
Member

keith commented May 17, 2023

and for the zlib warning, at least in bazel, we could just flip that warning flag off. but maybe there's also a version with a fix?

@pcjanzen
Copy link
Contributor

zlib is being somewhat recalcitrant about fixing: madler/zlib#633

@meteorcloudy
Copy link
Member

bump the minimum OS for the affected targets.

Which minimum OS version is required?

and for the zlib warning

The zlib failure has been worked around with a patch.

keith added a commit to keith/bazel that referenced this issue May 19, 2023
With Xcode 14.3+ on x86_64 machines there is an opaque error when
linking binaries on macOS because Apple removed an old support library.
That library is only linked if the macOS target is < 10.11, so this
bumps the default versions past that. This macOS version was released in
September 2015.

Fixes bazelbuild#18278
@keith
Copy link
Member

keith commented May 19, 2023

Here's a patch #18460, we only have to bump 1 more version. @adam-singer I see you changed a few more places in your patch, can you verify mine is enough? I didn't see any more issues (although I didn't run all tests either)

@keith
Copy link
Member

keith commented May 19, 2023

(the same patch would need to be applied to the 6.x release branch as well)

@meteorcloudy
Copy link
Member

@keith Thanks! I since it's just a minor version bump, I think we should just do it!

@meteorcloudy
Copy link
Member

@keith IIUC, users can also work around this issue by passing --macos_minimum_os=10.11?

@keith
Copy link
Member

keith commented May 22, 2023

Yep!

@adam-singer
Copy link
Contributor Author

--macos_minimum_os=10.11 worked for me, thanks!

iancha1992 pushed a commit to iancha1992/bazel that referenced this issue May 24, 2023
With Xcode 14.3+ on x86_64 machines there is an opaque error when linking binaries on macOS because Apple removed an old support library. That library is only linked if the macOS target is < 10.11, so this bumps the default versions past that. This macOS version was released in September 2015.

Fixes bazelbuild#18278

Closes bazelbuild#18460.

PiperOrigin-RevId: 534743568
Change-Id: I131880096c941df0097fe3b1faabd5a6afada4f3
iancha1992 added a commit that referenced this issue May 25, 2023
With Xcode 14.3+ on x86_64 machines there is an opaque error when linking binaries on macOS because Apple removed an old support library. That library is only linked if the macOS target is < 10.11, so this bumps the default versions past that. This macOS version was released in September 2015.

Fixes #18278

Closes #18460.

PiperOrigin-RevId: 534743568
Change-Id: I131880096c941df0097fe3b1faabd5a6afada4f3

Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
With Xcode 14.3+ on x86_64 machines there is an opaque error when linking binaries on macOS because Apple removed an old support library. That library is only linked if the macOS target is < 10.11, so this bumps the default versions past that. This macOS version was released in September 2015.

Fixes bazelbuild#18278

Closes bazelbuild#18460.

PiperOrigin-RevId: 534743568
Change-Id: I131880096c941df0097fe3b1faabd5a6afada4f3
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
Development

Successfully merging a pull request may close this issue.

6 participants