Emitting build-id when linking ELF binaries

As a point of comparison, gcc has a configure-time build option --enable-linker-build-id which makes it pass --build-id to all linker invocations. I don't know how to find out how widespread this is in practice, but I suspect all major distros enable this since they're all using Build IDs for locating debug info.

I'm curious about the results from the original post, however. Given the fact that rustc invokes the system C compiler as the linker for linux-gnu targets, if your distro's C compiler enables build ids by default then binaries produced by rustc should also have them. I tested this on my local system (Ubuntu 20.04, gcc 9.3.0) and it does result in binaries containing a build id.

2 Likes