//! # Cranelift Control1//!2//! This is the home of the control plane of chaos mode, a compilation feature3//! intended to be turned on for certain fuzz targets. When the feature is4//! turned off, as is normally the case, [ControlPlane] will be a zero-sized5//! type and optimized away.6//!7//! While the feature is turned on, the struct [ControlPlane]8//! provides functionality to tap into pseudo-randomness at specific locations9//! in the code. It may be used for targeted fuzzing of compiler internals,10//! e.g. manipulate heuristic optimizations, clobber undefined register bits11//! etc.12//!13//! There are two ways to acquire a [ControlPlane]:14//! - [arbitrary] for the real deal (requires the `fuzz` feature, enabled by default)15//! - [default] for an "empty" control plane which always returns default16//! values17//!18//! ## Fuel Limit19//!20//! Controls the number of mutations or optimizations that the compiler will21//! perform before stopping.22//!23//! When a perturbation introduced by chaos mode triggers a bug, it may not be24//! immediately clear which of the introduced perturbations was the trigger. The25//! fuel limit can then be used to binary-search for the trigger. It limits the26//! number of perturbations introduced by the control plane. The fuel limit will27//! typically be set with a command line argument passed to a fuzz target. For28//! example:29//! ```sh30//! cargo fuzz run --features chaos $TARGET -- --fuel=1631//! ```32//!33//! ## `no_std` support34//!35//! This crate compiles in `no_std` environments, although both the `fuzz`36//! or `chaos` features have a dependency on `std`. This means that on `no_std`37//! you can't use [arbitrary] to initialize [ControlPlane] and can't enable38//! chaos mode, although the rest of the usual [ControlPlane] API is available.39//!40//! [arbitrary]: ControlPlane#method.arbitrary41//! [default]: ControlPlane#method.default4243#![no_std]4445// The `alloc` crate is only needed by chaos mode, which guarantees that46// `alloc` is present because of its dependency on `std`.47#[cfg(feature = "chaos")]48extern crate alloc;4950#[cfg(not(feature = "chaos"))]51mod zero_sized;52#[cfg(not(feature = "chaos"))]53pub use zero_sized::*;5455#[cfg(feature = "chaos")]56mod chaos;57#[cfg(feature = "chaos")]58pub use chaos::*;596061