cgosymbolizer icon indicating copy to clipboard operation
cgosymbolizer copied to clipboard

Undefined _cgoTraceback in MacOS

Open raff opened this issue 4 years ago • 4 comments

Trying to build this (imported by some other package) on MacOS 11.2 Beta, with Xcode 12.3 / Apple clang version 12.0.0 (clang-1200.0.32.28), go version go1.15.5 darwin/amd64

I am getting:

# github.com/ianlancetaylor/cgosymbolizer
Undefined symbols for architecture x86_64:
  "_cgoTraceback", referenced from:
      __cgohack_cgoTraceback in _cgo_main.o
     (maybe you meant: __cgohack_cgoTraceback)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am not sure of where "cgohack" is coming from (I am assuming the missing symbol is the one defined in traceback.c).

raff avatar Jan 11 '21 02:01 raff

The package is only tested on GNU/Linux. You could try removing the +build linux line from traceback.c. I don't know whether it will work on Darwin or not. I've never tried it.

ianlancetaylor avatar Jan 11 '21 04:01 ianlancetaylor

Removing +build linux (or adding +build darwin) does solve the undefined. Not sure if it works, but it allows me to build the original package. Thanks!

raff avatar Jan 17 '21 06:01 raff

Adding +build linux darwin solves the linker problem but does not seem to resolve the symbol (function name), file, or line where a crash occurs.

My guess is that the build links to Apple's unwind.h, which perhaps doesn't function the same way. But maybe it will work if linked against a Mac build of LLVM's libunwind.

elv-peter avatar Jun 03 '21 05:06 elv-peter

https://github.com/benesch/cgosymbolizer includes an implementation that mostly works on Mac OS X.

evanj avatar Dec 16 '21 23:12 evanj