Skip to content

Commit c3736fb

Browse files
authored
Improve test_multiply_defined_libsymbols (#26953)
This test was first added in c735bb6. Hopefully these changes make it more obvious what is being tested, and also test more commonly used flags (`-shared` vs `-r`). Split out from #25930.
1 parent 378cc21 commit c3736fb

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ def emcc(self, filename, args=[], **kwargs): # noqa
12321232
filename = maybe_test_file(filename)
12331233
compile_only = '-c' in args or '-sSIDE_MODULE' in args
12341234
cmd = [compiler_for(filename), filename] + self.get_cflags(compile_only=compile_only) + args
1235-
self.run_process(cmd, **kwargs)
1235+
return self.run_process(cmd, **kwargs)
12361236

12371237
# Shared test code between main suite and others
12381238

test/test_other.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,13 +1353,19 @@ def test_multiply_defined_libsymbols(self):
13531353
}
13541354
''')
13551355

1356+
# Check linking libA.so multiple times (both directly and indirectly) does not result
1357+
# any multiply defined symbols. This is especially important with `FAKE_DYLIBS` where
1358+
# we model shared libraries using regular object files. Without special handling
1359+
# fake `libA.so` could get linked multiple times.
13561360
self.cflags.remove('-Werror')
13571361
self.emcc('libA.c', ['-shared', '-o', 'libA.so'])
13581362

1359-
self.emcc('a2.c', ['-r', '-L.', '-lA', '-o', 'a2.o'])
1360-
self.emcc('b2.c', ['-r', '-L.', '-lA', '-o', 'b2.o'])
1363+
err = self.emcc('a2.c', ['-shared', '-L.', '-lA', '-o', 'liba2.so'], stderr=PIPE).stderr
1364+
self.assertContained('emcc: warning: ignoring dynamic library libA.so when generating an object file', err)
1365+
err = self.emcc('b2.c', ['-shared', '-L.', '-lA', '-o', 'libb2.so'], stderr=PIPE).stderr
1366+
self.assertContained('emcc: warning: ignoring dynamic library libA.so when generating an object file', err)
13611367

1362-
self.do_runf('main.c', 'result: 1', cflags=['-L.', '-lA', 'a2.o', 'b2.o'])
1368+
self.do_runf('main.c', 'result: 1', cflags=['-L.', '-lA', 'liba2.so', 'libb2.so'])
13631369

13641370
def test_multiply_defined_libsymbols_2(self):
13651371
create_file('a.c', "int x() { return 55; }")

0 commit comments

Comments
 (0)