[macOS] use dead_strip linker option to reduce binary size

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 26
    • Affects Version/s: 25, 26
    • Component/s: infrastructure
    • None
    • b27
    • aarch64
    • os_x

      The dead_strip linker option on macOS removes functions and data that are unreachable by the entry point or exported symbols.
      Setting it can reduce the size of some binaries we generate quite a lot, for example (product build, Xcode 15 is used) :
      (before -> after setting the option)
      1.4M -> 1.1M images/jdk/lib/libfontmanager.dylib
      264K -> 248K images/jdk/lib/libjavajpeg.dylib
      152K -> 132K images/jdk/lib/libjli.dylib
      388K -> 296K images/jdk/lib/liblcms.dylib
      164K -> 128K images/jdk/lib/libzip.dylib

      and libjvm :
      20M -> 18M images/jdk/lib/server/libjvm.dylib
      146M -> 137M images/jdk/lib/server/libjvm.dylib.dSYM

      Because libjvm contains 'dead' code that would be stripped, but is not really 'dead' but used in some scenarios (debuggers, serviceability agent), we limit the dead_strip linker option to jdk native libs.

            Assignee:
            Matthias Baesken
            Reporter:
            Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: