From f117e4037e72a616923e030f65f55b793bae9319 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 8 Oct 2019 18:14:48 -0700 Subject: [PATCH] Fix backwards dependencies on JS functions in -l archives Previously we were allowing -l flags to flow all the way through the linker, but that meant the library files they referred too were not getting passed though to `system_libraries.calculate`. This change reverts back to the previous behavior prior to #9436. Fixes: 9566 --- emcc.py | 5 ----- tests/test_other.py | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/emcc.py b/emcc.py index d98507d6be76c..b8cc0ff934f29 100755 --- a/emcc.py +++ b/emcc.py @@ -3510,11 +3510,6 @@ def process_libraries(libs, lib_dirs, temp_files): logger.debug('looking for library "%s"', lib) suffixes = STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS - if shared.Settings.WASM_BACKEND: - # under the wasm .a files are found using the normal -l/-L flags to - # the linker. - suffixes = DYNAMICLIB_ENDINGS - found = False for prefix in LIB_PREFIXES: for suff in suffixes: diff --git a/tests/test_other.py b/tests/test_other.py index c4a8071bc515b..a89fe8d40b385 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9796,3 +9796,12 @@ def test_link_to_object(self): run_process([PYTHON, EMCC, 'hello1.o', '-o', 'hello3.o']) content3 = open('hello2.o', 'rb').read() self.assertEqual(content1, content3) + + def test_backwards_deps_in_archive(self): + # Test that JS dependencies from deps_info.json work for code linked via + # static archives using -l + run_process([PYTHON, EMCC, path_from_root('tests', 'sockets', 'test_gethostbyname.c'), '-o', 'a.o']) + run_process([LLVM_AR, 'cr', 'liba.a', 'a.o']) + create_test_file('empty.c', 'static int foo = 0;') + run_process([PYTHON, EMCC, 'empty.c', '-la', '-L.']) + self.assertContained('success', run_js('a.out.js'))