MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / create_target_isa

Function create_target_isa

cranelift/src/run.rs:108–126  ·  view source on GitHub ↗

Build an ISA based on the current machine running this code (the host)

(isa_spec: &IsaSpec)

Source from the content-addressed store, hash-verified

106
107/// Build an ISA based on the current machine running this code (the host)
108fn create_target_isa(isa_spec: &IsaSpec) -> Result<OwnedTargetIsa> {
109 let builder = host_isa_builder().map_err(|s| anyhow::anyhow!("{s}"))?;
110 match *isa_spec {
111 IsaSpec::None(ref flags) => {
112 // build an ISA for the current machine
113 Ok(builder.finish(flags.clone())?)
114 }
115 IsaSpec::Some(ref isas) => {
116 for isa in isas {
117 if isa.triple().architecture == HOST.architecture {
118 return Ok(builder.finish(isa.flags().clone())?);
119 }
120 }
121 anyhow::bail!(
122 "The target ISA specified in the file is not compatible with the host ISA"
123 )
124 }
125 }
126}
127
128#[cfg(test)]
129mod test {

Callers 1

run_file_contentsFunction · 0.85

Calls 5

OkFunction · 0.85
finishMethod · 0.45
cloneMethod · 0.45
tripleMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected