Add command line option for custom cache directory

This commit is contained in:
Artur Jamro
2019-07-26 17:00:54 -07:00
committed by Dan Gohman
parent 7dc81cbbc0
commit 3c33fe63a1
4 changed files with 149 additions and 65 deletions

View File

@@ -63,7 +63,7 @@ The translation is dependent on the environment chosen.
The default is a dummy environment that produces placeholder values.
Usage:
wasm2obj [--target TARGET] [-cdg] [--enable-simd] <file> -o <output>
wasm2obj [--target TARGET] [-dg] [--cache | --cache-dir=<cache_dir>] [--enable-simd] <file> -o <output>
wasm2obj --help | --version
Options:
@@ -71,7 +71,9 @@ Options:
-h, --help print this help message
--target <TARGET> build for the target triple; default is the host machine
-g generate debug information
-c, --cache enable caching system
-c, --cache enable caching system, use default cache directory
--cache-dir=<cache_dir>
enable caching system, use specified cache directory
--enable-simd enable proposed SIMD instructions
--version print the Cranelift version
-d, --debug enable debug output on stderr/stdout
@@ -85,6 +87,7 @@ struct Args {
flag_g: bool,
flag_debug: bool,
flag_cache: bool,
flag_cache_dir: Option<String>,
flag_enable_simd: bool,
}
@@ -111,7 +114,10 @@ fn main() {
wasmtime::init_file_per_thread_logger("wasm2obj.dbg.");
}
cache_conf::init(args.flag_cache);
cache_conf::init(
args.flag_cache || args.flag_cache_dir.is_some(),
args.flag_cache_dir.as_ref(),
);
let path = Path::new(&args.arg_file);
match handle_module(

View File

@@ -61,14 +61,16 @@ including calling the start function if one is present. Additional functions
given with --invoke are then called.
Usage:
wasmtime [-ocdg] [--enable-simd] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-ocdg] [--enable-simd] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-dir=<cache_dir>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-dir=<cache_dir>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime --help | --version
Options:
--invoke=<fn> name of function to run
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system
-c, --cache enable caching system, use default cache directory
--cache-dir=<cache_dir>
enable caching system, use specified cache directory
-g generate debug information
-d, --debug enable debug output on stderr/stdout
--enable-simd enable proposed SIMD instructions
@@ -88,6 +90,7 @@ struct Args {
arg_arg: Vec<String>,
flag_optimize: bool,
flag_cache: bool,
flag_cache_dir: Option<String>,
flag_debug: bool,
flag_g: bool,
flag_enable_simd: bool,
@@ -211,7 +214,10 @@ fn rmain() -> Result<(), Error> {
wasmtime::init_file_per_thread_logger("wasmtime.dbg.");
}
cache_conf::init(args.flag_cache);
cache_conf::init(
args.flag_cache || args.flag_cache_dir.is_some(),
args.flag_cache_dir.as_ref(),
);
let isa_builder = cranelift_native::builder()
.map_err(|s| format_err!("host machine is not a supported target: {}", s))?;

View File

@@ -41,14 +41,16 @@ const USAGE: &str = "
Wast test runner.
Usage:
run_wast [-cdo] [--enable-simd] <file>...
run_wast [-do] [--enable-simd] [--cache | --cache-dir=<cache_dir>] <file>...
run_wast --help | --version
Options:
-h, --help print this help message
--version print the Cranelift version
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system
-c, --cache enable caching system, use default cache directory
--cache-dir=<cache_dir>
enable caching system, use specified cache directory
-d, --debug enable debug output on stderr/stdout
--enable-simd enable proposed SIMD instructions
";
@@ -60,6 +62,7 @@ struct Args {
flag_function: Option<String>,
flag_optimize: bool,
flag_cache: bool,
flag_cache_dir: Option<String>,
flag_enable_simd: bool,
}
@@ -79,7 +82,10 @@ fn main() {
wasmtime::init_file_per_thread_logger("cranelift.dbg.");
}
cache_conf::init(args.flag_cache);
cache_conf::init(
args.flag_cache || args.flag_cache_dir.is_some(),
args.flag_cache_dir.as_ref(),
);
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
panic!("host machine is not a supported target");