edsrzf / mmap-go

A portable mmap package for Go
BSD 3-Clause "New" or "Revised" License
938 stars 129 forks source link

Build fails on netbsd and plan9 #3

Closed mvdan closed 9 years ago

mvdan commented 9 years ago

I was playing around with gox on github.com/mvdan/pastecat which uses mmap-go, and found that it fails to build on netbsd and plan9:

4 errors occurred:
--> netbsd/amd64 error: exit status 2
Stderr: # github.com/edsrzf/mmap-go
../../edsrzf/mmap-go/mmap.go:73: undefined: mmap
../../edsrzf/mmap-go/mmap.go:84: undefined: lock
../../edsrzf/mmap-go/mmap.go:92: undefined: unlock
../../edsrzf/mmap-go/mmap.go:98: undefined: flush
../../edsrzf/mmap-go/mmap.go:109: undefined: unmap

--> netbsd/386 error: exit status 2
Stderr: # github.com/edsrzf/mmap-go
../../edsrzf/mmap-go/mmap.go:73: undefined: mmap
../../edsrzf/mmap-go/mmap.go:84: undefined: lock
../../edsrzf/mmap-go/mmap.go:92: undefined: unlock
../../edsrzf/mmap-go/mmap.go:98: undefined: flush
../../edsrzf/mmap-go/mmap.go:109: undefined: unmap

--> netbsd/arm error: exit status 2
Stderr: # github.com/edsrzf/mmap-go
../../edsrzf/mmap-go/mmap.go:73: undefined: mmap
../../edsrzf/mmap-go/mmap.go:84: undefined: lock
../../edsrzf/mmap-go/mmap.go:92: undefined: unlock
../../edsrzf/mmap-go/mmap.go:98: undefined: flush
../../edsrzf/mmap-go/mmap.go:109: undefined: unmap

--> plan9/386 error: exit status 2
Stderr: # github.com/edsrzf/mmap-go
../../edsrzf/mmap-go/mmap.go:73: undefined: mmap
../../edsrzf/mmap-go/mmap.go:84: undefined: lock
../../edsrzf/mmap-go/mmap.go:92: undefined: unlock
../../edsrzf/mmap-go/mmap.go:98: undefined: flush
../../edsrzf/mmap-go/mmap.go:109: undefined: unmap

My first guess is that for some reason these platforms don't make use of the mmap_unix.go file.

dchapes commented 9 years ago

In 6c75090 I fixed building for FreeBSD (which I run). I also changed the set of OSes listed to match the set for which it cross built correctly for me. I don't recall the details of why I didn't bother to get the others to build. But you can see in that commit that although I added dragonfly and Solaris I explicitly removed NetBSD.

You could try just adding other Unix like OSes to the top of map_unix.go and see if it "just works" with the latest Go releases or to find out what's missing/different with those syscall packages and what might be required to get them to build.

In my experience the Go syscall package (and golang.org/x/sys) sometimes are deficient beyond linux, darwin, and windows :(.

mvdan commented 9 years ago

Right, I wasn't aware that the unix source files worked like that :) I don't really have any plan9/netbsd systems to test this on, so I guess we can leave this issue open as a TODO. Feel free to rename it.

dchapes commented 9 years ago

The Go team has moved most/all new syscall related stuff to the golang.org/x/sys sub-repository. Sadly SYS_MSYNC (the reason it won't compile for NetBSD) isn't defined there for NetBSD either. (And golang.org/x/sys hasn't built on FreeBSD since September) so switching to it won't help at the moment.

edsrzf commented 9 years ago

I don't believe Plan 9 supports mmap, so it's probably a lost cause. (Someone correct me if I'm wrong.)

I'm happy to take pull requests to fix NetBSD, though.

mvdan commented 9 years ago

You seem to be correct about plan9, found a few references to plan9 not having mmap by design.

mvdan commented 9 years ago

Why did I leave this open?