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
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def build_symbol_list(filename):
"""
library_syms = generate_js_sym_info()

write_file(filename, json.dumps(library_syms, separators=(',', ':')))
write_file(filename, json.dumps(library_syms, separators=(',', ':'), indent=2))

# We need to use a separate lock here for symbol lists because, unlike with system libraries,
# it's normally for these file to get pruned as part of normal operation. This means that it
Expand Down
30 changes: 24 additions & 6 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5198,15 +5198,17 @@ def test_bad_lookup(self):
'full_only': [{'EMCC_FORCE_STDLIBS': 'libc,libc++abi,libc++,libmalloc', 'EMCC_ONLY_FORCED_STDLIBS': '1'}, False],
})
def test_only_force_stdlibs(self, env, fail):
cmd = [EMXX, test_file('hello_libcxx.cpp')]
with env_modify(env):
err = self.run_process([EMXX, test_file('hello_libcxx.cpp'), '-sWARN_ON_UNDEFINED_SYMBOLS=0'], stderr=PIPE).stderr
if 'EMCC_ONLY_FORCED_STDLIBS' in env:
self.assertContained('EMCC_ONLY_FORCED_STDLIBS is deprecated', err)
if fail:
output = self.run_js('a.out.js', assert_returncode=NON_ZERO)
self.assertContained('missing function', output)
err = self.expect_fail(cmd)
self.assertContained('undefined symbol: malloc', err)
else:
self.assertContained('hello, world!', self.run_js('a.out.js'))
err = self.run_process(cmd, stderr=PIPE).stderr
if 'EMCC_ONLY_FORCED_STDLIBS' in env:
self.assertContained('EMCC_ONLY_FORCED_STDLIBS is deprecated', err)
else:
self.assertContained('hello, world!', self.run_js('a.out.js'))

def test_only_force_stdlibs_2(self):
create_file('src.cpp', r'''
Expand Down Expand Up @@ -12049,6 +12051,22 @@ def test_main_module_no_undefined(self):
# Test that ERROR_ON_UNDEFINED_SYMBOLS works with MAIN_MODULE.
self.do_runf(test_file('hello_world.c'), emcc_args=['-sMAIN_MODULE', '-sERROR_ON_UNDEFINED_SYMBOLS'])

def test_reverse_deps_allow_undefined(self):
# Check that reverse deps are still included even when -sERROR_ON_UNDEFINED_SYMBOLS=0.
create_file('test.c', '''
#include <assert.h>
#include <stdio.h>
#include <netdb.h>

int main() {
// Reference in getaddrinfo which has reverse deps on malloc and htons
// We expect these to be exported even when -sERROR_ON_UNDEFINED_SYMBOLS=0.
printf("%p\\n", &getaddrinfo);
return 0;
}
''')
self.do_runf('test.c', emcc_args=['-sERROR_ON_UNDEFINED_SYMBOLS=0'])

@parameterized({
'relocatable': ('-sRELOCATABLE',),
'linkable': ('-sLINKABLE',),
Expand Down
5 changes: 1 addition & 4 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ def create_stub_object(external_symbols):
stubfile = shared.get_temp_files().get('libemscripten_js_symbols.so').name
stubs = ['#STUB']
for name, deps in external_symbols.items():
if settings.ERROR_ON_UNDEFINED_SYMBOLS:
stubs.append('%s: %s' % (name, ','.join(deps)))
else:
stubs.append(name)
stubs.append('%s: %s' % (name, ','.join(deps)))
utils.write_file(stubfile, '\n'.join(stubs))
return stubfile

Expand Down