Skip to content

Link failing with attempt to add bitcode file after LTO #16836

@tklajnscek

Description

@tklajnscek

Happens with 2.0.34 onward, latest I tried is 3.1.9, haven't tried earlier ones

When we compile our project with -flto we get:

[build] wasm-ld: error: D:\SDK\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc.a(fputc.o): attempt to add bitcode file after LTO.

I've looked at the relevant LLVM change log here https://reviews.llvm.org/rGb062fe181625bd1944ca9ca2a58246ffd7cd3536
And the previous issues #11545 and #15506

We don't use fputc, so it's most likely being generated by this transform https://github.com/llvm/llvm-project/blob/35cc2ec4ed4a7a0862e62ad009d561f61e2d12c3/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp#L2887

fwrite(S,1,1,F) -> fputc(S[0],F)

Adding a reference to it with Wl,-u,fputc fixes the issue, but I thought this has been fixed since #11545 is closed.

Does the non-LTO symbol list in system_libs.py need updating maybe to keep up with any transforms that may emit these symbols late? Or is there another fix for this on the horizon?

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