Why nominal type descriptors are always marked 'no dead strip'?

I found this thread while trying to figure out why virtual methods in a class are being pulled, even if the class itself is not being included.

I have a large library that I am trying to put on a diet [1], and one of the major sources of code bloat is that Swift is including classes into my final executable that are not referenced, and these classes end up bringing all of their open/virtual methods, which in turn cause the bloat.

I have a sample test case that exhibits the problem[2]

When attempting to track down the source for these symbols, I found that “lnominal type descriptor runtime record” is being flagged as ‘dont-dead-strip’, I have a trivial example in [2] where I am trying these assorted flags, with no luck.

This class that is unreferenced ends up being pulled like this via the linker why_live feature:

lnominal type descriptor runtime record for SimpleLibraryStrip.SUBCLASSABLE from SimpleLibrary.swift.o
  dont-dead-strip
lnominal type descriptor runtime record for SimpleLibraryStrip.SUBCLASSABLE from SimpleLibrary.swift.o
  lnominal type descriptor runtime record for SimpleLibraryStrip.SUBCLASSABLE from SimpleLibrary.swift.o

I am using the -internalize-at-link, -conditional-runtime-records and have tried both version of lto, llvm-full and llvm-thin

[1] How do I put my Swift libraries on a diet?

[2] GitHub - migueldeicaza/LinkSample: Attempt to figure out how to link code out in Swift

1 Like