winfsp / cgofuse

Cross-platform FUSE library for Go - Works on Windows, macOS, Linux, FreeBSD, NetBSD, OpenBSD
https://winfsp.dev
MIT License
514 stars 82 forks source link

"Nocgo" version of cgofuse #25

Closed billziss-gh closed 6 years ago

billziss-gh commented 6 years ago

It is conceptually possible to eliminate the need for cgo under Windows. The intent is to allow building with either CGO_ENABLED=1 to build the (default) "cgo" version of cgofuse, or CGO_ENABLED=0 to build a "nocgo" version of cgofuse. This is accomplished with the help of syscall.DLL, syscall.Proc and syscall.NewCallbackCDecl and a rewrite of all Windows related C code in Go.

This work is currently in the windll branch.

Unfortunately this approach currently does not work, because of a hard bug in the Go runtime: golang/go#6751. According to that bug report callbacks created with syscall.NewCallback will hang the runtime if they are invoked in a non-Go thread. This indeed happens when the FUSE init operation is called in the "nocgo" cgofuse.

The information in golang/go#6751 suggests that doing an import "C" fixes the issue. Unfortunately it also makes the program use cgo, which is what we wanted to avoid with "nocgo". Still it might be useful to allows us to complete testing the "nocgo" version in anticipation that the runtime bug is fixed in the future.

Additional information: https://github.com/ipfs/go-ipfs/issues/5003#issuecomment-390868198

billziss-gh commented 6 years ago

This support has now been merged into the master branch and this issue can be closed.