[Lldb-commits] [lldb] [lldb] Add an option to build liblldb statically (PR #223210)

Anutosh Bhat via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 14 22:17:44 PDT 2026


anutosh491 wrote:

Hey @bulbazord,

Replying to the above ... my intention isn't to introduce static `liblldb` as another generally supported configuration. **It is specifically useful for Emscripten builds, where loading a large side module can be very expensive.**

Using Emscripten 6.0.8 with Release builds at `-O3` and no LTO, I measured:

- Static executable: `80,719,834` bytes
- Shared setup: `385,510` byte main module plus a `102,532,861` byte `liblldb.so`

For the same minimal harness:

```text
static:  real 0.57s
shared:  real 93.72s
```

The shared version spends most of that time loading, compiling and relocating `liblldb.so`. Emscripten also documents limitations around synchronously loading modules larger than 8 MB in Chromium, while dynamic linking with pthreads is still experimental.

`-Oz` is worth testing with a clean build, but I see that as an independent build optimization rather than a replacement for static linking support. Also, dynamic linking existed through `SIDE_MODULE` before Emscripten 6; Emscripten 6 mainly made ordinary `-shared` produce a real dynamic library by default.

I'll restrict `LLDB_BUILD_STATIC_LIBLLDB` to Emscripten and make CMake reject it on other platforms. WasmBolt is one concrete consumer, but this should also help other browser and Emscripten embedders. The overall LLDB/Emscripten work is tracked in https://github.com/llvm/llvm-project/issues/223598.

https://github.com/llvm/llvm-project/pull/223210


More information about the lldb-commits mailing list