8148655: LOG=cmdlines and other build-infra fixes
authorihse
Tue, 02 Feb 2016 15:02:55 +0100
changeset 35444 4d323e794486
parent 35443 d0ab5664b35a
child 35447 00f226dd004b
8148655: LOG=cmdlines and other build-infra fixes Reviewed-by: erikj
common/autoconf/basics.m4
common/autoconf/flags.m4
common/autoconf/generated-configure.sh
common/autoconf/jdk-version.m4
common/autoconf/spec.gmk.in
make/Init.gmk
make/InitSupport.gmk
make/common/JavaCompilation.gmk
make/common/MakeBase.gmk
make/common/NativeCompilation.gmk
--- a/common/autoconf/basics.m4	Mon Feb 01 10:07:35 2016 -0800
+++ b/common/autoconf/basics.m4	Tue Feb 02 15:02:55 2016 +0100
@@ -573,6 +573,11 @@
 
   # Locate the directory of this script.
   AUTOCONF_DIR=$TOPDIR/common/autoconf
+
+  # Setup username (for use in adhoc version strings etc)
+  # Outer [ ] to quote m4.
+  [ USERNAME=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ]
+  AC_SUBST(USERNAME)
 ])
 
 # Evaluates platform specific overrides for devkit variables.
--- a/common/autoconf/flags.m4	Mon Feb 01 10:07:35 2016 -0800
+++ b/common/autoconf/flags.m4	Tue Feb 02 15:02:55 2016 +0100
@@ -601,22 +601,22 @@
     esac
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
-	    if test "x$OPENJDK_TARGET_CPU" = xx86; then
-	      # Force compatibility with i586 on 32 bit intel platforms.
-	      COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
-	    fi
-	    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
-	        -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
-	    case $OPENJDK_TARGET_CPU_ARCH in
-	      ppc )
-	        # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
-	        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
-	        ;;
-	      * )
-	        COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
-	        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
-	        ;;
-	    esac
+      if test "x$OPENJDK_TARGET_CPU" = xx86; then
+        # Force compatibility with i586 on 32 bit intel platforms.
+        COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
+      fi
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
+          -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
+      case $OPENJDK_TARGET_CPU_ARCH in
+        ppc )
+          # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
+          CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
+          ;;
+        * )
+          COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
+          CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
+          ;;
+      esac
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
--- a/common/autoconf/generated-configure.sh	Mon Feb 01 10:07:35 2016 -0800
+++ b/common/autoconf/generated-configure.sh	Tue Feb 02 15:02:55 2016 +0100
@@ -917,6 +917,7 @@
 JVM_INTERPRETER
 JDK_VARIANT
 SET_OPENJDK
+USERNAME
 CANONICAL_TOPDIR
 ORIGINAL_TOPDIR
 TOPDIR
@@ -4835,7 +4836,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1454146111
+DATE_WHEN_GENERATED=1454421750
 
 ###############################################################################
 #
@@ -15652,6 +15653,11 @@
   # Locate the directory of this script.
   AUTOCONF_DIR=$TOPDIR/common/autoconf
 
+  # Setup username (for use in adhoc version strings etc)
+  # Outer [ ] to quote m4.
+   USERNAME=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'`
+
+
 
 # Check if it's a pure open build or if custom sources are to be used.
 
@@ -23429,9 +23435,8 @@
       # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
       timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
       # Outer [ ] to quote m4.
-       username=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'`
        basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'`
-      VERSION_OPT="$timestamp.$username.$basedirname"
+      VERSION_OPT="$timestamp.$USERNAME.$basedirname"
     fi
   fi
 
@@ -46441,22 +46446,22 @@
     esac
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
-	    if test "x$OPENJDK_TARGET_CPU" = xx86; then
-	      # Force compatibility with i586 on 32 bit intel platforms.
-	      COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
-	    fi
-	    COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
-	        -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
-	    case $OPENJDK_TARGET_CPU_ARCH in
-	      ppc )
-	        # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
-	        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
-	        ;;
-	      * )
-	        COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
-	        CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
-	        ;;
-	    esac
+      if test "x$OPENJDK_TARGET_CPU" = xx86; then
+        # Force compatibility with i586 on 32 bit intel platforms.
+        COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
+      fi
+      COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
+          -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
+      case $OPENJDK_TARGET_CPU_ARCH in
+        ppc )
+          # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
+          CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
+          ;;
+        * )
+          COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
+          CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
+          ;;
+      esac
     fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
--- a/common/autoconf/jdk-version.m4	Mon Feb 01 10:07:35 2016 -0800
+++ b/common/autoconf/jdk-version.m4	Tue Feb 02 15:02:55 2016 +0100
@@ -162,9 +162,8 @@
       # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
       timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
       # Outer [ ] to quote m4.
-      [ username=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ]
       [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ]
-      VERSION_OPT="$timestamp.$username.$basedirname"
+      VERSION_OPT="$timestamp.$USERNAME.$basedirname"
     fi
   fi
 
--- a/common/autoconf/spec.gmk.in	Mon Feb 01 10:07:35 2016 -0800
+++ b/common/autoconf/spec.gmk.in	Tue Feb 02 15:02:55 2016 +0100
@@ -184,6 +184,7 @@
 COMPANY_NAME:=@COMPANY_NAME@
 MACOSX_BUNDLE_NAME_BASE=@MACOSX_BUNDLE_NAME_BASE@
 MACOSX_BUNDLE_ID_BASE=@MACOSX_BUNDLE_ID_BASE@
+USERNAME:=@USERNAME@
 
 # Different naming strings generated from the above information.
 RUNTIME_NAME=$(PRODUCT_NAME) $(PRODUCT_SUFFIX)
--- a/make/Init.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/Init.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -168,7 +168,7 @@
 
     MAKE_INIT_WITH_SPEC_ARGUMENTS := ACTUAL_TOPDIR=$(topdir) \
         USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \
-        LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) \
+        LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) LOG_CMDLINES=$(LOG_CMDLINES) \
         INIT_TARGETS="$(INIT_TARGETS)" \
         SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
         PARALLEL_TARGETS="$(PARALLEL_TARGETS)"
--- a/make/InitSupport.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/InitSupport.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -121,6 +121,23 @@
     endif
   endef
 
+  # Look for a given option in the LOG variable, and if found, set a variable
+  # and remove the option from the LOG variable
+  # $1: The option to look for
+  # $2: The option to set to "true" if the option is found
+  define ParseLogOption
+    ifneq ($$(findstring $1, $$(LOG)),)
+      $2 := true
+      # COMMA is defined in spec.gmk, but that is not included yet
+      COMMA := ,
+      # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+      LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$(strip $1),, $$(LOG)))
+      # We might have ended up with a leading comma. Remove it. Need override
+      # since LOG is set from the command line.
+      override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+    endif
+  endef
+
   define ParseLogLevel
     # Catch old-style VERBOSE= command lines.
     ifneq ($$(origin VERBOSE), undefined)
@@ -131,17 +148,12 @@
     # Setup logging according to LOG
 
     # If the "nofile" argument is given, act on it and strip it away
-    ifneq ($$(findstring nofile, $$(LOG)),)
-      LOG_NOFILE := true
-      # COMMA is defined in spec.gmk, but that is not included yet
-      COMMA := ,
-      # First try to remove ",nofile" if it exists, otherwise just remove "nofile"
-      LOG_STRIPPED := $$(subst nofile,, $$(subst $$(COMMA)nofile,, $$(LOG)))
-      # We might have ended up with a leading comma. Remove it
-      LOG_LEVEL := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
-    else
-      LOG_LEVEL := $$(LOG)
-    endif
+    $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
+
+    # If the "cmdline" argument is given, act on it and strip it away
+    $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
+
+    LOG_LEVEL := $$(LOG)
 
     ifeq ($$(LOG_LEVEL),)
       # Set LOG to "warn" as default if not set
@@ -157,7 +169,9 @@
     else ifeq ($$(LOG_LEVEL), trace)
       MAKE_LOG_FLAGS :=
     else
-      $$(info Error: LOG must be one of: warn, info, debug or trace.)
+      $$(info Error: LOG contains unknown option or log level: $$(LOG).)
+      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines)
+      $$(info and <level> is warn | info | debug | trace)
       $$(error Cannot continue)
     endif
   endef
--- a/make/common/JavaCompilation.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/common/JavaCompilation.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -339,13 +339,13 @@
     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
 
     $$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
-	$(MKDIR) -p $$(@D) $$(dir $$($1_SJAVAC_PORTFILE))
+	$$(call MakeDir, $$(@D) $$(dir $$($1_SJAVAC_PORTFILE)))
 	$$(eval $$(call ListPathsSafely,$1_SRCS, $$@.tmp))
         ifneq ($$($1_SJAVAC_ARGS_FILE), )
 	  $$(eval $$(call ListPathsSafely,$1_SJAVAC_ARGS_STRING, $$($1_SJAVAC_ARGS_FILE)))
         endif
-	$(ECHO) Compiling $1
-	$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, $$($1_SAFE_NAME), \
+	$$(call LogWarn, Compiling $1)
+	$$(call ExecuteWithLog, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, \
 	    $$($1_JVM) $$($1_SJAVAC) \
 	        $$($1_REMOTE) \
 	        -j 1 \
@@ -406,10 +406,10 @@
 
     # When not using sjavac, pass along all sources to javac using an @file.
     $$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
-	$(MKDIR) -p $$(@D)
+	$$(call MakeDir, $$(@D))
 	$$(eval $$(call ListPathsSafely,$1_SRCS, $$@.tmp))
-	$(ECHO) Compiling `$(WC) $$@.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
-	$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, $$($1_SAFE_NAME), \
+	$$(call LogWarn, Compiling $$(words $$($1_SRCS)) files for $1)
+	$$(call ExecuteWithLog, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, \
 	    $$($1_JVM) $$($1_JAVAC_CMD) $$($1_FLAGS) \
 	        -implicit:none \
 		-d $$($1_BIN) $$($1_HEADERS_ARG) @$$@.tmp) && \
--- a/make/common/MakeBase.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/common/MakeBase.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -284,7 +284,8 @@
     WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL)
     SHELL := $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
   endif
-  # Never remove warning messages; this is just for completeness
+  # The warn level can never be turned off
+  LogWarn = $$(info $$(strip $$1))
   LOG_WARN :=
   ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
     LogInfo = $$(info $$(strip $$1))
@@ -372,7 +373,10 @@
 # Make directory without forking mkdir if not needed
 # 1: List of directories to create
 MakeDir = \
-    $(strip $(if $(wildcard $1), , $(shell $(MKDIR) -p $1)))
+    $(strip \
+        $(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, $(if $(wildcard $d), , $d)))) \
+        $(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
+    )
 
 ################################################################################
 # Assign a variable only if it is empty
@@ -678,22 +682,29 @@
 DependOnVariable = \
     $(call DependOnVariableHelper,$(strip $1),$(strip $2))
 
+# LogCmdlines is only intended to be used by ExecuteWithLog
+ifeq ($(LOG_CMDLINES), true)
+  LogCmdlines = $(info $(strip $1))
+else
+  LogCmdlines =
+endif
+
 ################################################################################
-# Failure logging support macros. These are supposed to be used by the Setup*
-# compilation macros.
+# ExecuteWithLog will run a command and log the output appropriately. This is
+# meant to be used by commands that do "real" work, like a compilation.
+# The output is stored in a specified log file, which is displayed at the end
+# of the build in case of failure. The  command line itself is stored in a file,
+# and also logged to stdout if the LOG=cmdlines option has been given.
 #
-# LogFailures will run a command and store a copy of output in a specified file.
-# If the command succeeds, the file is deleted, otherwise it is moved to the
-# failure-logs directory.
-# Param 1 - The base name of the log file / command line file
-# Param 2 - A compact but representative name to describe this command
-# Param 3 - Command to run
-LogFailures = \
-  ( $(ECHO) '$3' > $1.cmdline  && \
-      ( $3 > >($(TEE) $1.log) 2> >($(TEE) $1.log >&2) || \
-      (exitcode=$(DOLLAR)$(DOLLAR)? && \
-      $(CP) $1.log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && \
-      exit $(DOLLAR)$(DOLLAR)exitcode) ) )
+# Param 1 - The path to base the name of the log file / command line file on
+# Param 2 - The command to run
+ExecuteWithLog = \
+  $(call LogCmdlines, Exececuting: [$(strip $2)]) \
+  $(call WriteFile, $2, $(strip $1).cmdline) \
+  ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
+      ( exitcode=$(DOLLAR)? && \
+      $(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \
+      exit $(DOLLAR)exitcode ) )
 
 ################################################################################
 # Find lib dir for module
--- a/make/common/NativeCompilation.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/common/NativeCompilation.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -138,7 +138,7 @@
 ################################################################################
 
 # Extensions of files handled by this macro.
-NATIVE_SOURCE_EXTENSIONS := %.s %.c %.cpp %.cc %.m %.mm
+NATIVE_SOURCE_EXTENSIONS := %.s %.S %.c %.cpp %.cc %.m %.mm
 
 # Replaces native source extensions with the object file extension in a string.
 # Param 1: the string containing source file names with extensions
@@ -198,7 +198,7 @@
     $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
     $1_$2_COMP=$5
     $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
-  else ifneq (,$$(filter %.s,$2))
+  else ifneq (,$$(filter %.s %.S,$2))
     # Compile as assembler file
     $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"'
     $1_$2_COMP=$(AS)
@@ -217,7 +217,7 @@
   # source file override any other with the same name.
   ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR)))
     $1_OBJS_SO_FAR+=$$($1_$2_OBJ)
-    ifeq (,$$(filter %.s,$2))
+    ifeq (,$$(filter %.s %.S,$2))
       # And this is the dependency file for this obj file.
       $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
       # The dependency target file lists all dependencies as empty targets
@@ -246,11 +246,11 @@
           ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio)
             # The Solaris studio compiler doesn't output the full path to the object file in the
             # generated deps files. Fixing it with sed. If compiling assembly, don't try this.
-	    $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \
+	    $$(call ExecuteWithLog, $$@, \
 	        $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP).tmp $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
 	    $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
           else
-	    $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \
+	    $$(call ExecuteWithLog, $$@, \
 	        $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
           endif
           # Create a dependency target file from the dependency file.
@@ -265,7 +265,7 @@
           # Keep as much as possible on one execution line for best performance on Windows.
           # No need to save exit code from compilation since pipefail is always active on
           # Windows.
-	  $(call LogFailures, $$($1_$2_OBJ), $$($1_SAFE_NAME)_$$(notdir $2), \
+	  $$(call ExecuteWithLog, $$@, \
 	      $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \
 	          $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \
 	      | $(GREP) -v -e "^Note: including file:" \
@@ -315,6 +315,7 @@
 #   DISABLED_WARNINGS_CXX_<toolchain> Disable the given warnings for the specified
 #       toolchain when compiling C++ code
 #   STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it
+#   DEBUG_SYMBOLS Set to false to disable generation of debug symbols
 #   STRIPFLAGS Optionally change the flags given to the strip command
 SetupNativeCompilation = $(NamedParamsMacroTemplate)
 define SetupNativeCompilationBody
@@ -679,66 +680,68 @@
 
   # Need to make sure TARGET is first on list
   $1 := $$($1_TARGET)
-  
-  ifeq ($(COPY_DEBUG_SYMBOLS), true)
-    # Only copy debug symbols for dynamic libraries and programs.
-    ifeq ($$($1_STATIC_LIBRARY), )
-      ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
-        # The dependency on TARGET is needed on windows for debuginfo files
-        # to be rebuilt properly.
-        $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
-		$(CP) $$< $$@
-      endif
 
-      # Generate debuginfo files.
-      ifeq ($(OPENJDK_TARGET_OS), windows)
-        $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
-            "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
-        $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
-            $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
-        # No separate command is needed for debuginfo on windows, instead
-        # touch target to make sure it has a later time stamp than the debug
-        # symbol files to avoid unnecessary relinking on rebuild.
-        $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
+  ifeq ($(COPY_DEBUG_SYMBOLS), true)
+    ifneq ($$($1_DEBUG_SYMBOLS), false)
+      # Only copy debug symbols for dynamic libraries and programs.
+      ifeq ($$($1_STATIC_LIBRARY), )
+        ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
+          # The dependency on TARGET is needed on windows for debuginfo files
+          # to be rebuilt properly.
+          $$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
+		$(CP) $$< $$@
+        endif
+
+        # Generate debuginfo files.
+        ifeq ($(OPENJDK_TARGET_OS), windows)
+          $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
+              "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
+          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
+              $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
+          # No separate command is needed for debuginfo on windows, instead
+          # touch target to make sure it has a later time stamp than the debug
+          # symbol files to avoid unnecessary relinking on rebuild.
+          $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
 
-      else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
-        $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
-        # Setup the command line creating debuginfo files, to be run after linking.
-        # It cannot be run separately since it updates the original target file
-        $1_CREATE_DEBUGINFO_CMDS := \
-            $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
-            $(CD) $$($1_OUTPUT_DIR) && \
-                $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
+        else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
+          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
+          # Setup the command line creating debuginfo files, to be run after linking.
+          # It cannot be run separately since it updates the original target file
+          $1_CREATE_DEBUGINFO_CMDS := \
+              $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+              $(CD) $$($1_OUTPUT_DIR) && \
+                  $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 
-      else ifeq ($(OPENJDK_TARGET_OS), macosx)
-        $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
-        # On Macosx, the debuginfo generation doesn't touch the linked binary, but
-        # to avoid always relinking, touch it anyway to force a later timestamp than
-        # the dSYM files.
-        $1_CREATE_DEBUGINFO_CMDS := \
-            $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
-            $(TOUCH) $$($1_TARGET)
-      endif # OPENJDK_TARGET_OS
+        else ifeq ($(OPENJDK_TARGET_OS), macosx)
+          $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
+          # On Macosx, the debuginfo generation doesn't touch the linked binary, but
+          # to avoid always relinking, touch it anyway to force a later timestamp than
+          # the dSYM files.
+          $1_CREATE_DEBUGINFO_CMDS := \
+              $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
+              $(TOUCH) $$($1_TARGET)
+        endif # OPENJDK_TARGET_OS
 
-      # This dependency dance ensures that debug info files get rebuilt
-      # properly if deleted.
-      $$($1_TARGET): $$($1_DEBUGINFO_FILES)
-      $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
+        # This dependency dance ensures that debug info files get rebuilt
+        # properly if deleted.
+        $$($1_TARGET): $$($1_DEBUGINFO_FILES)
+        $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
 
-      ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
-        $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
-        $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
+        ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
+          $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
+          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
 
-        # The dependency on TARGET is needed for debuginfo files
-        # to be rebuilt properly.
-        $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
+          # The dependency on TARGET is needed for debuginfo files
+          # to be rebuilt properly.
+          $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
 		$(CD) $$($1_OBJECT_DIR) \
 		&& $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
 
-      else
-        $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
-      endif
-    endif # !STATIC_LIBRARY
+        else
+          $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
+        endif
+      endif # !STATIC_LIBRARY
+    endif # $1_DEBUG_SYMBOLS != false
   endif # COPY_DEBUG_SYMBOLS
 
   ifeq ($$($1_STRIP_SYMBOLS), true)
@@ -786,7 +789,7 @@
                 # on Windows
 		$$(call LogInfo, Linking $$($1_BASENAME))
                 ifeq ($(OPENJDK_TARGET_OS), windows)
-		  $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \
+		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
 		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
 		      $$($1_EXTRA_LIBS)) \
@@ -795,7 +798,7 @@
 		  $$($1_CREATE_DEBUGINFO_CMDS)
 		  $$($1_STRIP_CMD)
                 else
-		  $(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \
+		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
 		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
 		      $$($1_EXTRA_LIBS)) ; \
@@ -814,7 +817,7 @@
     # Generating a static library, ie object file archive.
     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE)
 	$$(call LogInfo, Archiving $$($1_STATIC_LIBRARY))
-	$(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \
+	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 	    $$($1_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
 	        $$($1_RES))
         ifeq ($(STATIC_BUILD), true)
@@ -836,7 +839,7 @@
     $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
         $$($1_VARDEPS_FILE)
 		$$(call LogInfo, Linking executable $$($1_BASENAME))
-		$(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, $$($1_SAFE_NAME)_link, \
+		$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 		    $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
 		        $(EXE_OUT_OPTION)$$($1_TARGET) \
 		        $$($1_ALL_OBJS) $$($1_RES) \