From 472cd9f5cc1e2ed0393428c033c7b9610835beec Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 14 May 2026 13:10:49 -0700 Subject: [PATCH 1/2] Update test_multiply_defined_libsymbols This test was first added in c735bb646. --- test/common.py | 2 +- test/test_other.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/common.py b/test/common.py index 106a9f84e8ea8..8f2ba6bdb312c 100644 --- a/test/common.py +++ b/test/common.py @@ -1232,7 +1232,7 @@ def emcc(self, filename, args=[], **kwargs): # noqa filename = maybe_test_file(filename) compile_only = '-c' in args or '-sSIDE_MODULE' in args cmd = [compiler_for(filename), filename] + self.get_cflags(compile_only=compile_only) + args - self.run_process(cmd, **kwargs) + return self.run_process(cmd, **kwargs) # Shared test code between main suite and others diff --git a/test/test_other.py b/test/test_other.py index 57e2707417a48..54537ee495f92 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -1353,13 +1353,19 @@ def test_multiply_defined_libsymbols(self): } ''') + # Check linking libA.so multiple times (both directly and indirectly) does not result + # any multiply defined symbols. This is especially important with `FAKE_DYLIBS` where + # the we model shared libraries using regular object file. Without special handling + # fake `libA.so` could get linked multiple times. self.cflags.remove('-Werror') self.emcc('libA.c', ['-shared', '-o', 'libA.so']) - self.emcc('a2.c', ['-r', '-L.', '-lA', '-o', 'a2.o']) - self.emcc('b2.c', ['-r', '-L.', '-lA', '-o', 'b2.o']) + err = self.emcc('a2.c', ['-shared', '-L.', '-lA', '-o', 'liba2.so'], stderr=PIPE).stderr + self.assertContained('emcc: warning: ignoring dynamic library libA.so when generating an object file', err) + err = self.emcc('b2.c', ['-shared', '-L.', '-lA', '-o', 'libb2.so'], stderr=PIPE).stderr + self.assertContained('emcc: warning: ignoring dynamic library libA.so when generating an object file', err) - self.do_runf('main.c', 'result: 1', cflags=['-L.', '-lA', 'a2.o', 'b2.o']) + self.do_runf('main.c', 'result: 1', cflags=['-L.', '-lA', 'liba2.so', 'libb2.so']) def test_multiply_defined_libsymbols_2(self): create_file('a.c', "int x() { return 55; }") From 2c3fb5281b658807ae81995f52144bfa57f2bd61 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 14 May 2026 15:44:51 -0700 Subject: [PATCH 2/2] Update test/test_other.py Co-authored-by: Alon Zakai --- test/test_other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_other.py b/test/test_other.py index 54537ee495f92..d1c489530eba7 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -1355,7 +1355,7 @@ def test_multiply_defined_libsymbols(self): # Check linking libA.so multiple times (both directly and indirectly) does not result # any multiply defined symbols. This is especially important with `FAKE_DYLIBS` where - # the we model shared libraries using regular object file. Without special handling + # we model shared libraries using regular object files. Without special handling # fake `libA.so` could get linked multiple times. self.cflags.remove('-Werror') self.emcc('libA.c', ['-shared', '-o', 'libA.so'])