cargo-compiler-interrupts

Crates.iocargo-compiler-interrupts
lib.rscargo-compiler-interrupts
version4.0.1
sourcesrc
created_at2021-07-02 19:17:51.057095
updated_at2022-10-19 18:46:11.545973
descriptionCargo subcommands that integrate the Compiler Interrupts to the package
homepage
repositoryhttps://github.com/bitslab/cargo-compiler-interrupts
max_upload_size
id417984
size123,237
Quan Tran (quanshousio)

documentation

README

cargo-compiler-interrupts

crates.io docs.rs license

cargo-compiler-interrupts provides you a seamless way to integrate the Compiler Interrupts to any Rust packages. Check out the Compiler Interrupts main repository for more info.

Requirements

  • Rust 1.45.0 or later and LLVM 9 or later are required. Both must have the same LLVM major version.
  • You can check the LLVM version from Rust toolchain and LLVM toolchain by running rustc -vV and llvm-config --version respectively.
  • x86-64 architecture with Linux or macOS is highly recommended. Other architectures and platforms have not been tested.

Installation

cargo-compiler-interrupts can be installed via cargo install.

cargo install cargo-compiler-interrupts

You can also fetch the repo and install using --path.

git clone https://github.com/bitslab/cargo-compiler-interrupts
cargo install --path ./cargo-compiler-interrupts

Install the Compiler Interrupts library.

cargo-lib-ci install

Getting started

Commands

  • cargo-lib-ci — manage the Compiler Interrupts library.
  • cargo-build-ci — build and integrate the Compiler Interrupts to the package.
  • cargo-run-ci — run the integrated binary. You can specify which binary to run by passing --bin <BINARY>.
cargo-lib-ci install    # install the CI library
cargo-build-ci          # build and integrate CI to the binary
cargo-run-ci            # run the CI-integrated binary

Integration

  • Run cargo-lib-ci install to install the Compiler Interrupts library first.
  • Before running cargo-build-ci, add the Compiler Interrupts API package as the dependency for your Rust program and registers the Compiler Interrupts handler. Compiler Interrupts API is provided through the compiler-interrupts crate.
fn interrupt_handler(ic: i64) {
    println!("Compiler interrupt called with instruction count: {}", ic);
}

unsafe {
    compiler_interrupts::register(1000, 1000, interrupt_handler);
}

For more detailed usages and internals, run the command with --help option and check out the documentation.

Contribution

All issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated. Issues relating to the Compiler Interrupts library should be reported to the main repository.

Author

Quan Tran (@quanshousio)

Acknowledgements

License

cargo-compiler-interrupts is available under the MIT license. See the LICENSE file for more info.

Commit count: 10

cargo fmt