Skip to content

Commit 68ecfae

Browse files
committed
fix: remove shell: for linker opts
1 parent 988f52a commit 68ecfae

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ if(ZMQ_WASM OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
9292
add_link_options("--export-table")
9393

9494
# Add WebAssembly-specific exports for napi-wasm
95-
add_link_options("SHELL:-s EXPORTED_FUNCTIONS=['_malloc','_free','napi_wasm_malloc','napi_register_module_v1']")
96-
add_link_options("SHELL:-s EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
97-
add_link_options("SHELL:-s ALLOW_MEMORY_GROWTH=1")
98-
add_link_options("SHELL:-s MODULARIZE=1")
99-
add_link_options("SHELL:-s EXPORT_NAME='createModule'")
100-
add_link_options("SHELL:-s ENVIRONMENT='web,worker'")
95+
add_link_options("-s EXPORTED_FUNCTIONS=['_malloc','_free','napi_wasm_malloc','napi_register_module_v1']")
96+
add_link_options("-s EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
97+
add_link_options("-s ALLOW_MEMORY_GROWTH=1")
98+
add_link_options("-s MODULARIZE=1")
99+
add_link_options("-s EXPORT_NAME='createModule'")
100+
add_link_options("-s ENVIRONMENT='web,worker'")
101101
add_link_options("--no-entry")
102-
add_link_options("SHELL:-Wl,--strip-all")
102+
add_link_options("-Wl,--strip-all")
103103

104104
# Allow undefined symbols on Linux for runtime loading
105-
add_link_options("SHELL:-Wl,--unresolved-symbols=ignore-all")
105+
add_link_options("-Wl,--unresolved-symbols=ignore-all")
106106
endif()
107107

108108
# Set MacOS deployment target

browser/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import {Environment, napi} from "napi-wasm"
22

33
async function main() {
4-
const response = await fetch("./addon.wasm")
5-
const bytes = await response.arrayBuffer()
64
const {instance} = await WebAssembly.instantiate(
7-
bytes,
5+
fetch("./addon.wasm"),
86
{
97
env: napi,
10-
},
8+
}
119
)
1210

1311
// Create an environment.

src/wasm.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
#include <cstdint>
44
#include <cstdlib>
55

6-
extern "C" uint8_t* napi_wasm_malloc(size_t size) {
6+
// export visibility
7+
#define EXPORT_VISIBILITY __attribute__((visibility("default")))
8+
9+
extern "C" EXPORT_VISIBILITY uint8_t* napi_wasm_malloc(size_t size) {
710
const size_t align = alignof(size_t);
811

912
if (size > 0) {

0 commit comments

Comments
 (0)