What’s the impact on the native sysroot and target packages when we link rust against all of libLLVM.so dynamically vs statically linking the pieces that are used?
Hi Ross,
Below are the observed impacts when linking Rust against shared libLLVM.so versus
statically linking LLVM components.
On Native:
**********
All required LLVM-related libraries were already present in recipe-sysroot-native before switching
Rust to dynamic LLVM. Dynamic linking does not introduce any new native dependencies.
Existing llvm-native artifacts are reused.
Static:
-rw-r--r-- 1 xxx users 213M Feb 13 00:29 librustc_driver-4b6f2c2478f9ef2c.so
Dynamic:
-rw-r--r-- 1 xxx users 132M Feb 13 00:52 librustc_driver-4b6f2c2478f9ef2c.so
So on native we see ~81 MB reduction in librustc_driver, with no additional sysroot growth.
On Target:
**********
librustc_driver shrinks from 144.8 MB to 84.2 MB (~60 MB reduction).
However, dynamic linking introduces shared libLLVM.so plus a few runtime dependencies.
Static:
root@qemux86-64:~# ls -lh /usr/lib/librustc_driver-*.so
-rw-r--r-- 1 root root 144.8M Apr 5 2011 /usr/lib/librustc_driver-151eed90355bbdac.so
Dynamic:
root@qemux86-64:~# ls -lh /usr/lib/librustc_driver-*.so
-rw-r--r-- 1 root root 84.2M Apr 5 2011 /usr/lib/librustc_driver-151eed90355bbdac.so
New dynamic dependencies:
root@qemux86-64:~# ldd /usr/lib/librustc_driver-*.so
libLLVM.so.21.1 libffi.so.8 libxml2.so.16
Size contribution on target:
- libLLVM.so.21.1 ≈ 75.5 MB
- libxml2.so.16 ≈ 1.2 MB
- libffi.so.8 ≈ 42.5 KB
When LLVM is only used by Rust, this results in a net image increase of approximately 15–16 MB.