emscripten-core / emscripten-core/emscripten
relocation R_WASM_MEMORY_ADDR_TLS_SLEB cannot be used against `__THREW__` in non-TLS section: .bss
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
While building our code with LTO enabled, I get this link error:
```
wasm-ld: error: lto.tmp: relocation R_WASM_MEMORY_ADDR_TLS_SLEB cannot be used against `__THREW__` in non-TLS section: .bss
wasm-ld: error: lto.tmp: relocation R_WASM_MEMORY_ADDR_TLS_SLEB cannot be used against `__threwValue` in non-TLS section: .bss
```
So far I've traced that this happens as soon as I link in `libopencv_imgcodecs.a` in my app, even though no code ever calls any function from it. My app also uses google test framework. The whole code is compiled with `-fno-exceptions`, except the `libopencv_imgcodecs.a` module, which internally uses exceptions.
To work around the issue, I can either not link to `libopencv_imgcodecs.a` or compile google test framework with `-fexceptions`.
However, if I add a call to a function from `libopencv_imgcodecs.a`, linker fails even with LTO disabled with following message:
```
[build] wasm-ld: error: /Users/dodo/.conan/data/OpenCV/3.2.0.13/nenad/testing/package/e4723bf11185e19bfb3ebb3beb683969bf2bd20f/lib/libopencv_imgcodecs.a(loadsave.cpp.o): relocation R_WASM_MEMORY_ADDR_TLS_SLEB cannot be used against `__THREW__` in non-TLS section: .bss
```
This happens no matter if exceptions are enabled or disabled in Google Test Framework.
I've googled this error message and found [this LLVM pull request](https://reviews.llvm.org/D91276) by @sbc100 as the one that adds that message to the LLD.
I hope I'll be able to reproduce this using entirely open source components (OpenCV and Google Test Framework), without any proprietary code. If I succeed, I'll share the code here.
I am using emscripten 2.0.9 on MacOS Big Sur.
Contributor guide
Assessment
This issue has not been assessed yet.