Optimization #6126
closedcompiling with outdated cbindgen does not have a corresponding err msg
Description
Observed when compiling with the current master.
When compiling suricata with an outdated cbindgen , there is no err message indication this is the actual problem by the resulting errors and the compilation fails.
A regular user following the docs would not be able to figure it out by themselves i think.
We should probably have a minimum cbindgen version that is needed to compile with (just as we do with rust).
Example of the errs that are related to older cbindgen :
./../rust/gen/rust-bindings.h:4794:3: error: typedef redefinition with different types ('struct AppLayerTxData' (aka 'AppLayerTxData') vs 'struct AppLayerTxData')
} AppLayerTxData;
^
./detect.h:1333:31: note: previous definition is here
typedef struct AppLayerTxData AppLayerTxData;
^
make[2]: *** [Makefile:3482: app-layer-parser.o] Error 1
1 error generated.
5 errors generated.
In file included from detect-engine-file.c:42:
In file included from ./app-layer-parser.h:30:
In file included from ./rust.h:27:
./../rust/gen/rust-bindings.h:4794:3: error: typedef redefinition with different types ('struct AppLayerTxData' (aka 'AppLayerTxData') vs 'struct AppLayerTxData')
} AppLayerTxData;
^
./detect.h:1333:31: note: previous definition is here
typedef struct AppLayerTxData AppLayerTxData;
^
In file included from detect-engine-enip.c:28:
./app-layer-enip-common.h:206:20: error: field has incomplete type 'AppLayerTxData' (aka 'struct AppLayerTxData')
AppLayerTxData tx_data;
^
./detect.h:1333:16: note: forward declaration of 'struct AppLayerTxData'
typedef struct AppLayerTxData AppLayerTxData;
...
Updated by Peter Manev over 2 years ago
- Tracker changed from Bug to Optimization
- Affected Versions deleted (
git main)
Updated by Jason Ish over 2 years ago
What version were you running into issues with? We do have a minimum version allowed, but it probably needs to be updated.
Updated by Lukas Sismis over 2 years ago
I've stumbled upon this as well. No error message was shown during ./autogen.sh && ./configure but after manually running cargo install --force cbindgen the issue was outdated rustc.
cargo install --force cbindgen
Updating crates.io index
Downloaded cbindgen v0.24.5
Downloaded 1 crate (196.6 KB) in 0.71s
Installing cbindgen v0.24.5
Downloaded tempfile v3.6.0
Downloaded os_str_bytes v6.5.1
Downloaded quote v1.0.28
Downloaded proc-macro2 v1.0.60
Downloaded log v0.4.19
Downloaded serde_derive v1.0.164
Downloaded unicode-ident v1.0.9
Downloaded io-lifetimes v1.0.11
Downloaded serde v1.0.164
Downloaded serde_json v1.0.97
Downloaded syn v2.0.18
Downloaded rustix v0.37.20
Downloaded linux-raw-sys v0.3.8
Downloaded libc v0.2.146
Downloaded 14 crates (2.8 MB) in 0.90s (largest was `linux-raw-sys` at 1013.8 KB)
error: failed to compile `cbindgen v0.24.5`, intermediate artifacts can be found at `/tmp/cargo-installBqQARo`
Caused by:
package `log v0.4.19` cannot be built because it requires rustc 1.60.0 or newer, while the currently active rustc version is 1.58.1
My current cbindgen version is 0.24.3
After updating rust to 1.60+ and cbindgen to v0.24.5 then everything runs ok.
I tried to investigate the issue by installing old cbindgen v0.24.3 but the compilation succeded, I can't reproduce the issue. I also tried moving back and forth a few commits (to make sure Rust files are changed). I didn't downgrade Rust though...
Not sure how to detect this issue, the solution is likely to make sure your Rust and cbindgen are updated.
My personal comment:
What actually happened to me was that I didn't have cargo path exported to PATH variable. (I had it when I set up the repository previously but that was exported only manually - not in e.g. .bashrc). So when I updated the sources, cargo path was missing. Interestingly, autogen/configure didn't complain possibly because of artifacts from the previous builds. To test the idea, I uninstalled cbindgen and redid the whole autogen/configure/make process. Suricata successfully compiled so it seems unless Rust files are changed it does not call cbindgen and therefore doesn't complain.
Updated by Philippe Antoine 8 months ago
- Status changed from New to Closed
Fixed by commit c861685e2865a2e7e577fc4bb55d067144e613bc unless you find another way to reproduce