8148655: LOG=cmdlines and other build-infra fixes

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2016-02-02 15:02:55 +01:00
parent 363f1b669a
commit 7553186482
10 changed files with 169 additions and 131 deletions

@ -573,6 +573,11 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
# Locate the directory of this script. # Locate the directory of this script.
AUTOCONF_DIR=$TOPDIR/common/autoconf 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. # Evaluates platform specific overrides for devkit variables.

@ -601,22 +601,22 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
esac esac
elif test "x$TOOLCHAIN_TYPE" = xclang; then elif test "x$TOOLCHAIN_TYPE" = xclang; then
if test "x$OPENJDK_TARGET_OS" = xlinux; then if test "x$OPENJDK_TARGET_OS" = xlinux; then
if test "x$OPENJDK_TARGET_CPU" = xx86; then if test "x$OPENJDK_TARGET_CPU" = xx86; then
# Force compatibility with i586 on 32 bit intel platforms. # Force compatibility with i586 on 32 bit intel platforms.
COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586" COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
fi fi
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ 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" -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
case $OPENJDK_TARGET_CPU_ARCH in case $OPENJDK_TARGET_CPU_ARCH in
ppc ) ppc )
# on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;; ;;
* ) * )
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;; ;;
esac esac
fi fi
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"

@ -917,6 +917,7 @@ JVM_VARIANTS
JVM_INTERPRETER JVM_INTERPRETER
JDK_VARIANT JDK_VARIANT
SET_OPENJDK SET_OPENJDK
USERNAME
CANONICAL_TOPDIR CANONICAL_TOPDIR
ORIGINAL_TOPDIR ORIGINAL_TOPDIR
TOPDIR TOPDIR
@ -4835,7 +4836,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE #CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks: # 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 @@ $as_echo "$as_me: The path of TOPDIR, which resolves as \"$path\", is invalid."
# Locate the directory of this script. # Locate the directory of this script.
AUTOCONF_DIR=$TOPDIR/common/autoconf 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. # Check if it's a pure open build or if custom sources are to be used.
@ -23429,9 +23435,8 @@ $as_echo "$as_me: WARNING: --with-version-opt value has been sanitized from '$wi
# Default is to calculate a string like this <timestamp>.<username>.<base dir name> # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
timestamp=`$DATE '+%Y-%m-%d-%H%M%S'` timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
# Outer [ ] to quote m4. # 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].-'` basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'`
VERSION_OPT="$timestamp.$username.$basedirname" VERSION_OPT="$timestamp.$USERNAME.$basedirname"
fi fi
fi fi
@ -46441,22 +46446,22 @@ $as_echo "$supports" >&6; }
esac esac
elif test "x$TOOLCHAIN_TYPE" = xclang; then elif test "x$TOOLCHAIN_TYPE" = xclang; then
if test "x$OPENJDK_TARGET_OS" = xlinux; then if test "x$OPENJDK_TARGET_OS" = xlinux; then
if test "x$OPENJDK_TARGET_CPU" = xx86; then if test "x$OPENJDK_TARGET_CPU" = xx86; then
# Force compatibility with i586 on 32 bit intel platforms. # Force compatibility with i586 on 32 bit intel platforms.
COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586" COMMON_CCXXFLAGS="${COMMON_CCXXFLAGS} -march=i586"
fi fi
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ 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" -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
case $OPENJDK_TARGET_CPU_ARCH in case $OPENJDK_TARGET_CPU_ARCH in
ppc ) ppc )
# on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;; ;;
* ) * )
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;; ;;
esac esac
fi fi
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"

@ -162,9 +162,8 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
# Default is to calculate a string like this <timestamp>.<username>.<base dir name> # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
timestamp=`$DATE '+%Y-%m-%d-%H%M%S'` timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
# Outer [ ] to quote m4. # 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].-'` ] [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ]
VERSION_OPT="$timestamp.$username.$basedirname" VERSION_OPT="$timestamp.$USERNAME.$basedirname"
fi fi
fi fi

@ -184,6 +184,7 @@ JDK_RC_PLATFORM_NAME:=@JDK_RC_PLATFORM_NAME@
COMPANY_NAME:=@COMPANY_NAME@ COMPANY_NAME:=@COMPANY_NAME@
MACOSX_BUNDLE_NAME_BASE=@MACOSX_BUNDLE_NAME_BASE@ MACOSX_BUNDLE_NAME_BASE=@MACOSX_BUNDLE_NAME_BASE@
MACOSX_BUNDLE_ID_BASE=@MACOSX_BUNDLE_ID_BASE@ MACOSX_BUNDLE_ID_BASE=@MACOSX_BUNDLE_ID_BASE@
USERNAME:=@USERNAME@
# Different naming strings generated from the above information. # Different naming strings generated from the above information.
RUNTIME_NAME=$(PRODUCT_NAME) $(PRODUCT_SUFFIX) RUNTIME_NAME=$(PRODUCT_NAME) $(PRODUCT_SUFFIX)

@ -168,7 +168,7 @@ ifeq ($(HAS_SPEC),)
MAKE_INIT_WITH_SPEC_ARGUMENTS := ACTUAL_TOPDIR=$(topdir) \ MAKE_INIT_WITH_SPEC_ARGUMENTS := ACTUAL_TOPDIR=$(topdir) \
USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \ 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)" \ INIT_TARGETS="$(INIT_TARGETS)" \
SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \ SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
PARALLEL_TARGETS="$(PARALLEL_TARGETS)" PARALLEL_TARGETS="$(PARALLEL_TARGETS)"

@ -121,6 +121,23 @@ ifeq ($(HAS_SPEC),)
endif endif
endef 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 define ParseLogLevel
# Catch old-style VERBOSE= command lines. # Catch old-style VERBOSE= command lines.
ifneq ($$(origin VERBOSE), undefined) ifneq ($$(origin VERBOSE), undefined)
@ -131,17 +148,12 @@ ifeq ($(HAS_SPEC),)
# Setup logging according to LOG # Setup logging according to LOG
# If the "nofile" argument is given, act on it and strip it away # If the "nofile" argument is given, act on it and strip it away
ifneq ($$(findstring nofile, $$(LOG)),) $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
LOG_NOFILE := true
# COMMA is defined in spec.gmk, but that is not included yet # If the "cmdline" argument is given, act on it and strip it away
COMMA := , $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
# First try to remove ",nofile" if it exists, otherwise just remove "nofile"
LOG_STRIPPED := $$(subst nofile,, $$(subst $$(COMMA)nofile,, $$(LOG))) LOG_LEVEL := $$(LOG)
# We might have ended up with a leading comma. Remove it
LOG_LEVEL := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
else
LOG_LEVEL := $$(LOG)
endif
ifeq ($$(LOG_LEVEL),) ifeq ($$(LOG_LEVEL),)
# Set LOG to "warn" as default if not set # Set LOG to "warn" as default if not set
@ -157,7 +169,9 @@ ifeq ($(HAS_SPEC),)
else ifeq ($$(LOG_LEVEL), trace) else ifeq ($$(LOG_LEVEL), trace)
MAKE_LOG_FLAGS := MAKE_LOG_FLAGS :=
else 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) $$(error Cannot continue)
endif endif
endef endef

@ -339,13 +339,13 @@ define SetupJavaCompilationBody
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps) $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_BIN)/_the.$1.vardeps)
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE) $$($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)) $$(eval $$(call ListPathsSafely,$1_SRCS, $$@.tmp))
ifneq ($$($1_SJAVAC_ARGS_FILE), ) ifneq ($$($1_SJAVAC_ARGS_FILE), )
$$(eval $$(call ListPathsSafely,$1_SJAVAC_ARGS_STRING, $$($1_SJAVAC_ARGS_FILE))) $$(eval $$(call ListPathsSafely,$1_SJAVAC_ARGS_STRING, $$($1_SJAVAC_ARGS_FILE)))
endif endif
$(ECHO) Compiling $1 $$(call LogWarn, Compiling $1)
$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, $$($1_SAFE_NAME), \ $$(call ExecuteWithLog, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, \
$$($1_JVM) $$($1_SJAVAC) \ $$($1_JVM) $$($1_SJAVAC) \
$$($1_REMOTE) \ $$($1_REMOTE) \
-j 1 \ -j 1 \
@ -406,10 +406,10 @@ define SetupJavaCompilationBody
# When not using sjavac, pass along all sources to javac using an @file. # When not using sjavac, pass along all sources to javac using an @file.
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE) $$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
$(MKDIR) -p $$(@D) $$(call MakeDir, $$(@D))
$$(eval $$(call ListPathsSafely,$1_SRCS, $$@.tmp)) $$(eval $$(call ListPathsSafely,$1_SRCS, $$@.tmp))
$(ECHO) Compiling `$(WC) $$@.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1 $$(call LogWarn, Compiling $$(words $$($1_SRCS)) files for $1)
$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, $$($1_SAFE_NAME), \ $$(call ExecuteWithLog, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch, \
$$($1_JVM) $$($1_JAVAC_CMD) $$($1_FLAGS) \ $$($1_JVM) $$($1_JAVAC_CMD) $$($1_FLAGS) \
-implicit:none \ -implicit:none \
-d $$($1_BIN) $$($1_HEADERS_ARG) @$$@.tmp) && \ -d $$($1_BIN) $$($1_HEADERS_ARG) @$$@.tmp) && \

@ -284,7 +284,8 @@ define SetupLogging
WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL) 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) 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 endif
# Never remove warning messages; this is just for completeness # The warn level can never be turned off
LogWarn = $$(info $$(strip $$1))
LOG_WARN := LOG_WARN :=
ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),) ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
LogInfo = $$(info $$(strip $$1)) LogInfo = $$(info $$(strip $$1))
@ -372,7 +373,10 @@ endef
# Make directory without forking mkdir if not needed # Make directory without forking mkdir if not needed
# 1: List of directories to create # 1: List of directories to create
MakeDir = \ 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 # Assign a variable only if it is empty
@ -678,22 +682,29 @@ DependOnVariableHelper = \
DependOnVariable = \ DependOnVariable = \
$(call DependOnVariableHelper,$(strip $1),$(strip $2)) $(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* # ExecuteWithLog will run a command and log the output appropriately. This is
# compilation macros. # 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. # Param 1 - The path to base the name of the log file / command line file on
# If the command succeeds, the file is deleted, otherwise it is moved to the # Param 2 - The command to run
# failure-logs directory. ExecuteWithLog = \
# Param 1 - The base name of the log file / command line file $(call LogCmdlines, Exececuting: [$(strip $2)]) \
# Param 2 - A compact but representative name to describe this command $(call WriteFile, $2, $(strip $1).cmdline) \
# Param 3 - Command to run ( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
LogFailures = \ ( exitcode=$(DOLLAR)? && \
( $(ECHO) '$3' > $1.cmdline && \ $(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \
( $3 > >($(TEE) $1.log) 2> >($(TEE) $1.log >&2) || \ exit $(DOLLAR)exitcode ) )
(exitcode=$(DOLLAR)$(DOLLAR)? && \
$(CP) $1.log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && \
exit $(DOLLAR)$(DOLLAR)exitcode) ) )
################################################################################ ################################################################################
# Find lib dir for module # Find lib dir for module

@ -138,7 +138,7 @@ $(eval $(call DefineNativeToolchain, TOOLCHAIN_BUILD_LINK_CXX, \
################################################################################ ################################################################################
# Extensions of files handled by this macro. # 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. # Replaces native source extensions with the object file extension in a string.
# Param 1: the string containing source file names with extensions # Param 1: the string containing source file names with extensions
@ -198,7 +198,7 @@ define add_native_source
$1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
$1_$2_COMP=$5 $1_$2_COMP=$5
$1_$2_DEP_FLAG:=$(C_FLAG_DEPS) $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
else ifneq (,$$(filter %.s,$2)) else ifneq (,$$(filter %.s %.S,$2))
# Compile as assembler file # Compile as assembler file
$1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"' $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"'
$1_$2_COMP=$(AS) $1_$2_COMP=$(AS)
@ -217,7 +217,7 @@ define add_native_source
# source file override any other with the same name. # source file override any other with the same name.
ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR))) ifeq (,$$(findstring $$($1_$2_OBJ),$$($1_OBJS_SO_FAR)))
$1_OBJS_SO_FAR+=$$($1_$2_OBJ) $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. # And this is the dependency file for this obj file.
$1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ)) $1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
# The dependency target file lists all dependencies as empty targets # The dependency target file lists all dependencies as empty targets
@ -246,11 +246,11 @@ define add_native_source
ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio) ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s,$2), solstudio)
# The Solaris studio compiler doesn't output the full path to the object file in the # 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. # 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) $$($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) $(SED) 's|^$$(@F):|$$@:|' $$($1_$2_DEP).tmp > $$($1_$2_DEP)
else 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) $$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
endif endif
# Create a dependency target file from the dependency file. # Create a dependency target file from the dependency file.
@ -265,7 +265,7 @@ define add_native_source
# Keep as much as possible on one execution line for best performance on Windows. # 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 # No need to save exit code from compilation since pipefail is always active on
# Windows. # 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) \ $$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \
$(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \ $(CC_OUT_OPTION)$$($1_$2_OBJ) $2) \
| $(GREP) -v -e "^Note: including file:" \ | $(GREP) -v -e "^Note: including file:" \
@ -315,6 +315,7 @@ endef
# DISABLED_WARNINGS_CXX_<toolchain> Disable the given warnings for the specified # DISABLED_WARNINGS_CXX_<toolchain> Disable the given warnings for the specified
# toolchain when compiling C++ code # toolchain when compiling C++ code
# STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it # 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 # STRIPFLAGS Optionally change the flags given to the strip command
SetupNativeCompilation = $(NamedParamsMacroTemplate) SetupNativeCompilation = $(NamedParamsMacroTemplate)
define SetupNativeCompilationBody define SetupNativeCompilationBody
@ -679,66 +680,68 @@ define SetupNativeCompilationBody
# Need to make sure TARGET is first on list # Need to make sure TARGET is first on list
$1 := $$($1_TARGET) $1 := $$($1_TARGET)
ifeq ($(COPY_DEBUG_SYMBOLS), true) ifeq ($(COPY_DEBUG_SYMBOLS), true)
# Only copy debug symbols for dynamic libraries and programs. ifneq ($$($1_DEBUG_SYMBOLS), false)
ifeq ($$($1_STATIC_LIBRARY), ) # Only copy debug symbols for dynamic libraries and programs.
ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR)) ifeq ($$($1_STATIC_LIBRARY), )
# The dependency on TARGET is needed on windows for debuginfo files ifneq ($$($1_OUTPUT_DIR), $$($1_OBJECT_DIR))
# to be rebuilt properly. # The dependency on TARGET is needed on windows for debuginfo files
$$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET) # to be rebuilt properly.
$$($1_OUTPUT_DIR)/% : $$($1_OBJECT_DIR)/% $$($1_TARGET)
$(CP) $$< $$@ $(CP) $$< $$@
endif endif
# Generate debuginfo files. # Generate debuginfo files.
ifeq ($(OPENJDK_TARGET_OS), windows) ifeq ($(OPENJDK_TARGET_OS), windows)
$1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \ $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
"-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map" "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \ $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
# No separate command is needed for debuginfo on windows, instead # No separate command is needed for debuginfo on windows, instead
# touch target to make sure it has a later time stamp than the debug # touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild. # symbol files to avoid unnecessary relinking on rebuild.
$1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET) $1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
# Setup the command line creating debuginfo files, to be run after linking. # Setup the command line creating debuginfo files, to be run after linking.
# It cannot be run separately since it updates the original target file # It cannot be run separately since it updates the original target file
$1_CREATE_DEBUGINFO_CMDS := \ $1_CREATE_DEBUGINFO_CMDS := \
$(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \ $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
$(CD) $$($1_OUTPUT_DIR) && \ $(CD) $$($1_OUTPUT_DIR) && \
$(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET) $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
else ifeq ($(OPENJDK_TARGET_OS), macosx) else ifeq ($(OPENJDK_TARGET_OS), macosx)
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_BASENAME).dSYM
# On Macosx, the debuginfo generation doesn't touch the linked binary, but # 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 # to avoid always relinking, touch it anyway to force a later timestamp than
# the dSYM files. # the dSYM files.
$1_CREATE_DEBUGINFO_CMDS := \ $1_CREATE_DEBUGINFO_CMDS := \
$(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \ $(DSYMUTIL) --out $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$(NEWLINE) \
$(TOUCH) $$($1_TARGET) $(TOUCH) $$($1_TARGET)
endif # OPENJDK_TARGET_OS endif # OPENJDK_TARGET_OS
# This dependency dance ensures that debug info files get rebuilt # This dependency dance ensures that debug info files get rebuilt
# properly if deleted. # properly if deleted.
$$($1_TARGET): $$($1_DEBUGINFO_FILES) $$($1_TARGET): $$($1_DEBUGINFO_FILES)
$$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS) $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS)
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
$1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
$1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP)) $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
# The dependency on TARGET is needed for debuginfo files # The dependency on TARGET is needed for debuginfo files
# to be rebuilt properly. # to be rebuilt properly.
$$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET) $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
$(CD) $$($1_OBJECT_DIR) \ $(CD) $$($1_OBJECT_DIR) \
&& $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES)) && $(ZIP) -q -r $$@ $$(notdir $$($1_DEBUGINFO_FILES))
else else
$1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES)) $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_FILES))
endif endif
endif # !STATIC_LIBRARY endif # !STATIC_LIBRARY
endif # $1_DEBUG_SYMBOLS != false
endif # COPY_DEBUG_SYMBOLS endif # COPY_DEBUG_SYMBOLS
ifeq ($$($1_STRIP_SYMBOLS), true) ifeq ($$($1_STRIP_SYMBOLS), true)
@ -786,7 +789,7 @@ define SetupNativeCompilationBody
# on Windows # on Windows
$$(call LogInfo, Linking $$($1_BASENAME)) $$(call LogInfo, Linking $$($1_BASENAME))
ifeq ($(OPENJDK_TARGET_OS), windows) 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) \ $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
$(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
$$($1_EXTRA_LIBS)) \ $$($1_EXTRA_LIBS)) \
@ -795,7 +798,7 @@ define SetupNativeCompilationBody
$$($1_CREATE_DEBUGINFO_CMDS) $$($1_CREATE_DEBUGINFO_CMDS)
$$($1_STRIP_CMD) $$($1_STRIP_CMD)
else 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) \ $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
$(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \ $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
$$($1_EXTRA_LIBS)) ; \ $$($1_EXTRA_LIBS)) ; \
@ -814,7 +817,7 @@ define SetupNativeCompilationBody
# Generating a static library, ie object file archive. # Generating a static library, ie object file archive.
$$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE)
$$(call LogInfo, Archiving $$($1_STATIC_LIBRARY)) $$(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_AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \
$$($1_RES)) $$($1_RES))
ifeq ($(STATIC_BUILD), true) ifeq ($(STATIC_BUILD), true)
@ -836,7 +839,7 @@ define SetupNativeCompilationBody
$$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
$$($1_VARDEPS_FILE) $$($1_VARDEPS_FILE)
$$(call LogInfo, Linking executable $$($1_BASENAME)) $$(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) \ $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
$(EXE_OUT_OPTION)$$($1_TARGET) \ $(EXE_OUT_OPTION)$$($1_TARGET) \
$$($1_ALL_OBJS) $$($1_RES) \ $$($1_ALL_OBJS) $$($1_RES) \