Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12406,6 +12406,21 @@ def test_autoconf_mode(self):
output = self.run_process([os.path.abspath('a.out')], stdout=PIPE).stdout
self.assertContained('Hello, world!', output)

def test_autoconf_check_lib_side_module(self):
# AC_CHECK_LIB probes for a symbol using an unprototyped declaration and a
# zero-argument call. Verify that the signature mismatch against the real
# function does not make the probe fail when the library is a side module.
create_file('libtest.c', 'int identity(int x) { return x; }\n')
self.run_process([EMCC, '-fPIC', '-shared', '-o', 'libtest.so', 'libtest.c'])
create_file('conftest.c', '''
char identity ();

int main(void) {
return identity ();
}
''')
self.run_process([EMCC, 'conftest.c', 'libtest.so', '-o', 'conftest.js'])

def test_standalone_export_main(self):
# Tests that explicitly exported `_main` does not fail, even though `_start` is the entry
# point.
Expand Down
7 changes: 7 additions & 0 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,13 @@ def phase_linker_setup(linker_args): # ruff: ignore[complex-structure, too-many
# autoconf declares functions without their proper signatures, and STRICT causes that to trip up by passing --fatal-warnings to the linker.
if settings.STRICT:
exit_with_error('autoconfiguring is not compatible with STRICT')
# AC_CHECK_LIB probes for a symbol by declaring it without a prototype
# (`char foo ();`) and then calling it with no arguments. When the symbol
# comes from an object file or an archive lld only warns about the
# resulting signature mismatch and synthesizes a thunk, but when it comes
# from a shared library the mismatch is a hard error. This turns off the
# shared library check.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment comment above on line 889 is already describing the issue.

Maybe we can just say "For the same reason, we need to disable signature check for shared library symbols."?

Its kind of strange to me that static signature checks would be a warning but not shared signature checks would be an error? I believe the reason static signature checks are only a warning by default is precisely to allow for autoconf/cmake games like this. If that is true then the same logic should apply for shared libraries.

Perhaps if we are going to land this we should add a TOTO with a link to and llvm bug to consider changing the default?

linker_args.append('--no-shlib-sigcheck')

if settings.OPT_LEVEL >= 1:
default_setting('ASSERTIONS', 0)
Expand Down
Loading