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

Function run

cranelift/src/compile.rs:47–76  ·  view source on GitHub ↗
(options: &Options)

Source from the content-addressed store, hash-verified

45}
46
47pub fn run(options: &Options) -> Result<()> {
48 let parsed = parse_sets_and_triple(&options.settings, &options.target)?;
49
50 let mut module = match (&options.output, &parsed) {
51 (Some(output), OwnedFlagsOrIsa::Isa(isa)) => {
52 let builder = cranelift_object::ObjectBuilder::new(
53 isa.clone(),
54 output
55 .file_name()
56 .and_then(|s| s.to_str())
57 .unwrap_or("a.out"),
58 cranelift_module::default_libcall_names(),
59 )?;
60 Some(cranelift_object::ObjectModule::new(builder))
61 }
62 _ => None,
63 };
64
65 for path in &options.files {
66 let name = String::from(path.as_os_str().to_string_lossy());
67 handle_module(options, path, &name, parsed.as_fisa(), module.as_mut())?;
68 }
69
70 if let (Some(module), Some(output)) = (module, &options.output) {
71 let bytes = module.finish().emit()?;
72 std::fs::write(output, bytes)?;
73 }
74
75 Ok(())
76}
77
78fn handle_module(
79 options: &Options,

Callers

nothing calls this directly

Calls 14

parse_sets_and_tripleFunction · 0.85
default_libcall_namesFunction · 0.85
fromFunction · 0.85
handle_moduleFunction · 0.85
OkFunction · 0.85
file_nameMethod · 0.80
to_strMethod · 0.80
as_fisaMethod · 0.80
newFunction · 0.50
writeFunction · 0.50
cloneMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected