Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
libcxx_noexcept
libcxxabi
gl
struct_info
native_optimizer
bullet
freetype
Expand Down Expand Up @@ -80,7 +79,7 @@ def build_port(port_name, lib_name, params):
if operation == 'build':
tasks = sys.argv[2:]
if 'ALL' in tasks:
tasks = ['libc', 'libc-mt', 'dlmalloc', 'dlmalloc_threadsafe', 'pthreads', 'libcxx', 'libcxx_noexcept', 'libcxxabi', 'gl', 'struct_info', 'bullet', 'freetype', 'libpng', 'ogg', 'sdl2', 'sdl2-image', 'vorbis', 'zlib']
tasks = ['libc', 'libc-mt', 'dlmalloc', 'dlmalloc_threadsafe', 'pthreads', 'libcxx', 'libcxx_noexcept', 'libcxxabi', 'gl', 'bullet', 'freetype', 'libpng', 'ogg', 'sdl2', 'sdl2-image', 'vorbis', 'zlib']
if os.environ.get('EMSCRIPTEN_NATIVE_OPTIMIZER'):
print 'Skipping building of native-optimizer since environment variable EMSCRIPTEN_NATIVE_OPTIMIZER is present and set to point to a prebuilt native optimizer path.'
elif hasattr(shared, 'EMSCRIPTEN_NATIVE_OPTIMIZER'):
Expand Down Expand Up @@ -138,10 +137,6 @@ def build_port(port_name, lib_name, params):
return int(emscripten_GetProcAddress("waka waka"));
}
''', ['gl.bc'])
elif what == 'struct_info':
build('''
int main() {}
''', ['struct_info.compiled.json'])
elif what == 'native_optimizer':
build('''
int main() {}
Expand Down
2 changes: 1 addition & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ def main(args, compiler_engine, cache, temp_files, DEBUG, DEBUG_CACHE):
# libraries
libraries = args.libraries[0].split(',') if len(args.libraries) > 0 else []

settings.setdefault('STRUCT_INFO', cache.get_path('struct_info.compiled.json'))
settings.setdefault('STRUCT_INFO', shared.path_from_root('src', 'struct_info.compiled.json'))
struct_info = settings.get('STRUCT_INFO')

if not os.path.exists(struct_info) and not settings.get('BOOTSTRAPPING_STRUCT_INFO'):
Expand Down
2 changes: 1 addition & 1 deletion src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ mergeInto(LibraryManager.library, {
// persistence
//
indexedDB: function() {
return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
return Module.indexedDB;
},

DB_NAME: function() {
Expand Down
6 changes: 1 addition & 5 deletions src/library_idbfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ mergeInto(LibraryManager.library, {
$IDBFS: {
dbs: {},
indexedDB: function() {
if (typeof indexedDB !== 'undefined') return indexedDB;
var ret = null;
if (typeof window === 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
assert(ret, 'IDBFS used, but indexedDB not supported');
return ret;
return Module.indexedDB;
},
DB_VERSION: 21,
DB_STORE_NAME: 'FILE_DATA',
Expand Down
1 change: 1 addition & 0 deletions src/struct_info.compiled.json

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ def test_embuilder(self):
([PYTHON, 'embuilder.py', 'build', 'libcxx_noexcept'], ['success'], True, ['libcxx_noexcept.a']),
([PYTHON, 'embuilder.py', 'build', 'libcxxabi'], ['success'], True, ['libcxxabi.bc']),
([PYTHON, 'embuilder.py', 'build', 'gl'], ['success'], True, ['gl.bc']),
([PYTHON, 'embuilder.py', 'build', 'struct_info'], ['success'], True, ['struct_info.compiled.json']),
([PYTHON, 'embuilder.py', 'build', 'native_optimizer'], ['success'], True, ['optimizer.2.exe']),
([PYTHON, 'embuilder.py', 'build', 'zlib'], ['building and verifying zlib', 'success'], True, [os.path.join('ports-builds', 'zlib', 'libz.a')]),
([PYTHON, 'embuilder.py', 'build', 'libpng'], ['building and verifying libpng', 'success'], True, [os.path.join('ports-builds', 'libpng', 'libpng.bc')]),
Expand Down Expand Up @@ -794,11 +793,23 @@ def test():
test()

try:
print 'wacky env vars, these should not mess our bootstrapping of struct_info etc. up'
print 'wacky env vars, these should not mess our bootstrapping'
os.environ['EMCC_FORCE_STDLIBS'] = '1'
Cache.erase()
build()
test()
finally:
del os.environ['EMCC_FORCE_STDLIBS']

def test_struct_info(self):
restore()

struct_info_file = path_from_root('src', 'struct_info.compiled.json')
before = open(struct_info_file).read()
os.remove(struct_info_file)
self.check_working([EMCC, 'tests/hello_world.c'], '')
self.assertContained('hello, world!', run_js('a.out.js'))
assert os.path.exists(struct_info_file), 'removing the struct info file forces a rebuild'
after = open(struct_info_file).read()
assert after == before, 'struct info must be already valid, recreating it should not alter anything'

17 changes: 11 additions & 6 deletions tools/js-optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7779,15 +7779,15 @@ function JSDCE(ast) {
};
return scope[name];
}
function cleanUp(ast, name) {
function cleanUp(ast, names) {
traverse(ast, function(node, type) {
if (type === 'defun' && node[1] === name) return emptyNode();
if (type === 'defun' && node[1] in names) return emptyNode();
if (type === 'defun' || type === 'function') return null; // do not enter other scopes
if (type === 'var') {
node[1] = node[1].filter(function(varItem, j) {
var curr = varItem[0];
var value = varItem[1];
return curr !== name || (value && hasSideEffects(value));
return !(curr in names) || (value && hasSideEffects(value));
});
if (node[1].length === 0) return emptyNode();
}
Expand Down Expand Up @@ -7818,6 +7818,7 @@ function JSDCE(ast) {
}, function(node, type) {
if (type === 'defun' || type === 'function') {
var scope = scopes.pop();
var names = set();
for (name in scope) {
var data = scope[name];
if (data.use && !data.def) {
Expand All @@ -7827,22 +7828,26 @@ function JSDCE(ast) {
}
if (data.def && !data.use && !data.param) {
// this is eliminateable!
cleanUp(node[3], name);
names[name] = 0;
}
}
cleanUp(node[3], names);
}
});
// toplevel
var scope = scopes.pop();
assert(scopes.length === 0);
for (name in scope) {

var names = set();
for (var name in scope) {
var data = scope[name];
if (data.def && !data.use) {
assert(!data.param); // can't be
// this is eliminateable!
cleanUp(ast, name);
names[name] = 0;
}
}
cleanUp(ast, names);
}

// Passes table
Expand Down