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

Apple M1 ARM support #2246

Closed
luminacious opened this issue Dec 2, 2020 · 25 comments · Fixed by #2285
Closed

Apple M1 ARM support #2246

luminacious opened this issue Dec 2, 2020 · 25 comments · Fixed by #2285

Comments

@luminacious
Copy link

Hi All

Hope you're all safe and well.

You're probably already aware of this but just in case.

When trying to debug on Apple M1, it comes back with "rosetta error: failed to allocate vm space for aot".

Just wondering if there's any recommendations please.

Love your work 😊👍

@aarzilli
Copy link
Member

aarzilli commented Dec 3, 2020

Go doesn't officially support darwin/arm64 until go1.16, delve won't ufficially support go1.16 until 1.6.0, we don't have access to darwin/arm64 machines to port delve to them so support for delve on darwin/arm64 is unplanned. It's highly unlikely that debuggers can work through rosetta.

@oxisto
Copy link
Contributor

oxisto commented Dec 5, 2020

I have started with a darwin-arm64 branch on my fork here. https://github.com/oxisto/delve/tree/darwin-arm64

I basically just started this a couple of hours ago. The native code seems to compile (I am pretty sure it is not functional yet), but Go still throws some link errors. I am not too familiar with that kind of low level programming, so I need some more prep time to fully understand all of it.

Beware, you need a recent Go version that can compile darwin/arm64, i.e. installed using go tip.

Update : Ah, looks like I was going down the wrong route using the native backend. I think I might need to have a better understanding of delve first, I will continue with this tomorrow.

@aarzilli
Copy link
Member

aarzilli commented Dec 5, 2020

The native code has always had problems, the backend that's being used by default is in pkg/proc/gdbserial, I would focus on that.

@oxisto
Copy link
Contributor

oxisto commented Dec 5, 2020

The native code has always had problems, the backend that's being used by default is in pkg/proc/gdbserial, I would focus on that.

Thanks for the pointer in the right direction. I have begun working in this direction on a second fork (https://github.com/oxisto/delve/tree/darwin-arm64-lldb) just by duplicating code for the gdbserver for arm64 now. Spawning an executable works but setting a breakpoint already crashes. I will continue working in this direction then. I will also apply for the mailing list, as you would like to move the discussion there and not on the GitHub issues if I have seen the guidelines correctly.

@aarzilli aarzilli changed the title Apple M1 ARM - trying to debug - rosetta error: failed to allocate vm space for aot Apple M1 ARM support Dec 19, 2020
@eoarch
Copy link

eoarch commented Dec 28, 2020

Is is possible to test a fork/version currently, or is this issue still awaiting other changes? (:

@andig
Copy link

andig commented Mar 1, 2021

I'm still seeing these errors on Go 1.16:

API server listening at: 127.0.0.1:3694
rosetta error: failed to allocate vm space for aot
Failed to continue - protocol error E74 during registers read for packet $g;thread:88fee;
Last known immediate stacktrace (goroutine id 0):
    ?:-1
        <unknown>
    :0
        <unknown>

Should I open a go ticket?

@s0xzwasd
Copy link

s0xzwasd commented Mar 1, 2021

@andig pay attention that you go version should be 1.16 darwin/arm64 instead of 1.16 darwin/amd64.

@dragonly
Copy link

dragonly commented Mar 9, 2021

I installed go with go version go1.16 darwin/arm64, and delve 1.6.0, and setup to debug TiDB. which starts fine, but prints wrong var values, and the n command behave like drunk 😦

btw, I run dlv exec bin/tidb-server and break server/conn.go:953, then connect with mysql -uroot -P 4000 -h 127.0.0.1. the cmd variable should have value 3 which means query command in mysql protocol, but it shows 200. Running on amd64 platform and it is correct.

and the next command will lead me to arbitrary line, which is not useful.

@aronchick
Copy link

I'm also still seeing this --

go version 
go version go1.16.3 darwin/amd64
❯ dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

Any suggestions? Inside of VSCode, still not working.

@dragonly
Copy link

dragonly commented Apr 14, 2021

@aronchick You need to install the arm64 version of golang. You now have amd64 version of golang, which is not native on Apple M1.

@aronchick
Copy link

Thanks! That got it.

@SVilgelm
Copy link

SVilgelm commented Apr 27, 2021

I still have this issue:

I'm using vscode and go and dlv installed using brew:

21-04-27 16:01 % brew install dlv
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Downloading https://ghcr.io/v2/homebrew/core/delve/manifests/1.6.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/delve/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260
==> Downloading from https://pkg-containers-az.githubusercontent.com/ghcr1/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260?se=2021-04-27T21%3A10%3A00Z&sig=IDSYg4McG9VCtlqyACF
######################################################################## 100.0%
==> Pouring delve--1.6.0.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/delve/1.6.0: 6 files, 13.1MB

21-04-27 16:05 % go version
go version go1.16.3 darwin/arm64

21-04-27 16:08 % dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

% code --version
1.55.2
3c4e3df9e89829dce27b7b5c24508306b151f30d
arm64

but when I run the debugger in vscode I see this error:

API server listening at: 127.0.0.1:41753
Failed to continue - protocol error E74 during registers read for packet $g;thread:21ffc;
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

what am I doing wrong? I have go for arm64 and the dlv also is arm64 and vscode as well

@XMLHexagram
Copy link

I still have this issue:

I'm using vscode and go and dlv installed using brew:

21-04-27 16:01 % brew install dlv
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Downloading https://ghcr.io/v2/homebrew/core/delve/manifests/1.6.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/delve/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260
==> Downloading from https://pkg-containers-az.githubusercontent.com/ghcr1/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260?se=2021-04-27T21%3A10%3A00Z&sig=IDSYg4McG9VCtlqyACF
######################################################################## 100.0%
==> Pouring delve--1.6.0.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/delve/1.6.0: 6 files, 13.1MB

21-04-27 16:05 % go version
go version go1.16.3 darwin/arm64

21-04-27 16:08 % dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

% code --version
1.55.2
3c4e3df9e89829dce27b7b5c24508306b151f30d
arm64

but when I run the debugger in vscode I see this error:

API server listening at: 127.0.0.1:41753
Failed to continue - protocol error E74 during registers read for packet $g;thread:21ffc;
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

what am I doing wrong? I have go for arm64 and the dlv also is arm64 and vscode as well

I meet the same problem after update my m1 chip macOS to 11.3 (20E232)
in this version breakpoint in Goland delve can't get variables and can't move to next point in normal way.
on Vscode I meet the same problem with you.
So I wonder if there is something wrong with new version of macOS

@Thomascm19
Copy link

I still have this issue:

I'm using vscode and go and dlv installed using brew:

21-04-27 16:01 % brew install dlv
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Downloading https://ghcr.io/v2/homebrew/core/delve/manifests/1.6.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/delve/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260
==> Downloading from https://pkg-containers-az.githubusercontent.com/ghcr1/blobs/sha256:396965ab785d39bc07d52eb6004f4113d77aa4513d34573e613f03b87567f260?se=2021-04-27T21%3A10%3A00Z&sig=IDSYg4McG9VCtlqyACF
######################################################################## 100.0%
==> Pouring delve--1.6.0.arm64_big_sur.bottle.tar.gz
🍺 /opt/homebrew/Cellar/delve/1.6.0: 6 files, 13.1MB

21-04-27 16:05 % go version
go version go1.16.3 darwin/arm64

21-04-27 16:08 % dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

% code --version
1.55.2
3c4e3df9e89829dce27b7b5c24508306b151f30d
arm64
but when I run the debugger in vscode I see this error:

API server listening at: 127.0.0.1:41753
Failed to continue - protocol error E74 during registers read for packet $g;thread:21ffc;
Last known immediate stacktrace (goroutine id 0):
?:-1

:0

what am I doing wrong? I have go for arm64 and the dlv also is arm64 and vscode as well

I have the same problem on my mac book air m1 chip, using VScode and GoLand(jetbrains) i'm using macOS to 11.3 (20E232)

@s0xzwasd
Copy link

@Thomascm19 @lmx-Hexagram @SVilgelm please see the corresponding issue: #2436

Especially the possible workarounds: #2436 (comment) & #2436 (comment)

@SVilgelm
Copy link

@s0xzwasd thank you!

@Thomascm19
Copy link

@s0xzwasd thanks works for me

@risyadaji
Copy link

@s0xzwasd thanks for referring us to the corresponding issue. It works for me

@hielfx
Copy link

hielfx commented Jun 25, 2021

In my case, I fixed it by downloading "Apple Silicon" version of vscode, instead of clicking the big download one, and then deleting and reinstalling all the go-tools.
imagen

@microyahoo
Copy link

The issue still exists in new version again. @oxisto

🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ dlv exec client
Type 'help' for list of commands.
(dlv) b main.main
Breakpoint 1 (enabled) set at 0x13d919b for main.main() ./greeter_client/main.go:37
(dlv) c
rosetta error: failed to allocate vm space for aot
Stopped at: 0x0
=>   1:	no source available
(dlv) exit
🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ dlv version
Delve Debugger
Version: 1.6.1
Build: de117a2f4f16350a59b06970693d383613399782
🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zhl/Library/Caches/go-build"
GOENV="/Users/zhl/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zhl/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/zhl/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zhl/go/src/github.com/grpc/grpc-go/examples/go.mod"
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/x2/p8kghjr100j209q5zspdwhgc0000gn/T/go-build2395424900=/tmp/go-build -gno-record-gcc-switches -fno-common"

@derekparker
Copy link
Member

The issue still exists in new version again. @oxisto

You’re running the amd64 tool chain on apple silicon. You should instead download the Darwin/arm64 version which runs natively on Apple silicon.

@oxisto
Copy link
Contributor

oxisto commented Jul 3, 2021

The issue still exists in new version again. @oxisto

🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ dlv exec client
Type 'help' for list of commands.
(dlv) b main.main
Breakpoint 1 (enabled) set at 0x13d919b for main.main() ./greeter_client/main.go:37
(dlv) c
rosetta error: failed to allocate vm space for aot
Stopped at: 0x0
=>   1:	no source available
(dlv) exit
🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ dlv version
Delve Debugger
Version: 1.6.1
Build: de117a2f4f16350a59b06970693d383613399782
🍺 /Users/zhl/go/src/github.com/grpc/grpc-go/examples/helloworld ☞ git:(master) ✗ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zhl/Library/Caches/go-build"
GOENV="/Users/zhl/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zhl/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/zhl/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zhl/go/src/github.com/grpc/grpc-go/examples/go.mod"
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/x2/p8kghjr100j209q5zspdwhgc0000gn/T/go-build2395424900=/tmp/go-build -gno-record-gcc-switches -fno-common"

According to go env you are using an amd64 version of Go. You need to install the arm64 version of Go to make dlv function properly on an M1 machine.

@esmaeil-mazahery
Copy link

make sure vs code or goland are arm64 and in vs code reinstall tools

@Schachte
Copy link

Schachte commented Apr 9, 2022

extender.InitTcpServer(ctx, reset)
Unable to evaluate expression: function calls not allowed without using 'call'
call extender.InitTcpServer(ctx, reset)
Unable to evaluate expression: backend does not support function calls

I'm still unable to invoke function calls using DLV via the debug console.

@Jaydonchong
Copy link

Jaydonchong commented Jan 17, 2023

Chiming in here as I ran into the same E74 during registers read for packet $g;thread:... issue while trying to run go1.16 on vscode. I was able to resolve this by updating delve to use 1.6.1 for the fix in wrong g address (not exactly sure what this is for but I'm guessing it's got to do with reading memory address) (src). I was also facing an issue whereby my filepath wasn't resolving properly in program and the update solved it as well

Not sure if this is the clean way to do it but the way I updated dlv from 1.6 was :

  1. rm -rf $GOPATH/bin/dlv
  2. run go install github.com/go-delve/delve/cmd/dlv@v1.6.1
  3. restarted vscode and the debug was working fine

Hope this helps 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet