Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 8:17 PM Ian Lance Taylor wrote: > Exact alignment/offset compatibility with the C ABI is not a goal. > Sorry. (It's actually harder than one might think to maintain that > kind of compatibility. For example, on x86, the C ABI uses one > alignment for double variables and

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 4:59 AM Jan Mercl <0xj...@gmail.com> wrote: > > If the intent is to have Go alignments/offsets of types compatible > with the C ABI then I think it's safe to say this is a bug. > > And the existence of the syscall package, in some cases passing > Go-defined structs to the

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 1:45 PM 'Dan Kortschak' via golang-nuts wrote: > I think it comes down to these lines in src/cmd/internal/sys/arch.go > [1] > > ``` > var ArchARM = { > Name: "arm", > Family:ARM, > ByteOrder: binary.LittleEndian, > PtrSize: 4, >

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread 'Dan Kortschak' via golang-nuts
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 > > >

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
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

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-09-09 at 12:50 +0200, Jan Mercl wrote: > On Wed, Sep 9, 2020 at 12:41 PM Dan Kortschak > wrote: > > > I get the following > > > > ``` > > C alignof struct s: 8 > > Go alignof struct s: 8 > > Go alignofS: 8 > > ~/cznic $ go version > > go version go1.15.1 linux/arm64 > >

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 12:41 PM Dan Kortschak wrote: > I get the following > > ``` > C alignof struct s: 8 > Go alignof struct s: 8 > Go alignofS: 8 > ~/cznic $ go version > go version go1.15.1 linux/arm64 > ~/cznic $ uname -a > Linux bildr 4.19.0-10-arm64 #1 SMP Debian 4.19.132-1

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-09-09 at 12:19 +0200, Jan Mercl wrote: > Observation: > > 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; > > size_t align() { > return

[go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
Observation: 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; size_t align() { return _Alignof(struct s); } */ import "C" import ( "fmt" "unsafe" )