-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Projects needing CGO_ENABLED=1 cause "could not find rodata struct member" on M1 MacOS #3701
Comments
Are you using Xcode 15? |
cc @cherrymui are there already known situations where debug info are not produced using cgo on macos? |
It should be XCode Commandline Tools version 15. I recently removed the XCode App itself (it took to much space). But the CLI tools are still there. Edit: |
I'm not aware of issues like this. I just tried building a cgo program on Mac and it comes with debug info as expected. Could you share the command that the program is built with? |
For the demonstration video I've used what ever VSCode (VSCodium) has by default (I don' As for my own project, I build it with: CGO_ENABLED=1 go build -ldflags="-X main.Version=$(DEVVERSION)" -o ./tnt You can check the command in the Projects Makefile. The Project can compile without CGO_ENABLED (but the cross-builds won't run anywhere else without) . I then started to debug it with |
Hi there!
i'm running VsCode:
|
I'm also experiencing this issue, but I was able to work around it by using the |
Can confirm, that this made https://github.com/rocco-gossmann/tnt debuggable via delve. Unfortunately, now my raylib-go project does not seem to like that flag and doesn't build at all. 😢 However, that doesn't have anything to do with Delve. |
Issue golang/go#61229 is closed. Maybe a new one should be opened on golang/go for this, it will probably be easier to track for the compiler team if it's there. |
Could you share the source code and a command (ideally without makefile) that I can reproduce? I'll try to reproduce and look into it. Thanks. |
In my case, this debug issue is happening for every Go program. The easiest repro that I've encountered is if I do this without setting that go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 Then the resulting binary is unusable: oapi-codegen --help
[1] 6393 killed oapi-codegen --help I'm not sure which system specs will be most helpful, but I'm on a MacBook Pro with an Apple M3 Max chip, running Sonoma 14.4.1: uname -a
Darwin ... 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:37 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6031 arm64
xcode-select --version
xcode-select version 2406.
go version
go version go1.22.2 darwin/arm64
dlv version
Delve Debugger
Version: 1.22.1
Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $ |
I had not planned on making it public, but if it helps. just clone that: git clone https://github.com/Rocco-Gossmann/RayTheater---Go RayTheater
cd RayTheater
go mod tidy I tried various commands, none of which worked:
(Interestingly enough, it seems to work fine on Asahi Linux on an M1 Mac, so the issue must be specifically MacOS related). I've heard, that Apple uses their own fork of clang, maybe that could also be a factor. |
Thanks for the information. I'll try to reproduce next week. What C compiler do you use? Do you use the one from Xcode, or a custom installation of clang (built from upstream LLVM, or not) or some other C toolchain? From what I've heard a non-Xcode C toolchain sometimes may not work very well. Thanks. |
Thank YOU for trying to help. 🤗 I'm using the clang, that came with LLVM clang --version
Homebrew clang version 18.1.5
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin I just figured out, that Delve works with the CC=/usr/bin/cc CXX=/usr/bin/c++ dlv debug . works. 🎉 For the others, if you use VSCode. {
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {
"CC": "/usr/bin/cc",
"CXX": "/usr/bin/c++",
}
}
]
} |
Thank you very much for sharing. I have encountered a similar problem. According to your vscode debugging settings, I can now debug breakpoints normally. |
Thanks for the update. I think this is an issue of the custom installation of clang (that doesn't work well with the new Apple linker), and not a Go bug, or a Delve bug. @aarzilli perhaps we can close this. |
Select another Xcode command line tools version would fix. For me, I installed Xcode 14.3 then problem fixes. |
Thank you very much, uninstalling xcode fixed the issue. |
@jiafans how can you install a different version for Xcode command tools without installing Xcode itself? |
Please answer the following before submitting your issue:
dlv version
)?go version
)?MacOS 13.6 M1 MacBook Air (2020)
What did you do?
Setup a Project, that uses
Raylib-Go
and needsCGO_ENABLED=1
to be set.As soon as any code using the
raylib-go/raylib
package is added Delve crashed.What did you expect to see?
The Debugger working as it did before I added the
raylib-go/raylib
code.What did you see instead?
It crashed with the message
The same happens on other projects too. So it is not related to Raylib-Go alone.
One of my projects (https://github.com/rocco-gossmann/tnt) requires CGO_ENABLED=1 to use the SQLite Database. It has the same issues.
See Video for a Demonstration.
2024-04-14_14-58-10.mov
The text was updated successfully, but these errors were encountered: