A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Ignore wizer subdirectory for now
Alex Crichton19c3380b988d
diff --git a/Cargo.toml b/Cargo.tomlindex 4dddc77a35..9129c25296 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -172,6 +172,7 @@ members = []exclude = ['docs/rust_wasi_markdown_parser',+ 'crates/wizer',][workspace.package]diff --git a/crates/wizer/benches/uap-bench/uap-core b/crates/wizer/benches/uap-bench/uap-coredeleted file mode 160000index f21592418f..0000000000--- a/crates/wizer/benches/uap-bench/uap-core+++ /dev/null@@ -1 +0,0 @@-Subproject commit f21592418f6323f9ce32f10e231841cf8e782b43diff --git a/crates/wizer/examples/cpp/main.cpp b/crates/wizer/examples/cpp/main.cppindex 6bf2757131..86d1c00072 100644--- a/crates/wizer/examples/cpp/main.cpp+++ b/crates/wizer/examples/cpp/main.cpp@@ -2,15 +2,12 @@#include <wizer.h>class Test {- public:- Test() : value(1) {- printf(- "global constructor (should be the first printed line)\n");- }- ~Test() {- printf("global destructor (should be the last printed line)\n");- }- int value;+public:+ Test() : value(1) {+ printf("global constructor (should be the first printed line)\n");+ }+ ~Test() { printf("global destructor (should be the last printed line)\n"); }+ int value;};bool initialized = false;@@ -18,17 +15,18 @@ int orig_value = 0;Test t;static void init_func() {- // This should run after the ctor for `t`, and before `main`.- orig_value = t.value;- t.value = 2;- initialized = true;+ // This should run after the ctor for `t`, and before `main`.+ orig_value = t.value;+ t.value = 2;+ initialized = true;}WIZER_INIT(init_func);-int main(int argc, char** argv) {- if (!initialized) init_func();- printf("argc (should not be baked into snapshot): %d\n", argc);- printf("orig_value (should be 1): %d\n", orig_value);- printf("t.value (should be 2): %d\n", t.value);+int main(int argc, char **argv) {+ if (!initialized)+ init_func();+ printf("argc (should not be baked into snapshot): %d\n", argc);+ printf("orig_value (should be 1): %d\n", orig_value);+ printf("t.value (should be 2): %d\n", t.value);}diff --git a/crates/wizer/include/wizer.h b/crates/wizer/include/wizer.hindex 5492c0ec37..b138a5e27b 100644--- a/crates/wizer/include/wizer.h+++ b/crates/wizer/include/wizer.h@@ -23,7 +23,8 @@//// wasi-sdk-17 ships with clang-15.0.6// wasi-sdk-16 ships with clang-14.0.4-#if __clang_major__ >= 15 || (__clang_major__ == 14 && __clang_patchlevel__ == 4)+#if __clang_major__ >= 15 || \+ (__clang_major__ == 14 && __clang_patchlevel__ == 4)#define WIZER_MAIN_VOID __main_void#else#define WIZER_MAIN_VOID __original_main@@ -82,42 +83,41 @@* should be run), use `WIZER_DEFAULT_INIT()` instead.*/#define WIZER_INIT(init_func) \- __WIZER_EXTERN_C void __wasm_call_ctors(); \- __WIZER_EXTERN_C void __wasm_call_dtors(); \- __WIZER_EXTERN_C void __wasi_proc_exit(int); \- __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \- /* This function's export name `wizer.initialize` is specially */ \- /* recognized by Wizer. It is the direct entry point for pre-init. */ \- __attribute__((export_name("wizer.initialize"))) void \- __wizer_initialize() { \- /* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \- /* of the global constructors. It is safe (and in fact necessary) */ \- /* to manually invoke it here because `wizer.initialize` is the */ \- /* direct entry point, and no libc startup (crt1.o or equivalent) */ \- /* is executed before this code does. */ \- __wasm_call_ctors(); \- /* We now invoke the provided init function before returning. */ \- init_func(); \+ __WIZER_EXTERN_C void __wasm_call_ctors(); \+ __WIZER_EXTERN_C void __wasm_call_dtors(); \+ __WIZER_EXTERN_C void __wasi_proc_exit(int); \+ __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \+ /* This function's export name `wizer.initialize` is specially */ \+ /* recognized by Wizer. It is the direct entry point for pre-init. */ \+ __attribute__((export_name("wizer.initialize"))) void __wizer_initialize() { \+ /* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \+ /* of the global constructors. It is safe (and in fact necessary) */ \+ /* to manually invoke it here because `wizer.initialize` is the */ \+ /* direct entry point, and no libc startup (crt1.o or equivalent) */ \+ /* is executed before this code does. */ \+ __wasm_call_ctors(); \+ /* We now invoke the provided init function before returning. */ \+ init_func(); \+ } \+ /* This function replaces `_start` (the WASI-specified entry point) in */ \+ /* the pre-initialized Wasm module. */ \+ __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \+ /* `__main_void()` is defined by the WASI SDK toolchain due to */ \+ /* special semantics in C/C++ for the `main()` function, i.e., ito */ \+ /* can either take argc/argv or not. It collects arguments using */ \+ /* the appropriate WASI calls and then invokes the user program's */ \+ /* `main()`. This may change in the future; when it does, we will */ \+ /* coordinate with the WASI-SDK toolchain to implement this entry */ \+ /* point in an alternate way. */ \+ int r = WIZER_MAIN_VOID(); \+ /* Because we are replacing `_start()`, we need to manually invoke */ \+ /* destructors as well. */ \+ __wasm_call_dtors(); \+ /* If main returned non-zero code, call `__wasi_proc_exit`. */ \+ if (r != 0) { \+ __wasi_proc_exit(r); \} \- /* This function replaces `_start` (the WASI-specified entry point) in */ \- /* the pre-initialized Wasm module. */ \- __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \- /* `__main_void()` is defined by the WASI SDK toolchain due to */ \- /* special semantics in C/C++ for the `main()` function, i.e., ito */ \- /* can either take argc/argv or not. It collects arguments using */ \- /* the appropriate WASI calls and then invokes the user program's */ \- /* `main()`. This may change in the future; when it does, we will */ \- /* coordinate with the WASI-SDK toolchain to implement this entry */ \- /* point in an alternate way. */ \- int r = WIZER_MAIN_VOID(); \- /* Because we are replacing `_start()`, we need to manually invoke */ \- /* destructors as well. */ \- __wasm_call_dtors(); \- /* If main returned non-zero code, call `__wasi_proc_exit`. */ \- if (r != 0) { \- __wasi_proc_exit(r); \- } \- }+ }/** This macro is like `WIZER_INIT()`, but takes no initialization function.@@ -126,8 +126,8 @@** See documentation for `WIZER_INIT()` for more details and usage instructions.*/-#define WIZER_DEFAULT_INIT() \- static void __empty_init() {} \- WIZER_INIT(__empty_init)+#define WIZER_DEFAULT_INIT() \+ static void __empty_init() {} \+ WIZER_INIT(__empty_init)-#endif // _WIZER_H_+#endif // _WIZER_H_diff --git a/scripts/publish.rs b/scripts/publish.rsindex c9f8feea64..0d410336a6 100644--- a/scripts/publish.rs+++ b/scripts/publish.rs@@ -244,6 +244,12 @@ fn run_cmd(cmd: &mut Command) {}fn find_crates(dir: &Path, ws: &Workspace, dst: &mut Vec<Crate>) {+ // Temporary exclusion of Wizer to get reverted in #11805 with full Wizer+ // integration.+ if dir.ends_with("wizer") {+ return;+ }+if dir.join("Cargo.toml").exists() {let krate = read_crate(Some(ws), &dir.join("Cargo.toml"));if !krate.publish || CRATES_TO_PUBLISH.iter().any(|c| krate.name == *c) {