@@ -2131,63 +2131,59 @@ def test_dylink_exceptions_and_assertions(self):
21312131 'side.wasm',
21322132 ])
21332133
2134- def test_multidynamic_link(self):
2134+ @parameterized({
2135+ '': (['-lfile'], ''), # -l, auto detection from library path
2136+ 'suffixed': (['libdir/libfile.so.3.1.4.1.5.9'], '.3.1.4.1.5.9'), # handle libX.so.1.2.3 as well
2137+ })
2138+ def test_multidynamic_link(self, link_flags, lib_suffix):
21352139 # Linking the same dynamic library in statically will error, normally, since we statically link
21362140 # it, causing dupe symbols
2141+ ensure_dir('libdir')
21372142
2138- def test(link_flags, lib_suffix):
2139- print(link_flags, lib_suffix)
2140-
2141- self.clear()
2142- ensure_dir('libdir')
2143+ create_file('main.c', r'''
2144+ #include <stdio.h>
2145+ extern void printey();
2146+ extern void printother();
2147+ int main() {
2148+ printf("*");
2149+ printey();
2150+ printf("\n");
2151+ printother();
2152+ printf("\n");
2153+ printf("*\n");
2154+ return 0;
2155+ }
2156+ ''')
21432157
2144- create_file('main.c', r'''
2145- #include <stdio.h>
2146- extern void printey();
2147- extern void printother();
2148- int main() {
2149- printf("*");
2150- printey();
2151- printf("\n");
2152- printother();
2153- printf("\n");
2154- printf("*\n");
2155- return 0;
2156- }
2157- ''')
2158+ create_file('libdir/libfile.c', '''
2159+ #include <stdio.h>
2160+ void printey() {
2161+ printf("hello from lib");
2162+ }
2163+ ''')
21582164
2159- create_file('libdir/libfile.c', '''
2160- #include <stdio.h>
2161- void printey() {
2162- printf("hello from lib");
2163- }
2164- ''')
2165+ create_file('libdir/libother.c', '''
2166+ #include <stdio.h>
2167+ extern void printey();
2168+ void printother() {
2169+ printf("|");
2170+ printey();
2171+ printf("|");
2172+ }
2173+ ''')
21652174
2166- create_file('libdir/libother.c', '''
2167- #include <stdio.h>
2168- extern void printey();
2169- void printother() {
2170- printf("|");
2171- printey();
2172- printf("|");
2173- }
2174- ''')
2175+ # Build libfile normally into an .so
2176+ self.run_process([EMCC, 'libdir/libfile.c', '-shared', '-o', 'libdir/libfile.so' + lib_suffix])
2177+ # Build libother and dynamically link it to libfile
2178+ self.run_process([EMCC, '-Llibdir', 'libdir/libother.c'] + link_flags + ['-shared', '-o', 'libdir/libother.so'])
2179+ # Build the main file, linking in both the libs
2180+ self.run_process([EMCC, '-Llibdir', os.path.join('main.c')] + link_flags + ['-lother', '-c'])
2181+ print('...')
2182+ # The normal build system is over. We need to do an additional step to link in the dynamic
2183+ # libraries, since we ignored them before
2184+ self.run_process([EMCC, '-Llibdir', 'main.o'] + link_flags + ['-lother'])
21752185
2176- # Build libfile normally into an .so
2177- self.run_process([EMCC, 'libdir/libfile.c', '-shared', '-o', 'libdir/libfile.so' + lib_suffix])
2178- # Build libother and dynamically link it to libfile
2179- self.run_process([EMCC, '-Llibdir', 'libdir/libother.c'] + link_flags + ['-shared', '-o', 'libdir/libother.so'])
2180- # Build the main file, linking in both the libs
2181- self.run_process([EMCC, '-Llibdir', os.path.join('main.c')] + link_flags + ['-lother', '-c'])
2182- print('...')
2183- # The normal build system is over. We need to do an additional step to link in the dynamic
2184- # libraries, since we ignored them before
2185- self.run_process([EMCC, '-Llibdir', 'main.o'] + link_flags + ['-lother'])
2186-
2187- self.assertContained('*hello from lib\n|hello from lib|\n*\n', self.run_js('a.out.js'))
2188-
2189- test(['-lfile'], '') # -l, auto detection from library path
2190- test(['libdir/libfile.so.3.1.4.1.5.9'], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well
2186+ self.assertContained('*hello from lib\n|hello from lib|\n*\n', self.run_js('a.out.js'))
21912187
21922188 @node_pthreads
21932189 @also_with_modularize
0 commit comments