@@ -2221,6 +2221,46 @@ def test_dylink_no_autoload(self):
2221
2221
output = self.run_js('a.out.js')
2222
2222
self.assertContained('sidey: 42\n', output)
2223
2223
2224
+ def test_dylink_dependencies(self):
2225
+ create_file('side1.c', r'''
2226
+ #include <stdio.h>
2227
+ #include <stdlib.h>
2228
+
2229
+ void side2();
2230
+
2231
+ void side1() {
2232
+ printf("side1\n");
2233
+ side2();
2234
+ }
2235
+ ''')
2236
+ create_file('side2.c', r'''
2237
+ #include <stdio.h>
2238
+ #include <stdlib.h>
2239
+
2240
+ void side2() {
2241
+ printf("side2\n");
2242
+ }
2243
+ ''')
2244
+ create_file('main.c', '''
2245
+ void side1();
2246
+
2247
+ int main() {
2248
+ side1();
2249
+ return 0;
2250
+ }
2251
+ ''')
2252
+ self.emcc('side2.c', ['-fPIC', '-sSIDE_MODULE', '-olibside2.so'])
2253
+ self.emcc('side1.c', ['-fPIC', '-sSIDE_MODULE', '-olibside1.so', 'libside2.so'])
2254
+ cmd = [EMCC, 'main.c', '-fPIC', '-sMAIN_MODULE=2', 'libside1.so']
2255
+
2256
+ # Unless `.` is added to the library path the libside2.so won't be found.
2257
+ err = self.expect_fail(cmd)
2258
+ self.assertContained('emcc: error: libside1.so: shared library dependency not found in library path: `libside2.so`.', err)
2259
+
2260
+ # Adding -L. to the library path makes it work.
2261
+ self.run_process(cmd + ['-L.'])
2262
+ self.run_js('a.out.js')
2263
+
2224
2264
def test_js_link(self):
2225
2265
create_file('main.c', '''
2226
2266
#include <stdio.h>
@@ -8664,7 +8704,7 @@ def test_side_module_missing(self):
8664
8704
# When linking against `libside2.wasm` (which depends on libside1.wasm) that library path is used
8665
8705
# to locate `libside1.wasm`. Expect the link to fail with an unmodified library path.
8666
8706
err = self.expect_fail([EMCC, '-sMAIN_MODULE=2', test_file('hello_world.c'), 'libside2.wasm'])
8667
- self.assertContained('libside2.wasm: shared library dependency not found: `libside1.wasm`', err)
8707
+ self.assertContained('libside2.wasm: shared library dependency not found in library path : `libside1.wasm`', err)
8668
8708
8669
8709
# But succeed if `.` is added the library path.
8670
8710
self.run_process([EMCC, '-sMAIN_MODULE=2', test_file('hello_world.c'), '-L.', 'libside2.wasm'])
@@ -8680,7 +8720,7 @@ def test_side_module_transitive_deps(self):
8680
8720
self.run_process(final_link)
8681
8721
os.remove('libside1.wasm')
8682
8722
err = self.expect_fail(final_link)
8683
- self.assertContained('error: libside2.wasm: shared library dependency not found: `libside1.wasm`', err)
8723
+ self.assertContained('error: libside2.wasm: shared library dependency not found in library path : `libside1.wasm`', err)
8684
8724
8685
8725
def test_side_module_folder_deps(self):
8686
8726
# Build side modules in a subfolder
0 commit comments