link
Cranelift codegen backend for rust
- https://github.com/rust-lang/rustc_codegen_cranelift
- The goal of this project is to create an alternative codegen backend for the rust compiler based on Cranelift. This has the potential to improve compilation times in debug mode. If your project doesn’t use any of the things listed under “Not yet supported”, it should work fine. If not please open an issue.
- 이 프로젝트의 목표는 Cranelift를 기반으로 한 러스트 컴파일러를 위한 대체 코드젠 백엔드를 만드는 것입니다. 이는 디버그 모드에서 컴파일 시간을 개선할 수 있는 잠재력을 가지고 있습니다. 프로젝트에서 “아직 지원되지 않음”에 나열된 항목을 사용하지 않는다면 잘 작동할 것입니다. 그렇지 않다면 문제를 열어주세요.
Cranelift
A Bytecode Alliance project
Cranelift is a fast, secure, relatively simple and innovative compiler backend. It takes an intermediate representation of a program generated by some frontend and compiles it to executable machine code. Cranelift is meant to be used as a library within an “embedder”. It is in successful use by the Wasmtime WebAssembly virtual machine, for just-in-time (JIT) and ahead-of-time (AOT) compilation, and also as an experimental backend for the Rust compiler. Its most common use is as a WebAssembly compiler, but it is fully general and usable for most code-generation needs. Cranelift itself is written in Rust.
Cranelift currently supports x86-64, aarch64 (ARM64), s390x (IBM Z), and riscv64 platforms. It is retargetable and contributions of further ISA support are welcome.
Cranelift is actively maintained and used in production to run sandboxed untrusted code with close-to-native performance. We continue to develop it to add feature support, improve performance, and further verify its correctness. We follow Wasmtime’s release policy and security policy.
바이트코드 얼라이언스 프로젝트
Cranelift는 빠르고 안전하며 비교적 간단하고 혁신적인 컴파일러 백엔드입니다. 일부 프론트엔드에서 생성된 프로그램의 중간 표현을 가져와 실행 가능한 기계 코드로 컴파일합니다. Cranelift는 “임베더” 내에서 라이브러리로 사용되도록 되어 있습니다. 이는 Wasmtime WebAssembly 가상 머신, JIT(Just-in-Time) 및 AOT(앞뒤처리) 컴파일, 그리고 Rust 컴파일러의 실험 백엔드로도 성공적으로 사용되고 있습니다. 가장 일반적인 사용은 WebAssembly 컴파일러이지만, 완전히 일반적이며 대부분의 코드 생성 요구 사항에 사용할 수 있습니다. Cranelift 자체는 Rust로 작성되었습니다.
Cranelift는 현재 x86-64, arch64(ARM64), s390x(IBM Z) 및 riscv64 플랫폼을 지원합니다. 리타겟팅이 가능하며 추가적인 ISA 지원에 대한 기여도 환영합니다.
Cranelift는 네이티브에 가까운 성능으로 샌드박스된 신뢰할 수 없는 코드를 실행하기 위해 적극적으로 유지 관리되고 생산에 사용됩니다. 우리는 기능 지원을 추가하고 성능을 향상시키며 그 정확성을 더욱 검증하기 위해 계속해서 개발하고 있습니다. 우리는 Wasmtime의 릴리스 정책과 보안 정책을 따릅니다.
(Cranelift) Install
Cranelift codegen backend for rust
- The goal of this project is to create an alternative codegen backend for the rust compiler based on Cranelift. This has the potential to improve compilation times in debug mode. If your project doesn’t use any of the things listed under “Not yet supported”, it should work fine. If not please open an issue.
Download using Rustup
- The Cranelift codegen backend is distributed in nightly builds on Linux, macOS and x86_64 Windows. If you want to install it using Rustup, you can do that by running:
rustup component add rustc-codegen-cranelift-preview --toolchain nightly- Once it is installed, you can enable it with one of the following approaches:
CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly build -Zcodegen-backend- Add the following to
.cargo/config.toml:
[unstable]
codegen-backend = true
[profile.dev]
codegen-backend = "cranelift"- Add the following to
Cargo.toml:
# This line needs to come before anything else in Cargo.toml
cargo-features = ["codegen-backend"]
[profile.dev]
codegen-backend = "cranelift"Precompiled builds
- You can also download a pre-built version from the releases page. Extract the dist directory in the archive anywhere you want. If you want to use cargo clif build instead of having to specify the full path to the cargo-clif executable, you can add the bin subdirectory of the extracted dist directory to your PATH. (tutorial for Windows, and for Linux/MacOS).
Building and testing
- If you want to build the backend manually, you can download it from GitHub and build it yourself:
git clone https://github.com/rust-lang/rustc_codegen_cranelift
cd rustc_codegen_cranelift
./y.sh build- To run the test suite replace the last command with:
./y.sh prepare # only needs to be run the first time
./test.sh