From 3a8cb2a57868269dea162840e97fb34d1584efae Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 5 Feb 2025 11:04:26 -0800 Subject: [PATCH] Improve warning message when ignore fake shared libraries. NFC (#23594) Also, add a test for this warning which was previously not tested. --- test/test_other.py | 5 ++++- tools/link.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index e21668e847e11..496afbe80a0d1 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12866,9 +12866,12 @@ def test_euidaccess(self): self.do_other_test('test_euidaccess.c') def test_shared_flag(self): + self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'libother.so']) + # Test that `-shared` flag causes object file generation but gives a warning - err = self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'out.foo'], stderr=PIPE).stderr + err = self.run_process([EMCC, '-shared', test_file('hello_world.c'), '-o', 'out.foo', 'libother.so'], stderr=PIPE).stderr self.assertContained('linking a library with `-shared` will emit a static object', err) + 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) self.assertIsObjectFile('out.foo') # Test that using an executable output name overrides the `-shared` flag, but produces a warning. diff --git a/tools/link.py b/tools/link.py index 36acb56d1af9e..7423b453fc51b 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2894,7 +2894,7 @@ def filter_out_fake_dynamic_libs(options, inputs): def is_fake_dylib(input_file): if get_file_suffix(input_file) in DYLIB_EXTENSIONS and os.path.exists(input_file) and not building.is_wasm_dylib(input_file): if not options.ignore_dynamic_linking: - diagnostics.warning('emcc', 'ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end', os.path.basename(input_file)) + diagnostics.warning('emcc', 'ignoring dynamic library %s when generating an object file, this will need to be included explicitly in the final link', os.path.basename(input_file)) return True else: return False