Fix Version/s: 13
Compatibility Risk Description: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.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
Add a new
--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
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.
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.
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
--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-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.