(
mut self,
tunables: &mut Tunables,
features: WasmFeatures,
)
| 2814 | |
| 2815 | #[cfg(any(feature = "cranelift", feature = "winch"))] |
| 2816 | pub(crate) fn build_compiler( |
| 2817 | mut self, |
| 2818 | tunables: &mut Tunables, |
| 2819 | features: WasmFeatures, |
| 2820 | ) -> Result<(Self, Box<dyn wasmtime_environ::Compiler>)> { |
| 2821 | let target = self.compiler_target(); |
| 2822 | |
| 2823 | // The target passed to the builders below is an `Option<Triple>` where |
| 2824 | // `None` represents the current host with CPU features inferred from |
| 2825 | // the host's CPU itself. The `target` above is not an `Option`, so |
| 2826 | // switch it to `None` in the case that a target wasn't explicitly |
| 2827 | // specified (which indicates no feature inference) and the target |
| 2828 | // matches the host. |
| 2829 | let target_for_builder = |
| 2830 | if self.target.is_none() && target == target_lexicon::Triple::host() { |
| 2831 | None |
| 2832 | } else { |
| 2833 | Some(target.clone()) |
| 2834 | }; |
| 2835 | |
| 2836 | let mut compiler = match self.compiler_config_mut().strategy { |
| 2837 | #[cfg(feature = "cranelift")] |
| 2838 | Some(Strategy::Cranelift) => wasmtime_cranelift::builder(target_for_builder)?, |
| 2839 | #[cfg(not(feature = "cranelift"))] |
| 2840 | Some(Strategy::Cranelift) => bail!("cranelift support not compiled in"), |
| 2841 | #[cfg(feature = "winch")] |
| 2842 | Some(Strategy::Winch) => wasmtime_winch::builder(target_for_builder)?, |
| 2843 | #[cfg(not(feature = "winch"))] |
| 2844 | Some(Strategy::Winch) => bail!("winch support not compiled in"), |
| 2845 | |
| 2846 | None | Some(Strategy::Auto) => unreachable!(), |
| 2847 | }; |
| 2848 | |
| 2849 | if let Some(path) = &self.compiler_config_mut().clif_dir { |
| 2850 | compiler.clif_dir(path)?; |
| 2851 | } |
| 2852 | |
| 2853 | // If probestack is enabled for a target, Wasmtime will always use the |
| 2854 | // inline strategy which doesn't require us to define a `__probestack` |
| 2855 | // function or similar. |
| 2856 | self.compiler_config_mut() |
| 2857 | .settings |
| 2858 | .insert("probestack_strategy".into(), "inline".into()); |
| 2859 | |
| 2860 | // We enable stack probing by default on all targets. |
| 2861 | // This is required on Windows because of the way Windows |
| 2862 | // commits its stacks, but it's also a good idea on other |
| 2863 | // platforms to ensure guard pages are hit for large frame |
| 2864 | // sizes. |
| 2865 | self.compiler_config_mut() |
| 2866 | .flags |
| 2867 | .insert("enable_probestack".into()); |
| 2868 | |
| 2869 | // The current wasm multivalue implementation depends on this. |
| 2870 | // FIXME(#9510) handle this in wasmtime-cranelift instead. |
| 2871 | self.compiler_config_mut() |
| 2872 | .flags |
| 2873 | .insert("enable_multi_ret_implicit_sret".into()); |
no test coverage detected