@@ -1235,10 +1235,10 @@ def test_odd_suffixes(self):
12351235 shutil.copy(test_file('hello_world.c'), 'test.' + suffix)
12361236 self.do_runf('test.' + suffix, 'hello, world!')
12371237
1238- for suffix in ('lo'):
1238+ for suffix in ('lo', ):
12391239 self.clear()
12401240 print(suffix)
1241- self.run_process([EMCC, test_file('hello_world.c'), '-shared', '-o', 'binary.' + suffix])
1241+ self.run_process([EMCC, test_file('hello_world.c'), '-sFAKE_DYLIBS', '- shared', '-o', 'binary.' + suffix])
12421242 self.run_process([EMCC, 'binary.' + suffix])
12431243 self.assertContained('hello, world!', self.run_js('a.out.js'))
12441244
@@ -1419,7 +1419,7 @@ def test_multiply_defined_libsymbols(self):
14191419 ''')
14201420
14211421 self.cflags.remove('-Werror')
1422- self.emcc('libA.c', ['-shared', '-o', 'libA.so'])
1422+ self.emcc('libA.c', ['-shared', '-sFAKE_DYLIBS', '- o', 'libA.so'])
14231423
14241424 self.emcc('a2.c', ['-r', '-L.', '-lA', '-o', 'a2.o'])
14251425 self.emcc('b2.c', ['-r', '-L.', '-lA', '-o', 'b2.o'])
@@ -1552,7 +1552,12 @@ def test_link_group_bitcode(self):
15521552 # We deliberately ignore duplicate input files in order to allow
15531553 # "libA.so" on the command line twice. This is not really .so support
15541554 # and the .so files are really object files.
1555- def test_redundant_link(self):
1555+ @parameterized({
1556+ '': ([],),
1557+ 'fake_dylibs': (['-sFAKE_DYLIBS'],),
1558+ })
1559+ def test_redundant_link(self, args):
1560+ self.cflags += args
15561561 create_file('libA.c', 'int mult() { return 1; }')
15571562 create_file('main.c', r'''
15581563 #include <stdio.h>
@@ -1564,7 +1569,7 @@ def test_redundant_link(self):
15641569 ''')
15651570
15661571 self.cflags.remove('-Werror')
1567- self.emcc('libA.c', ['-shared', '-o', 'libA.so'])
1572+ self.emcc('libA.c', ['-fPIC', '- shared', '-o', 'libA.so'])
15681573 self.emcc('main.c', ['libA.so', 'libA.so', '-o', 'a.out.js'])
15691574 self.assertContained('result: 1', self.run_js('a.out.js'))
15701575
@@ -2159,9 +2164,9 @@ def test_multidynamic_link(self, link_flags, lib_suffix):
21592164 ''')
21602165
21612166 # Build libfile normally into an .so
2162- self.run_process([EMCC, 'libdir/libfile.c', '-shared', '-o', 'libdir/libfile.so' + lib_suffix])
2167+ self.run_process([EMCC, 'libdir/libfile.c', '-sFAKE_DYLIBS', '- shared', '-fPIC ', '-o', 'libdir/libfile.so' + lib_suffix])
21632168 # Build libother and dynamically link it to libfile
2164- self.run_process([EMCC, '-Llibdir', 'libdir/libother.c'] + link_flags + ['-shared', '-o', 'libdir/libother.so'])
2169+ self.run_process([EMCC, '-Llibdir', 'libdir/libother.c'] + link_flags + ['-sFAKE_DYLIBS', '- shared', '-fPIC ', '-o', 'libdir/libother.so'])
21652170 # Build the main file, linking in both the libs
21662171 self.run_process([EMCC, '-Llibdir', os.path.join('main.c')] + link_flags + ['-lother', '-c'])
21672172 print('...')
@@ -4906,20 +4911,6 @@ def test_valid_abspath_2(self):
49064911 self.run_process(cmd)
49074912 self.assertContained('hello, world!', self.run_js('a.out.js'))
49084913
4909- def test_warn_dylibs(self):
4910- shared_suffixes = ['.so', '.dylib', '.dll']
4911-
4912- for suffix in ('.o', '.bc', '.so', '.dylib', '.js', '.html'):
4913- print(suffix)
4914- cmd = [EMCC, test_file('hello_world.c'), '-o', 'out' + suffix]
4915- if suffix in ['.o', '.bc']:
4916- cmd.append('-c')
4917- if suffix in ['.dylib', '.so']:
4918- cmd.append('-shared')
4919- err = self.run_process(cmd, stderr=PIPE).stderr
4920- warning = 'linking a library with `-shared` will emit a static object file'
4921- self.assertContainedIf(warning, err, suffix in shared_suffixes)
4922-
49234914 @crossplatform
49244915 @parameterized({
49254916 'O2': [['-O2']],
@@ -8369,20 +8360,6 @@ def test_side_module_folder_deps(self):
83698360 self.run_process([EMCC, test_file('hello_world.c'), '-sSIDE_MODULE', '-o', 'subdir/libside2.so', '-L', 'subdir', '-lside1'])
83708361 self.run_process([EMCC, test_file('hello_world.c'), '-sMAIN_MODULE', '-o', 'main.js', '-L', 'subdir', '-lside2'])
83718362
8372- @crossplatform
8373- def test_side_module_ignore(self):
8374- self.run_process([EMCC, test_file('hello_world.c'), '-sSIDE_MODULE', '-o', 'libside.so'])
8375-
8376- # Attempting to link statically against a side module (libside.so) should fail.
8377- err = self.expect_fail([EMCC, '-L.', '-lside'])
8378- self.assertContained(r'error: attempted static link of dynamic object \.[/\\]libside.so', err, regex=True)
8379-
8380- # But a static library in the same location (libside.a) should take precedence.
8381- self.run_process([EMCC, test_file('hello_world.c'), '-c'])
8382- self.run_process([EMAR, 'cr', 'libside.a', 'hello_world.o'])
8383- self.run_process([EMCC, '-L.', '-lside'])
8384- self.assertContained('hello, world!', self.run_js('a.out.js'))
8385-
83868363 @is_slow_test
83878364 @parameterized({
83888365 '': ([],),
@@ -11903,23 +11880,24 @@ def test_err(self):
1190311880 def test_euidaccess(self):
1190411881 self.do_other_test('test_euidaccess.c')
1190511882
11906- def test_shared_flag(self):
11907- self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'libother.so'])
11883+ def test_fake_dylibs(self):
11884+ self.run_process([EMCC, '-shared', '-sFAKE_DYLIBS', '-fPIC', test_file('hello_world.c'), '-o', 'libother.so'])
11885+ self.assertIsObjectFile('libother.so')
1190811886
11909- # Test that `-shared ` flag causes object file generation but gives a warning
11910- err = self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'out.foo', 'libother.so'], stderr=PIPE).stderr
11911- self.assertContained('linking a library with ` -shared` will emit a static object', err)
11887+ # Test that `-sFAKE_DYLIBS ` flag causes object file generation and will generate a warning about
11888+ # dylink dependencies being ignored.
11889+ err = self.run_process([EMCC, ' -shared', '-sFAKE_DYLIBS', '-fPIC', test_file('hello_world.c'), '-o', 'out.foo', 'libother.so'], stderr=PIPE).stderr
1191211890 self.assertContained('emcc: warning: ignoring dynamic library libother.so when generating an object file, this will need to be included explicitly in the final link', err)
1191311891 self.assertIsObjectFile('out.foo')
1191411892
1191511893 # Test that using an executable output name overrides the `-shared` flag, but produces a warning.
11916- err = self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'out.js'],
11894+ err = self.run_process([EMCC, '-shared', '-sFAKE_DYLIBS', '-fPIC', test_file('hello_world.c'), '-o', 'out.js'],
1191711895 stderr=PIPE).stderr
1191811896 self.assertContained('warning: -shared/-r used with executable output suffix', err)
1191911897 self.run_js('out.js')
1192011898
1192111899 def test_shared_soname(self):
11922- self.run_process([EMCC, '-shared', '-Wl,-soname', '-Wl,libfoo.so.13', test_file('hello_world.c'), '-lc', '-o', 'libfoo.so'])
11900+ self.run_process([EMCC, '-shared', '-sFAKE_DYLIBS', '- Wl,-soname', '-Wl,libfoo.so.13', test_file('hello_world.c'), '-lc', '-o', 'libfoo.so'])
1192311901 self.run_process([EMCC, '-sSTRICT', 'libfoo.so'])
1192411902 self.assertContained('hello, world!', self.run_js('a.out.js'))
1192511903
0 commit comments