Skip to content

Commit e3eb782

Browse files
committed
Turn off UBSan and try to polyfill customSections on WASM
1 parent d3320b0 commit e3eb782

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

bin/compile.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
9595
if (platform === 'win32') make = make.replace('RPYDIR = ', 'RPYDIR = "' + rpydir + '"#')
9696
make = make.replace(/-lutil/g, '');
9797
make = make.replace(/--export-all-symbols/g, '--export-dynamic');
98-
make = make.replace('CC = ', 'CC = ' + emcc + (!use_wasm ? ' -s WASM=0 ' : ' ') + '-s ALLOW_MEMORY_GROWTH=1 -s \'EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]\' -s \'EXPORTED_RUNTIME_METHODS=["ccall", "wasmMemory"]\'' + (debug_flag ? ' -g3' : (source_flag ? ' -g4' : '')) + ' #');
98+
make = make.replace('CC = ', 'CC = ' + emcc + (!use_wasm ? ' -s WASM=0 ' : ' ') + '-fsanitize=undefined -s ALLOW_MEMORY_GROWTH=1 -s \'EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]\' -s \'EXPORTED_RUNTIME_METHODS=["ccall", "wasmMemory"]\'' + (debug_flag ? ' -g3' : (source_flag ? ' -g4' : '')) + ' #');
9999
make = make.replace('TARGET = ', 'TARGET = ' + file + '.js #');
100100
make = make.replace('DEFAULT_TARGET = ', 'DEFAULT_TARGET = ' + file + '.js #');
101101
fs.writeFileSync(makefile, make);
@@ -113,7 +113,7 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
113113
}
114114
}
115115
try {
116-
fs.appendFileSync(path.join(process.cwd(), file + '.js' ), '\n' + deserialize_rpython_json.toString() + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json, "get_dirname": function () {return __dirname;}};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;\n if (typeof global !== "undefined") rpyGlobalArg.node = global;');
116+
fs.appendFileSync(path.join(process.cwd(), file + '.js' ), '\n' + deserialize_rpython_json.toString() + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json, "get_dirname": function () {return __dirname;}};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;\n if (typeof global !== "undefined") rpyGlobalArg.node = global;\nif (!WebAssembly.Module.customSections) WebAssembly.Module.customSections = () => [];');
117117
if (source_flag) {
118118
var source_map = JSON.parse(require('fs').readFileSync(path.join(directory, file + '.wasm.map')));
119119
source_map.sources.forEach(function (filename, index) {
@@ -125,8 +125,10 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
125125
}
126126
if (process.argv.indexOf('--keep-temp') !== -1) process.exit();
127127
try {
128-
if (fs.rmSync) fs.rmSync(tempdir, {recursive: true});
129-
else fs.rmdirSync(tempdir, {recursive: true});
128+
if (!process.env.KEEP_TMP) {
129+
if (fs.rmSync) fs.rmSync(tempdir, {recursive: true});
130+
else fs.rmdirSync(tempdir, {recursive: true});
131+
}
130132
}
131133
catch (error) {
132134
child_process.execSync('rm -rf ' + tempdir);

typing/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def configure_object(object):
7676
loads += '\n' + indent + "self." + key + ' = ' + variable + '(' + "values.unsafe_get_item('" + key + "')" + ')'
7777
else: loads += '\n' + indent + "if values.unsafe_get_item('" + key + "').type != 'undefined': self." + key + ' = ' + "values.unsafe_get_item('" + key + "')" + adapt_object_to_field(field)
7878
loads += '\n' + indent + 'return self'
79-
print(loads)
8079
exec(loads, namespace)
8180
object.loads = namespace['loads']
8281

0 commit comments

Comments
 (0)