protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.75k stars 15.51k forks source link

Cannot build //:protobuf under macOS #4841

Closed vmax closed 6 years ago

vmax commented 6 years ago

What version of protobuf and what language are you using? Version: 3.6.0.1 Language: Java

What operating system (Linux, Windows, ...) and version? macOS 10.13.5

What runtime / compiler are you using (e.g., python version or gcc version)

ghost:protobuf-3.6.0.1 vmax$ clang -v
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
ghost:protobuf-3.6.0.1 vmax$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-351.8
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
LTO support using: LLVM version 9.1.0, (clang-902.0.39.2) (static support for 21, runtime is 21)
TAPI support using: Apple TAPI version 9.1.0 (tapi-902.0.9)

What did you do? bazel build //:protobuf

What did you expect to see Build completing successfully

What did you see instead?

INFO: Analysed target //:protobuf (0 packages loaded).
INFO: Found 1 target...
INFO: From Linking libprotobuf.a:
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/darwin-fastbuild/bin/_objs/protobuf/src/google/protobuf/io/gzip_stream.pic.o has no symbols
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/darwin-fastbuild/bin/_objs/protobuf/src/google/protobuf/util/internal/error_listener.pic.o has no symbols
ERROR: /Users/vmax/protobuf-3.6.0.1/BUILD:105:1: Linking of rule '//:protobuf' failed (Exit 1)
ld: unknown option: -no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //:protobuf failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.467s, Critical Path: 0.24s
INFO: 1 process: 1 darwin-sandbox.
FAILED: Build did NOT complete successfully

Anything else we should know about your project / environment Using clang and ld from Command Line Tools 9.4 It may be connected since it worked before

yuikns commented 6 years ago

I am meeting exactly the same question.

It seems like to be an environment related issue, since it had worked pretty well before I updated some packages through App Store and bazel itself.

My bazel:

$ bazel version
Build label: 0.15.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 26 12:42:27 2018 (1530016947)
Build timestamp: 1530016947
Build timestamp as int: 1530016947

My error message :

(18:55:23) INFO: Current date is 2018-06-28
(18:55:23) INFO: Analysed 73 targets (0 packages loaded).
(18:55:23) INFO: Found 73 targets...
(18:55:27) ERROR: /Users/yu/.cache/bazel/_bazel_yu/a0ef8c220ea214c47900c6dfb6f89ce6/external/com_google_protobuf/BUILD:260:1: Linking of rule '@com_google_protobuf//:js_embed' failed (Exit 1): cc_wrapper.sh failed: error executing command
  (cd /Users/yu/.cache/bazel/_bazel_yu/a0ef8c220ea214c47900c6dfb6f89ce6/execroot/com_github_argcv_argcv && \
  exec env - \
    PATH=/usr/local/bin:/usr/bin \
    PWD=/proc/self/cwd \
  external/local_config_cc/cc_wrapper.sh -o bazel-out/host/bin/external/com_google_protobuf/js_embed bazel-out/host/bin/external/com_google_protobuf/_objs/js_embed/external/com_google_protobuf/src/google/protobuf/compiler/js/embed.o -Wl,-no-as-needed -Wl,-z,relro,-z,now -undefined dynamic_lookup -headerpad_max_install_names -lstdc++ -lm -Wl,-S)

Use --sandbox_debug to see verbose messages from the sandbox
ld: unknown option: -no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(18:55:27) INFO: Elapsed time: 3.542s, Critical Path: 2.86s
(18:55:27) INFO: 11 processes: 11 darwin-sandbox.
(18:55:27) FAILED: Build did NOT complete successfully
yuikns commented 6 years ago

It worked pretty fine in bazel-0.14.1

Going to the release page and download the binary release for mac through url https://github.com/bazelbuild/bazel/releases/download/0.14.1/bazel-0.14.1-darwin-x86_64

It resolve the problem.

bazelbuild/bazel#5468

xfxyjwf commented 6 years ago

@vmax @yuikns Thanks for the reports. Closing as this looks like a bazel issue: https://github.com/bazelbuild/bazel/issues/5468