Migrate most of wasmtime from lazy_static to once_cell (#4368)

* Update tracing-core to a version which doesn't depend on lazy-static.

* Update crossbeam-utils to a version that doesn't depend on lazy-static.

* Update crossbeam-epoch to a version that doesn't depend on lazy-static.

* Update clap to a version that doesn't depend on lazy-static.

* Convert Wasmtime's own use of lazy_static to once_cell.

* Make `GDB_REGISTRATION`'s comment a doc comment.

* Fix compilation on Windows.
This commit is contained in:
Dan Gohman
2022-07-05 10:52:48 -07:00
committed by GitHub
parent d9e0e6a6a9
commit 371ae80ac3
25 changed files with 123 additions and 138 deletions

View File

@@ -2,36 +2,35 @@
use anyhow::{bail, Context, Result};
use clap::Parser;
use once_cell::sync::Lazy;
use std::fs;
use std::path::PathBuf;
use target_lexicon::Triple;
use wasmtime::Engine;
use wasmtime_cli_flags::CommonOptions;
lazy_static::lazy_static! {
static ref AFTER_HELP: String = {
format!(
"By default, no CPU features or presets will be enabled for the compilation.\n\
\n\
{}\
\n\
Usage examples:\n\
\n\
Compiling a WebAssembly module for the current platform:\n\
\n \
wasmtime compile example.wasm
\n\
Specifying the output file:\n\
\n \
wasmtime compile -o output.cwasm input.wasm\n\
\n\
Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\
\n \
wasmtime compile --target x86_64-unknown-linux --cranelift-enable skylake foo.wasm\n",
crate::FLAG_EXPLANATIONS.as_str()
)
};
}
static AFTER_HELP: Lazy<String> = Lazy::new(|| {
format!(
"By default, no CPU features or presets will be enabled for the compilation.\n\
\n\
{}\
\n\
Usage examples:\n\
\n\
Compiling a WebAssembly module for the current platform:\n\
\n \
wasmtime compile example.wasm
\n\
Specifying the output file:\n\
\n \
wasmtime compile -o output.cwasm input.wasm\n\
\n\
Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\
\n \
wasmtime compile --target x86_64-unknown-linux --cranelift-enable skylake foo.wasm\n",
crate::FLAG_EXPLANATIONS.as_str()
)
});
/// Compiles a WebAssembly module.
#[derive(Parser)]

View File

@@ -2,6 +2,7 @@
use anyhow::{anyhow, bail, Context as _, Result};
use clap::Parser;
use once_cell::sync::Lazy;
use std::fs::File;
use std::io::Read;
use std::thread;
@@ -65,11 +66,7 @@ fn parse_preloads(s: &str) -> Result<(String, PathBuf)> {
Ok((parts[0].into(), parts[1].into()))
}
lazy_static::lazy_static! {
static ref AFTER_HELP: String = {
crate::FLAG_EXPLANATIONS.to_string()
};
}
static AFTER_HELP: Lazy<String> = Lazy::new(|| crate::FLAG_EXPLANATIONS.to_string());
/// Runs a WebAssembly module
#[derive(Parser)]

View File

@@ -2,16 +2,13 @@
use anyhow::{Context as _, Result};
use clap::Parser;
use once_cell::sync::Lazy;
use std::path::PathBuf;
use wasmtime::{Engine, Store};
use wasmtime_cli_flags::CommonOptions;
use wasmtime_wast::WastContext;
lazy_static::lazy_static! {
static ref AFTER_HELP: String = {
crate::FLAG_EXPLANATIONS.to_string()
};
}
static AFTER_HELP: Lazy<String> = Lazy::new(|| crate::FLAG_EXPLANATIONS.to_string());
/// Runs a WebAssembly test script file
#[derive(Parser)]