Go: x/sys/unix: type alias Nfgenmsg breaks build on go 1.8

Created on 25 May 2018  路  2Comments  路  Source: golang/go

I believe the issue is directly linked to this change:
https://github.com/golang/sys/commit/31355384c89b50e6faeffdb36f64a77a8210188e#diff-790e11cae6867313825b103954c3a3fbR1405

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.8.3

Does this issue reproduce with the latest release?

Uncertain, likely not

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

Builds ran as usual this morning on timer, during go get stage they all failed on golang.org/x/sys/unix

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

get get moving onto the next dependency

What did you see instead?

golang.org/x/sys/unix/ztypes_linux_amd64.go:1405: syntax error: unexpected = in type declaration
golang.org/x/sys/unix/ztypes_linux_amd64.go:1407: syntax error: non-declaration statement outside function body

FrozenDueToAge NeedsFix OS-Linux

Most helpful comment

This seems to behave differently with each go version. 1.8 produces the syntax error reported by @thepauleh (because go 1.8 doesn't support type aliases), 1.9 produces a segfault in cmd/compile (see #25561) and go 1.10 builds fine (that's also why the trybots didn't catch it).

According to https://golang.org/doc/devel/release.html only the last two major releases are supported (i.e. 1.9 and 1.10), so strictly speaking we could use the type alias in golang.org/x/sys/unix and add a fix to go 1.9 as suggested in #25561. But since the type alias is not strictly necessary and there is no other in x/sys/unix I suggest we also fix this this for 1.8 by changin the type alias to a type definition, i.e.

// in linux/types.go
type Nfgenmsg C.struct_nfgenmsg

// resulting in the following in ztype_linux_amd64.go
type Nfgenmsg struct {
    Nfgen_family uint8
    Version      uint8
    Res_id       uint16
}

/cc @stapelberg

All 2 comments

This seems to behave differently with each go version. 1.8 produces the syntax error reported by @thepauleh (because go 1.8 doesn't support type aliases), 1.9 produces a segfault in cmd/compile (see #25561) and go 1.10 builds fine (that's also why the trybots didn't catch it).

According to https://golang.org/doc/devel/release.html only the last two major releases are supported (i.e. 1.9 and 1.10), so strictly speaking we could use the type alias in golang.org/x/sys/unix and add a fix to go 1.9 as suggested in #25561. But since the type alias is not strictly necessary and there is no other in x/sys/unix I suggest we also fix this this for 1.8 by changin the type alias to a type definition, i.e.

// in linux/types.go
type Nfgenmsg C.struct_nfgenmsg

// resulting in the following in ztype_linux_amd64.go
type Nfgenmsg struct {
    Nfgen_family uint8
    Version      uint8
    Res_id       uint16
}

/cc @stapelberg

Change https://golang.org/cl/114596 mentions this issue: unix: make Nfgenmsg a type definition

Was this page helpful?
0 / 5 - 0 ratings