# HG changeset patch # User sgehwolf # Date 1531824954 -7200 # Node ID 19e8754f5415cdda79904b9f21a4b8981505cb78 # Parent 1380ce862bbd0b65c619bfcea454d612b240e332 8036003: Add --with-native-debug-symbols=[none|internal|external|zipped] Reviewed-by: erikj diff -r 1380ce862bbd -r 19e8754f5415 common/autoconf/jdk-options.m4 --- openjdk/common/autoconf/jdk-options.m4 Mon Jul 16 15:37:08 2018 +0100 +++ openjdk/common/autoconf/jdk-options.m4 Tue Jul 17 12:55:54 2018 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -606,11 +606,88 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], if test "x${enable_zip_debug_info}" = "xno"; then ZIP_DEBUGINFO_FILES=false + 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) AC_SUBST(CFLAGS_DEBUG_SYMBOLS) AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS) diff -r 1380ce862bbd -r 19e8754f5415 common/autoconf/spec.gmk.in --- openjdk/common/autoconf/spec.gmk.in Mon Jul 16 15:37:08 2018 +0100 +++ openjdk/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 diff -r 1380ce862bbd -r 19e8754f5415 make/common/NativeCompilation.gmk --- openjdk/make/common/NativeCompilation.gmk Mon Jul 16 15:37:08 2018 +0100 +++ openjdk/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