changeset 2205:19e8754f5415

8036003: Add --with-native-debug-symbols=[none|internal|external|zipped] Reviewed-by: erikj
author sgehwolf
date Tue, 17 Jul 2018 12:55:54 +0200
parents 1380ce862bbd
children 2560cb8631bf
files common/autoconf/jdk-options.m4 common/autoconf/spec.gmk.in make/common/NativeCompilation.gmk
diffstat 3 files changed, 130 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/jdk-options.m4	Mon Jul 16 15:37:08 2018 +0100
+++ b/common/autoconf/jdk-options.m4	Tue Jul 17 12:55:54 2018 +0200
@@ -556,6 +556,9 @@
 
 AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
 [
+  # Backwards compatibility. --with-native-debug-symbols is preferred post JDK-8207234,
+  # but if somebody does not specify it via configure, we still want to preserve old
+  # behaviour of --disable-debug-symbols
   #
   # ENABLE_DEBUG_SYMBOLS
   # This must be done after the toolchain is setup, since we're looking at objcopy.
@@ -589,6 +592,9 @@
 
   AC_MSG_RESULT([$ENABLE_DEBUG_SYMBOLS])
 
+  # Backwards compatibility. --with-native-debug-symbols is preferred post JDK-8207234,
+  # but if somebody does not specify it via configure, we still want to preserve old
+  # behaviour of --disable-zip-debug-info.
   #
   # ZIP_DEBUGINFO_FILES
   #
@@ -600,11 +606,88 @@
 
   if test "x${enable_zip_debug_info}" = "xno"; then
     ZIP_DEBUGINFO_FILES=false
-  else
+  elif test "x${enable_zip_debug_info}" = "xyes"; then
     ZIP_DEBUGINFO_FILES=true
   fi
 
+  #
+  # NATIVE_DEBUG_SYMBOLS
+  # This must be done after the toolchain is setup, since we're looking at objcopy.
+  # In addition, this must be done after ENABLE_DEBUG_SYMBOLS and ZIP_DEBUGINFO_FILES
+  # checking in order to preserve backwards compatibility post JDK-8207234.
+  #
+  AC_MSG_CHECKING([what type of native debug symbols to use (this will override previous settings)])
+  AC_ARG_WITH([native-debug-symbols],
+      [AS_HELP_STRING([--with-native-debug-symbols],
+      [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
+      [
+        if test "x$OPENJDK_TARGET_OS" = xaix; then
+          if test "x$with_native_debug_symbols" = xexternal || test "x$with_native_debug_symbols" = xzipped; then
+            AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols])
+          fi
+        fi
+      ],
+      [
+        # Default to unset for backwards compatibility
+        with_native_debug_symbols=""
+      ])
+  NATIVE_DEBUG_SYMBOLS=$with_native_debug_symbols
+  if test "x$NATIVE_DEBUG_SYMBOLS" = x; then
+    AC_MSG_RESULT([not specified])
+  else
+    AC_MSG_RESULT([$NATIVE_DEBUG_SYMBOLS])
+  fi
+  # Default is empty
+  DEBUG_BINARIES=
+  # Default is min_strip. Possible values are min_strip, all_strip, no_strip
+  STRIP_POLICY=min_strip
+
+  if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then
+
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+      if test "x$OBJCOPY" = x; then
+        # enabling of enable-debug-symbols and can't find objcopy
+        # this is an error
+        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
+      fi
+    fi
+
+    ENABLE_DEBUG_SYMBOLS=true
+    STRIP_POLICY=min_strip
+    ZIP_DEBUGINFO_FILES=true
+  elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then
+    ENABLE_DEBUG_SYMBOLS=false
+    STRIP_POLICY=min_strip
+    ZIP_DEBUGINFO_FILES=false
+  elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then
+    ENABLE_DEBUG_SYMBOLS=true
+    STRIP_POLICY=no_strip
+    ZIP_DEBUGINFO_FILES=false
+    POST_STRIP_CMD=
+    DEBUG_BINARIES=true
+  elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then
+
+    if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
+      if test "x$OBJCOPY" = x; then
+        # enabling of enable-debug-symbols and can't find objcopy
+        # this is an error
+        AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
+      fi
+    fi
+
+    ENABLE_DEBUG_SYMBOLS=true
+    STRIP_POLICY=min_strip
+    ZIP_DEBUGINFO_FILES=false
+  elif test "x$NATIVE_DEBUG_SYMBOLS" != x; then
+    AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
+  else
+    AC_MSG_NOTICE([--with-native-debug-symbols not specified. Using values from --disable-debug-symbols and --disable-zip-debug-info])
+  fi
+
   AC_SUBST(ENABLE_DEBUG_SYMBOLS)
+  AC_SUBST(STRIP_POLICY)
+  AC_SUBST(POST_STRIP_CMD)
+  AC_SUBST(DEBUG_BINARIES)
   AC_SUBST(ZIP_DEBUGINFO_FILES)
 ])
 
--- a/common/autoconf/spec.gmk.in	Mon Jul 16 15:37:08 2018 +0100
+++ b/common/autoconf/spec.gmk.in	Tue Jul 17 12:55:54 2018 +0200
@@ -416,6 +416,8 @@
 CFLAGS_DEBUG_SYMBOLS:=@CFLAGS_DEBUG_SYMBOLS@
 CXXFLAGS_DEBUG_SYMBOLS:=@CXXFLAGS_DEBUG_SYMBOLS@
 ZIP_DEBUGINFO_FILES:=@ZIP_DEBUGINFO_FILES@
+STRIP_POLICY:=@STRIP_POLICY@
+DEBUG_BINARIES:=@DEBUG_BINARIES@
 
 #
 # Compress (or not) jars
--- a/make/common/NativeCompilation.gmk	Mon Jul 16 15:37:08 2018 +0100
+++ b/make/common/NativeCompilation.gmk	Tue Jul 17 12:55:54 2018 +0200
@@ -260,6 +260,10 @@
     $1_CC:=$(CC)
   endif
 
+  ifeq ($$($1_STRIP_POLICY),)
+    $1_STRIP_POLICY:=$$(STRIP_POLICY)
+  endif
+
   # Make sure the dirs exist.
   $$(eval $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR)))
   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
@@ -455,28 +459,34 @@
         ifneq ($(OPENJDK_TARGET_OS), macosx)   # OBJCOPY is not used on MacOS X
           ifneq ($(OPENJDK_TARGET_OS), windows)  # nor on Windows
             ifeq ($(OPENJDK_TARGET_OS), solaris)
-              # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-              # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
-              # empty section headers until a fixed $(OBJCOPY) is available.
-              # An empty section header has sh_addr == 0 and sh_size == 0.
-              # This problem has only been seen on Solaris X64, but we call this tool
-              # on all Solaris builds just in case.
-              #
-              # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-              # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-              $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \
+              ifneq ($$($1_STRIP_POLICY), no_strip)
+                # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
+                # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
+                # empty section headers until a fixed $(OBJCOPY) is available.
+                # An empty section header has sh_addr == 0 and sh_size == 0.
+                # This problem has only been seen on Solaris X64, but we call this tool
+                # on all Solaris builds just in case.
+                #
+                # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
+                # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
+                $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \
 				$(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
 		$(RM) $$@
 		$(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$<
 		$(OBJCOPY) --only-keep-debug $$< $$@
 		$(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$<
+              endif
             else # not solaris
-              $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET)
+              ifneq ($$($1_STRIP_POLICY), no_strip)
+                $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET)
 		$(RM) $$@
 		$(OBJCOPY) --only-keep-debug $$< $$@
 		$(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$<
+              endif
             endif # Touch to not retrigger rule on rebuild
+            ifneq ($$($1_STRIP_POLICY), no_strip)
 		$(TOUCH) $$@
+            endif
           endif # !windows
         endif # !macosx
 
@@ -500,7 +510,9 @@
             $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \
                 $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb
           else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files
-            $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo
+            ifneq ($$($1_STRIP_POLICY), no_strip)
+              $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo
+            endif
           endif
         endif
       endif
@@ -539,28 +551,34 @@
         ifneq ($(OPENJDK_TARGET_OS), macosx)   # OBJCOPY is not used on MacOS X
           ifneq ($(OPENJDK_TARGET_OS), windows)  # nor on Windows
             ifeq ($(OPENJDK_TARGET_OS), solaris)
-              # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-              # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
-              # empty section headers until a fixed $(OBJCOPY) is available.
-              # An empty section header has sh_addr == 0 and sh_size == 0.
-              # This problem has only been seen on Solaris X64, but we call this tool
-              # on all Solaris builds just in case.
-              #
-              # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-              # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-              $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \
+              ifneq ($$($1_STRIP_POLICY), no_strip)
+                # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
+                # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
+                # empty section headers until a fixed $(OBJCOPY) is available.
+                # An empty section header has sh_addr == 0 and sh_size == 0.
+                # This problem has only been seen on Solaris X64, but we call this tool
+                # on all Solaris builds just in case.
+                #
+                # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
+                # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
+                $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \
 				$(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
 		$(RM) $$@
 		$(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$<
 		$(OBJCOPY) --only-keep-debug $$< $$@
 		$(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$<
+              endif
             else # not solaris
-              $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET)
+              ifneq ($$($1_STRIP_POLICY), no_strip)
+                $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET)
 		$(RM) $$@
 		$(OBJCOPY) --only-keep-debug $$< $$@
 		$(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$<
+              endif
             endif
+            ifneq ($$($1_STRIP_POLICY), no_strip)
 		$(TOUCH) $$@
+            endif
           endif # !windows
         endif # !macosx
 
@@ -584,7 +602,9 @@
             $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \
                 $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb
           else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files
-            $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo
+            ifneq ($$($1_STRIP_POLICY), no_strip)
+              $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo
+            endif
           endif
         endif
       endif