wasm_interp: Use String for CLI args. It was crashing with OsString.

This commit is contained in:
Brian Carroll 2022-12-16 16:03:23 +00:00
parent b938648dad
commit 66aaa7c73c
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0

View file

@ -1,11 +1,9 @@
use bumpalo::{collections::Vec, Bump}; use bumpalo::{collections::Vec, Bump};
use clap::ArgAction; use clap::ArgAction;
use clap::{Arg, Command}; use clap::{Arg, Command};
use std::ffi::OsString;
use std::fs; use std::fs;
use std::io; use std::io;
use std::iter::once; use std::iter::once;
use std::os::unix::prelude::OsStrExt;
use std::process; use std::process;
use roc_wasm_interp::{DefaultImportDispatcher, Instance}; use roc_wasm_interp::{DefaultImportDispatcher, Instance};
@ -64,10 +62,8 @@ fn main() -> io::Result<()> {
let start_fn_name = matches.get_one::<String>(FLAG_FUNCTION).unwrap(); let start_fn_name = matches.get_one::<String>(FLAG_FUNCTION).unwrap();
let is_debug_mode = matches.get_flag(FLAG_DEBUG); let is_debug_mode = matches.get_flag(FLAG_DEBUG);
let is_hex_format = matches.get_flag(FLAG_HEX); let is_hex_format = matches.get_flag(FLAG_HEX);
let start_arg_strings = matches let start_arg_strings = matches.get_many::<String>(ARGS_FOR_APP).unwrap_or_default();
.get_many::<OsString>(ARGS_FOR_APP) let wasm_path = matches.get_one::<String>(WASM_FILE).unwrap();
.unwrap_or_default();
let wasm_path = matches.get_one::<OsString>(WASM_FILE).unwrap();
// WASI expects the .wasm file to be argv[0] // WASI expects the .wasm file to be argv[0]
let wasi_argv_iter = once(wasm_path) let wasi_argv_iter = once(wasm_path)
.chain(start_arg_strings) .chain(start_arg_strings)