Build an ISA based on the current machine running this code (the host)
(isa_spec: &IsaSpec)
| 106 | |
| 107 | /// Build an ISA based on the current machine running this code (the host) |
| 108 | fn 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)] |
| 129 | mod test { |