diff --git a/Cargo.toml b/Cargo.toml index da24490125..86375aeef8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,18 +9,6 @@ categories = ["wasm"] repository = "https://github.com/CraneStation/wasmtime" edition = "2018" -[[bin]] -name = "wasmtime" -path = "src/wasmtime.rs" - -[[bin]] -name = "wast" -path = "src/wast.rs" - -[[bin]] -name = "wasm2obj" -path = "src/wasm2obj.rs" - [dependencies] cranelift-codegen = { version = "0.38.0", features = ["enable-serde"] } cranelift-native = "0.38.0" diff --git a/src/wasm2obj.rs b/src/bin/wasm2obj.rs similarity index 98% rename from src/wasm2obj.rs rename to src/bin/wasm2obj.rs index 5958077e3b..cf767d5e17 100644 --- a/src/wasm2obj.rs +++ b/src/bin/wasm2obj.rs @@ -56,10 +56,6 @@ use wasmtime_environ::{ }; use wasmtime_obj::emit_module; -mod utils; - -static LOG_FILENAME_PREFIX: &str = "wasm2obj.dbg."; - const USAGE: &str = " Wasm to native object translation utility. Takes a binary WebAssembly module into a native object file. @@ -112,7 +108,7 @@ fn main() { if args.flag_debug { pretty_env_logger::init(); } else { - utils::init_file_per_thread_logger(); + wasmtime::init_file_per_thread_logger("wasm2obj.dbg."); } cache_conf::init(args.flag_cache); diff --git a/src/wasmtime.rs b/src/bin/wasmtime.rs similarity index 98% rename from src/wasmtime.rs rename to src/bin/wasmtime.rs index 3591697927..7ff144c04d 100644 --- a/src/wasmtime.rs +++ b/src/bin/wasmtime.rs @@ -54,10 +54,6 @@ use wasmtime_wast::instantiate_spectest; #[cfg(feature = "wasi-c")] use wasmtime_wasi_c::instantiate_wasi_c; -mod utils; - -static LOG_FILENAME_PREFIX: &str = "wasmtime.dbg."; - const USAGE: &str = " Wasm runner. @@ -207,7 +203,7 @@ fn main() { if args.flag_debug { pretty_env_logger::init(); } else { - utils::init_file_per_thread_logger(); + wasmtime::init_file_per_thread_logger("wasmtime.dbg."); } cache_conf::init(args.flag_cache); diff --git a/src/wast.rs b/src/bin/wast.rs similarity index 96% rename from src/wast.rs rename to src/bin/wast.rs index 49d2ae2b98..cb1bc56951 100644 --- a/src/wast.rs +++ b/src/bin/wast.rs @@ -37,10 +37,6 @@ use wasmtime_environ::cache_conf; use wasmtime_jit::{Compiler, Features}; use wasmtime_wast::WastContext; -mod utils; - -static LOG_FILENAME_PREFIX: &str = "cranelift.dbg."; - const USAGE: &str = " Wast test runner. @@ -80,7 +76,7 @@ fn main() { if args.flag_debug { pretty_env_logger::init(); } else { - utils::init_file_per_thread_logger(); + wasmtime::init_file_per_thread_logger("cranelift.dbg."); } cache_conf::init(args.flag_cache); diff --git a/src/utils.rs b/src/lib.rs similarity index 71% rename from src/utils.rs rename to src/lib.rs index b6804d27e1..aa6546c1c9 100644 --- a/src/utils.rs +++ b/src/lib.rs @@ -1,14 +1,12 @@ -pub fn init_file_per_thread_logger() { - use super::LOG_FILENAME_PREFIX; - - file_per_thread_logger::initialize(LOG_FILENAME_PREFIX); +pub fn init_file_per_thread_logger(prefix: &'static str) { + file_per_thread_logger::initialize(prefix); // Extending behavior of default spawner: // https://docs.rs/rayon/1.1.0/rayon/struct.ThreadPoolBuilder.html#method.spawn_handler // Source code says DefaultSpawner is implementation detail and // shouldn't be used directly. rayon::ThreadPoolBuilder::new() - .spawn_handler(|thread| { + .spawn_handler(move |thread| { let mut b = std::thread::Builder::new(); if let Some(name) = thread.name() { b = b.name(name.to_owned()); @@ -16,8 +14,8 @@ pub fn init_file_per_thread_logger() { if let Some(stack_size) = thread.stack_size() { b = b.stack_size(stack_size); } - b.spawn(|| { - file_per_thread_logger::initialize(LOG_FILENAME_PREFIX); + b.spawn(move || { + file_per_thread_logger::initialize(prefix); thread.run() })?; Ok(())