I’m using Debian 10 and tried to install suricata build from source and I got the following log message:
....
error[E0277]: cannot subtract `usize` from `u32`
--> /root/temp/src/suricata-6.0.2/rust/vendor/lexical-core/src/atof/algorithm/math.rs:2071:25
|
2071 | let rs = Limb::BITS - s;
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
error: aborting due to 27 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `lexical-core`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
make[2]: *** [Makefile:544: all-local] Error 101
make[2]: Leaving directory '/root/temp/src/suricata-6.0.2/rust'
make[1]: *** [Makefile:492: install-recursive] Error 1
make[1]: Leaving directory '/root/temp/src/suricata-6.0.2'
make: *** [Makefile:908: install-full] Error 2
I think lexical-core is the culprit here. If anyone know if I should downgrade something in order to pass this error message? I’m not really familiar with this rustc thing. I actually followed the similar installation procedure that I’ve written in here: Install suricata 6.0.1 on Debian 10 from source
I have the same error with suricata 6.0.2 on OpenBSD, using rustc 1.53.0 (released recently). The build was fine with previous rustc version (1.52.1).
The problem is related to lexical-core and integer::BITS stabilization on rust side. A fix landed in lexical-core but only on 0.7 branch (release 0.7.5 fixed it). suricata 6.0.2 tarball ships lexical-core 0.6.7 which is affected.
Other then downgrading your Rust, one work-around is to rm -rf rust/vendor before running ./configure. That will cause the Rust deps to be pulled from the internet instead of the vendored.
No real graceful way to handle Rust deciding to make some new reserved keywords unfortunately.
that might be unacceptable for downstream distribution if they want to ship updated rustc and suricata versions.
lexical-core comes from nom 5.1.1 requirement in suricata. nom has a 5.1.2 version published and this version allows lexical-core 0.7.x. updating nom to 5.1.2 might be a migration path for this issue.
Yes, thats a valid concern, but its hard to get right for everyone. We vendor the sources to allow building offline which is a requirement for some downstream distributions, and just in general to provide the more classic unix software install experience without having to go out to the network… It also has the affect of doing a Cargo.lock without having a Cargo.lock - even if we didn’t vendor and shipped a Cargo.lock, you’d run into the same situation, however it is easier to patch.
One thing we could do is provide a ./configure argument like --without-rust-vendored to always fetch from the internet. That may have issues as well, as you could end up with versions we didn’t use during QA, etc. We’ve seen patch releases in dependencies break APIs as well, but in this case its rust.
So the best we can do is handle what we know when we stamp a release archive, and unfortunately deal with these breakages from time to time.
I also just saw commit 639f3d26 on suricata which pin nom to 5.1.1 on purpose (5.1.2 pulls in dependencies that don’t build on Rust 1.34).
Please note that not using vendored crates might not be enough to build suricata with Rust 1.53: nom 5.1.1 is bound to lexical-core 0.6 (see nom Cargo.toml and so it is not buildable with Rust >=1.53.
For downstream usage, I will go on the road to (partially) backport lexical-core patch.
I’m going to try the work around that you have suggested by removing rm -rf rust/vendor before running ./configure
EDIT: well the solution removing rust/vendor does not work (similar error). Here is the log:
error[E0277]: cannot divide usize by u32
→ /root/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.7/src/atof/algorithm/math.rs:1260:17
|
1260 | let div = n / bits;
| ^ no implementation for usize / u32
|
= help: the trait Div<u32> is not implemented for usize
error[E0308]: mismatched types
→ /root/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.7/src/atof/algorithm/math.rs:2071:27
|
2071 | let rs = Limb::BITS - s;
| ^ expected u32, found usize
error[E0277]: cannot subtract usize from u32
→ /root/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.7/src/atof/algorithm/math.rs:2071:25
|
2071 | let rs = Limb::BITS - s;
| ^ no implementation for u32 - usize
|
= help: the trait Sub<usize> is not implemented for u32
error: aborting due to 27 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try rustc --explain E0277.
error: could not compile lexical-core
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish…
error: build failed
make[2]: *** [Makefile:544: all-local] Error 101
make[2]: Leaving directory ‘/root/temp/src/suricata-6.0.2/rust’
make[1]: *** [Makefile:492: install-recursive] Error 1
make[1]: Leaving directory ‘/root/temp/src/suricata-6.0.2’
make: *** [Makefile:908: install-full] Error 2
Thank you @ish, I was able to use a rust binary of 1.52 earlier this week, and now build with rustup using your suggested variable version pass to compile.
At this point I still got the same error and the installer terminated:
error[E0277]: cannot subtract `usize` from `u32`
--> /root/temp/src/suricata-6.0.2/rust/vendor/lexical-core/src/atof/algorithm/math.rs:2071:25
|
2071 | let rs = Limb::BITS - s;
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
error: aborting due to 27 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `lexical-core`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
make[2]: *** [Makefile:544: all-local] Error 101
make[2]: Leaving directory '/root/temp/src/suricata-6.0.2/rust'
make[1]: *** [Makefile:492: install-recursive] Error 1
make[1]: Leaving directory '/root/temp/src/suricata-6.0.2'
make: *** [Makefile:908: install-full] Error 2
Is there anything else I can provide to debug this. Thanks for helping …