[package]
name = "rustc_codegen_cranelift"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", features = ["unwind", "all-arch"] }
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git" }
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git" }
cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git" }
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", optional = true }
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git" }
target-lexicon = "0.12.0"
gimli = { version = "0.25.0", default-features = false, features = ["write"]}
object = { version = "0.26.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
indexmap = "1.0.2"
libloading = { version = "0.6.0", optional = true }
smallvec = "1.6.1"

# Uncomment to use local checkout of cranelift
#[patch."https://github.com/bytecodealliance/wasmtime.git"]
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" }
#cranelift-module = { path = "../wasmtime/cranelift/module" }
#cranelift-native = { path = "../wasmtime/cranelift/native" }
#cranelift-jit = { path = "../wasmtime/cranelift/jit" }
#cranelift-object = { path = "../wasmtime/cranelift/object" }

#[patch.crates-io]
#gimli = { path = "../" }

[features]
# Enable features not ready to be enabled when compiling as part of rustc
unstable-features = ["jit", "inline_asm"]
jit = ["cranelift-jit", "libloading"]
inline_asm = []

[profile.dev]
# By compiling dependencies with optimizations, performing tests gets much faster.
opt-level = 3

[profile.dev.package.rustc_codegen_cranelift]
# Disabling optimizations for cg_clif itself makes compilation after a change faster.
opt-level = 0

[profile.release.package.rustc_codegen_cranelift]
incremental = true

# Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the
# execution time of build scripts is so fast that optimizing them slows down the total build time.
[profile.dev.build-override]
opt-level = 0
debug = false

[profile.release.build-override]
opt-level = 0
debug = false

[profile.dev.package.cranelift-codegen-meta]
opt-level = 0
debug = false

[profile.release.package.cranelift-codegen-meta]
opt-level = 0
debug = false

[package.metadata.rust-analyzer]
rustc_private = true
