Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to build on mips(el): expected ‘dev_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘long unsigned int *’ #11247

Closed
mbiebl opened this issue Dec 22, 2018 · 12 comments
Labels
bug 🐛 Programming errors, that need preferential fixing needs-patch not-our-bug regression ⚠️ A bug in something that used to work correctly and broke through some recent commit

Comments

@mbiebl
Copy link
Contributor

mbiebl commented Dec 22, 2018

systemd version the issue has been seen with

v240

Used distribution

Debian sid

The latest upstream release of systemd fails to build on mips/mipsel with the following error message:

[346/1708] cc -Isrc/core/2ac6ece@@core@sta -Isrc/core -I../src/core -Isrc/basic -I../src/basic -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I../ -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -flto -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -std=gnu99 -Wextra -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fPIE -ffunction-sections -fdata-sections -Werror=shadow -include config.h -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -pthread  -MD -MQ 'src/core/2ac6ece@@core@sta/cgroup.c.o' -MF 'src/core/2ac6ece@@core@sta/cgroup.c.o.d' -o 'src/core/2ac6ece@@core@sta/cgroup.c.o' -c ../src/core/cgroup.c
FAILED: src/core/2ac6ece@@core@sta/cgroup.c.o 
cc -Isrc/core/2ac6ece@@core@sta -Isrc/core -I../src/core -Isrc/basic -I../src/basic -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I../ -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -flto -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -std=gnu99 -Wextra -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fPIE -ffunction-sections -fdata-sections -Werror=shadow -include config.h -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -pthread  -MD -MQ 'src/core/2ac6ece@@core@sta/cgroup.c.o' -MF 'src/core/2ac6ece@@core@sta/cgroup.c.o.d' -o 'src/core/2ac6ece@@core@sta/cgroup.c.o' -c ../src/core/cgroup.c
../src/core/cgroup.c: In function ‘lookup_block_device’:
../src/core/cgroup.c:405:59: error: passing argument 3 of ‘device_path_parse_major_minor’ from incompatible pointer type [-Werror=incompatible-pointer-types]
         r = device_path_parse_major_minor(p, &st.st_mode, &st.st_rdev);
                                                           ^~~~~~~~~~~
In file included from ../src/core/cgroup.c:22:
../src/basic/stat-util.h:87:78: note: expected ‘dev_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘long unsigned int *’
 int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno);
                                                                       ~~~~~~~^~~~~~~~~
../src/core/cgroup.c: In function ‘whitelist_device’:
../src/core/cgroup.c:448:62: error: passing argument 3 of ‘device_path_parse_major_minor’ from incompatible pointer type [-Werror=incompatible-pointer-types]
         r = device_path_parse_major_minor(node, &st.st_mode, &st.st_rdev);
                                                              ^~~~~~~~~~~
In file included from ../src/core/cgroup.c:22:
../src/basic/stat-util.h:87:78: note: expected ‘dev_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘long unsigned int *’
 int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno);
                                                                       ~~~~~~~^~~~~~~~~
cc1: some warnings being treated as errors
[347/1708] cc -Isrc/core/2ac6ece@@core@sta -Isrc/core -I../src/core -Isrc/basic -I../src/basic -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I../ -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -flto -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -std=gnu99 -Wextra -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fPIE -ffunction-sections -fdata-sections -Werror=shadow -include config.h -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -pthread  -MD -MQ 'src/core/2ac6ece@@core@sta/dbus-execute.c.o' -MF 'src/core/2ac6ece@@core@sta/dbus-execute.c.o.d' -o 'src/core/2ac6ece@@core@sta/dbus-execute.c.o' -c ../src/core/dbus-execute.c
[348/1708] cc  -o libsystemd.so.0.24.0 'systemd@sha/src_libsystemd_disable-mempool.c.o' -flto -Wl,--no-undefined -Wl,--as-needed -shared -fPIC -Wl,--start-group -Wl,-soname,libsystemd.so.0 -Wl,--whole-archive src/libsystemd/libsystemd_static.a src/journal/libjournal-client.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -pie -Wl,--gc-sections -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro src/basic/libbasic.a src/basic/libbasic-gcrypt.a -shared -Wl,--version-script=/<<PKGBUILDDIR>>/src/libsystemd/libsystemd.sym -lrt /usr/lib/mips-linux-gnu/liblzma.so /usr/lib/gcc/mips-linux-gnu/8/../../../mips-linux-gnu/liblz4.so /usr/lib/mips-linux-gnu/libcap.so /usr/lib/gcc/mips-linux-gnu/8/../../../mips-linux-gnu/libselinux.so -lm -lgcrypt -lrt -Wl,--end-group -pthread '-Wl,-rpath,$ORIGIN/src/basic' -Wl,-rpath-link,/<<PKGBUILDDIR>>/build-deb/src/basic  
[349/1708] cc  -o src/shared/libsystemd-shared-240.so 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-device.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-enumerate.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-hwdb.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-list.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-monitor.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-queue.c.o' 'src/shared/5afaae1@@systemd-shared-240@sha/.._libudev_libudev-util.c.o' -flto -Wl,--no-undefined -Wl,--as-needed -shared -fPIC -Wl,--start-group -Wl,-soname,libsystemd-shared-240.so -Wl,--whole-archive src/shared/libsystemd-shared-240.a src/basic/libbasic.a src/basic/libbasic-gcrypt.a src/libsystemd/libsystemd_static.a src/journal/libjournal-client.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -pie -Wl,--gc-sections -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -shared -Wl,--version-script=/<<PKGBUILDDIR>>/src/shared/libshared.sym -lrt /usr/lib/mips-linux-gnu/libcap.so -lacl /usr/lib/gcc/mips-linux-gnu/8/../../../mips-linux-gnu/libcryptsetup.so -lgcrypt /usr/lib/mips-linux-gnu/libip4tc.so /usr/lib/mips-linux-gnu/libip6tc.so /usr/lib/mips-linux-gnu/libkmod.so /usr/lib/mips-linux-gnu/libmount.so /usr/lib/mips-linux-gnu/libseccomp.so /usr/lib/gcc/mips-linux-gnu/8/../../../mips-linux-gnu/libselinux.so /usr/lib/mips-linux-gnu/libidn.so /usr/lib/mips-linux-gnu/liblzma.so /usr/lib/gcc/mips-linux-gnu/8/../../../mips-linux-gnu/liblz4.so /usr/lib/mips-linux-gnu/libblkid.so -lrt -lacl -lgcrypt -lm -lgcrypt -lrt -Wl,--end-group -pthread  
ninja: build stopped: subcommand failed.

A full build log is available on
https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=mips&ver=240-1&stamp=1545503314&raw=0
or
https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=mipsel&ver=240-1&stamp=1545497753&raw=0

@mbiebl mbiebl added bug 🐛 Programming errors, that need preferential fixing regression ⚠️ A bug in something that used to work correctly and broke through some recent commit labels Dec 22, 2018
@mbiebl mbiebl changed the title fails to build on mips(el) fails to build on mips(el): expected ‘dev_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘long unsigned int *’ Dec 22, 2018
@poettering
Copy link
Member

Hmmm? .st_rdev is not of type dev_t on mips? Sounds like a bug in the mips abi to me.

@poettering
Copy link
Member

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html

Posix says its dev_t. Seems mips' definition of stat is borked somehow?

@mbiebl
Copy link
Contributor Author

mbiebl commented Dec 22, 2018

@jcowgill
Copy link
Contributor

This is absolutely a bug in the MIPS o32 ABI and glibc needs fixing:
https://sourceware.org/bugzilla/show_bug.cgi?id=17786
https://sourceware.org/bugzilla/show_bug.cgi?id=21278

Unfortunately changing struct stat is not a trivial thing to do, and I no longer work on MIPS so I won't be able to help on the glibc side.

@mbiebl
Copy link
Contributor Author

mbiebl commented Dec 22, 2018

Thanks a lot for your input, @jcowgill

Is there a reasonably clean way to workaround this? If so, is there interest by upstream to take such a patch? Not sure if Debian is the only distro which builds binaries for MIPS

@boucman
Copy link
Contributor

boucman commented Dec 23, 2018

FYI, buildroot does support MIPS, but I havn't tried actually building it there..

@poettering
Copy link
Member

So, on the affected mips machines is there an actualy difference between "long long" and "long"? Is the latter 32bit and the former 64bit? (on x64-64 both would be 64bit, hence the difference wouldn't matter)

@poettering
Copy link
Member

I find this quite a major fuckup in the MIPS ABI tbh, and given how big this is I am tempted to just leave it to the MIPS folks to fix their own mess there. But I also see that this is not going to be fixed quickly soon.

Hence, if anyone who cares about mips preps a patch that reworks the two pieces of code on our side to store the result of device_path_parse_major_minor() in a separate dev_tvariable instead of directly in "struct stat", and to move the declaration of that to an inner scope and copy the data out, I'd review that and merge.

@wzssyqa
Copy link
Contributor

wzssyqa commented Dec 24, 2018

So, on the affected mips machines is there an actualy difference between "long long" and "long"? Is the latter 32bit and the former 64bit? (on x64-64 both would be 64bit, hence the difference wouldn't matter)

on O32, long is 32bit, and long long is 64bit. o32 is an quite old ABI. Let me have a try.

@wzssyqa
Copy link
Contributor

wzssyqa commented Dec 25, 2018

O32 doesn't meet the standard. the dev_t of it was should be 32bit, while it is wrongly defined as 64bit.

mipsel-linux-gnu/sys/stat.h:typedef __dev_t dev_t;
mipsel-linux-gnu/bits/types.h:__STD_TYPE __DEV_T_TYPE __dev_t;
mipsel-linux-gnu/bits/typesizes.h:#define __DEV_T_TYPE __UQUAD_TYPE
mipsel-linux-gnu/bits/types.h:# define __UQUAD_TYPE __u_quad_t
mipsel-linux-gnu/sys/types.h:typedef __u_quad_t u_quad_t;
mipsel-linux-gnu/bits/types.h:extension typedef unsigned long long int __u_quad_t;

No matter we modify struct stat or dev_t, the ABI are both broken.

@wzssyqa
Copy link
Contributor

wzssyqa commented Dec 25, 2018

@wzssyqa
Copy link
Contributor

wzssyqa commented Dec 25, 2018

#11268

wzssyqa added a commit to wzssyqa/systemd that referenced this issue Dec 30, 2018
MIPS/O32's st_rdev member of struct stat is unsigned long, which
is 32bit, while dev_t is defined as 64bit, which make some problems
in device_path_parse_major_minor.

Don't pass st.st_rdev, st_mode to device_path_parse_major_minor,
while pass 2 seperate variables. The result of stat is alos copied
out into these 2 variables. Fixes: systemd#11247
@keszybz keszybz closed this as completed in f585569 Jan 3, 2019
floppym pushed a commit to gentoo/systemd that referenced this issue Jan 7, 2019
MIPS/O32's st_rdev member of struct stat is unsigned long, which
is 32bit, while dev_t is defined as 64bit, which make some problems
in device_path_parse_major_minor.

Don't pass st.st_rdev, st_mode to device_path_parse_major_minor,
while pass 2 seperate variables. The result of stat is alos copied
out into these 2 variables. Fixes: systemd#11247

(cherry picked from commit f585569)
wkennington pushed a commit to triton/systemd that referenced this issue Jan 20, 2019
MIPS/O32's st_rdev member of struct stat is unsigned long, which
is 32bit, while dev_t is defined as 64bit, which make some problems
in device_path_parse_major_minor.

Don't pass st.st_rdev, st_mode to device_path_parse_major_minor,
while pass 2 seperate variables. The result of stat is alos copied
out into these 2 variables. Fixes: systemd#11247

(cherry picked from commit f585569)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing needs-patch not-our-bug regression ⚠️ A bug in something that used to work correctly and broke through some recent commit
Development

No branches or pull requests

5 participants