Commit 6a0a8e98 by Tianqi Chen Committed by GitHub

[WEB] update web runtime to latest emcc (#742)

parent 5f1816db
......@@ -29,8 +29,10 @@ INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -
CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
FRAMEWORKS =
OBJCFLAGS = -fno-objc-arc
EMCC_FLAGS= -s RESERVED_FUNCTION_POINTERS=2 -s NO_EXIT_RUNTIME=1 -s MAIN_MODULE=1 -DDMLC_LOG_STACK_TRACE=0\
-std=c++11 -Oz $(INCLUDE_FLAGS)
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
$(INCLUDE_FLAGS)
# llvm configuration
ifdef LLVM_CONFIG
......
......@@ -26,13 +26,16 @@ def create_js(output,
The compile string.
"""
cmd = [cc]
cmd += ["-s", "RESERVED_FUNCTION_POINTERS=2"]
cmd += ["-s", "NO_EXIT_RUNTIME=1"]
cmd += ["-Oz"]
cmd += ["-o", output]
if side_module:
if not side_module:
cmd += ["-s", "RESERVED_FUNCTION_POINTERS=2"]
cmd += ["-s", "NO_EXIT_RUNTIME=1"]
extra_methods = ['cwrap', 'getValue', 'setValue', 'addFunction']
cfg = "[" + (','.join("\'%s\'" % x for x in extra_methods)) + "]"
cmd += ["-s", "EXTRA_EXPORTED_RUNTIME_METHODS=" + cfg]
else:
cmd += ["-s", "SIDE_MODULE=1"]
cmd += ["-o", output]
objects = [objects] if isinstance(objects, str) else objects
with_runtime = False
for obj in objects:
......@@ -47,9 +50,8 @@ def create_js(output,
if options:
cmd += options
args = ' '.join(cmd)
proc = subprocess.Popen(
args, shell=True,
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
(out, _) = proc.communicate()
......
......@@ -493,7 +493,8 @@ var tvm_runtime = tvm_runtime || {};
}
var fptrInvokeCallback = null;
var fptrFreeCallback = null;
if (typeof Runtime !== "undefined") {
if (typeof Runtime !== "undefined" &&
typeof Runtime.addFunction !== "undefined") {
fptrInvokeCallback = Runtime.addFunction(invokeCallback);
fptrFreeCallback = Runtime.addFunction(freeCallback);
}
......@@ -513,7 +514,8 @@ var tvm_runtime = tvm_runtime || {};
*/
this.convertFunc = function(f) {
if (isPackedFunc(f)) return f;
CHECK(fptrInvokeCallback !== null, "Emscripten Runtime is not available");
CHECK(fptrInvokeCallback !== null,
"Emscripten Runtime addFunction is not available");
var fid;
if (freeFuncId.length != 0) {
fid = freeFuncId.pop();
......@@ -1086,7 +1088,11 @@ var tvm_runtime = tvm_runtime || {};
this.create = function(Module) {
var tvm = {};
tvm.Module = Module;
tvm.Runtime = Module.Runtime;
if (typeof Module.addFunction !== "undefined") {
tvm.Runtime = Module;
} else {
tvm.Runtime = Module.Runtime;
}
TVMRuntime.apply(tvm);
return tvm;
};
......
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