rules_proto
rules_proto copied to clipboard
symbol not found in flat namespace on apple M1
I am building a project with protos on apple M1 and I get a symbol not found in flat namespace '__ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev'
error when protoc gets invoked.
I opened a stack overflow about it, but I figured out this might come from the way protoc is built with rules_proto
.
It is a c++ project and I made sure to use the c++17 by passing the option to the command line.
After some research it seems that the problem comes most likely a conflict between libc++ and libstdc++, but I have no clue where it comes from and how I should solve it.
I am using proto with grpc, here is the related part of my WORKSPACE file:
http_archive(
name = "rules_proto",
sha256 = "afa0473881bd472a514254786f38527f8f8cf6dbf82bc24706c140a5bfeeb573",
strip_prefix = "rules_proto-4.0.0-3.19.1",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.19.1.tar.gz",
],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
http_archive(
name = "com_github_grpc_grpc",
urls = [
"https://github.com/grpc/grpc/archive/refs/tags/v1.44.0.tar.gz",
],
sha256 = "8c05641b9f91cbc92f51cc4a5b3a226788d7a63f20af4ca7aaca50d92cc94a0d",
strip_prefix = "grpc-1.44.0",
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
❯ bazel build lib --cxxopt -std=c++17 --cxxopt -fpic --verbose_failures
INFO: Analyzed target //:lib (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/user/work/proj/3rdparty/Project/cc/project/protos/BUILD:10:19: Action cc/project/protos/file.grpc.pb.h failed: (Aborted): protoc failed: error executing command
(cd /private/var/tmp/_bazel_user/dedfc382dcde4c27bfad3e37c75660b3/sandbox/darwin-sandbox/526/execroot/__main__ && \
exec env - \
PATH=/Users/user/Library/Caches/bazelisk/downloads/bazelbuild/bazel-5.4.0-darwin-arm64/bin:/Users/user/nvim-macos/bin/:/Users/user/perl5/bin/:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/Users/user/nvim-macos/bin:/Users/user/perl5/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/Caskroom/miniforge/base/bin:/opt/homebrew/Caskroom/miniforge/base/condabin:/Users/user/.nvm/versions/node/v17.6.0/bin:/Users/user/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/user/nvim-macos/bin:/Users/user/perl5/bin:/Applications/kitty.app/Contents/MacOS:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin:/opt/homebrew/opt/fzf/bin:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin \
bazel-out/host/bin/external/com_github_protocolbuffers_protobuf/protoc '--plugin=protoc-gen-PLUGIN=bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/grpc_cpp_plugin' '--PLUGIN_out=bazel-out/darwin_arm64-fastbuild/bin' '--proto_path=.' '--proto_path=bazel-out/darwin_arm64-fastbuild/bin' cc/project/protos/file.proto)
# Configuration: 0dea222a1412967d38294213555f40fafc2ad3d3044e96efc6da0592ce3c1478
# Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
dyld[92815]: symbol not found in flat namespace '__ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev'
Target //:lib failed to build
ERROR: /Users/user/work/proj/3rdparty/Project/cc/project/protos/BUILD:10:19 Middleman _middlemen/_S_Scc_Sproject_Sprotos_Cfile-BazelCppSemantics_build_arch_darwin_arm64-fastbuild failed: (Aborted): protoc failed: error executing command
(cd /private/var/tmp/_bazel_user/dedfc382dcde4c27bfad3e37c75660b3/sandbox/darwin-sandbox/526/execroot/__main__ && \
exec env - \
PATH=/Users/user/Library/Caches/bazelisk/downloads/bazelbuild/bazel-5.4.0-darwin-arm64/bin:/Users/user/nvim-macos/bin/:/Users/user/perl5/bin/:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/Users/user/nvim-macos/bin:/Users/user/perl5/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/Caskroom/miniforge/base/bin:/opt/homebrew/Caskroom/miniforge/base/condabin:/Users/user/.nvm/versions/node/v17.6.0/bin:/Users/user/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/user/nvim-macos/bin:/Users/user/perl5/bin:/Applications/kitty.app/Contents/MacOS:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin:/opt/homebrew/opt/fzf/bin:/Users/user/go/bin:/opt/homebrew/opt/go/libexec/bin \
bazel-out/host/bin/external/com_github_protocolbuffers_protobuf/protoc '--plugin=protoc-gen-PLUGIN=bazel-out/host/bin/external/com_github_grpc_grpc/src/compiler/grpc_cpp_plugin' '--PLUGIN_out=bazel-out/darwin_arm64-fastbuild/bin' '--proto_path=.' '--proto_path=bazel-out/darwin_arm64-fastbuild/bin' cc/project/protos/file.proto)
# Configuration: 0dea222a1412967d38294213555f40fafc2ad3d3044e96efc6da0592ce3c1478
# Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
INFO: Elapsed time: 0.675s, Critical Path: 0.25s
INFO: 10 processes: 9 internal, 1 darwin-sandbox.
FAILED: Build did NOT complete successfully
I see you're using rules_proto-4.0.0-3.19.1
. Is the bug also present with newer version?
Technically the C++ code for protoc is in protobuf repo, so any symbol problems need to be handled there.