Tue, 17 Jul 2018 12:55:54 +0200
8036003: Add --with-native-debug-symbols=[none|internal|external|zipped]
Reviewed-by: erikj
1.1 --- a/common/autoconf/jdk-options.m4 Mon Jul 16 15:37:08 2018 +0100 1.2 +++ b/common/autoconf/jdk-options.m4 Tue Jul 17 12:55:54 2018 +0200 1.3 @@ -556,6 +556,9 @@ 1.4 1.5 AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], 1.6 [ 1.7 + # Backwards compatibility. --with-native-debug-symbols is preferred post JDK-8207234, 1.8 + # but if somebody does not specify it via configure, we still want to preserve old 1.9 + # behaviour of --disable-debug-symbols 1.10 # 1.11 # ENABLE_DEBUG_SYMBOLS 1.12 # This must be done after the toolchain is setup, since we're looking at objcopy. 1.13 @@ -589,6 +592,9 @@ 1.14 1.15 AC_MSG_RESULT([$ENABLE_DEBUG_SYMBOLS]) 1.16 1.17 + # Backwards compatibility. --with-native-debug-symbols is preferred post JDK-8207234, 1.18 + # but if somebody does not specify it via configure, we still want to preserve old 1.19 + # behaviour of --disable-zip-debug-info. 1.20 # 1.21 # ZIP_DEBUGINFO_FILES 1.22 # 1.23 @@ -600,11 +606,88 @@ 1.24 1.25 if test "x${enable_zip_debug_info}" = "xno"; then 1.26 ZIP_DEBUGINFO_FILES=false 1.27 - else 1.28 + elif test "x${enable_zip_debug_info}" = "xyes"; then 1.29 ZIP_DEBUGINFO_FILES=true 1.30 fi 1.31 1.32 + # 1.33 + # NATIVE_DEBUG_SYMBOLS 1.34 + # This must be done after the toolchain is setup, since we're looking at objcopy. 1.35 + # In addition, this must be done after ENABLE_DEBUG_SYMBOLS and ZIP_DEBUGINFO_FILES 1.36 + # checking in order to preserve backwards compatibility post JDK-8207234. 1.37 + # 1.38 + AC_MSG_CHECKING([what type of native debug symbols to use (this will override previous settings)]) 1.39 + AC_ARG_WITH([native-debug-symbols], 1.40 + [AS_HELP_STRING([--with-native-debug-symbols], 1.41 + [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])], 1.42 + [ 1.43 + if test "x$OPENJDK_TARGET_OS" = xaix; then 1.44 + if test "x$with_native_debug_symbols" = xexternal || test "x$with_native_debug_symbols" = xzipped; then 1.45 + AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols]) 1.46 + fi 1.47 + fi 1.48 + ], 1.49 + [ 1.50 + # Default to unset for backwards compatibility 1.51 + with_native_debug_symbols="" 1.52 + ]) 1.53 + NATIVE_DEBUG_SYMBOLS=$with_native_debug_symbols 1.54 + if test "x$NATIVE_DEBUG_SYMBOLS" = x; then 1.55 + AC_MSG_RESULT([not specified]) 1.56 + else 1.57 + AC_MSG_RESULT([$NATIVE_DEBUG_SYMBOLS]) 1.58 + fi 1.59 + # Default is empty 1.60 + DEBUG_BINARIES= 1.61 + # Default is min_strip. Possible values are min_strip, all_strip, no_strip 1.62 + STRIP_POLICY=min_strip 1.63 + 1.64 + if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then 1.65 + 1.66 + if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then 1.67 + if test "x$OBJCOPY" = x; then 1.68 + # enabling of enable-debug-symbols and can't find objcopy 1.69 + # this is an error 1.70 + AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 1.71 + fi 1.72 + fi 1.73 + 1.74 + ENABLE_DEBUG_SYMBOLS=true 1.75 + STRIP_POLICY=min_strip 1.76 + ZIP_DEBUGINFO_FILES=true 1.77 + elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then 1.78 + ENABLE_DEBUG_SYMBOLS=false 1.79 + STRIP_POLICY=min_strip 1.80 + ZIP_DEBUGINFO_FILES=false 1.81 + elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then 1.82 + ENABLE_DEBUG_SYMBOLS=true 1.83 + STRIP_POLICY=no_strip 1.84 + ZIP_DEBUGINFO_FILES=false 1.85 + POST_STRIP_CMD= 1.86 + DEBUG_BINARIES=true 1.87 + elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then 1.88 + 1.89 + if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then 1.90 + if test "x$OBJCOPY" = x; then 1.91 + # enabling of enable-debug-symbols and can't find objcopy 1.92 + # this is an error 1.93 + AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 1.94 + fi 1.95 + fi 1.96 + 1.97 + ENABLE_DEBUG_SYMBOLS=true 1.98 + STRIP_POLICY=min_strip 1.99 + ZIP_DEBUGINFO_FILES=false 1.100 + elif test "x$NATIVE_DEBUG_SYMBOLS" != x; then 1.101 + AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) 1.102 + else 1.103 + AC_MSG_NOTICE([--with-native-debug-symbols not specified. Using values from --disable-debug-symbols and --disable-zip-debug-info]) 1.104 + fi 1.105 + 1.106 AC_SUBST(ENABLE_DEBUG_SYMBOLS) 1.107 + AC_SUBST(STRIP_POLICY) 1.108 + AC_SUBST(POST_STRIP_CMD) 1.109 + AC_SUBST(DEBUG_BINARIES) 1.110 AC_SUBST(ZIP_DEBUGINFO_FILES) 1.111 ]) 1.112
2.1 --- a/common/autoconf/spec.gmk.in Mon Jul 16 15:37:08 2018 +0100 2.2 +++ b/common/autoconf/spec.gmk.in Tue Jul 17 12:55:54 2018 +0200 2.3 @@ -416,6 +416,8 @@ 2.4 CFLAGS_DEBUG_SYMBOLS:=@CFLAGS_DEBUG_SYMBOLS@ 2.5 CXXFLAGS_DEBUG_SYMBOLS:=@CXXFLAGS_DEBUG_SYMBOLS@ 2.6 ZIP_DEBUGINFO_FILES:=@ZIP_DEBUGINFO_FILES@ 2.7 +STRIP_POLICY:=@STRIP_POLICY@ 2.8 +DEBUG_BINARIES:=@DEBUG_BINARIES@ 2.9 2.10 # 2.11 # Compress (or not) jars
3.1 --- a/make/common/NativeCompilation.gmk Mon Jul 16 15:37:08 2018 +0100 3.2 +++ b/make/common/NativeCompilation.gmk Tue Jul 17 12:55:54 2018 +0200 3.3 @@ -260,6 +260,10 @@ 3.4 $1_CC:=$(CC) 3.5 endif 3.6 3.7 + ifeq ($$($1_STRIP_POLICY),) 3.8 + $1_STRIP_POLICY:=$$(STRIP_POLICY) 3.9 + endif 3.10 + 3.11 # Make sure the dirs exist. 3.12 $$(eval $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))) 3.13 $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d))) 3.14 @@ -455,28 +459,34 @@ 3.15 ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X 3.16 ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows 3.17 ifeq ($(OPENJDK_TARGET_OS), solaris) 3.18 - # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 3.19 - # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 3.20 - # empty section headers until a fixed $(OBJCOPY) is available. 3.21 - # An empty section header has sh_addr == 0 and sh_size == 0. 3.22 - # This problem has only been seen on Solaris X64, but we call this tool 3.23 - # on all Solaris builds just in case. 3.24 - # 3.25 - # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 3.26 - # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 3.27 - $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ 3.28 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.29 + # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 3.30 + # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 3.31 + # empty section headers until a fixed $(OBJCOPY) is available. 3.32 + # An empty section header has sh_addr == 0 and sh_size == 0. 3.33 + # This problem has only been seen on Solaris X64, but we call this tool 3.34 + # on all Solaris builds just in case. 3.35 + # 3.36 + # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 3.37 + # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 3.38 + $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ 3.39 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) 3.40 $(RM) $$@ 3.41 $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< 3.42 $(OBJCOPY) --only-keep-debug $$< $$@ 3.43 $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< 3.44 + endif 3.45 else # not solaris 3.46 - $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) 3.47 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.48 + $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) 3.49 $(RM) $$@ 3.50 $(OBJCOPY) --only-keep-debug $$< $$@ 3.51 $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< 3.52 + endif 3.53 endif # Touch to not retrigger rule on rebuild 3.54 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.55 $(TOUCH) $$@ 3.56 + endif 3.57 endif # !windows 3.58 endif # !macosx 3.59 3.60 @@ -500,7 +510,9 @@ 3.61 $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \ 3.62 $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb 3.63 else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files 3.64 - $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo 3.65 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.66 + $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo 3.67 + endif 3.68 endif 3.69 endif 3.70 endif 3.71 @@ -539,28 +551,34 @@ 3.72 ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X 3.73 ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows 3.74 ifeq ($(OPENJDK_TARGET_OS), solaris) 3.75 - # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 3.76 - # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 3.77 - # empty section headers until a fixed $(OBJCOPY) is available. 3.78 - # An empty section header has sh_addr == 0 and sh_size == 0. 3.79 - # This problem has only been seen on Solaris X64, but we call this tool 3.80 - # on all Solaris builds just in case. 3.81 - # 3.82 - # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 3.83 - # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 3.84 - $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ 3.85 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.86 + # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. 3.87 + # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from 3.88 + # empty section headers until a fixed $(OBJCOPY) is available. 3.89 + # An empty section header has sh_addr == 0 and sh_size == 0. 3.90 + # This problem has only been seen on Solaris X64, but we call this tool 3.91 + # on all Solaris builds just in case. 3.92 + # 3.93 + # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. 3.94 + # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. 3.95 + $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ 3.96 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) 3.97 $(RM) $$@ 3.98 $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< 3.99 $(OBJCOPY) --only-keep-debug $$< $$@ 3.100 $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< 3.101 + endif 3.102 else # not solaris 3.103 - $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) 3.104 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.105 + $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) 3.106 $(RM) $$@ 3.107 $(OBJCOPY) --only-keep-debug $$< $$@ 3.108 $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< 3.109 + endif 3.110 endif 3.111 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.112 $(TOUCH) $$@ 3.113 + endif 3.114 endif # !windows 3.115 endif # !macosx 3.116 3.117 @@ -584,7 +602,9 @@ 3.118 $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \ 3.119 $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb 3.120 else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files 3.121 - $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo 3.122 + ifneq ($$($1_STRIP_POLICY), no_strip) 3.123 + $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo 3.124 + endif 3.125 endif 3.126 endif 3.127 endif