linker out of memory on compile?
I'm not a GO programmer, so please forgive me. I am however trying to contribute a fix for an issue in Hashicorp vault. Goland compiles and runs the project without errors, but when I try to execute the project in debug mode, the compilation throws an error that I don't entirely understand:
GOROOT=/opt/homebrew/opt/go/libexec #gosetup
GOPATH=/Users/rhornsby/go #gosetup
/opt/homebrew/opt/go/libexec/bin/go build -o /Users/rhornsby/Library/Caches/JetBrains/GoLand2023.2/tmp/GoLand/___1go_build_github_com_hashicorp_vault -gcflags all=-N -l github.com/hashicorp/vault #gosetup
# github.com/hashicorp/vault
/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64/link: running cc failed: exit status 1
ld: B/BL out of range -149822468 (max +/-128MB) to '_runtime.memequal'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I can read the words, and can guess that there's a memory constraint somehow related to compiling with symbols and/or linking debug-related libraries? - but I'm not entirely sure what the bigger picture is or what I can do about it. My Google-foo is failing, I can't figure out for example if runtime.memequal
is settable and set too low, and if so how I could change it.
It might matter, so to be clear I'm trying to compile/run this on an ARM mac (Sonoma 14.1.1) just because that's the desktop I happen to run things on.
Please sign in to leave a comment.
After more digging, this does seem to be a platform or architecture specific issue, though I'm still not sure how/why. The debug behaves exactly as expected on x64 linux. I don't think the problem was ever with GoLand specifically, but rather something with the compiler/toolchain/linker. Was hoping someone here might have an idea.
Could you please provide the output of go version and go env in the terminal?
Sorry, should have included that.
go version go1.21.5 darwin/arm64
goenv:
Thanks for sharing.
It's indeed a strange error. Have you tried to re-install XCode CLI Tools (https://apple.stackexchange.com/q/93573) or install Go using an official installation (https://go.dev/doc/install) instead of Homebrew?
I think since the original post, xcode has been updated and at your suggestion, I re-installed golang ("Go") from the go.dev package rather than from homebrew. Something seems to have fixed it, so maybe a weird thing with xcode or a weird incompatibility in the go compiler.
Weird. I dunno. Seems to be solved either way. Thanks for the suggestions.
I`ve met the same problem. I exactly installed GO exactly using the official installation, and I even don`t have a xcode . what can I do to solve the problem ?
Hello 920866163,
Could you share the output of
go env
andgo build
in your environment?This is my go env.
But what does `go build` mean ?
Could you share the output of
clang --version
, try to build your project and share the console output? If you are not comfortable sharing the build output, please let us know the build flags you are using (if any).This is my clang version
In fact I was trying to run a unit test ,so i didn`t have a build output.
This was my command.
Thanks .
I found it`s not a problem of JetBrains , it is a problem of cgo . Just set CGO_ENABLED=0 , the problem could be solved .