The argument Rdev is defined as type uint32 in mips arch and uint64 in others

Hi,

I need to compile docker which depends on golang/sys, but there is an argument s.Rdev that comes from golang/sys I must force converse it to uint64 otherwise the compilation can’t go on.

error information: “cannot use s.Rdev (type uint32) as type uint64 in field value”

I have read the part source code of golang/sys, found that argument defined as type uint32 in mips arch but uint64 in others. my machine is based on mips64 arch, so I want to know why it implemented as uint32 in mips.

mips64: https://github.com/golang/sys/blob/master/unix/ztypes_linux_mips64.go#L92
amd64: https://github.com/golang/sys/blob/master/unix/ztypes_linux_amd64.go#L92

Thanks, best regards.

On the mips64 platform for which you are compiling Docker, what is your output?

$ cat dev.c
#include <sys/stat.h>
#include <stdio.h>

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 dev.c -o dev && ./dev
$

Those headers are automatically generated from the kernel C headers I seem to remember.

At least that is what was stated in this issue which I made about some of those fields being renamed

If s.Rdev can be uint32 then the fact it doesn’t compile is probably a bug in docker.

Thanks for your reply, this is the output on mips64:

[root@node001 git]# 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.

[root@node001 git]# gcc dev.c -o dev && ./dev
8
8
8

Thanks. I am not familiar with the kernel. You mean that the field rdev in my OS kernel is of u32 type. If it is, could the problem be with docker?

It looks like from the output of the C program that the size of rdev in your OS is 8 bytes so it is of uint64 type.

This means the bug is in the go standard library…

It would be worth making an issue on the main Go repo about this I think.

Thanks a lot, I have made an issue on the golang repo

1 Like

I see cherrymui’s response that Go uses the kernel layout. That is unexpected that the kernel is 32 bit but what he says makes sense.

So if it isn’t a Go bug it must be a Docker bug…