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

runtime/cgo Undefined symbols for architecture arm64: _darwin_arm_init_mach_exception_handler #46032

Closed
UnivexDont opened this issue May 7, 2021 · 10 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@UnivexDont
Copy link

UnivexDont commented May 7, 2021

What version of Go are you using (go version)?

go version go1.16.3 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/donto/Library/Caches/go-build"
GOENV="/Users/donto/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/donto/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/donto/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sh/qsg17h7x3137bt_p6qcqh1g80000gn/T/go-build4147123810=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=4e9e4b" -X "github.com/Dreamacro/clash/constant.BuildTime=2021-05-07-1435"' -buildmode=c-archive -o goClash_arm64.a

What did you expect to see?

Build successed && generate .a for iOS

What did you see instead?

runtime/cgo
Undefined symbols for architecture arm64:
"_darwin_arm_init_mach_exception_handler", referenced from:
_x_cgo_init in _x004.o
"_darwin_arm_init_thread_exception_port", referenced from:
_threadentry in _x004.o
_x_cgo_init in _x004.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):

@AlexRouSg
Copy link
Contributor

Your go version says amd64 but your output says arm64
Please clarify whether you set GOOS and GOARCH

Also is there a reason you are not using golang.org/x/mobile ?

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 7, 2021
@UnivexDont
Copy link
Author

Your go version says amd64 but your output says arm64
Please clarify whether you set GOOS and GOARCH

Also is there a reason you are not using golang.org/x/mobile ?

Thank you so much!
I'll try it.

@UnivexDont
Copy link
Author

already fixed

@jaroslavas
Copy link

So how have you fixed it?

@wuhan005
Copy link

So how have you fixed it?

I switch my Go version from go1.16.x to go1.14. Then it works.

@ChristianOrgler
Copy link

That's not working for M1 MacBooks tho - any suggestion on how to fix it?

go version go1.16.5 darwin/arm64

Error:

go build -ldflags=-w -trimpath -v -o "/Users/someone/Library/Developer/Xcode/DerivedData/something-bipqhwawbdbbciblevyubvleyofz/Build/Intermediates.noindex/something.build/Debug-iphonesimulator/wireguard-go-bridge/libwg-go-arm64.a" -buildmode c-archive
runtime/ago
# runtime/cgo
Undefined symbols for architecture arm64:
  "_darwin_arm_init_mach_exception_handler", referenced from:
      _x_cgo_init in _x004.o
  "_darwin_arm_init_thread_exception_port", referenced from:
      _threadentry in _x004.o
      _x_cgo_init in _x004.o

ld: symbol(s) not found for architecture arm64

@maks-shevchenko
Copy link

That's not working for M1 MacBooks tho - any suggestion on how to fix it?

go version go1.16.5 darwin/arm64

Error:

go build -ldflags=-w -trimpath -v -o "/Users/someone/Library/Developer/Xcode/DerivedData/something-bipqhwawbdbbciblevyubvleyofz/Build/Intermediates.noindex/something.build/Debug-iphonesimulator/wireguard-go-bridge/libwg-go-arm64.a" -buildmode c-archive
runtime/ago
# runtime/cgo
Undefined symbols for architecture arm64:
  "_darwin_arm_init_mach_exception_handler", referenced from:
      _x_cgo_init in _x004.o
  "_darwin_arm_init_thread_exception_port", referenced from:
      _threadentry in _x004.o
      _x_cgo_init in _x004.o

ld: symbol(s) not found for architecture arm64

I know it's been almost a year ago but.. :)
have you managed to fix it?

@blacktop
Copy link

ping same-zeezes

@drew-512
Copy link

drew-512 commented Dec 17, 2022

Getting this here too.

Adding -tags=ios to go build causes the unresolved linker errors to go away but then there's a crash on startup.

If anyone gets any insight into this, please post -- thanks.

@drew-512
Copy link

drew-512 commented Dec 17, 2022

I figured out the issue was I was using GOOS=darwin rather than the more recent GOOS=ios (since go 1.16?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

10 participants