Commit 1ec95cd5 authored by Kirill Smelkov's avatar Kirill Smelkov

linking to libk_so works

wasm@deco:~/trydynlib$ node prog.js
prog!
libk.kfunc1 -> 12
parent 36f52cc1
......@@ -2,8 +2,8 @@
#define _DSO_H
// DSO_EXPORT marks a symbol as exported from currently-compiled DSO.
// XXX + attr(used) ? (emscripten does this)
#define DSO_EXPORT __attribute__((visibility("default")))
// NOTE attr(used) is important for emscripten - otherwise the symbol is not exported via Module
#define DSO_EXPORT __attribute__((used)) __attribute__((visibility("default")))
// XXX stub (__declspec(dllimport) on mingw)
#define DSO_IMPORT
......
......@@ -197,16 +197,23 @@ function runPostSets() {
// EMSCRIPTEN_END_FUNCS
return { establishStackSpace: establishStackSpace, runPostSets: runPostSets, setThrew: setThrew, stackAlloc: stackAlloc, stackRestore: stackRestore, stackSave: stackSave };
return { _kfunc1: _kfunc1, establishStackSpace: establishStackSpace, runPostSets: runPostSets, setThrew: setThrew, stackAlloc: stackAlloc, stackRestore: stackRestore, stackSave: stackSave };
})
// EMSCRIPTEN_END_ASM
(Module.asmGlobalArg, Module.asmLibraryArg, buffer);
var real__kfunc1 = asm["_kfunc1"]; asm["_kfunc1"] = function() {
assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
return real__kfunc1.apply(null, arguments);
};
var real_setThrew = asm["setThrew"]; asm["setThrew"] = function() {
assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
return real_setThrew.apply(null, arguments);
};
var _kfunc1 = Module["_kfunc1"] = asm["_kfunc1"];
var runPostSets = Module["runPostSets"] = asm["runPostSets"];
var setThrew = Module["setThrew"] = asm["setThrew"];
......
......@@ -325,7 +325,6 @@ var asm2wasmImports = { // special asm2wasm imports
var loadedDynamicLibraries = [];
function loadDynamicLibrary(lib) {
console.log("loading", lib)
var libModule;
var src = Module['read'](lib);
libModule = eval(src)(
......@@ -334,7 +333,6 @@ function loadDynamicLibrary(lib) {
);
// add symbols into global namespace TODO: weak linking etc.
for (var sym in libModule) {
console.log("symbol", sym)
if (!Module.hasOwnProperty(sym)) {
Module[sym] = libModule[sym];
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment