Skip to content

Trouble with emcc 6.0.0 from #25930 #27403

Description

@hoodmane

I'm not 100% sure what the problem is but emcc 6.0.0 works fine for me if I revert #25930. The problem is that -Bstatic is passed when I'm trying to link a static library.

I think the problem is that the condition here is wrong:

  if settings.FAKE_DYLIBS or (not settings.MAIN_MODULE and not settings.SIDE_MODULE):
    cmd.append('-Bstatic')
  else:
    # wasm-ld still defaults to static linking by default. If that ever changes, we can remove this line.
    cmd.append('-Bdynamic')

if settings.FAKE_DYLIBS or (not settings.MAIN_MODULE and not settings.SIDE_MODULE):
cmd.append('-Bstatic')
else:
# wasm-ld still defaults to static linking by default. If that ever changes, we can remove this line.
cmd.append('-Bdynamic')

Activity

  1. hoodmane commented on Jul 22, 2026

    @hoodmane
    CollaboratorAuthor

    Maybe it should be:

    if settings.FAKE_DYLIBS and (not settings.MAIN_MODULE and not settings.SIDE_MODULE): 
  2. hoodmane commented on Jul 22, 2026

    @hoodmane
    CollaboratorAuthor

    Well this patch:

       if settings.FAKE_DYLIBS or (not settings.MAIN_MODULE and not settings.SIDE_MODULE):
    -    cmd.append('-Bstatic')
    +    pass

    fixes the build but it still breaks at runtime.

  3. sbc100 commented on Jul 22, 2026

    @sbc100
    Collaborator

    Do you know why passing -Bstatic would be a problem when linking a static library? Are you passing either -Bstatic or -Bdynamic yourself, or are we just talking about the internal injection of these flags?

  4. hoodmane commented on Jul 24, 2026

    @hoodmane
    CollaboratorAuthor

    It's trying to link a shared library into a static library and failing. Either they should both be dynamic or both be static and I'm not sure which. Perhaps it involves some strange combination of flags which work on more standard linkers.

  5. sbc100 commented on Jul 24, 2026

    @sbc100
    Collaborator

    Do you want what the intent of the build is? Maybe you should share the full build command that is being used to build this library (either the emcc or the host version).

    I'm a little confused what you mean by "trying to link a shared library into a static library and failing" since static libraries are not linked at all using emcc right? They use emar

  6. hoodmane commented on Jul 28, 2026

    @hoodmane
    CollaboratorAuthor

    Apparently I misunderstood the issue, binary searching the diff shows that the problem is that it was passing --whole-archive before and now it's not. It's this one line that causes the problem:
    https://github.com/emscripten-core/emscripten/pull/25930/changes#diff-e6615de4338b98e08471c53f2d6fc250dc6ca22cd8c303ac33ab259c18ae68d2R288

    Reverting that one change makes it work as before:

    -  if settings.LINKABLE and (settings.FAKE_DYLIBS or not settings.SIDE_MODULE):
    +  if settings.LINKABLE:
         args.insert(0, '--whole-archive')
         args.append('--no-whole-archive')
  7. hoodmane commented on Jul 28, 2026

    @hoodmane
    CollaboratorAuthor

    I think it maybe should read:

    if settings.LINKABLE and (settings.FAKE_DYLIBS or settings.SIDE_MODULE != 2):

    because I think SIDE_MODULE=1 is supposed to imply --whole-archive but it seems like it doesn't anymore?

  8. hoodmane commented on Jul 28, 2026

    @hoodmane
    CollaboratorAuthor

    Okay opened a PR with that.

  9. added 4 commits that reference this issue on Oct 23, 2026
    203a550
    1ee38c3
    849e531
    6f27d59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions