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

Cgofuse creates non static binaries #30

Closed scudette closed 5 years ago

scudette commented 5 years ago

Is there a way to make cgo build with static linking? We can not have a runtime dependencies on libfuse which may not be installed on the target platform. I noticed that when building for windows there is no runtime dependency as it opens the winfsp dll dynamically (it will just fail if its not installed). Is it possible to have the same thing on Linux?

billziss-gh commented 5 years ago

Unfortunately not currently. The issue is that go is missing universal support for dlopen and friends.

See golang/go#18296.

scudette commented 5 years ago

I wasnt thinking of dlopen in runtime, I was more thinking of linking to a .a library at build time so libfuse gets embedded into the final binary. AFAIK libfuse does not have a hard version dependency on the kernel like libc?

I am not entirely sure how its done but in our project we use github.com/hanwen/go-fuse for the linux implementation and it does not have the same runtime dependency on libfuse.

I would really like to use cgofuse because then we can merge the linux and windows implementations in the same dependency and the same implementation for better maintainability. But if it cant be done then we can live with it I suppose.

billziss-gh commented 5 years ago

I have not used the Hanwen implementation, but I believe it interfaces directly with /dev/fuse and does not use libfuse. I do not currently have any plans to do this for cgofuse.

I wasnt thinking of dlopen in runtime, I was more thinking of linking to a .a library at build time so libfuse gets embedded into the final binary.

I do not believe this is possible with the current go tooling.