Skip to content

Commit 4ce6507

Browse files
authored
chore: Update the version of wizer.h we use (#365)
1 parent d13f607 commit 4ce6507

File tree

1 file changed

+23
-2
lines changed
  • c-dependencies/js-compute-runtime

1 file changed

+23
-2
lines changed

c-dependencies/js-compute-runtime/wizer.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@
1515
#define __WIZER_EXTERN_C extern
1616
#endif
1717

18+
#ifdef __clang_major__
19+
// wasi-sdk-16 was the first wasi-sdk version that shipped with a version of
20+
// wasi-libc that did not include __original_main. However, wasi-sdk-15 shipped
21+
// with clang-14.0.0. To correctly identify the boundary where __original_main
22+
// no longer exists, we check for either clang-15+ or specifically clang-14.0.4.
23+
//
24+
// wasi-sdk-17 ships with clang-15.0.6
25+
// wasi-sdk-16 ships with clang-14.0.4
26+
#if __clang_major__ >= 15 || (__clang_major__ == 14 && __clang_patchlevel__ == 4)
27+
#define WIZER_MAIN_VOID __main_void
28+
#else
29+
#define WIZER_MAIN_VOID __original_main
30+
#endif
31+
#endif
32+
33+
// We default to assuming that the compiler is new enough to provide
34+
// __main_void.
35+
#ifndef WIZER_MAIN_VOID
36+
#define WIZER_MAIN_VOID __main_void
37+
#endif
38+
1839
/*
1940
* This macro inserts the exported functions necessary to allow Wizer to
2041
* pre-initialize a Wasm module.
@@ -63,7 +84,7 @@
6384
#define WIZER_INIT(init_func) \
6485
__WIZER_EXTERN_C void __wasm_call_ctors(); \
6586
__WIZER_EXTERN_C void __wasm_call_dtors(); \
66-
__WIZER_EXTERN_C int __main_void(); \
87+
__WIZER_EXTERN_C int WIZER_MAIN_VOID(); \
6788
/* This function's export name `wizer.initialize` is specially */ \
6889
/* recognized by Wizer. It is the direct entry point for pre-init. */ \
6990
__attribute__((export_name("wizer.initialize"))) void \
@@ -87,7 +108,7 @@
87108
/* `main()`. This may change in the future; when it does, we will */ \
88109
/* coordinate with the WASI-SDK toolchain to implement this entry */ \
89110
/* point in an alternate way. */ \
90-
__main_void(); \
111+
WIZER_MAIN_VOID(); \
91112
/* Because we are replacing `_start()`, we need to manually invoke */ \
92113
/* destructors as well. */ \
93114
__wasm_call_dtors(); \

0 commit comments

Comments
 (0)