ibm-s390-linux / s390-tools

Tools for use with the s390 Linux kernel and device drivers
MIT License
63 stars 60 forks source link

rust - build fails due "error: unnecessary qualification" #173

Closed sharkcz closed 2 months ago

sharkcz commented 2 months ago

I am getting a build failure in the rust code on ELN (on all arches), but not in Rawhide. I suspect it's somehow related to rust compiler flags as both builds use Rust 1.80.1 and generally the buildroot is almost identical.

...   
Compiling s390_pv_core v0.10.0 (/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/pv_core)
     Running `/usr/bin/rustc --crate-name s390_pv_core --edition=2021 pv_core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=c17642eabcd7c33c -C extra-filename=-c17642eabcd7c33c --out-dir /builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps -C strip=debuginfo -L dependency=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps --extern byteorder=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/libbyteorder-0717dc3c157ec034.rmeta --extern libc=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/liblibc-daaeb3cf0188bac8.rmeta --extern log=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/liblog-f6a2d7686c9c97dc.rmeta --extern serde=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/libserde-9e234007a05fcf39.rmeta --extern thiserror=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/libthiserror-ac15447bbc88b5c0.rmeta --extern zerocopy=/builddir/build/BUILD/s390utils-2.34.0-build/s390-tools-2.34.0/rust/target/release/deps/libzerocopy-78339700b94fb7cc.rmeta -Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes`
error: unnecessary qualification
   --> pv_core/src/uvdevice/ffi.rs:106:29
    |
106 |     iowr(UVIO_TYPE_UVC, nr, std::mem::size_of::<uvio_ioctl_cb>())
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: the lint level is defined here
   --> pv_core/src/lib.rs:10:5
    |
10  |     unused_qualifications
    |     ^^^^^^^^^^^^^^^^^^^^^
help: remove the unnecessary path segments
    |
106 -     iowr(UVIO_TYPE_UVC, nr, std::mem::size_of::<uvio_ioctl_cb>())
106 +     iowr(UVIO_TYPE_UVC, nr, size_of::<uvio_ioctl_cb>())
    |
...

Please see eg. https://koji.fedoraproject.org/koji/taskinfo?taskID=121961756 for the complete logs. And see eg. https://koji.fedoraproject.org/koji/taskinfo?taskID=121842128 (Rawhide) for comparison.

hoeppnerj commented 2 months ago

This seems to be triggered by unused_qualifications here as the error message indicates: https://github.com/ibm-s390-linux/s390-tools/blob/54e5e99657b3f1eb433954e0ed19c93a3bc561c6/rust/pv_core/src/lib.rs#L4-L11

I'm not sure if we really want this. Per default this is an "allow" lint but we've put it into deny. This is really just a style issue but due to the deny list is causing an error. There is no actual programming issue.

I'll discuss with @steffen-eiden how we'll go about it.

hoeppnerj commented 2 months ago

The difference between the two builds is that Rawhide defines --cap-lints=warn for the rustc buildflags. This keeps all lints at a warn-level. To have a general solution, @steffen-eiden will provide a fix and set the lints mentioned above to warn-level instead of "deny". Deny is too aggressive.

hoeppnerj commented 2 months ago

@frank-heimes @ngueorguiev fyi

steffen-eiden commented 2 months ago

Seems like older rustc versions did not found this lint-issue -> our build test did not find this lint. A fix is on the way.

steffen-eiden commented 2 months ago

FYI: sizeof is in the prelude since rustc 1.80 -> the lint fires for 1.80+

See: https://github.com/rust-lang/rust/pull/123168/

sharkcz commented 2 months ago

Thanks, we can build again. And if I understand right, then you will keep code as it is, so it can be built with rust < 1.80, right?