3 ms·
A big part of why binaries are "big" is dynamic linking and external symbols. That Rust hello world is just hand-crafted to never be linkable to anything else
by mlyle 6y ago
A big part of why binaries are "big" is dynamic linking and external symbols.
That Rust hello world is just hand-crafted to never be linkable to anything else at runtime and invoke a system call with a buffer. This isn't really how we'd like to do most things.
- steveklabnik 6y agoInterestingly enough, I would say that dynamic linking makes binaries smaller, that code no longer lives in the binary, but another place instead.
- djeiasbsbo 6y agoI'm pretty sure that for the classic "Hello World" example that's not the case, because we can simply use the linux write system call. For example, an assembly program that just calls write and then exits is much smaller than even an unlinked version of it that uses printf, because the ELF binary doesn't need to contain information for the linker.
- steveklabnik 6y agoYes, on the very very very low end, this is the case, but generally, in more real programs, it's not. (The program I linked is an example of exactly what you're talking about)
- mlyle 6y agoSure. But there's a lot of overhead that comes with it, too.