gen2brain / raylib-go

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
zlib License
1.61k stars 165 forks source link

delve fails to build, can't find utils_log.h #394

Closed wintermute-cell closed 5 months ago

wintermute-cell commented 5 months ago

Hey!

Running dlv debug cmd/game/main.go fails: image

So far, I have traced this down to this flag dlv uses to disable inlining and optimizations for gc: -gcflags "all=-N -l"

When running go build -o outfile -gcflags "all=-N -l" cmd/game/main.go, the same error occurs: image

Both flags individually cause the same problem (so either -N or -l is enough to break it). Edit: other gcflags seem to cause the same problem.

Not sure where I could continue searching from this point on.

gen2brain commented 5 months ago

https://github.com/gen2brain/raylib-go/issues/373

wintermute-cell commented 5 months ago

I don't think this issue is related to the issue you linked. https://github.com/gen2brain/raylib-go/issues/373 (and the delve and go issues related to it) seems to boil down to the apple linker. This issue does not appear to be affected by the underlying C compiler and linker (I tried gcc, clang and internal linking).

Furthermore, I was not able to reproduce the bug without raylib-go specifically. While it might be possible that the actual error lies somewhere within the go toolchain, I think further investigation why this problem occurs with specifically raylib-go would be worthwhile.

Hence I'd like to ask you to please reopen this.

gen2brain commented 5 months ago

The issue is the support for Delve and CGO, I don't think anyone managed to debug i.e. InitWIndow() and OpenGL context with Delve. Whatever the issue is, and how Delve works with C will not be fixed here in this repo. Unless you are sure that raylib-go is the problem and you can identify the issue, I don't see a reason for the issue to be kept open.

wintermute-cell commented 5 months ago

Okay, I found out more. The problem actually has nothing to do with the -gcflags, sorry for the misdirection. Passing the gcflags simply skipped my existing build cache, which I discovered when clearing said cache.

Well, now I can't build raylib-go at all anymore, always encountering this error:

image

Since I don't know a lot about CGO, I am again pretty lost and would appreciate some insight if you have any. I tried all kinds of Go versions, from 1.19 to 1.22, none work; so I'm not sure what could have broken the process since it last compiled successfully.

Sorry again for the incorrect investigation so far!

gen2brain commented 5 months ago

Do you have a C compiler installed?

wintermute-cell commented 5 months ago

yes

 ~ % gcc --version
gcc (GCC) 13.2.0
gen2brain commented 5 months ago

And you are not using vendor and CGO_ENABLED=1?

wintermute-cell commented 5 months ago

yes

wintermute-cell commented 5 months ago

Okay, I finally figured it out!

It was an exec $SHELL at the end of my CGO shell hook. I have no idea why it would cause this issue, but for me it is fixed now.

Thanks again, and sorry for the fuss.