golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.33k stars 17.7k forks source link

x/sys: sizeof st_rdev is 64bits on mips64 #42370

Open meidli opened 4 years ago

meidli commented 4 years ago

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

$ go version
go version go1.13.9 linux/mips64le

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

go env Output
$ go env
GOHOSTARCH="mips64le"
GOHOSTOS="linux"

when I compile docker on mips64 arch, there is a field Rdev comes from golang/sys must be convert to uint64 otherwise it doesn't compile, this field defined as uint32 on mips64, but we do some test which shows the sizeof st_rdev on mips64 should be 8bytes.

$ uname -a Linux node001 4.19.90 #2 SMP PREEMPT Fri Sep 4 15:53:40 CST 2020 mips64 mips64 mips64 GNU/Linux $ cat dev.c

include <sys/stat.h>

include

int main(int argc, char *argv[]) { printf("%lu\n", sizeof(dev_t)); struct stat s; printf("%lu\n", sizeof(s.st_dev)); printf("%lu\n", sizeof(s.st_rdev)); } $ gcc --version gcc (GCC) 7.3.1 20180303 (Loongson 7.3.1-5) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc dev.c -o dev && ./dev 8 8 8

So I think Rdev should be defined as unit64 on mips64: https://github.com/golang/sys/blob/master/unix/ztypes_linux_mips64.go#L92

https://forum.golangbridge.org/t/the-argument-rdev-is-defined-as-type-uint32-in-mips-arch-and-uint64-in-others/21179

thanks.

cherrymui commented 4 years ago

Go uses the kernel's layout, instead of libc's. https://github.com/golang/go/issues/16500#issuecomment-235288559