Skip to content

Turn off shared library signature check when configuring - #27470

Open
hoodmane wants to merge 1 commit into
emscripten-core:mainfrom
hoodmane:no-shlib-sigcheck-autoconf
Open

Turn off shared library signature check when configuring#27470
hoodmane wants to merge 1 commit into
emscripten-core:mainfrom
hoodmane:no-shlib-sigcheck-autoconf

Conversation

@hoodmane

Copy link
Copy Markdown
Collaborator

AC_CHECK_LIB(somelib, func) writes the following to conftest.c:

char func ();

int main(void) {
   return func ();
}

Then runs emcc conftest.c -lsomelib and checks whether it succeeds. With static libraries the signature mismatch is just a warning but with shared libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make a shared library it would make a fake dynamic library instead and we didn't see this problem. But since then it makes a real dynamic library and then fails to configure.

The fix is if we are configuring pass -Wl,--no-shlib-sigcheck to disable the signature check.

`AC_CHECK_LIB(somelib, func)` writes the following to conftest.c:

```C
char func ();

int main(void) {
   return func ();
}
```
Then runs `emcc conftest.c -lsomelib` and checks whether it succeeds. With
static libraries the signature mismatch is just a warning but with shared
libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make
a shared library it would make a fake dynamic library instead and we didn't see
this problem. But since then it makes a real dynamic library and then fails to
configure.

The fix is if we are configuring pass `-Wl,--no-shlib-sigcheck` to disable the
signature check.
hoodmane added a commit to pyodide/pyodide that referenced this pull request Jul 31, 2026
emscripten-core/emscripten#27470

AC_CHECK_LIB(somelib, func)` writes the following to conftest.c:

```C
char func ();

int main(void) {
   return func ();
}
```
Then runs `emcc conftest.c -lsomelib` and checks whether it succeeds. With
static libraries the signature mismatch is just a warning but with shared
libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make
a shared library it would make a fake dynamic library instead and we didn't see
this problem. But since then it makes a real dynamic library and then fails to
configure.

The fix is if we are configuring pass `-Wl,--no-shlib-sigcheck` to disable the
signature check.
Comment thread tools/link.py
# 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?

@sbc100 sbc100 left a comment

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.

Thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants