@@ -52,6 +52,10 @@ use wasmtime_debug::{emit_debugsections, read_debuginfo};
5252use wasmtime_environ:: { Compiler , Cranelift , ModuleEnvironment , Tunables } ;
5353use wasmtime_obj:: emit_module;
5454
55+ mod utils;
56+
57+ static LOG_FILENAME_PREFIX : & str = "wasm2obj.dbg." ;
58+
5559const USAGE : & str = "
5660Wasm to native object translation utility.
5761Takes a binary WebAssembly module into a native object file.
@@ -68,6 +72,7 @@ Options:
6872 --target <TARGET> build for the target triple; default is the host machine
6973 -g generate debug information
7074 --version print the Cranelift version
75+ -d, --debug enable debug output on stderr/stdout
7176" ;
7277
7378#[ derive( Deserialize , Debug , Clone ) ]
@@ -76,6 +81,7 @@ struct Args {
7681 arg_output : String ,
7782 arg_target : Option < String > ,
7883 flag_g : bool ,
84+ flag_debug : bool ,
7985}
8086
8187fn read_wasm_file ( path : PathBuf ) -> Result < Vec < u8 > , io:: Error > {
@@ -95,6 +101,12 @@ fn main() {
95101 } )
96102 . unwrap_or_else ( |e| e. exit ( ) ) ;
97103
104+ if args. flag_debug {
105+ pretty_env_logger:: init ( ) ;
106+ } else {
107+ utils:: init_file_per_thread_logger ( ) ;
108+ }
109+
98110 let path = Path :: new ( & args. arg_file ) ;
99111 match handle_module (
100112 path. to_path_buf ( ) ,
0 commit comments