Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8219257

Add --strip-native-debug-symbols jlink plugin

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Hide
      There is no risk for adding the new `--strip-native-debug-symbols` plugin. Integration with `--strip-debug` on platforms which support it changes the default behavior of that plugin. Currently Linux-only. Previously on Linux, `--strip-debug` stripped Java debug attributes only. After this change it would strip debug symbols from native libraries and executables as well.
      Show
      There is no risk for adding the new `--strip-native-debug-symbols` plugin. Integration with `--strip-debug` on platforms which support it changes the default behavior of that plugin. Currently Linux-only. Previously on Linux, `--strip-debug` stripped Java debug attributes only. After this change it would strip debug symbols from native libraries and executables as well.
    • Interface Kind:
      add/remove/modify command line option
    • Scope:
      JDK

      Description

      Summary

      Add a new jlink option --strip-native-debug-symbols so as to be able to strip native debug symbols from executables and shared libraries. The intention would be to also integrate this with the existing --strip-debug option.

      Problem

      Currently it's not possible to get debug symbols stripped from native libraries and executables. While this is most visible when creating custom JDK images from a build configured with --with-native-debug-symbols=internal, it's also conceivable that third-party Java module developers would want to compile their native libraries with full debug symbols. Then in a later step, a custom image could get packaged in two ways. Once with debug information available, a second time without debug symbols for reduced file size. The proposed new --strip-native-debug-symbols option allows for this.

      Solution

      Implement a new jlink Linux-only plugin available via --strip-native-debug-symbols. In addition, the new native library stripping plugin would integrate with the existing --strip-debug option so as to also strip native debug symbols from binaries and shared libraries (where available).

      Additional motivation for adding such an option is available in the bug for this CSR.

      Specification

      The jlink --list-plugins output for the proposed new --strip-native-debug-symbols would look like this:

      Plugin Name: strip-native-debug-symbols
      Option: --strip-native-debug-symbols=<exclude-debuginfo-files|keep-debuginfo-files|objcopy=/path/to/objcopy>
      Description: Strip debug symbols from native libraries (if any).
       This plugin requires at least one option:
         objcopy: The path to the objcopy binary. Defaults to objcopy in PATH.
         exclude-debuginfo-files: Exclude debug info files. Defaults to true.
         keep-debuginfo-files[=<ext>]: Keep debug info files in <file>.<ext>.
                                      Defaults to <file>.debuginfo
       Examples: --strip-native-debug-symbols keep-debuginfo-files:objcopy=/usr/bin/objcopy
                 --strip-native-debug-symbols=exclude-debuginfo-files

      If both --strip-debug and --strip-native-debug-symbols are specified on available platforms when creating an image, the command will fail. Example:

      $ jlink --add-modules java.base --strip-native-debug-symbols keep-debuginfo-files --strip-debug --output jdk-image
      Error: --strip-debug (-G) conflicts with --strip-native-debug-symbols. Please use one or the other, but not both.

      This is to avoid potentially conflicting configurations: --strip-debug invokes --strip-native-debug-symbols with parameter exclude-debuginfo-files and another explicit invocation of --strip-native-debug-symbols might specify keep-debuginfo-symbols. A conflicting combination.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sgehwolf Severin Gehwolf
              Reporter:
              sgehwolf Severin Gehwolf
              Reviewed By:
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: