glow icon indicating copy to clipboard operation
glow copied to clipboard

Remove Cgo dependency on Windows

Open hajimehoshi opened this issue 7 years ago • 13 comments
trafficstars

Fixes https://github.com/go-gl/gl/issues/109

Design Document

https://docs.google.com/document/d/1mqquznil9fR2amtb3eTC2ObCx3A8Af_5INqKjO-pKDg/edit?usp=sharing

tl;dr

I propose to eliminate Cgo usages on Windows from go-gl/gl by fixing go-gl/glow to generate code using syscall.Syscall.

hajimehoshi avatar Nov 12 '18 04:11 hajimehoshi

Please take a look: @slimsag @dmitshur

hajimehoshi avatar Nov 12 '18 04:11 hajimehoshi

friendly ping

hajimehoshi avatar Nov 14 '18 07:11 hajimehoshi

That's really sad that there has not been any feedback in the last 22 days. This change is really important (at least to me) e.g. in order to make compiling time shorten on Windows.

hajimehoshi avatar Dec 04 '18 02:12 hajimehoshi

Hi @hajimehoshi, thanks very much for your contribution. Sorry it is taking time, but please be aware that no one is paid to maintain these packages. It's a best effort in our spare time and we can only give so much. Please have patience and faith that we will get to it. Feel free to continue to send pings!

pwaller avatar Dec 04 '18 19:12 pwaller

@pwaller @kjozic or @errcw

Are any of you able to set aside some time and review this? Being able to not rely on CGo on Windows would be amazing and help with simplifying the build process of my game engine for less experienced users.

silbinarywolf avatar Jan 27 '19 23:01 silbinarywolf

I think I have addressed all the issues. Please take a look. Thank you!

hajimehoshi avatar Mar 12 '19 02:03 hajimehoshi

Oops, I need to rebase this

hajimehoshi avatar Mar 25 '19 05:03 hajimehoshi

Done. PTAL

hajimehoshi avatar Mar 25 '19 14:03 hajimehoshi

@hajimehoshi thank you very much for this. I can't understand why it has been abandoned.

I created a pull request on your nocgo branch to sync with master, implementing overloads.

Moreover, I found a bug, not linked to overloads, in function:

func DebugMessageCallback(callback DebugProc, userParam unsafe.Pointer) {
	syscall.Syscall(gpDebugMessageCallback, 2, syscall.NewCallbackCDecl(callback), uintptr(userParam), 0)
}

panic: compileCallback: expected function with one uintptr-sized result

This happens while creating a debug context with glfw 3.3; it works fine with cgo version.

If I succeed in fixing it, I will make another pull request on your branch.

neclepsio avatar Jun 19 '20 10:06 neclepsio

I would like everyone to take notice that using syscall will double the call overhead, because syscall always calls GetLastError() on Windows, even if you use it to invoke non-WINAPI functions. If your CPU is bottlenecking (which is likely because we already experience a ~70ns overhead due to CGO) it would then bottleneck doubly, without gaining anything in the process. This will then further cement the fact that Golang projects which use OpenGL must be able to make do with a fraction of the calls that a C program could use.

Zyl9393 avatar Oct 03 '20 14:10 Zyl9393

Does this change limit glow only to generating Golang GL bindings using desktop OpenGL? Thanks

zwang avatar Mar 05 '21 19:03 zwang

thank you very much for this. I can't understand why it has been abandoned.

Oh I forgot I created this PR... I was waiting for the reviews but reviewers seemed pretty busy.

If there are reviewers, I'm fine to continue this PR.

hajimehoshi avatar Oct 23 '21 13:10 hajimehoshi

We at Fyne would certainly be interested at testing this once it is ready. It has been suggested a few times in the past that we should remove CGo on Windows (see https://github.com/fyne-io/fyne/issues/911).

Jacalz avatar Oct 24 '21 14:10 Jacalz

Friedly ping ...

MatejMagat305 avatar Feb 20 '24 10:02 MatejMagat305

I'm quite busy to work on this. I'm fine if someone takes over this

hajimehoshi avatar Feb 20 '24 11:02 hajimehoshi