On Wed, 2020-09-09 at 13:21 +0200, Jan Mercl wrote: > > > On Wed, Sep 9, 2020 at 1:09 PM 'Dan Kortschak' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > > > What does cgo -godefs give you? On my amd64 and arm64 I get this: > > > > ``` > > ~/cznic $ cat main.go > > package main > > > > /* > > struct s { > > long long i; > > } x; > > */ > > import "C" > > > > type S struct { > > i int64 > > } > > > > type C_s C.struct_s > > > > ~/cznic $ go tool cgo -godefs main.go > > // Code generated by cmd/cgo -godefs; DO NOT EDIT. > > // cgo -godefs main.go > > > > package main > > > > type S struct { > > i int64 > > } > > > > type C_s struct { > > I int64 > > } > > ``` > > amd64 > ===================================================================== > ==== > > jnml@e5-1650:~/tmp$ go version > go version go1.15.1 linux/amd64 > jnml@e5-1650:~/tmp$ cat main.go > package main > > /* > struct s { > long long i; > } x; > */ > import "C" > > type S struct { > i int64 > } > > type C_s C.struct_s > jnml@e5-1650:~/tmp$ go tool cgo -godefs main.go > // Code generated by cmd/cgo -godefs; DO NOT EDIT. > // cgo -godefs main.go > > package main > > type S struct { > i int64 > } > > type C_s struct { > I int64 > } > jnml@e5-1650:~/tmp$ > > arm > ===================================================================== > ====== > > pi@raspberrypi:~/src/tmp.tmp $ go version > go version go1.15.1 linux/arm > pi@raspberrypi:~/src/tmp.tmp $ cat main.go > package main > > /* > struct s { > long long i; > } x; > */ > import "C" > > type S struct { > i int64 > } > > type C_s C.struct_s > pi@raspberrypi:~/src/tmp.tmp $ go tool cgo -godefs main.go > // Code generated by cmd/cgo -godefs; DO NOT EDIT. > // cgo -godefs main.go > > package main > > type S struct { > i int64 > } > > type C_s struct { > I int64 > } > pi@raspberrypi:~/src/tmp.tmp $ > > No difference between the outputs AFAICT. Seems good to me. > >
I think it comes down to these lines in src/cmd/internal/sys/arch.go [1] ``` var ArchARM = &Arch{ Name: "arm", Family: ARM, ByteOrder: binary.LittleEndian, PtrSize: 4, RegSize: 4, MinLC: 4, } var ArchARM64 = &Arch{ Name: "arm64", Family: ARM64, ByteOrder: binary.LittleEndian, PtrSize: 8, RegSize: 8, MinLC: 4, } ``` this line in src/cmd/compile/internal/gc/main.go [2] ``` Widthreg = thearch.LinkArch.RegSize ``` and these lines in src/cmd/compile/internal/gc/align.go [3] ``` case TINT64, TUINT64, TFLOAT64: w = 8 t.Align = uint8(Widthreg) ``` [1]https://golang.org/src/cmd/internal/sys/arch.go [2]https://golang.org/src/cmd/compile/internal/gc/main.go [3]https://golang.org/src/cmd/compile/internal/gc/align.go -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9faee5b3868886c3c7415ecc1c2469f2e008abe2.camel%40kortschak.io.