Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions src/wasm2obj.rs → src/bin/wasm2obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/wasmtime.rs → src/bin/wasmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/wast.rs → src/bin/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions src/utils.rs → src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
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());
}
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(())
Expand Down