Run your first Rust integration build analysis
In this topic, learn how to:
Enable Rust support
To enable Rust support:
-
Download the platform-appropriate
kwrustZIP archive. -
Extract the ZIP directly over your existing Klocwork build tools or command line tools installation (version 2026.1 or later).
The extraction will add Rust tooling support and enable the rustc compiler mapping via kwfilter.conf (overwriting your existing version).
Analyze Rust projects
Once the add-on is installed, you can analyze Rust projects following the same workflow used for other languages.
An example using kwcheck:
kwinject --overwrite sh -c 'cargo clean && cargo build'
kwcheck create
kwcheck set license.host=<license host>
kwcheck import kwinject.out
kwcheck run --rebuild
kwcheck list
Notes:
-
The
--overwriteflag is currently required when generating the build specification. -
All built‑in Klocwork Rust checkers are enabled by default. This behavior may evolve in future releases.
Configure Rust checkers in Validate
Klocwork includes two types of Rust checkers: native Rust checkers and Clippy‑based checkers. By default, the Validate UI does not list Rust as a language until you load the appropriate taxonomies.
To enable Rust checkers:
-
Go to your project's Configuration tab.
-
For native Rust checkers, load taxonomies/rs.base.tconf.
-
For Clippy-based checkers, load taxonomies/rs_clippy.tconf.
Rust will now appear as a language in the configuration panel, allowing you to activate or deactivate specific checkers.
Perform advanced configuration
Prevent Klocwork from affecting Rust project artifacts
By default, Klocwork recompiles Rust projects in-place, meaning that it will replace some of the generated artifacts. If your project uses cargo, this can be avoided using buildspec template variables.
Perform these steps:
-
Run kwinject:
kwinject -w -o buildspec.tpl --variable RUST_TARGET=/absolute/path/to/target sh -c 'cargo clean && cargo build'
-
Run kwbuildproject:
kwbuildproject -V RUST_TARGET=/absolute/path/to/another/folder -o tables buildspec.tpl
-
Run kwcheck:
kwcheck import buildspec.tpl kwcheck set-var RUST_TARGET=/absolute/path/to/another/folder kwcheck run --rebuild
Pass additional compiler or analysis options
Similar to C/C++, you can pass additional Rust-specific compiler or analysis flags using the following options:
-
--add-rs-compiler-options
-
--add-rs-analysis-options
See the following example for disabling the CLEF timeout:
kwbuildproject --add-rs-analysis-options "--clef-option --lef-time-limit=-1"