--- a/make/common/NativeCompilation.gmk Thu Mar 15 01:43:29 2018 +0100
+++ b/make/common/NativeCompilation.gmk Thu Apr 12 14:11:59 2018 +0200
@@ -292,13 +292,12 @@
endif
ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), )
- $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPT_CFLAGS) \
- $$($1_OPT_CXXFLAGS)
+ $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_OBJ).vardeps)
endif
$$($1_OBJ): $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \
- $$($1_VARDEPS_FILE) | $$($$($1_BASE)_BUILD_INFO)
+ $$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE) | $$($$($1_BASE)_BUILD_INFO)
$$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME)))
$$(call MakeDir, $$(@D))
ifneq ($(TOOLCHAIN_TYPE), microsoft)
@@ -367,6 +366,7 @@
# EXCLUDE_PATTERN exclude files matching any of these substrings
# EXTRA_FILES List of extra files not in any of the SRC dirs
# EXTRA_OBJECT_FILES List of extra object files to include when linking
+# EXTRA_DEPS List of extra dependencies to be added to each compiled file
# VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
# RC_FLAGS flags for RC.
# EMBED_MANIFEST if true, embed manifest on Windows.
@@ -798,10 +798,6 @@
"-map:$$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).map"
$1_DEBUGINFO_FILES := $$($1_OUTPUT_DIR)/$$($1_NOSUFFIX).pdb \
$$($1_OUTPUT_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_OUTPUT_DIR)/$$($1_NOSUFFIX).debuginfo
@@ -816,15 +812,25 @@
$1_DEBUGINFO_FILES := \
$$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
$$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
- # 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_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET) $$(NEWLINE) \
- $(TOUCH) $$($1_TARGET)
+ $(DSYMUTIL) --out $$($1_OUTPUT_DIR)/$$($1_BASENAME).dSYM $$($1_TARGET)
endif # OPENJDK_TARGET_OS
+ # Since the link rule creates more than one file that we want to track,
+ # we have to use some tricks to get make to cooperate. To properly
+ # trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
+ # a recipe in the rule below. To avoid rerunning the recipe every time
+ # have it touch the target. If a debuginfo file is deleted by something
+ # external, explicitly delete the TARGET to trigger a rebuild of both.
+ ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
+ $$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
+ $$(shell $(RM) $$($1_TARGET))
+ endif
$$($1_DEBUGINFO_FILES): $$($1_TARGET)
+ $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
+ $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
+ )
+ $(TOUCH) $$@
$1 += $$($1_DEBUGINFO_FILES)
@@ -855,22 +861,71 @@
endif
endif
- ifeq ($$($1_TYPE), LIBRARY)
- # Generating a dynamic library.
- $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
- ifeq ($(OPENJDK_TARGET_OS), windows)
- $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_NAME).lib"
- # Create a rule for the import lib so that other rules may depend on it
- $$($1_OBJECT_DIR)/$$($1_NAME).lib: $$($1_TARGET)
+ ifeq ($$($1_TYPE), STATIC_LIBRARY)
+ $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
+ $$($1_EXTRA_LIBS)
+ $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
+ $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
+
+ # Generating a static library, ie object file archive.
+ ifeq ($(STATIC_BUILD), true)
+ ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
+ STATIC_MAPFILE_DEP := $$($1_MAPFILE)
+ endif
endif
- # Create loadmap on AIX. Helps in diagnosing some problems.
- ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
- $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
+ $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
+ $$(call LogInfo, Building static library $$($1_BASENAME))
+ $$(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)
+ ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
+ $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
+ else
+ $(GetSymbols)
+ endif
+ endif
+ else
+ # A shared dynamic library or an executable binary has been specified
+ ifeq ($$($1_TYPE), LIBRARY)
+ # Generating a dynamic library.
+ $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
+
+ # Create loadmap on AIX. Helps in diagnosing some problems.
+ ifneq ($(COMPILER_BINDCMD_FILE_FLAG), )
+ $1_EXTRA_LDFLAGS += $(COMPILER_BINDCMD_FILE_FLAG)$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).loadmap
+ endif
+ endif
+
+ ifeq ($(OPENJDK_TARGET_OS), windows)
+ ifeq ($$($1_EMBED_MANIFEST), true)
+ $1_EXTRA_LDFLAGS += -manifest:embed
+ endif
+
+ $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
+ $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
+ ifeq ($$($1_TYPE), LIBRARY)
+ # To properly trigger downstream dependants of the import library, just as
+ # for debug files, we must have a recipe in the rule. To avoid rerunning
+ # the recipe every time have it touch the target. If an import library
+ # file is deleted by something external, explicitly delete the target to
+ # trigger a rebuild of both.
+ ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
+ $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
+ $$(shell $(RM) $$($1_TARGET))
+ endif
+ $$($1_IMPORT_LIBRARY): $$($1_TARGET)
+ $$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
+ $$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
+ )
+ $(TOUCH) $$@
+ endif
endif
$1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
- $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
+ $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
+ $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
$$($1_STRIP_CMD)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
@@ -909,8 +964,8 @@
endif
endif
- $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
- $$($1_VARDEPS_FILE)
+ $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
+ $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE)
ifneq ($$($1_OBJ_FILE_LIST), )
ifeq ($$($1_LINK_OBJS_RELATIVE), true)
$$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST)))
@@ -924,74 +979,21 @@
ifeq ($(OPENJDK_TARGET_OS), windows)
$$(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) $$(GLOBAL_LIBS) \
- $$($1_LIBS) $$($1_EXTRA_LIBS)) \
+ $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
+ $$($1_LIBS) $$($1_EXTRA_LIBS)) \
| $(GREP) -v "^ Creating library .*\.lib and object .*\.exp" || \
- test "$$$$?" = "1" ; \
+ test "$$$$?" = "1" ; \
$$($1_CREATE_DEBUGINFO_CMDS)
$$($1_STRIP_CMD)
else
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
$$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
- $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
- $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
+ $(LD_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
+ $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
$$($1_CREATE_DEBUGINFO_CMDS)
$$($1_STRIP_CMD)
endif
-
- endif
-
- ifeq ($$($1_TYPE), STATIC_LIBRARY)
- $1_VARDEPS := $$($1_AR) $$($1_ARFLAGS) $$($1_LIBS) \
- $$($1_EXTRA_LIBS)
- $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
- $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
-
- # Generating a static library, ie object file archive.
- ifeq ($(STATIC_BUILD), true)
- ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
- STATIC_MAPFILE_DEP := $$($1_MAPFILE)
- endif
- endif
-
- $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP)
- $$(call LogInfo, Building static library $$($1_BASENAME))
- $$(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)
- ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true)
- $(CP) $$($1_MAPFILE) $$(@D)/$$(basename $$(@F)).symbols
- else
- $(GetSymbols)
- endif
- endif
- endif
-
- ifeq ($$($1_TYPE), EXECUTABLE)
- # A executable binary has been specified, setup the target for it.
- $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
- $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
- $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
- $$($1_STRIP_CMD)
- $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
- $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
-
- ifeq ($(OPENJDK_TARGET_OS), windows)
- ifeq ($$($1_EMBED_MANIFEST), true)
- $1_EXTRA_LDFLAGS += -manifest:embed
- endif
- endif
-
- $$($1_TARGET): $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
- $$($1_VARDEPS_FILE)
- $$(call LogInfo, Linking executable $$($1_BASENAME))
- $$(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) \
- $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS))
ifeq ($(OPENJDK_TARGET_OS), windows)
ifneq ($$($1_MANIFEST), )
$$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
@@ -1004,9 +1006,6 @@
$(CODESIGN) -s openjdk_codesign $$@
endif
endif
- $$($1_CREATE_DEBUGINFO_CMDS)
- $$($1_STRIP_CMD)
-
endif
endef