Compile these `CompileInput`s (maybe in parallel) and return the resulting `UnlinkedCompileOutput`s.
(
self,
engine: &Engine,
types: &'a ModuleTypesBuilder,
)
| 592 | /// Compile these `CompileInput`s (maybe in parallel) and return the |
| 593 | /// resulting `UnlinkedCompileOutput`s. |
| 594 | fn compile( |
| 595 | self, |
| 596 | engine: &Engine, |
| 597 | types: &'a ModuleTypesBuilder, |
| 598 | ) -> Result<UnlinkedCompileOutputs<'a>> { |
| 599 | let compiler = engine.try_compiler()?; |
| 600 | |
| 601 | if self.inputs.len() > 0 && cfg!(miri) { |
| 602 | bail!( |
| 603 | "\ |
| 604 | You are attempting to compile a WebAssembly module or component that contains |
| 605 | functions in Miri. Running Cranelift through Miri is known to take quite a long |
| 606 | time and isn't what we want in CI at least. If this is a mistake then you should |
| 607 | ignore this test in Miri with: |
| 608 | |
| 609 | #[cfg_attr(miri, ignore)] |
| 610 | |
| 611 | If this is not a mistake then try to edit the `pulley_provenance_test` test |
| 612 | which runs Cranelift outside of Miri. If you still feel this is a mistake then |
| 613 | please open an issue or a topic on Zulip to talk about how best to accommodate |
| 614 | the use case. |
| 615 | " |
| 616 | ); |
| 617 | } |
| 618 | |
| 619 | let mut raw_outputs = if let Some(inlining_compiler) = compiler.inlining_compiler() { |
| 620 | if engine.tunables().inlining != Inlining::No { |
| 621 | self.compile_with_inlining(engine, compiler, inlining_compiler)? |
| 622 | } else { |
| 623 | // Inlining compiler but inlining is disabled: compile each |
| 624 | // input and immediately finish its output in parallel, skipping |
| 625 | // call graph computation and all that. |
| 626 | engine.run_maybe_parallel::<_, _, Error, _>(self.inputs, |f| { |
| 627 | let mut compiled = f(compiler)?; |
| 628 | inlining_compiler.finish_compiling( |
| 629 | &mut compiled.function, |
| 630 | compiled.func_body.take(), |
| 631 | &compiled.symbol, |
| 632 | )?; |
| 633 | Ok(compiled) |
| 634 | })? |
| 635 | } |
| 636 | } else { |
| 637 | // No inlining: just compile each individual input in parallel. |
| 638 | engine.run_maybe_parallel(self.inputs, |f| f(compiler))? |
| 639 | }; |
| 640 | |
| 641 | if cfg!(debug_assertions) { |
| 642 | let mut symbols: Vec<_> = raw_outputs.iter().map(|i| &i.symbol).collect(); |
| 643 | symbols.sort(); |
| 644 | for [a, b] in symbols.array_windows() { |
| 645 | assert_ne!( |
| 646 | a, b, |
| 647 | "should never have duplicate symbols, but found two functions with the symbol `{a}`", |
| 648 | ); |
| 649 | } |
| 650 | } |
| 651 |
no test coverage detected