diff --git a/make/TestImage.gmk b/make/TestImage.gmk index a1ba75b01b..8fd3a0c0ef 100644 --- a/make/TestImage.gmk +++ b/make/TestImage.gmk @@ -37,10 +37,22 @@ ifeq ($(call isTargetOs, windows), true) $(call install-file) endif -prepare-test-image: $(FIXPATH_COPY) +BUILD_INFO_PROPERTIES := $(TEST_IMAGE_DIR)/build-info.properties + +FIXPATH_ECHO := $(FIXPATH) $(call FixPath, $(ECHO)) + +$(BUILD_INFO_PROPERTIES): + $(call MakeTargetDir) + $(ECHO) "# Build info properties for JDK tests" > $@ + $(FIXPATH_ECHO) "build.workspace.root=$(WORKSPACE_ROOT)" >> $@ + $(FIXPATH_ECHO) "build.output.root=$(OUTPUTDIR)" >> $@ + +prepare-test-image: $(FIXPATH_COPY) $(BUILD_INFO_PROPERTIES) $(call MakeDir, $(TEST_IMAGE_DIR)) $(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image' +################################################################################ + all: prepare-test-image .PHONY: default all prepare-test-image diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4 index e1f1c08049..6075707a56 100644 --- a/make/autoconf/basics.m4 +++ b/make/autoconf/basics.m4 @@ -703,6 +703,13 @@ AC_DEFUN_ONCE([BASIC_SETUP_PATHS], AC_SUBST(TOPDIR) AC_SUBST(CONFIGURE_START_DIR) + if test "x$CUSTOM_ROOT" != x; then + WORKSPACE_ROOT="${CUSTOM_ROOT}" + else + WORKSPACE_ROOT="${TOPDIR}" + fi + AC_SUBST(WORKSPACE_ROOT) + # We can only call BASIC_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS. BASIC_FIXUP_PATH(CONFIGURE_START_DIR) BASIC_FIXUP_PATH(TOPDIR) @@ -930,11 +937,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], AC_MSG_RESULT([in build directory with custom name]) fi - if test "x$CUSTOM_ROOT" != x; then - WORKSPACE_ROOT="${CUSTOM_ROOT}" - else - WORKSPACE_ROOT="${TOPDIR}" - fi OUTPUTDIR="${WORKSPACE_ROOT}/build/${CONF_NAME}" $MKDIR -p "$OUTPUTDIR" if test ! -d "$OUTPUTDIR"; then @@ -991,7 +993,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], AC_SUBST(SPEC) AC_SUBST(CONF_NAME) AC_SUBST(OUTPUTDIR) - AC_SUBST(WORKSPACE_ROOT) AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR) # The spec.gmk file contains all variables for the make system. diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index 7ba3ae011c..4f0d93beb3 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -97,6 +97,9 @@ HOTSPOT_SETUP_JVM_VARIANTS # With basic setup done, call the custom early hook. CUSTOM_EARLY_HOOK +# This only needs debug level to be setup +JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT + # Check if we have devkits, extra paths or sysroot set. BASIC_SETUP_DEVKIT diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 17ebdebec2..ef39f71267 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -862,18 +862,27 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP], $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized" fi - if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then - # Check if compiler supports -fmacro-prefix-map. If so, use that to make - # the __FILE__ macro resolve to paths relative to the workspace root. - workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/" - FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}=" - FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}], - PREFIX: $3, - IF_FALSE: [ - FILE_MACRO_CFLAGS= - ] - ) + # Prevent the __FILE__ macro from generating absolute paths into the built + # binaries. Depending on toolchain, different mitigations are possible. + # * GCC and Clang of new enough versions have -fmacro-prefix-map. + # * For most other toolchains, supplying all source files and -I flags as + # relative paths fixes the issue. + FILE_MACRO_CFLAGS= + if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # Check if compiler supports -fmacro-prefix-map. If so, use that to make + # the __FILE__ macro resolve to paths relative to the workspace root. + workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/" + FILE_MACRO_CFLAGS="-fmacro-prefix-map=${workspace_root_trailing_slash}=" + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}], + PREFIX: $3, + IF_FALSE: [ + FILE_MACRO_CFLAGS= + ] + ) + fi fi + AC_SUBST(FILE_MACRO_CFLAGS) # EXPORT to API CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM \ diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index 45efbbee93..24b0da889d 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -153,6 +153,12 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined -pie" fi + if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + BASIC_LDFLAGS="$BASIC_LDFLAGS -pdbaltpath:%_PDB%" + fi + fi + # Export some intermediate variables for compatibility LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY" AC_SUBST(LDFLAGS_CXX_JDK) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 2fe10bb170..7a8ec8a366 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -707,3 +707,35 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE], AC_SUBST(BUILD_CDS_ARCHIVE) ]) + +################################################################################ +# +# Disallow any output from containing absolute paths from the build system. +# This setting defaults to allowed on debug builds and not allowed on release +# builds. +# +AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT], +[ + AC_ARG_ENABLE([absolute-paths-in-output], + [AS_HELP_STRING([--disable-absolute-paths-in-output], + [Set to disable to prevent any absolute paths from the build to end up in + any of the build output. @<:@disabled in release builds, otherwise enabled@:>@]) + ]) + + AC_MSG_CHECKING([if absolute paths should be allowed in the build output]) + if test "x$enable_absolute_paths_in_output" = "xno"; then + AC_MSG_RESULT([no, forced]) + ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" + elif test "x$enable_absolute_paths_in_output" = "xyes"; then + AC_MSG_RESULT([yes, forced]) + ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" + elif test "x$DEBUG_LEVEL" = "xrelease"; then + AC_MSG_RESULT([no, release build]) + ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" + else + AC_MSG_RESULT([yes, debug build]) + ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" + fi + + AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT) +]) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index d7ddb646af..3a85303e80 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -332,6 +332,8 @@ BUILD_MANPAGES := @BUILD_MANPAGES@ BUILD_CDS_ARCHIVE := @BUILD_CDS_ARCHIVE@ +ALLOW_ABSOLUTE_PATHS_IN_OUTPUT := @ALLOW_ABSOLUTE_PATHS_IN_OUTPUT@ + # The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep # it in sync. BOOT_JDK:=@BOOT_JDK@ @@ -375,6 +377,7 @@ LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@ ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@ LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@ GRAALUNIT_LIB := @GRAALUNIT_LIB@ +FILE_MACRO_CFLAGS := @FILE_MACRO_CFLAGS@ STATIC_LIBS_CFLAGS := @STATIC_LIBS_CFLAGS@ diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index c3a7b0b1bd..6219fc1f83 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -204,6 +204,68 @@ DEPENDENCY_TARGET_SED_PATTERN := \ -e 's/$$$$/ :/' \ # +################################################################################ +# When absolute paths are not allowed in the output, and the compiler does not +# support any options to avoid it, we need to rewrite compile commands to use +# relative paths. By doing this, the __FILE__ macro will resolve to relative +# paths. The relevant input paths on the command line are the -I flags and the +# path to the source file itself. +# +# The macro MakeCommandRelative is used to rewrite the command line like this: +# 'CD $(WORKSPACE_ROOT) && ' +# and changes all paths in cmd to be relative to the workspace root. This only +# works properly if the build dir is inside the workspace root. If it's not, +# relative paths are still calculated, but depending on the distance between the +# dirs, paths in the build dir may end up as essentially absolute anyway. +# +# The fix-deps-file macro is used to adjust the contents of the generated make +# dependency files to contain paths compatible with make. +# +ifeq ($(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)-$(FILE_MACRO_CFLAGS), false-) + # Need to handle -I flags as both '-Ifoo' and '-I foo'. + MakeCommandRelative = \ + $(CD) $(WORKSPACE_ROOT) && \ + $(foreach o, $1, \ + $(if $(filter $(WORKSPACE_ROOT)/% $(OUTPUTDIR)/%, $o), \ + $(call RelativePath, $o, $(WORKSPACE_ROOT)) \ + , \ + $(if $(filter -I$(WORKSPACE_ROOT)/%, $o), \ + -I$(call RelativePath, $(patsubst -I%, %, $o), $(WORKSPACE_ROOT)) \ + , \ + $o \ + ) \ + ) \ + ) + + # When compiling with relative paths, the deps file comes out with relative + # paths. + ifeq ($(TOOLCHAIN_TYPE), solstudio) + define fix-deps-file + $(SED) -e 's|\./|$(WORKSPACE_ROOT)/|g' $1.tmp > $1 + endef + else + define fix-deps-file + $(SED) -e 's|^\([ ]*\)|\1$(WORKSPACE_ROOT)|' $1.tmp > $1 + endef + endif +else + # By default the MakeCommandRelative macro does nothing. + MakeCommandRelative = $1 + + # Even with absolute paths on the command line, the Solaris studio compiler + # doesn't output the full path to the object file in the generated deps files. + # For other toolchains, no adjustment is needed. + ifeq ($(TOOLCHAIN_TYPE), solstudio) + define fix-deps-file + $(SED) 's|^$$(@F):|$$@:|' $1.tmp > $1 + endef + else + define fix-deps-file + $(MV) $1.tmp $1 + endef + endif +endif + ################################################################################ # Create the recipe needed to compile a single native source file. # @@ -214,7 +276,6 @@ DEPENDENCY_TARGET_SED_PATTERN := \ # Remaining parameters are named arguments: # FILE - The full path of the source file to compiler # BASE - The name of the rule for the entire binary to build ($1) -# DISABLE_THIS_FILE_DEFINE - Set to true to disable the THIS_FILE define. # SetupCompileNativeFile = $(NamedParamsMacroTemplate) define SetupCompileNativeFileBody @@ -236,12 +297,6 @@ define SetupCompileNativeFileBody # This is the definite source file to use for $1_FILENAME. $1_SRC_FILE := $$($1_FILE) - ifneq ($$($1_DEFINE_THIS_FILE), false) - ifneq ($$($$($1_BASE)_DEFINE_THIS_FILE), false) - $1_THIS_FILE = -DTHIS_FILE='"$$($1_FILENAME)"' - endif - endif - ifeq ($$($1_OPTIMIZATION), ) $1_OPT_CFLAGS := $$($$($1_BASE)_OPT_CFLAGS) $1_OPT_CXXFLAGS := $$($$($1_BASE)_OPT_CXXFLAGS) @@ -284,13 +339,13 @@ define SetupCompileNativeFileBody ifneq ($$(filter %.c, $$($1_FILENAME)), ) # Compile as a C file $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CFLAGS) \ - $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c + $$($1_OPT_CFLAGS) $$($1_CFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CC) $1_DEP_FLAG := $(C_FLAG_DEPS) else ifneq ($$(filter %.m, $$($1_FILENAME)), ) # Compile as an Objective-C file $1_FLAGS := -x objective-c $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) \ - $$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) $$($1_THIS_FILE) -c + $$($1_BASE_CFLAGS) $$($1_OPT_CFLAGS) $$($1_CFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CC) $1_DEP_FLAG := $(C_FLAG_DEPS) else ifneq ($$(filter %.s %.S, $$($1_FILENAME)), ) @@ -301,7 +356,7 @@ define SetupCompileNativeFileBody else ifneq ($$(filter %.cpp %.cc %.mm, $$($1_FILENAME)), ) # Compile as a C++ or Objective-C++ file $1_FLAGS := $(CFLAGS_CCACHE) $$($1_USE_PCH_FLAGS) $$($1_BASE_CXXFLAGS) \ - $$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) $$($1_THIS_FILE) -c + $$($1_OPT_CXXFLAGS) $$($1_CXXFLAGS) -c $1_COMPILER := $$($$($1_BASE)_CXX) $1_DEP_FLAG := $(CXX_FLAG_DEPS) else @@ -341,21 +396,17 @@ define SetupCompileNativeFileBody $$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME))) $$(call MakeDir, $$(@D)) ifneq ($(TOOLCHAIN_TYPE), microsoft) - ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), 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 ExecuteWithLog, $$@, \ - $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE).tmp $$($1_COMPILE_OPTIONS)) - $(SED) 's|^$$(@F):|$$@:|' $$($1_DEPS_FILE).tmp > $$($1_DEPS_FILE) - else - $$(call ExecuteWithLog, $$@, \ - $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE) $$($1_COMPILE_OPTIONS)) - endif - # Create a dependency target file from the dependency file. - # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ + $$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \ + $$($1_COMPILER) $$($1_DEP_FLAG) \ + $$(addsuffix .tmp, $$($1_DEPS_FILE)) \ + $$($1_COMPILE_OPTIONS))) ifneq ($$($1_DEPS_FILE), ) - $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) > $$($1_DEPS_TARGETS_FILE) + $$(call fix-deps-file, $$($1_DEPS_FILE)) + # Create a dependency target file from the dependency file. + # Solution suggested by: + # http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ + $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) \ + > $$($1_DEPS_TARGETS_FILE) endif else # The Visual Studio compiler lacks a feature for generating make @@ -365,8 +416,8 @@ define SetupCompileNativeFileBody # 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 ExecuteWithLog, $$@, \ - $$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS)) \ + $$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \ + $$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS))) \ | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \ -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \ $(ECHO) $$@: \\ > $$($1_DEPS_FILE) ; \ @@ -430,7 +481,6 @@ endef # STRIPFLAGS Optionally change the flags given to the strip command # PRECOMPILED_HEADER Header file to use as precompiled header # PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH -# DEFINE_THIS_FILE Set to false to not set the THIS_FILE preprocessor macro # # After being called, some variables are exported from this macro, all prefixed # with parameter 1 followed by a '_': @@ -734,7 +784,6 @@ define SetupNativeCompilationBody FILE := $$($1_GENERATED_PCH_SRC), \ BASE := $1, \ EXTRA_CXXFLAGS := -Fp$$($1_PCH_FILE) -Yc$$(notdir $$($1_PRECOMPILED_HEADER)), \ - DEFINE_THIS_FILE := false, \ )) $1_USE_PCH_FLAGS := \ @@ -769,7 +818,8 @@ define SetupNativeCompilationBody $$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE) $$(call LogInfo, Generating precompiled header) $$(call MakeDir, $$(@D)) - $$(call ExecuteWithLog, $$@, $$($1_PCH_COMMAND) $$< -o $$@) + $$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \ + $$($1_PCH_COMMAND) $$< -o $$@)) $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEPS_FILE) \ > $$($1_PCH_DEPS_TARGETS_FILE) @@ -825,9 +875,9 @@ define SetupNativeCompilationBody $$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE) $$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME))) $$(call MakeDir, $$(@D) $$($1_OBJECT_DIR)) - $$(call ExecuteWithLog, $$@, \ + $$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \ $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \ - $$($1_VERSIONINFO_RESOURCE) 2>&1 ) + $$($1_VERSIONINFO_RESOURCE) 2>&1 )) # Windows RC compiler does not support -showIncludes, so we mis-use CL # for this. Filter out RC specific arguments that are unknown to CL. # For some unknown reason, in this case CL actually outputs the show diff --git a/make/gensrc/GensrcCharacterData.gmk b/make/gensrc/GensrcCharacterData.gmk index 32e04e3d04..9c2a4902da 100644 --- a/make/gensrc/GensrcCharacterData.gmk +++ b/make/gensrc/GensrcCharacterData.gmk @@ -38,6 +38,7 @@ define SetupCharacterData $$(call LogInfo, Generating $1.java) $$(call MakeDir, $$(@D)) $(TOOL_GENERATECHARACTER) $2 \ + $(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), true), -d) \ -template $(CHARACTERDATA)/$1.java.template \ -spec $(UNICODEDATA)/UnicodeData.txt \ -specialcasing $(UNICODEDATA)/SpecialCasing.txt \ diff --git a/make/gensrc/GensrcModuleInfo.gmk b/make/gensrc/GensrcModuleInfo.gmk index 789fd2b700..56b5fb54eb 100644 --- a/make/gensrc/GensrcModuleInfo.gmk +++ b/make/gensrc/GensrcModuleInfo.gmk @@ -81,7 +81,9 @@ ifneq ($(MOD_FILES), ) $(call DependOnVariable, ALL_MODULES) $(call MakeTargetDir) $(RM) $@ $@.tmp - $(TOOL_GENMODULEINFOSOURCE) -o $@.tmp \ + $(TOOL_GENMODULEINFOSOURCE) \ + $(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), true), -d) \ + -o $@.tmp \ --source-file $< \ --modules $(call CommaList, $(ALL_MODULES)) \ $(MOD_FILES) diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index e1c6aded5a..d302a3df65 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -75,7 +75,6 @@ ifeq ($(call check-jvm-feature, compiler2), true) OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \ DEBUG_SYMBOLS := false, \ DISABLED_WARNINGS_clang := tautological-compare, \ - DEFINE_THIS_FILE := false, \ )) ADLC_TOOL := $(BUILD_ADLC_TARGET) @@ -201,6 +200,9 @@ ifeq ($(call check-jvm-feature, compiler2), true) $(NAWK) \ 'BEGIN { print "#line 1 \"$*\""; } \ /^#line 999999$$/ {print "#line " (NR+1) " \"$*\""; next} \ + $(if $(call equals, $(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT), false), \ + /^#line .*$$/ {sub("$(WORKSPACE_ROOT)/","")} \ + ) \ {print}' \ < $(ADLC_SUPPORT_DIR)/$* > $@ diff --git a/make/hotspot/gensrc/GensrcDtrace.gmk b/make/hotspot/gensrc/GensrcDtrace.gmk index 608f1dff7b..2a54a6391f 100644 --- a/make/hotspot/gensrc/GensrcDtrace.gmk +++ b/make/hotspot/gensrc/GensrcDtrace.gmk @@ -80,7 +80,6 @@ ifeq ($(call check-jvm-feature, dtrace), true) EXTRA_DEPS := $(JVMTI_H) $(JFR_FILES), \ OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \ OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \ - DEFINE_THIS_FILE := false, \ )) DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET) diff --git a/make/hotspot/lib/CompileDtraceLibraries.gmk b/make/hotspot/lib/CompileDtraceLibraries.gmk index 1a459d6a87..7f49a8eb9f 100644 --- a/make/hotspot/lib/CompileDtraceLibraries.gmk +++ b/make/hotspot/lib/CompileDtraceLibraries.gmk @@ -42,7 +42,6 @@ ifeq ($(call check-jvm-feature, dtrace), true) LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ LIBS := $(LIBDL) -lthread -ldoor, \ OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \ - DEFINE_THIS_FILE := false, \ )) # Note that libjvm_db.c has tests for COMPILER2, but this was never set by @@ -55,7 +54,6 @@ ifeq ($(call check-jvm-feature, dtrace), true) CFLAGS := -I$(DTRACE_GENSRC_DIR) $(JNI_INCLUDE_FLAGS) -m64 -G -mt -KPIC -xldscope=hidden, \ LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \ - DEFINE_THIS_FILE := false, \ )) TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB) diff --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk index f7c0524bc5..7932c2d909 100644 --- a/make/hotspot/lib/CompileGtest.gmk +++ b/make/hotspot/lib/CompileGtest.gmk @@ -96,7 +96,6 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \ STRIP_SYMBOLS := false, \ PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \ PRECOMPILED_HEADER_EXCLUDE := gtest-all.cc gmock-all.cc gtestMain.cpp, \ - DEFINE_THIS_FILE := false, \ )) TARGETS += $(BUILD_GTEST_LIBJVM) @@ -123,7 +122,6 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LAUNCHER, \ LIBS_windows := $(JVM_OUTPUTDIR)/gtest/objs/jvm.lib, \ COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \ ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \ - DEFINE_THIS_FILE := false, \ )) $(BUILD_GTEST_LAUNCHER): $(BUILD_GTEST_LIBJVM) diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 1f9610c618..33d2b0301e 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -203,7 +203,6 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \ VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \ PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \ PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \ - DEFINE_THIS_FILE := false, \ )) # Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures diff --git a/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java b/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java index 23a2f8b220..46b9357b4e 100644 --- a/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java +++ b/make/jdk/src/classes/build/tools/generatecharacter/GenerateCharacter.java @@ -942,14 +942,15 @@ OUTER: for (int i = 0; i < n; i += m) { int n = sizes.length; StringBuffer result = new StringBuffer(); // liu : Add a comment showing the source of this table - result.append(commentStart + " The following tables and code generated using:" + - commentEnd + "\n "); - result.append(commentStart + ' ' + commandLineDescription + commentEnd + "\n "); - - if (plane == 0 && bLatin1 == false) { + if (debug) { + result.append(commentStart + " The following tables and code generated using:" + + commentEnd + "\n "); + result.append(commentStart + ' ' + commandLineDescription + commentEnd + "\n "); + } + if (plane == 0 && bLatin1 == false) { genCaseMapTableDeclaration(result); genCaseMapTable(initializers, specialCaseMaps); - } + } int totalBytes = 0; for (int k = 0; k < n - 1; k++) { genTable(result, tableNames[k], tables[k], 0, bytes[k]<<3, sizes[k], preshifted[k], @@ -1612,6 +1613,7 @@ OUTER: for (int i = 0; i < n; i += m) { */ static boolean verbose = false; + static boolean debug = false; static boolean nobidi = false; static boolean nomirror = false; static boolean identifiers = false; @@ -1692,6 +1694,8 @@ OUTER: for (int i = 0; i < n; i += m) { for (int j = 0; j < args.length; j++) { if (args[j].equals("-verbose") || args[j].equals("-v")) verbose = true; + else if (args[j].equals("-d")) + debug = true; else if (args[j].equals("-nobidi")) nobidi = true; else if (args[j].equals("-nomirror")) diff --git a/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java b/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java index d2688af3ba..ce9b94db7a 100644 --- a/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java +++ b/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java @@ -59,11 +59,14 @@ import static java.util.stream.Collectors.*; */ public class GenModuleInfoSource { private final static String USAGE = - "Usage: GenModuleInfoSource -o \n" + - " --source-file \n" + - " --modules [,...]\n" + - " ...\n"; + "Usage: GenModuleInfoSource \n" + + " [-d]\n" + + " -o \n" + + " --source-file \n" + + " --modules [,...]\n" + + " ...\n"; + static boolean debug = false; static boolean verbose = false; public static void main(String... args) throws Exception { Path outfile = null; @@ -75,6 +78,9 @@ public class GenModuleInfoSource { String option = args[i]; String arg = i+1 < args.length ? args[i+1] : null; switch (option) { + case "-d": + debug = true; + break; case "-o": outfile = Paths.get(arg); i++; @@ -148,10 +154,12 @@ public class GenModuleInfoSource { for (String l : lines) { writer.println(l); if (l.trim().startsWith("module ")) { - // print URI rather than file path to avoid escape - writer.format(" // source file: %s%n", sourceFile.toUri()); - for (Path file: extraFiles) { - writer.format(" // %s%n", file.toUri()); + if (debug) { + // print URI rather than file path to avoid escape + writer.format(" // source file: %s%n", sourceFile.toUri()); + for (Path file : extraFiles) { + writer.format(" // %s%n", file.toUri()); + } } break; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m index f83c66036e..d437d6d969 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m @@ -33,11 +33,6 @@ #import "ThreadUtilities.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - NSColor **sColors = nil; NSColor **appleColors = nil; @@ -135,7 +130,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol result = (useAppleColor ? appleColors : sColors)[colorIndex]; } else { - NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex); + NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex); result = [NSColor blackColor]; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m index 434186ee3a..99660d1e7f 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m @@ -36,11 +36,6 @@ #import "QuartzSurfaceData.h" #include "AWTStrike.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 }; @@ -531,7 +526,7 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc if (glyphs == NULL || uniChars == NULL || advances == NULL) { (*env)->DeleteLocalRef(env, glyphsArray); - [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__]; + [NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__]; if (glyphs) { free(glyphs); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m index e55a267d5f..4a55084770 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m @@ -32,11 +32,6 @@ #import "CoreTextSupport.h" #include "fontscalerdefs.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - @implementation AWTStrike static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 }; @@ -107,7 +102,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 }; #define AWT_FONT_CLEANUP_FINISH \ if (_fontThrowJavaException == YES) { \ char s[512]; \ - sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__); \ + sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \ [JNFException raise:env as:kRuntimeException reason:s]; \ } diff --git a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiOut.c b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiOut.c index 037d69eeff..a62dceb93d 100644 --- a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiOut.c +++ b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiOut.c @@ -26,11 +26,6 @@ //#define USE_ERROR //#define USE_TRACE -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #if USE_PLATFORM_MIDI_OUT == TRUE #include "PLATFORM_API_MacOSX_MidiUtils.h" @@ -133,7 +128,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT case 0xF7: // System exclusive fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n", - THIS_FILE, __LINE__, data[0]); + __FILE__, __LINE__, data[0]); byteIsInvalid = TRUE; break; @@ -159,7 +154,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT default: // Invalid message fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", - THIS_FILE, __LINE__, data[0]); + __FILE__, __LINE__, data[0]); byteIsInvalid = TRUE; break; } @@ -169,7 +164,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT default: // This can't happen, but handle it anyway. fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n", - THIS_FILE, __LINE__, data[0]); + __FILE__, __LINE__, data[0]); byteIsInvalid = TRUE; break; } diff --git a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c index 4491c14b9c..b139020c7b 100644 --- a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c +++ b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c @@ -42,11 +42,6 @@ //#define USE_ERROR //#define USE_TRACE -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE) #include "PLATFORM_API_MacOSX_MidiUtils.h" @@ -322,7 +317,7 @@ static void processMessagesForPacket(const MIDIPacket* packet, MacMidiDeviceHand packedMsg = pendingMessageStatus | pendingData[0] << 8; } else { fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n", - THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength); + __FILE__, __LINE__, pendingMessageStatus, pendingDataLength); byteIsInvalid = TRUE; } pendingDataLength = 0; diff --git a/src/java.desktop/macosx/native/libosxui/ScreenMenu.m b/src/java.desktop/macosx/native/libosxui/ScreenMenu.m index d7b469e797..3572b711d5 100644 --- a/src/java.desktop/macosx/native/libosxui/ScreenMenu.m +++ b/src/java.desktop/macosx/native/libosxui/ScreenMenu.m @@ -37,11 +37,6 @@ #import "ThreadUtilities.h" #import "CMenuBar.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu"); static jint ns2awtModifiers(NSUInteger keyMods) { @@ -101,7 +96,7 @@ static jint ns2awtMouseButton(NSInteger mouseButton) { { if (self.javaObjectWrapper == nil) { #ifdef DEBUG - NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__); + NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__); #endif return; } @@ -119,7 +114,7 @@ JNF_COCOA_EXIT(env); { if (self.javaObjectWrapper == nil) { #ifdef DEBUG - NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__); + NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__); #endif return; } @@ -137,7 +132,7 @@ JNF_COCOA_EXIT(env); { if (self.javaObjectWrapper == nil) { #ifdef DEBUG - NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__); + NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__); #endif return; } diff --git a/src/java.desktop/share/native/common/awt/debug/debug_assert.h b/src/java.desktop/share/native/common/awt/debug/debug_assert.h index fbe16ee5dd..e96dee5c8b 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_assert.h +++ b/src/java.desktop/share/native/common/awt/debug/debug_assert.h @@ -32,22 +32,17 @@ extern "C" { #include "debug_util.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #if defined(DEBUG) #define DASSERT(_expr) \ if ( !(_expr) ) { \ - DAssert_Impl( #_expr, THIS_FILE, __LINE__); \ + DAssert_Impl( #_expr, __FILE__, __LINE__); \ } else { \ } #define DASSERTMSG(_expr, _msg) \ if ( !(_expr) ) { \ - DAssert_Impl( (_msg), THIS_FILE, __LINE__); \ + DAssert_Impl( (_msg), __FILE__, __LINE__); \ } else { \ } diff --git a/src/java.desktop/share/native/common/awt/debug/debug_mem.c b/src/java.desktop/share/native/common/awt/debug/debug_mem.c index 6522bca4b2..aee4b84e96 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_mem.c +++ b/src/java.desktop/share/native/common/awt/debug/debug_mem.c @@ -27,11 +27,6 @@ #include "debug_util.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #define DMEM_MIN(a,b) (a) < (b) ? (a) : (b) #define DMEM_MAX(a,b) (a) > (b) ? (a) : (b) @@ -296,7 +291,7 @@ void DMem_ReportLeaks() { DMutex_Enter(DMemMutex); /* Force memory leaks to be output regardless of trace settings */ - DTrace_EnableFile(THIS_FILE, TRUE); + DTrace_EnableFile(__FILE__, TRUE); DTRACE_PRINTLN("--------------------------"); DTRACE_PRINTLN("Debug Memory Manager Leaks"); DTRACE_PRINTLN("--------------------------"); diff --git a/src/java.desktop/share/native/common/awt/debug/debug_trace.h b/src/java.desktop/share/native/common/awt/debug/debug_trace.h index 39df7bd6a3..1f7064ef00 100644 --- a/src/java.desktop/share/native/common/awt/debug/debug_trace.h +++ b/src/java.desktop/share/native/common/awt/debug/debug_trace.h @@ -34,11 +34,6 @@ extern "C" { #include "debug_util.h" -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - typedef int dtrace_id; enum { UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */ @@ -75,7 +70,7 @@ static dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID; #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \ { \ static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \ - DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \ + DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \ } /* printf style trace macros */ diff --git a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipeline.h b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipeline.h index 20019851eb..e57ac0b19d 100644 --- a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipeline.h +++ b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipeline.h @@ -28,11 +28,6 @@ #define D3D_DEBUG_INFO #endif // DEBUG -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE THIS_FILE -#endif - #ifdef D3D_PPL_DLL @@ -109,7 +104,7 @@ do { \ #define ACT_IF_NULL(ACTION, value) \ if ((value) == NULL) { \ J2dTraceLn3(J2D_TRACE_ERROR, \ - "%s is null in %s:%d", #value, THIS_FILE, __LINE__); \ + "%s is null in %s:%d", #value, __FILE__, __LINE__); \ ACTION; \ } else do { } while (0) #define RETURN_IF_NULL(value) ACT_IF_NULL(return, value) @@ -119,12 +114,12 @@ do { \ #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \ if (FAILED(res = (EXPR))) { \ - DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \ + DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \ return res; \ } else do { } while (0) #define RETURN_STATUS_IF_FAILED(status) \ if (FAILED((status))) { \ - DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\ + DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\ return (status); \ } else do { } while (0) diff --git a/src/java.desktop/windows/native/libawt/windows/alloc.h b/src/java.desktop/windows/native/libawt/windows/alloc.h index 953c4de4d6..289adefe82 100644 --- a/src/java.desktop/windows/native/libawt/windows/alloc.h +++ b/src/java.desktop/windows/native/libawt/windows/alloc.h @@ -26,11 +26,6 @@ #ifndef _ALLOC_H_ #define _ALLOC_H_ -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #include "stdhdrs.h" // By defining std::bad_alloc in a local header file instead of including @@ -135,12 +130,12 @@ void handle_bad_alloc(void); throw (std::bad_alloc); #define safe_Malloc(size) \ - safe_Malloc_outofmem(size, THIS_FILE, __LINE__) + safe_Malloc_outofmem(size, __FILE__, __LINE__) #define safe_Calloc(num, size) \ - safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__) + safe_Calloc_outofmem(num, size, __FILE__, __LINE__) #define safe_Realloc(memblock, size) \ - safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__) - #define new new(THIS_FILE, __LINE__) + safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__) + #define new new(__FILE__, __LINE__) #endif /* OUTOFMEM_TEST */ #define TRY \ diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Debug.h b/src/java.desktop/windows/native/libawt/windows/awt_Debug.h index 0b964a0272..a17f569e04 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Debug.h +++ b/src/java.desktop/windows/native/libawt/windows/awt_Debug.h @@ -63,12 +63,7 @@ #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \ _DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0) - /* Use THIS_FILE when it is available. */ - #ifndef THIS_FILE - #define THIS_FILE __FILE__ - #endif - - #define new new(THIS_FILE, __LINE__) + #define new new(__FILE__, __LINE__) #define VERIFY(exp) DASSERT(exp) #define UNIMPLEMENTED() DASSERT(FALSE) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h b/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h index b22f685b2b..ac87951f44 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h +++ b/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h @@ -133,29 +133,24 @@ class CriticalSection { // Macros for using CriticalSection objects that help trace // lock/unlock actions -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #define CRITICAL_SECTION_ENTER(cs) { \ J2dTraceLn4(J2D_TRACE_VERBOSE2, \ "CS.Wait: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ - GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ + GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \ (cs).Enter(); \ J2dTraceLn4(J2D_TRACE_VERBOSE2, \ "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ - GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ + GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \ } #define CRITICAL_SECTION_LEAVE(cs) { \ J2dTraceLn4(J2D_TRACE_VERBOSE2, \ "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ - GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ + GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \ (cs).Leave(); \ J2dTraceLn4(J2D_TRACE_VERBOSE2, \ "CS.Left: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ - GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ + GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \ } // Redefine WinAPI values related to touch input, if OS < Windows 7. diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp index 3db6ce2e53..706ab62177 100644 --- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp +++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp @@ -39,14 +39,9 @@ extern "C" { #ifdef USE_ERROR #include -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #define MIDIIN_CHECK_ERROR { \ if (err != MMSYSERR_NOERROR) \ - ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \ + ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \ } #else #define MIDIIN_CHECK_ERROR diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiOut.c b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiOut.c index 1eee22b594..572d7427dd 100644 --- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiOut.c +++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiOut.c @@ -37,14 +37,9 @@ #ifdef USE_ERROR #include -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #define MIDIOUT_CHECK_ERROR { \ if (err != MMSYSERR_NOERROR) \ - ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \ + ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \ } #else #define MIDIOUT_CHECK_ERROR diff --git a/src/java.instrument/share/native/libinstrument/JPLISAssert.h b/src/java.instrument/share/native/libinstrument/JPLISAssert.h index 55a68b2f62..b63235495c 100644 --- a/src/java.instrument/share/native/libinstrument/JPLISAssert.h +++ b/src/java.instrument/share/native/libinstrument/JPLISAssert.h @@ -49,14 +49,9 @@ extern "C" { #define JPLISASSERT_ENABLEASSERTIONS (0) #endif -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #if JPLISASSERT_ENABLEASSERTIONS -#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__) -#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__) +#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__) +#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__) #else #define jplis_assert(x) #define jplis_assert_msg(x, msg) diff --git a/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c b/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c index 1049a3737f..13cca6453f 100644 --- a/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c +++ b/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c @@ -33,13 +33,8 @@ /* Routines to convert back and forth between Platform Encoding and UTF-8 */ -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - /* Error and assert macros */ -#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__, m) +#define UTF_ERROR(m) utfError(__FILE__, __LINE__, m) #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 ) #define UTF_DEBUG(x) diff --git a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h index 8dd964b866..513810d10a 100644 --- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h +++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h @@ -477,14 +477,9 @@ void *p11malloc(size_t c, char *file, int line); void *p11calloc(size_t c, size_t s, char *file, int line); void p11free(void *p, char *file, int line); -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - -#define malloc(c) (p11malloc((c), THIS_FILE, __LINE__)) -#define calloc(c, s) (p11calloc((c), (s), THIS_FILE, __LINE__)) -#define free(c) (p11free((c), THIS_FILE, __LINE__)) +#define malloc(c) (p11malloc((c), __FILE__, __LINE__)) +#define calloc(c, s) (p11calloc((c), (s), __FILE__, __LINE__)) +#define free(c) (p11free((c), __FILE__, __LINE__)) #endif diff --git a/src/jdk.jdi/share/native/libdt_shmem/shmemBase.h b/src/jdk.jdi/share/native/libdt_shmem/shmemBase.h index 104e263fb1..0187dd38b5 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/shmemBase.h +++ b/src/jdk.jdi/share/native/libdt_shmem/shmemBase.h @@ -49,16 +49,11 @@ jint shmemBase_receivePacket(SharedMemoryConnection *, jdwpPacket *packet); jint shmemBase_name(SharedMemoryTransport *, char **name); jint shmemBase_getlasterror(char *msg, jint size); -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #ifdef DEBUG #define SHMEM_ASSERT(expression) \ do { \ if (!(expression)) { \ - exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \ + exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \ } \ } while (0) #else @@ -68,7 +63,7 @@ do { \ #define SHMEM_GUARANTEE(expression) \ do { \ if (!(expression)) { \ - exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \ + exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \ } \ } while (0) diff --git a/src/jdk.jdi/windows/native/libdt_shmem/shmem_md.c b/src/jdk.jdi/windows/native/libdt_shmem/shmem_md.c index 056dce648f..a73808e498 100644 --- a/src/jdk.jdi/windows/native/libdt_shmem/shmem_md.c +++ b/src/jdk.jdi/windows/native/libdt_shmem/shmem_md.c @@ -30,11 +30,6 @@ #include "sysShmem.h" #include "shmemBase.h" /* for exitTransportWithError */ -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - /* * These functions are not completely universal. For now, they are used * exclusively for Jbug's shared memory transport mechanism. They have @@ -49,7 +44,7 @@ static HANDLE memHandle = NULL; if (!(expression)) { \ exitTransportWithError \ ("\"%s\", line %d: assertion failure\n", \ - THIS_FILE, __DATE__, __LINE__); \ + __FILE__, __DATE__, __LINE__); \ } \ } #else diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/error_messages.h b/src/jdk.jdwp.agent/share/native/libjdwp/error_messages.h index e25908c559..4126b76f22 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/error_messages.h +++ b/src/jdk.jdwp.agent/share/native/libjdwp/error_messages.h @@ -42,36 +42,31 @@ const char * jvmtiErrorText(jvmtiError); const char * eventText(int); const char * jdwpErrorText(jdwpError); -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #define EXIT_ERROR(error, msg) \ { \ print_message(stderr, "JDWP exit error ", "\n", \ "%s(%d): %s [%s:%d]", \ jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \ - THIS_FILE, __LINE__); \ + __FILE__, __LINE__); \ debugInit_exit((jvmtiError)error, msg); \ } #define JDI_ASSERT(expression) \ do { \ if (gdata && gdata->assertOn && !(expression)) { \ - jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \ + jdiAssertionFailed(__FILE__, __LINE__, #expression); \ } \ } while (0) #define JDI_ASSERT_MSG(expression, msg) \ do { \ if (gdata && gdata->assertOn && !(expression)) { \ - jdiAssertionFailed(THIS_FILE, __LINE__, msg); \ + jdiAssertionFailed(__FILE__, __LINE__, msg); \ } \ } while (0) #define JDI_ASSERT_FAILED(msg) \ - jdiAssertionFailed(THIS_FILE, __LINE__, msg) + jdiAssertionFailed(__FILE__, __LINE__, msg) void do_pause(void); diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.h b/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.h index 129fab66cd..3f79bfcea1 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.h +++ b/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.h @@ -33,15 +33,10 @@ void finish_logging(); #define LOG_NULL ((void)0) -/* Use THIS_FILE when it is available. */ -#ifndef THIS_FILE - #define THIS_FILE __FILE__ -#endif - #ifdef JDWP_LOGGING #define _LOG(flavor,args) \ - (log_message_begin(flavor,THIS_FILE,__LINE__), \ + (log_message_begin(flavor,__FILE__,__LINE__), \ log_message_end args) #define LOG_TEST(flag) (gdata->log_flags & (flag)) diff --git a/test/jdk/build/AbsPathsInImage.java b/test/jdk/build/AbsPathsInImage.java new file mode 100644 index 0000000000..bf55ac2dd2 --- /dev/null +++ b/test/jdk/build/AbsPathsInImage.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2019, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/* + * @test + * @bug 8226346 + * @summary Check all output files for absolute path fragments + * @requires !vm.debug + * @run main AbsPathsInImage + */ +public class AbsPathsInImage { + + // Set this property on command line to scan an alternate dir or file: + // JTREG=JAVA_OPTIONS=-Djdk.test.build.AbsPathInImage.dir=/path/to/dir + public static final String DIR_PROPERTY = "jdk.test.build.AbsPathsInImage.dir"; + + private boolean matchFound = false; + + public static void main(String[] args) throws Exception { + String jdkPathString = System.getProperty("test.jdk"); + Path jdkHome = Paths.get(jdkPathString); + + Path dirToScan = jdkHome; + String overrideDir = System.getProperty(DIR_PROPERTY); + if (overrideDir != null) { + dirToScan = Paths.get(overrideDir); + } + + String buildWorkspaceRoot = null; + String buildOutputRoot = null; + String testImageDirString = System.getenv("TEST_IMAGE_DIR"); + if (testImageDirString != null) { + Path testImageDir = Paths.get(testImageDirString); + Path buildInfoPropertiesFile = testImageDir.resolve("build-info.properties"); + System.out.println("Getting patterns from " + buildInfoPropertiesFile.toString()); + Properties buildInfoProperties = new Properties(); + try (InputStream inStream = Files.newInputStream(buildInfoPropertiesFile)) { + buildInfoProperties.load(inStream); + } + buildWorkspaceRoot = buildInfoProperties.getProperty("build.workspace.root"); + buildOutputRoot = buildInfoProperties.getProperty("build.output.root"); + } else { + System.out.println("Getting patterns from local environment"); + // Try to resolve the workspace root based on the jtreg test root dir + String testRootDirString = System.getProperty("test.root"); + if (testRootDirString != null) { + Path testRootDir = Paths.get(testRootDirString); + // Remove /test/jdk suffix + buildWorkspaceRoot = testRootDir.getParent().getParent().toString(); + } + // Remove /jdk + Path buildOutputRootPath = jdkHome.getParent(); + if (buildOutputRootPath.endsWith("images")) { + buildOutputRootPath = buildOutputRootPath.getParent(); + } + buildOutputRoot = buildOutputRootPath.toString(); + } + if (buildWorkspaceRoot == null) { + throw new Error("Could not find workspace root, test cannot run"); + } + if (buildOutputRoot == null) { + throw new Error("Could not find build output root, test cannot run"); + } + + List searchPatterns = new ArrayList<>(); + expandPatterns(searchPatterns, buildWorkspaceRoot); + expandPatterns(searchPatterns, buildOutputRoot); + + System.out.println("Looking for:"); + for (byte[] searchPattern : searchPatterns) { + System.out.println(new String(searchPattern)); + } + System.out.println(); + + AbsPathsInImage absPathsInImage = new AbsPathsInImage(); + absPathsInImage.scanFiles(dirToScan, searchPatterns); + + if (absPathsInImage.matchFound) { + throw new Exception("Test failed"); + } + } + + /** + * Add path pattern to list of patterns to search for. Create all possible + * variants depending on platform. + */ + private static void expandPatterns(List searchPatterns, String pattern) { + if (System.getProperty("os.name").toLowerCase().contains("windows")) { + String forward = pattern.replace('\\', '/'); + String back = pattern.replace('/', '\\'); + if (pattern.charAt(1) == ':') { + String forwardUpper = String.valueOf(pattern.charAt(0)).toUpperCase() + forward.substring(1); + String forwardLower = String.valueOf(pattern.charAt(0)).toLowerCase() + forward.substring(1); + String backUpper = String.valueOf(pattern.charAt(0)).toUpperCase() + back.substring(1); + String backLower = String.valueOf(pattern.charAt(0)).toLowerCase() + back.substring(1); + searchPatterns.add(forwardUpper.getBytes()); + searchPatterns.add(forwardLower.getBytes()); + searchPatterns.add(backUpper.getBytes()); + searchPatterns.add(backLower.getBytes()); + } else { + searchPatterns.add(forward.getBytes()); + searchPatterns.add(back.getBytes()); + } + } else { + searchPatterns.add(pattern.getBytes()); + } + } + + private void scanFiles(Path root, List searchPatterns) throws IOException { + Files.walkFileTree(root, new SimpleFileVisitor<>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + String fileName = file.toString(); + if (Files.isSymbolicLink(file)) { + return super.visitFile(file, attrs); + } else if (fileName.endsWith(".debuginfo") || fileName.endsWith(".pdb")) { + // Do nothing + } else if (fileName.endsWith("jvm.dll")) { + // On Windows, the Microsoft toolchain does not provide a way + // to reliably remove all absolute paths from __FILE__ usage. + // Until that is fixed, we simply exclude jvm.dll from this + // test. + } else if (fileName.endsWith(".zip")) { + scanZipFile(file, searchPatterns); + } else { + scanFile(file, searchPatterns); + } + return super.visitFile(file, attrs); + } + }); + } + + private void scanFile(Path file, List searchPatterns) throws IOException { + List matches = scanBytes(Files.readAllBytes(file), searchPatterns); + if (matches.size() > 0) { + System.out.println(file + ":"); + for (String match : matches) { + System.out.println(match); + } + System.out.println(); + } + } + + private void scanZipFile(Path zipFile, List searchPatterns) throws IOException { + try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(zipFile))) { + ZipEntry zipEntry; + while ((zipEntry = zipInputStream.getNextEntry()) != null) { + List matches = scanBytes(zipInputStream.readAllBytes(), searchPatterns); + if (matches.size() > 0) { + System.out.println(zipFile + ", " + zipEntry.getName() + ":"); + for (String match : matches) { + System.out.println(match); + } + System.out.println(); + } + } + } + } + + private List scanBytes(byte[] data, List searchPatterns) { + List matches = new ArrayList<>(); + for (int i = 0; i < data.length; i++) { + for (byte[] searchPattern : searchPatterns) { + boolean found = true; + for (int j = 0; j < searchPattern.length; j++) { + if ((i + j > data.length || data[i + j] != searchPattern[j])) { + found = false; + break; + } + } + if (found) { + matchFound = true; + matches.add(new String(data, charsStart(data, i), charsOffset(data, i, searchPattern.length))); + // No need to search the same string for multiple patterns + break; + } + } + } + return matches; + } + + private int charsStart(byte[] data, int startIndex) { + int index = startIndex; + while (--index > 0) { + byte datum = data[index]; + if (datum < 32 || datum > 126) { + break; + } + } + return index + 1; + } + + private int charsOffset(byte[] data, int startIndex, int startOffset) { + int offset = startOffset; + while (startIndex + ++offset < data.length) { + byte datum = data[startIndex + offset]; + if (datum < 32 || datum > 126) { + break; + } + } + return offset; + } +}