Skip to content

Commit

Permalink
Improve warning message when ignore fake shared libraries. NFC (#23594)
Browse files Browse the repository at this point in the history
Also, add a test for this warning which was previously not tested.
  • Loading branch information
sbc100 authored Feb 5, 2025
1 parent f9ca632 commit 3a8cb2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a8cb2a

Please sign in to comment.