<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59095>59095</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang generates mismatching wasm compiler-rt function signatures with -mmulti-value
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          TerrorJack
      </td>
    </tr>
</table>

<pre>
    When `-mmulti-value` is added in wasi-sdk (the `wasi-libc` CFLAGS, and all `CMAKE_C_FLAGS` & `CMAKE_CXX_FLAGS` in the top-level makefile), clang generates mismatching wasm compiler-rt function signatures, as can be seen in the `wasm-ld` warning messages:

```
wasm-ld: warning: function signature mismatch: __udivti3
>>> defined as (i32, i64, i64, i64, i64) -> void in /home/gitpod/.ghc-wasm/wasi-sdk/lib/clang/15.0.5/lib/wasi/libclang_rt.builtins-wasm32.a(muloti4.c.obj)
>>> defined as (i64, i64, i64, i64) -> i64 in /home/gitpod/.ghc-wasm/wasi-sdk/lib/clang/15.0.5/lib/wasi/libclang_rt.builtins-wasm32.a(udivti3.c.obj)

wasm-ld: warning: function signature mismatch: __multi3
>>> defined as (i32, i64, i64, i64, i64) -> void in /home/gitpod/.ghc-wasm/wasi-sdk/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(intscan.o)
>>> defined as (i64, i64, i64, i64) -> i64 in /home/gitpod/.ghc-wasm/wasi-sdk/lib/clang/15.0.5/lib/wasi/libclang_rt.builtins-wasm32.a(multi3.c.obj)

wasm-ld: warning: function signature mismatch: __muloti4
>>> defined as (i32, i64, i64, i64, i64, i32) -> void in /home/gitpod/.ghc-wasm/wasi-sdk/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(pselect.o)
>>> defined as (i64, i64, i64, i64, i32) -> i64 in /home/gitpod/.ghc-wasm/wasi-sdk/lib/clang/15.0.5/lib/wasi/libclang_rt.builtins-wasm32.a(muloti4.c.obj)
```

Posting the bug early, and a self-contained minimal repro should come later.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVclu2zAQ_RrpQkiQqMXWQQfXiQt0AQq0QHMzKHEsMaFIg6Qc5O87lGwn7npw0aCAwG2GwzfvUZxG86f6aw-KBGUSDcMonYgOTI6AcyIsYZwDJ0KRR2ZFZPkDCejS9eD9pyUpmtb7rjcfVm8_B3RNmOKESek91h9X72-36-1sQ6-Ali_W7-6eLXiED-v0PpJwAEkG9gA7ISGglY_aSqY60oECwxxYMgg7MNf2AlcRyEBaPezR3UTGkd2oWie0IlZ0irnRgJ2QWdIyRRogFjDl45FzJkMkucfxyIzyMQewlnW4L1sFyU2QnNoyOX7T9LQxW502-uGPx5_hevN2O3JxcCI7hsxu549wTFgh3YgTWRYZ9aBFmf-iq0jkdx20mBQK6KbXA_K16YTba46DuOvbyGPE8UlAHKJm2E6MYp8WcRIX52XvN08mh61xcTMKvBfKTqEyGjNEh1dFO5HHbaybe6_R73P5UxI4_vc5HGX4PodrlJ3-oFcTthHKG2NsbM8MnK1P1mjtXvKDHEQvaJr4EMpZ_EFi_Z_qOZP_l-X0t_xKPbHzLq8l696ChNZdJetlCq-l7s9enMsHeW4_aev8I-6f92bsCDAjn861CV9_uYtarRybch-EEgOTxMDeaGJ7PUruywkQiaXGxCHUaVkuq0VeVDTkdcarrGKhE05CfW1dIo_C9eSi9IajkXXv3H4qPnQz89uPTYyxPFHycOoiRHyP2uJUWDv6MrcpqqQqwr4um3y5ozTnWZO2LG9LWrY0SRY0h6TMl2koWQPS1kHxJihuQlHThNI0xTZJspTGGSt3dFHki6JcML5bBHkCAxMy9gfH2nShqScMyLBFoxTW2Wcjsz5JgFN8Nrpem_oLGKPNO9Y-hBPieoL7Dbg8obw">