|
48 | 48 | let mut builder = FunctionBuilder::new(params.as_slice(), results.as_slice()); |
49 | 49 | let _args = stub(&mut builder)?; |
50 | 50 |
|
| 51 | + println!("Warning: the component import '{full_import}#{name}' isn't listed in the target WIT world, and will abort execution when called."); |
51 | 52 | builder.replace_import_in_module(module, iid); |
52 | 53 |
|
53 | 54 | return Ok(Some(fid)); |
@@ -117,7 +118,7 @@ pub fn stub_wasi( |
117 | 118 | let mut target_world_imports = HashSet::new(); |
118 | 119 |
|
119 | 120 | for (key, _) in &target_world.imports { |
120 | | - target_world_imports.insert(resolve.name_world_key(key)); |
| 121 | + target_world_imports.insert(resolve.name_canonicalized_world_key(key)); |
121 | 122 | } |
122 | 123 |
|
123 | 124 | let mut module = Module::parse(wasm.as_slice(), false).unwrap(); |
@@ -174,22 +175,6 @@ fn target_world_requires_io(target_world_imports: &HashSet<String>) -> bool { |
174 | 175 |
|
175 | 176 | const PREVIEW1: &str = "wasi_snapshot_preview1"; |
176 | 177 | fn stub_preview1(module: &mut Module) -> Result<()> { |
177 | | - stub_import(module, PREVIEW1, "environ_get", unreachable_stub)?; |
178 | | - stub_import(module, PREVIEW1, "environ_sizes_get", unreachable_stub)?; |
179 | | - stub_import(module, PREVIEW1, "fd_close", unreachable_stub)?; |
180 | | - stub_import(module, PREVIEW1, "fd_fdstat_set_flags", unreachable_stub)?; |
181 | | - stub_import(module, PREVIEW1, "fd_prestat_get", unreachable_stub)?; |
182 | | - stub_import(module, PREVIEW1, "fd_readdir", unreachable_stub)?; |
183 | | - stub_import(module, PREVIEW1, "args_get", unreachable_stub)?; |
184 | | - stub_import(module, PREVIEW1, "args_sizes_get", unreachable_stub)?; |
185 | | - stub_import(module, PREVIEW1, "path_filestat_get", unreachable_stub)?; |
186 | | - stub_import(module, PREVIEW1, "fd_prestat_dir_name", unreachable_stub)?; |
187 | | - stub_import(module, PREVIEW1, "fd_read", unreachable_stub)?; |
188 | | - stub_import(module, PREVIEW1, "fd_seek", unreachable_stub)?; |
189 | | - stub_import(module, PREVIEW1, "path_open", unreachable_stub)?; |
190 | | - stub_import(module, PREVIEW1, "path_remove_directory", unreachable_stub)?; |
191 | | - stub_import(module, PREVIEW1, "path_unlink_file", unreachable_stub)?; |
192 | | - stub_import(module, PREVIEW1, "proc_exit", unreachable_stub)?; |
193 | 178 | // random comes from prevew2 only in StarlingMonkey |
194 | 179 | stub_import(module, PREVIEW1, "random_get", unreachable_stub)?; |
195 | 180 | Ok(()) |
@@ -1478,6 +1463,18 @@ fn stub_filesystem(module: &mut Module, world_imports: &HashSet<String>) -> Resu |
1478 | 1463 | "[resource-drop]directory-entry-stream", |
1479 | 1464 | unreachable_stub, |
1480 | 1465 | )?; |
| 1466 | + |
| 1467 | + stub_import(module, PREVIEW1, "fd_close", unreachable_stub)?; |
| 1468 | + stub_import(module, PREVIEW1, "fd_fdstat_set_flags", unreachable_stub)?; |
| 1469 | + stub_import(module, PREVIEW1, "fd_prestat_get", unreachable_stub)?; |
| 1470 | + stub_import(module, PREVIEW1, "fd_readdir", unreachable_stub)?; |
| 1471 | + stub_import(module, PREVIEW1, "fd_prestat_dir_name", unreachable_stub)?; |
| 1472 | + stub_import(module, PREVIEW1, "fd_read", unreachable_stub)?; |
| 1473 | + stub_import(module, PREVIEW1, "fd_seek", unreachable_stub)?; |
| 1474 | + stub_import(module, PREVIEW1, "path_open", unreachable_stub)?; |
| 1475 | + stub_import(module, PREVIEW1, "path_filestat_get", unreachable_stub)?; |
| 1476 | + stub_import(module, PREVIEW1, "path_remove_directory", unreachable_stub)?; |
| 1477 | + stub_import(module, PREVIEW1, "path_unlink_file", unreachable_stub)?; |
1481 | 1478 | } |
1482 | 1479 |
|
1483 | 1480 | if !world_imports.contains("wasi:filesystem/preopens@0.2") { |
@@ -1513,10 +1510,16 @@ fn stub_cli(module: &mut Module, world_imports: &HashSet<String>) -> Result<()> |
1513 | 1510 | "initial-cwd", |
1514 | 1511 | unreachable_stub, |
1515 | 1512 | )?; |
| 1513 | + |
| 1514 | + stub_import(module, PREVIEW1, "args_get", unreachable_stub)?; |
| 1515 | + stub_import(module, PREVIEW1, "args_sizes_get", unreachable_stub)?; |
| 1516 | + stub_import(module, PREVIEW1, "environ_get", unreachable_stub)?; |
| 1517 | + stub_import(module, PREVIEW1, "environ_sizes_get", unreachable_stub)?; |
1516 | 1518 | } |
1517 | 1519 |
|
1518 | 1520 | if !world_imports.contains("wasi:cli/exit@0.2") { |
1519 | 1521 | stub_wasi_imports(module, "wasi:cli/exit", "exit", unreachable_stub)?; |
| 1522 | + stub_import(module, PREVIEW1, "proc_exit", unreachable_stub)?; |
1520 | 1523 | } |
1521 | 1524 |
|
1522 | 1525 | if !world_imports.contains("wasi:cli/terminal-stdin@0.2") { |
|
0 commit comments