Skip to content

Commit 19c3380

Browse files
committed
Ignore wizer subdirectory for now
prtest:full
1 parent 71f290b commit 19c3380

File tree

5 files changed

+63
-59
lines changed

5 files changed

+63
-59
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ members = [
172172
]
173173
exclude = [
174174
'docs/rust_wasi_markdown_parser',
175+
'crates/wizer',
175176
]
176177

177178
[workspace.package]
Lines changed: 0 additions & 1 deletion
This file was deleted.

crates/wizer/examples/cpp/main.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22
#include <wizer.h>
33

44
class Test {
5-
public:
6-
Test() : value(1) {
7-
printf(
8-
"global constructor (should be the first printed line)\n");
9-
}
10-
~Test() {
11-
printf("global destructor (should be the last printed line)\n");
12-
}
13-
int value;
5+
public:
6+
Test() : value(1) {
7+
printf("global constructor (should be the first printed line)\n");
8+
}
9+
~Test() { printf("global destructor (should be the last printed line)\n"); }
10+
int value;
1411
};
1512

1613
bool initialized = false;
1714
int orig_value = 0;
1815
Test t;
1916

2017
static void init_func() {
21-
// This should run after the ctor for `t`, and before `main`.
22-
orig_value = t.value;
23-
t.value = 2;
24-
initialized = true;
18+
// This should run after the ctor for `t`, and before `main`.
19+
orig_value = t.value;
20+
t.value = 2;
21+
initialized = true;
2522
}
2623

2724
WIZER_INIT(init_func);
2825

29-
int main(int argc, char** argv) {
30-
if (!initialized) init_func();
31-
printf("argc (should not be baked into snapshot): %d\n", argc);
32-
printf("orig_value (should be 1): %d\n", orig_value);
33-
printf("t.value (should be 2): %d\n", t.value);
26+
int main(int argc, char **argv) {
27+
if (!initialized)
28+
init_func();
29+
printf("argc (should not be baked into snapshot): %d\n", argc);
30+
printf("orig_value (should be 1): %d\n", orig_value);
31+
printf("t.value (should be 2): %d\n", t.value);
3432
}

crates/wizer/include/wizer.h

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
//
2424
// wasi-sdk-17 ships with clang-15.0.6
2525
// wasi-sdk-16 ships with clang-14.0.4
26-
#if __clang_major__ >= 15 || (__clang_major__ == 14 && __clang_patchlevel__ == 4)
26+
#if __clang_major__ >= 15 || \
27+
(__clang_major__ == 14 && __clang_patchlevel__ == 4)
2728
#define WIZER_MAIN_VOID __main_void
2829
#else
2930
#define WIZER_MAIN_VOID __original_main
@@ -82,42 +83,41 @@
8283
* should be run), use `WIZER_DEFAULT_INIT()` instead.
8384
*/
8485
#define WIZER_INIT(init_func) \
85-
__WIZER_EXTERN_C void __wasm_call_ctors(); \
86-
__WIZER_EXTERN_C void __wasm_call_dtors(); \
87-
__WIZER_EXTERN_C void __wasi_proc_exit(int); \
88-
__WIZER_EXTERN_C int WIZER_MAIN_VOID(); \
89-
/* This function's export name `wizer.initialize` is specially */ \
90-
/* recognized by Wizer. It is the direct entry point for pre-init. */ \
91-
__attribute__((export_name("wizer.initialize"))) void \
92-
__wizer_initialize() { \
93-
/* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \
94-
/* of the global constructors. It is safe (and in fact necessary) */ \
95-
/* to manually invoke it here because `wizer.initialize` is the */ \
96-
/* direct entry point, and no libc startup (crt1.o or equivalent) */ \
97-
/* is executed before this code does. */ \
98-
__wasm_call_ctors(); \
99-
/* We now invoke the provided init function before returning. */ \
100-
init_func(); \
86+
__WIZER_EXTERN_C void __wasm_call_ctors(); \
87+
__WIZER_EXTERN_C void __wasm_call_dtors(); \
88+
__WIZER_EXTERN_C void __wasi_proc_exit(int); \
89+
__WIZER_EXTERN_C int WIZER_MAIN_VOID(); \
90+
/* This function's export name `wizer.initialize` is specially */ \
91+
/* recognized by Wizer. It is the direct entry point for pre-init. */ \
92+
__attribute__((export_name("wizer.initialize"))) void __wizer_initialize() { \
93+
/* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \
94+
/* of the global constructors. It is safe (and in fact necessary) */ \
95+
/* to manually invoke it here because `wizer.initialize` is the */ \
96+
/* direct entry point, and no libc startup (crt1.o or equivalent) */ \
97+
/* is executed before this code does. */ \
98+
__wasm_call_ctors(); \
99+
/* We now invoke the provided init function before returning. */ \
100+
init_func(); \
101+
} \
102+
/* This function replaces `_start` (the WASI-specified entry point) in */ \
103+
/* the pre-initialized Wasm module. */ \
104+
__attribute__((export_name("wizer.resume"))) void __wizer_resume() { \
105+
/* `__main_void()` is defined by the WASI SDK toolchain due to */ \
106+
/* special semantics in C/C++ for the `main()` function, i.e., ito */ \
107+
/* can either take argc/argv or not. It collects arguments using */ \
108+
/* the appropriate WASI calls and then invokes the user program's */ \
109+
/* `main()`. This may change in the future; when it does, we will */ \
110+
/* coordinate with the WASI-SDK toolchain to implement this entry */ \
111+
/* point in an alternate way. */ \
112+
int r = WIZER_MAIN_VOID(); \
113+
/* Because we are replacing `_start()`, we need to manually invoke */ \
114+
/* destructors as well. */ \
115+
__wasm_call_dtors(); \
116+
/* If main returned non-zero code, call `__wasi_proc_exit`. */ \
117+
if (r != 0) { \
118+
__wasi_proc_exit(r); \
101119
} \
102-
/* This function replaces `_start` (the WASI-specified entry point) in */ \
103-
/* the pre-initialized Wasm module. */ \
104-
__attribute__((export_name("wizer.resume"))) void __wizer_resume() { \
105-
/* `__main_void()` is defined by the WASI SDK toolchain due to */ \
106-
/* special semantics in C/C++ for the `main()` function, i.e., ito */ \
107-
/* can either take argc/argv or not. It collects arguments using */ \
108-
/* the appropriate WASI calls and then invokes the user program's */ \
109-
/* `main()`. This may change in the future; when it does, we will */ \
110-
/* coordinate with the WASI-SDK toolchain to implement this entry */ \
111-
/* point in an alternate way. */ \
112-
int r = WIZER_MAIN_VOID(); \
113-
/* Because we are replacing `_start()`, we need to manually invoke */ \
114-
/* destructors as well. */ \
115-
__wasm_call_dtors(); \
116-
/* If main returned non-zero code, call `__wasi_proc_exit`. */ \
117-
if (r != 0) { \
118-
__wasi_proc_exit(r); \
119-
} \
120-
}
120+
}
121121

122122
/*
123123
* This macro is like `WIZER_INIT()`, but takes no initialization function.
@@ -126,8 +126,8 @@
126126
*
127127
* See documentation for `WIZER_INIT()` for more details and usage instructions.
128128
*/
129-
#define WIZER_DEFAULT_INIT() \
130-
static void __empty_init() {} \
131-
WIZER_INIT(__empty_init)
129+
#define WIZER_DEFAULT_INIT() \
130+
static void __empty_init() {} \
131+
WIZER_INIT(__empty_init)
132132

133-
#endif // _WIZER_H_
133+
#endif // _WIZER_H_

scripts/publish.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ fn run_cmd(cmd: &mut Command) {
244244
}
245245

246246
fn find_crates(dir: &Path, ws: &Workspace, dst: &mut Vec<Crate>) {
247+
// Temporary exclusion of Wizer to get reverted in #11805 with full Wizer
248+
// integration.
249+
if dir.ends_with("wizer") {
250+
return;
251+
}
252+
247253
if dir.join("Cargo.toml").exists() {
248254
let krate = read_crate(Some(ws), &dir.join("Cargo.toml"));
249255
if !krate.publish || CRATES_TO_PUBLISH.iter().any(|c| krate.name == *c) {

0 commit comments

Comments
 (0)