[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

Nico Weber via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 8 12:24:40 PDT 2019

thakis added a comment.

Hello, in a bit of a https://xkcd.com/1172/ moment this breaks the chromium/android build. We have a list of "resources" (strings, bitmaps, etc) that we list in an XML file which then generates a header with lots of "IDR_foo" constants. As it turns out, now all of these resources are used on all platforms, so we use the following technique to only keep the ones actually used on android:

- Have an empty template function `template<int N> Whitelist() {}`
- Have the resource header expand IDR_foo to `(Whitelist<unique_id_per_resource>(), unique_id_per_resource)` where `unique_id_per_resource` is something like 123 (and different for every resource)
- For every IDR_foo referenced in a cc file, this generates debug info for the function call `Whitelist<unique_id_per_resource>()`

We then look at `'readelf', '-p', '.debug_str'` and grep for `WhitelistedResource<` and keep all resources whose ID is referenced from debug info.

Before this change, this worked great.

Now, resources that are referenced from functions that make it into the final binary get stripped. From the patch description, it sounds like maybe that shouldn't happen (can you confirm?), but in practice it does.

If this only stripped debug info for functions that don't make it into the final binary, this would be a great change for us though!




More information about the lldb-commits mailing list