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

Does not compile under Docker / XGO #24

Closed AlbinoGeek closed 4 years ago

AlbinoGeek commented 6 years ago

The instructions in your README get you this far:

go: GOPATH entry is relative; must be absolute path: "\\ext-go\\1".
For more details see: 'go help gopath'
Compiling for darwin-10.6/386...
go: GOPATH entry is relative; must be absolute path: "\\ext-go\\1".
For more details see: 'go help gopath'
2018/04/01 15:14:14 Failed to cross compile package: exit status 2.
billziss-gh commented 6 years ago

@AlbinoGeek you wrote in the GOX thread:

I am building from Windows 10 (Host) via Docker CE , Hyper-V (MobyOS)

This is generally equiv. to a typical Docker environment, except the Moby part (Windows-specific Hyper-V virtual machine that hosts the Docker Machine you speak with from your Windows client. Otherwise, all docker commands execute 100% as expected on any other platform.)

e.g.: If cgofuse built inside "just any" CentOS 7 or Ubuntu VM, it would work here too. Exception: If it requires gcc or libfuse to be available on the Docker HOST -- this would be MobyOS in my situation, which is much harder to accomplish. However, you can access libfuse locally, as it's installed in the Docker CONTAINER.

Cgofuse will not build without a C compilation environment that also includes FUSE for the intended platform. This is because cgofuse uses cgo.

Can you use the xgo-cgofuse docker image in the Docker for Windows environment? If the answer is no, you will unfortunately have to recreate the cross-compilation environment. This is non-trivial, but possible.

The xgo-cgofuse docker image acts as a cross-compilation host. It includes cross-compilers and tools for all supported platforms (Windows, macOS, Linux). It also includes FUSE for the supported platforms. Note that you do not need cross-compilation tools or FUSE on the Docker host for this to work.

AlbinoGeek commented 6 years ago

Using your image is what produces the above error, telling me that my code must be available via aboslute path. The docker host is MobyOS (a flavor of Linux) if you have Docker installed on Windows, it uses Hyper-V to host the MobyOS virtual machine.

As I said in my opening post, this is from following the README instructions


C:\WINDOWS\system32> docker pull billziss/xgo-cgofuse
Using default tag: latest
latest: Pulling from billziss/xgo-cgofuse
Digest: sha256:c15a00fc837f2ea009038dc2cfb37cb7b0d8938d318bf3b9698f2928a6e4780b
Status: Image is up to date for billziss/xgo-cgofuse:latest

C:\WINDOWS\system32> go get -u github.com/karalabe/xgo

C:\WINDOWS\system32> cd /c/tools/go/src/protected/memfs

C:\tools\go\src\protected\memfs> xgo --image=billziss/xgo-cgofuse --targets=linux/386,linux/amd64,windows/386,windows/amd64 .
Checking docker installation...
Client:
 Version:       18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:06:28 2018
 OS/Arch:       windows/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:      18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:        Wed Mar 21 23:14:32 2018
  OS/Arch:      linux/amd64
  Experimental: true

Checking for required docker image billziss/xgo-cgofuse... found.
Cross compiling protected/memfs...
Building locally protected/memfs...
go: GOPATH entry is relative; must be absolute path: "\\ext-go\\1".
For more details see: 'go help gopath'
Compiling for linux/386...
go: GOPATH entry is relative; must be absolute path: "\\ext-go\\1".
For more details see: 'go help gopath'
2018/04/14 17:30:19 Failed to cross compile package: exit status 2
`` 
AlbinoGeek commented 6 years ago

The issue here does not appear to be related to cgo or the availability of compilers, but that the xgo image was not written to handle local paths. I had found a few issues created in the past about this issue, but they did not help me to solve my issue (trying to use a local completed path, or even hosting a local HTTPd and fake DNS server to force it to be an absolute path, still results in a similar error.)