rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.79k stars 314 forks source link

"dyld: lazy symbol binding failed: Symbol not found" #389

Closed polyominal closed 3 years ago

polyominal commented 3 years ago

I'm working on macOS Mojave (10.14.6). I tried to compile a single file using bear -- make A, and it results in the following error:

$ bear -- make A
g++-11 -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -Wno-unused-result -Wno-sign-conversion    A.cpp   -o A
dyld: lazy symbol binding failed: Symbol not found: __ZN6google8protobuf5EmptyC1EPNS0_5ArenaE
  Referenced from: /usr/local/Cellar/bear/3.0.12/libexec/bear/wrapper.d/as
  Expected in: /usr/local/opt/protobuf/lib/libprotobuf.28.dylib

dyld: Symbol not found: __ZN6google8protobuf5EmptyC1EPNS0_5ArenaE
  Referenced from: /usr/local/Cellar/bear/3.0.12/libexec/bear/wrapper.d/as
  Expected in: /usr/local/opt/protobuf/lib/libprotobuf.28.dylib

g++-11: internal compiler error: Abort trap: 6 signal terminated program as
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
make: *** [A] Error 4
clang: error: no such file or directory: '/var/folders/v1/q03_4mm946j_mn_2t7kv4zlh0000gn/T//ccy83D1m.s'
clang: error: no input file

My Makefile is as follows:

TARGET := A

CC = gcc-11
CXX = g++-11
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -Wno-unused-result -Wno-sign-conversion

all: $(TARGET)
.PHONY: all

Another mac with 10.15.x also gave the exact same error, and everything seemed to be working fine on ubuntu under similar configuration.

rizsotto commented 3 years ago

Could you please answer the questions that is in the issue template? (Which version of Bear? How did you installed? etc...) Those are relevant info to understand to diagnose a problem like this.

It looks like a packaging problem to me. Your system has a different gRPC package installed, than the Bear was compiled and linked against... But that's just a guess at this point.

polyominal commented 3 years ago

dyld: Symbol not found: __ZN6google8protobuf5EmptyC1EPNS0_5ArenaE Referenced from: /usr/local/Cellar/bear/3.0.12/libexec/bear/wrapper.d/as Expected in: /usr/local/opt/protobuf/lib/libprotobuf.28.dylib

g++-11: internal compiler error: Abort trap: 6 signal terminated program as Please submit a full bug report, with preprocessed source if appropriate. See https://github.com/Homebrew/homebrew-core/issues for instructions. make: *** [A] Error 4 [22:23:00.497194, ic, 15459] Process wait request: done. [pid: 15460] [22:23:00.497212, ic, 15459] Running command. [Exited with 2] [22:23:00.497247, ic, 15459] Stopping gRPC server. [22:23:00.497716, ic, 15459] succeeded with: 2 [22:23:00.498354, br, 15458] Process wait request: done. [pid: 15459] [22:23:00.498405, br, 15458] Running intercept finished. [Exited with 2] [22:23:00.499061, br, 15458] Process spawned. [pid: 15466, command: [/usr/local/Cellar/bear/3.0.12/bin/citnames, --input, compile_commands.db, --output, compile_commands.json, --run-checks, --verbose]] [22:23:00.499085, br, 15458] Process wait requested. [pid: 15466] clang: error: no such file or directory: '/var/folders/v1/q03_4mm946j_mn_2t7kv4zlh0000gn/T//ccQ1278q.s' clang: error: no input files [22:23:00.509718, cs, 15466] citnames: 3.0.12 [22:23:00.509959, cs, 15466] arguments: ["/usr/local/Cellar/bear/3.0.12/bin/citnames", "--input", "compile_commands.db", "--output", "compile_commands.json", "--run-checks", "--verbose"] [22:23:00.509975, cs, 15466] environment: ["Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.PgYS0WXLfb/Render", "CC=/usr/local/bin/gcc-11", "COLORFGBG=12;8", "COLORTERM=truecolor", "CXX=/usr/local/bin/g++-11", "EDITOR=nvim", "HOME=/Users/hanfei", "ITERM_PROFILE=Default", "ITERM_SESSION_ID=w0t0p0:D2819D3B-2E56-4A8E-8B65-E8A0F8943B29", "LANG=en_US.UTF-8", "LC_TERMINAL=iTerm2", "LC_TERMINAL_VERSION=3.4.8", "LESS=-R", "LOGNAME=hanfei", "LSCOLORS=Gxfxcxdxbxegedabagacad", "OLDPWD=/Users/hanfei", "PAGER=less", "PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", "PWD=/Users/hanfei/programming/A", "SHELL=/usr/local/bin/zsh", "SHLVL=1", "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.GrKqDoFqre/Listeners", "TERM=xterm-256color", "TERM_PROGRAM=iTerm.app", "TERM_PROGRAM_VERSION=3.4.8", "TERM_SESSION_ID=w0t0p0:D2819D3B-2E56-4A8E-8B65-E8A0F8943B29", "TMPDIR=/var/folders/v1/q03_4mm946j_mn_2t7kv4zlh0000gn/T/", "USER=hanfei", "XPC_FLAGS=0x0", "XPC_SERVICENAME=0", "ZSH=/Users/hanfei/.oh-my-zsh", "=/usr/local/bin/bear", "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0", "all_proxy=socks5://127.0.0.1:1389"] [22:23:00.510043, cs, 15466] sysname: Darwin [22:23:00.510048, cs, 15466] release: 18.7.0 [22:23:00.510052, cs, 15466] version: Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 [22:23:00.510054, cs, 15466] machine: x86_64 [22:23:00.510066, cs, 15466] arguments parsed: {program: /usr/local/Cellar/bear/3.0.12/bin/citnames, arguments: [{--input: [compile_commands.db]}, {--output: [compile_commands.json]}, {--run-checks: []}, {--verbose: []}]} [22:23:00.510290, cs, 15466] Configuration: {"compilation":{"compilers_to_recognize":[{"executable":"/usr/local/bin/gcc-11"},{"executable":"/usr/local/bin/g++-11"}]},"output":{"content":{"include_only_existing_source":true},"format":{"command_as_array":true,"drop_output_field":false}}} [22:23:00.510376, cs, 15466] compilation entries created. [size: 0] [22:23:00.510381, cs, 15466] compilation entries to output. [size: 0] [22:23:00.510573, cs, 15466] compilation entries written. [size: 0] [22:23:00.510595, cs, 15466] succeeded with: 0 [22:23:00.511101, br, 15458] Process wait request: done. [pid: 15466] [22:23:00.511127, br, 15458] Running citnames finished. [Exited with 0] [22:23:00.511196, br, 15458] succeeded with: 2

rizsotto commented 3 years ago

Thanks for the updates. This looks to me a library incompatibility issue. Could you please check the followings?

If the two grpc versions are different, then you need to ask the package maintainers to rebuild. If the versions are the same, will re-open this ticket.

FrankBro commented 3 years ago

I have the same issue:

➜  brew install grpc
Warning: grpc 1.38.0 is already installed and up-to-date.
To reinstall 1.38.0, run:
  brew reinstall grpc
➜  brew install bear
Warning: bear 3.0.12 is already installed and up-to-date.
To reinstall 3.0.12, run:
  brew reinstall bear

And according to this https://formulae.brew.sh/formula/bear#default

That version of bear was built on that version of grpc.

Pretty much same setup as above.

Everything installed through brew.

dyld: lazy symbol binding failed: Symbol not found: __ZN6google8protobuf5EmptyC1EPNS0_5ArenaE
  Referenced from: /usr/local/Cellar/bear/3.0.12/libexec/bear/wrapper.d/clang
  Expected in: /usr/local/opt/protobuf/lib/libprotobuf.28.dylib

dyld: Symbol not found: __ZN6google8protobuf5EmptyC1EPNS0_5ArenaE
  Referenced from: /usr/local/Cellar/bear/3.0.12/libexec/bear/wrapper.d/clang
  Expected in: /usr/local/opt/protobuf/lib/libprotobuf.28.dylib
rizsotto commented 3 years ago

Thanks @FrankBro , could you find the build log of Bear package? Or can you ask the package maintainer how the package were built? Or ask him/her to do a rebuild?

Missing symbol is usually a simptom of different library versions. Compiling and linking Bear against grpc 1.38.0 works and pass the tests. This is a packaging problem in my opinion.

FrankBro commented 3 years ago

I wonder if this is related but, trying to build Bear locally, I get this:

loading initial cache file /Users/frankbro/Bear/subprojects/tmp/BearSource/BearSource-cache-Release.cmake
-- Checking for modules 'protobuf;grpc++'
--   Package 'openssl', required by 'grpc', not found

What's weird is openssl is installed...

rizsotto commented 3 years ago

Yes, that's a weirdness of Homebrew handling multiple ssl libraries (or multiple version of the same library).

Please take a look to the CI workflow, it shows what needs to do to make CMake happy. The install guide has a section to fix macOS specific compilation issues.