Cargo Features

cranelift-codegen = { version = "0.105.1", default-features = false, features = ["std", "core", "disas", "trace-log", "unwind", "x86", "arm64", "s390x", "riscv64", "host-arch", "all-arch", "enable-serde", "incremental-cache", "souper-harvest", "isle-errors", "isle-in-source-tree", "timing"] }
default = host-arch, std, timing, unwind

These default features are set whenever cranelift-codegen is added without default-features = false somewhere in the dependency tree.

std default

The "std" feature enables use of libstd. The "core" feature enables use of some minimal std-like replacement libraries. At least one of these two features need to be enabled.


The "core" feature used to enable a hashmap workaround, but is now deprecated (we (i) always use hashbrown, and (ii) don't support a no_std build anymore). The feature remains for backward compatibility as a no-op.

disas = anyhow, capstone

Enable the to_capstone method on TargetIsa, for constructing a Capstone context, and the disassemble method on MachBufferFinalized.

Affects isa::TargetIsa.to_capstone


Enables detailed logging which can be somewhat expensive.

unwind default = gimli

This enables unwind info generation functionality.

Affects isa::TargetIsa.map_regalloc_reg_to_dwarf, isa::TargetIsa.emit_unwind_info, isa::TargetIsa.create_systemv_cie, unwind::systemv, unwind::winx64

x86 all-arch?

ISA targets for which we should build.
If no ISA targets are explicitly enabled, the ISA target for the host machine is enabled.

Affects isa::x64

arm64 all-arch?

Affects isa::aarch64

s390x all-arch?
riscv64 all-arch?

Affects isa::riscv64

host-arch default

Enable the ISA target for the host machine

all-arch = arm64, riscv64, s390x, x86

Option to enable all architectures.

enable-serde incremental-cache? = serde, serde_derive

For dependent crates that want to serialize some parts of cranelift

Enables serde of smallvec, enable-serde of cranelift-entity and regalloc2

Affects buffer::CompilePhase

incremental-cache = bincode, enable-serde, sha2

Enable the incremental compilation cache for hot-reload use cases.

Affects cranelift-codegen::incremental_cache

souper-harvest = souper-ir

Enable support for the Souper harvester.

Enables stringify of souper-ir

isle-errors build

Report any ISLE errors in pretty-printed style.

Enables fancy-errors of cranelift-isle


Put ISLE generated files in isle_generated_code/, for easier inspection, rather than inside of target/.

timing default

Enable tracking how long passes take in Cranelift.

Enabled by default.

Features from optional dependencies

In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features.

anyhow disas?
capstone disas?

Enables capstone ^0.9.0

serde enable-serde?
serde_derive enable-serde?
bincode incremental-cache?
gimli unwind
souper-ir souper-harvest?
sha2 incremental-cache?