Cache config as a file
This commit is contained in:
@@ -50,7 +50,7 @@ use std::str;
|
||||
use std::str::FromStr;
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime_debug::{emit_debugsections, read_debuginfo};
|
||||
use wasmtime_environ::cache_conf;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::{
|
||||
Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo, Tunables, VMOffsets,
|
||||
};
|
||||
@@ -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] [-dg] [--cache] [--cache-dir=<cache_dir>] [--cache-compression-level=<compr_level>] [--enable-simd] <file> -o <output>
|
||||
wasm2obj [--target TARGET] [-dg] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--enable-simd] <file> -o <output>
|
||||
wasm2obj --help | --version
|
||||
|
||||
Options:
|
||||
@@ -71,11 +71,12 @@ 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, use default cache directory
|
||||
--cache-dir=<cache_dir>
|
||||
enable caching system, use specified cache directory
|
||||
--cache-compression-level=<compr_level>
|
||||
enable caching system, use custom compression level for new cache, values 1-21
|
||||
-c, --cache enable caching system, use default configuration
|
||||
--cache-config=<cache_config_file>
|
||||
enable caching system, use specified cache configuration
|
||||
--create-cache-config
|
||||
used with --cache or --cache-config, creates default configuration and writes it to the disk,
|
||||
will fail if specified file already exists (or default file if used with --cache)
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
--version print the Cranelift version
|
||||
-d, --debug enable debug output on stderr/stdout
|
||||
@@ -88,9 +89,9 @@ struct Args {
|
||||
arg_target: Option<String>,
|
||||
flag_g: bool,
|
||||
flag_debug: bool,
|
||||
flag_cache: bool,
|
||||
flag_cache_dir: Option<String>,
|
||||
flag_cache_compression_level: Option<i32>,
|
||||
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
|
||||
flag_cache_config_file: Option<String>,
|
||||
flag_create_cache_config: bool,
|
||||
flag_enable_simd: bool,
|
||||
}
|
||||
|
||||
@@ -117,14 +118,20 @@ fn main() {
|
||||
wasmtime::init_file_per_thread_logger("wasm2obj.dbg.");
|
||||
}
|
||||
|
||||
cache_conf::init(
|
||||
args.flag_cache
|
||||
|| args.flag_cache_dir.is_some()
|
||||
|| args.flag_cache_compression_level.is_some(),
|
||||
args.flag_cache_dir.as_ref(),
|
||||
args.flag_cache_compression_level,
|
||||
let errors = cache_config::init(
|
||||
args.flag_cache || args.flag_cache_config_file.is_some(),
|
||||
args.flag_cache_config_file.as_ref(),
|
||||
args.flag_create_cache_config,
|
||||
);
|
||||
|
||||
if !errors.is_empty() {
|
||||
eprintln!("Cache initialization failed. Errors:");
|
||||
for e in errors {
|
||||
eprintln!("-> {}", e);
|
||||
}
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let path = Path::new(&args.arg_file);
|
||||
match handle_module(
|
||||
path.to_path_buf(),
|
||||
|
||||
@@ -47,7 +47,7 @@ use std::rc::Rc;
|
||||
use wabt;
|
||||
use wasi_common::preopen_dir;
|
||||
use wasmtime_api::{Config, Engine, Instance, Module, Store};
|
||||
use wasmtime_environ::cache_conf;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_interface_types::ModuleData;
|
||||
use wasmtime_jit::Features;
|
||||
use wasmtime_wasi::instantiate_wasi;
|
||||
@@ -64,18 +64,19 @@ including calling the start function if one is present. Additional functions
|
||||
given with --invoke are then called.
|
||||
|
||||
Usage:
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache] [--cache-dir=<cache_dir>] [--cache-compression-level=<compr_level>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache] [--cache-dir=<cache_dir>] [--cache-compression-level=<compr_level>] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
|
||||
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--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, use default cache directory
|
||||
--cache-dir=<cache_dir>
|
||||
enable caching system, use specified cache directory
|
||||
--cache-compression-level=<compr_level>
|
||||
enable caching system, use custom compression level for new cache, values 1-21
|
||||
-c, --cache enable caching system, use default configuration
|
||||
--cache-config=<cache_config_file>
|
||||
enable caching system, use specified cache configuration
|
||||
--create-cache-config
|
||||
used with --cache or --cache-config, creates default configuration and writes it to the disk,
|
||||
will fail if specified file already exists (or default file if used with --cache)
|
||||
-g generate debug information
|
||||
-d, --debug enable debug output on stderr/stdout
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
@@ -94,9 +95,9 @@ struct Args {
|
||||
arg_file: String,
|
||||
arg_arg: Vec<String>,
|
||||
flag_optimize: bool,
|
||||
flag_cache: bool,
|
||||
flag_cache_dir: Option<String>,
|
||||
flag_cache_compression_level: Option<i32>,
|
||||
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
|
||||
flag_cache_config_file: Option<String>,
|
||||
flag_create_cache_config: bool,
|
||||
flag_debug: bool,
|
||||
flag_g: bool,
|
||||
flag_enable_simd: bool,
|
||||
@@ -201,7 +202,7 @@ fn main() {
|
||||
for cause in err.iter_causes() {
|
||||
eprintln!(" caused by: {}", cause);
|
||||
}
|
||||
std::process::exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fn rmain() -> Result<(), Error> {
|
||||
@@ -220,14 +221,20 @@ fn rmain() -> Result<(), Error> {
|
||||
wasmtime::init_file_per_thread_logger("wasmtime.dbg.");
|
||||
}
|
||||
|
||||
cache_conf::init(
|
||||
args.flag_cache
|
||||
|| args.flag_cache_dir.is_some()
|
||||
|| args.flag_cache_compression_level.is_some(),
|
||||
args.flag_cache_dir.as_ref(),
|
||||
args.flag_cache_compression_level,
|
||||
let errors = cache_config::init(
|
||||
args.flag_cache || args.flag_cache_config_file.is_some(),
|
||||
args.flag_cache_config_file.as_ref(),
|
||||
args.flag_create_cache_config,
|
||||
);
|
||||
|
||||
if !errors.is_empty() {
|
||||
eprintln!("Cache initialization failed. Errors:");
|
||||
for e in errors {
|
||||
eprintln!("-> {}", e);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let mut flag_builder = settings::builder();
|
||||
let mut features: Features = Default::default();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use pretty_env_logger;
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use wasmtime_environ::cache_conf;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_jit::{Compiler, Features};
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
@@ -41,18 +41,19 @@ const USAGE: &str = "
|
||||
Wast test runner.
|
||||
|
||||
Usage:
|
||||
wast [-do] [--enable-simd] [--cache] [--cache-dir=<cache_dir>] [--cache-compression-level=<compr_level>] <file>...
|
||||
wast [-do] [--enable-simd] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] <file>...
|
||||
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, use default cache directory
|
||||
--cache-dir=<cache_dir>
|
||||
enable caching system, use specified cache directory
|
||||
--cache-compression-level=<compr_level>
|
||||
enable caching system, use custom compression level for new cache, values 1-21
|
||||
-c, --cache enable caching system, use default configuration
|
||||
--cache-config=<cache_config_file>
|
||||
enable caching system, use specified cache configuration
|
||||
--create-cache-config
|
||||
used with --cache or --cache-config, creates default configuration and writes it to the disk,
|
||||
will fail if specified file already exists (or default file if used with --cache)
|
||||
-d, --debug enable debug output on stderr/stdout
|
||||
--enable-simd enable proposed SIMD instructions
|
||||
";
|
||||
@@ -63,9 +64,9 @@ struct Args {
|
||||
flag_debug: bool,
|
||||
flag_function: Option<String>,
|
||||
flag_optimize: bool,
|
||||
flag_cache: bool,
|
||||
flag_cache_dir: Option<String>,
|
||||
flag_cache_compression_level: Option<i32>,
|
||||
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
|
||||
flag_cache_config_file: Option<String>,
|
||||
flag_create_cache_config: bool,
|
||||
flag_enable_simd: bool,
|
||||
}
|
||||
|
||||
@@ -85,14 +86,20 @@ fn main() {
|
||||
wasmtime::init_file_per_thread_logger("cranelift.dbg.");
|
||||
}
|
||||
|
||||
cache_conf::init(
|
||||
args.flag_cache
|
||||
|| args.flag_cache_dir.is_some()
|
||||
|| args.flag_cache_compression_level.is_some(),
|
||||
args.flag_cache_dir.as_ref(),
|
||||
args.flag_cache_compression_level,
|
||||
let errors = cache_config::init(
|
||||
args.flag_cache || args.flag_cache_config_file.is_some(),
|
||||
args.flag_cache_config_file.as_ref(),
|
||||
args.flag_create_cache_config,
|
||||
);
|
||||
|
||||
if !errors.is_empty() {
|
||||
eprintln!("Cache initialization failed. Errors:");
|
||||
for e in errors {
|
||||
eprintln!("-> {}", e);
|
||||
}
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let isa_builder = cranelift_native::builder().unwrap_or_else(|_| {
|
||||
panic!("host machine is not a supported target");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user