Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install error on Solaris #96

Closed
lhoward opened this issue Jan 21, 2019 · 10 comments · Fixed by #117
Closed

install error on Solaris #96

lhoward opened this issue Jan 21, 2019 · 10 comments · Fixed by #117
Milestone

Comments

@lhoward
Copy link

lhoward commented Jan 21, 2019

Similar issue to #23 on Solaris. Worked around by creating azblob/zc_mmf_solaris.go with following contents (from some searching/copy/pasting – I don't know Go).

// +build solaris

package azblob

import (
        "os"
        "syscall"
        "golang.org/x/sys/unix"
)

type mmf []byte

func newMMF(file *os.File, writable bool, offset int64, length int) (mmf, error) {
        prot, flags := unix.PROT_READ, syscall.MAP_SHARED // Assume read-only
        if writable {
                prot, flags = syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED
        }
        addr, err := unix.Mmap(int(file.Fd()), offset, length, prot, flags)
        return mmf(addr), err
}

func (m *mmf) unmap() {
        err := unix.Munmap(*m)
        *m = nil
        if err != nil {
                panic("if we are unable to unmap the memory-mapped file, there is serious concern for memory corruption")
        }
}
@zezha-msft
Copy link
Contributor

Hi @lhoward, thanks for reaching out!

I've logged this item to provide support for solaris.

@lhoward
Copy link
Author

lhoward commented Jan 22, 2019

Re-reading that patch, and with about 1% more Go knowledge than when I filed the report, it should not mix the syscall and unix packages (so, remove import syscall and s/syscall/unix/).

@petems
Copy link
Contributor

petems commented Apr 2, 2019

I think we can just add the solaris build tag to the existing file right?

Opened a PR to do so 👍

@lhoward
Copy link
Author

lhoward commented Apr 3, 2019

No, it's a new file that uses golang.org/x/sys/unix instead of the syscall package; at least on the version of Go I have, syscall.Mmap and syscall.Munmap are unavailable on Solaris. The version below avoids mixing the two packages.

// +build solaris

package azblob

import (
        "os"
        "golang.org/x/sys/unix"
)

type mmf []byte

func newMMF(file *os.File, writable bool, offset int64, length int) (mmf, error) {
        prot, flags := unix.PROT_READ, unix.MAP_SHARED // Assume read-only
        if writable {
                prot, flags = unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED
        }
        addr, err := unix.Mmap(int(file.Fd()), offset, length, prot, flags)
        return mmf(addr), err
}

func (m *mmf) unmap() {
        err := unix.Munmap(*m)
        *m = nil
        if err != nil {
                panic("if we are unable to unmap the memory-mapped file, there is serious concern for memory corruption")
        }
}

@lhoward
Copy link
Author

lhoward commented Apr 3, 2019

(Above goes in zc_mmf_solaris.go.)

@petems
Copy link
Contributor

petems commented Apr 3, 2019

Yep, I just realised that after the build failed. IIRC syscall is now frozen so switching to the "golang.org/x/sys/unix" makes sesnse

@zezha-msft zezha-msft added this to the 0.7.0 milestone Apr 5, 2019
@jclulow
Copy link

jclulow commented Jul 21, 2019

I just hit this on an illumos system while trying to build Hugo, the static site generator. In the upcoming Go 1.13, there will be an illumos build tag. It'll imply the solaris build tag, though, so fixing this for solaris will fix it for both.

Does it make sense to just use sys/unix instead of syscall for all UNIX platforms? Can I help somehow with testing (e.g., on illumos systems) to get this over the line? Thanks.

@fazalmajid
Copy link

The problem is that for whatever reasons the Go Solaris calls for mmap and pty support, among others, are in x/sys/unix instead of syscall, even though the API interfaces are the same as on other Unices, thus creating unnecessary porting friction. There's little likelihood of this being fixed anytime soon.

@zezha-msft
Copy link
Contributor

Support for Solaris has been released in v0.10.0.

@jclulow
Copy link

jclulow commented Jun 26, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants