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

    <tr>
        <th>Summary</th>
        <td>
            [WebAssembly][lld] excessive undefined symbol errors when building a shared library
        </td>
    </tr>

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

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

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

<pre>
    after 22b7b84860d39da71964c9b329937f2ee1d875ba,
wasm-ld complains on undefined symbols when building -shared/-pie. it's nice.

however, it even complains on symbols which are expected to be provided/imported by wasm-ld itself. (eg. __heap_base)
i consider it a bug.

i saw it while buliding wasi-libc: https://github.com/WebAssembly/wasi-libc/pull/526

a smaller recipe to reproduce: https://github.com/yamt/garbage/tree/master/wasm/ld-shared

with:
```
clang version 20.0.0git (https://github.com/llvm/llvm-project.git c31ac810910ac87531de636ea508abec6e29e8ff)
```

spacetanuki% ./test.sh
```
+ CC=/Volumes/PortableSSD/llvm/build/bin/clang
+ /Volumes/PortableSSD/llvm/build/bin/clang -o liba.so -nostdlib -shared -mexception-handling -fPIC -fvisibility=default -Wl,--no-entry a.c
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __heap_base
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __heap_end
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __cpp_exception
wasm-ld: error: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/a-7ab945.o: undefined symbol: __c_longjmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVU-P27gP_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