make/common/NativeCompilation.gmk

Print this page

        

@@ -448,49 +448,52 @@
             $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
                 "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
                 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
 
-            # This dependency dance ensures that windows debug info files get rebuilt
-            # properly if deleted.
-            $$($1_TARGET): $$($1_DEBUGINFO_FILES)
-            $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS)
-
           else ifeq ($(OPENJDK_TARGET_OS), solaris)
             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
+            # Setup the command line creating debuginfo files, to be run after linking.
+            # It cannot be run separately since it updates the original target file
+            #
             # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
             # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
             # empty section headers until a fixed $(OBJCOPY) is available.
             # An empty section header has sh_addr == 0 and sh_size == 0.
             # This problem has only been seen on Solaris X64, but we call this tool
             # on all Solaris builds just in case.
             #
             # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
             # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-            $$($1_DEBUGINFO_FILES): $$($1_TARGET) \
-                $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
-                        $(RM) $$@
-                        $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$<
-                        $(OBJCOPY) --only-keep-debug $$< $$@
-                        $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$<
-                        $(TOUCH) $$@
+            $1_CREATE_DEBUGINFO_CMDS := \
+                $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$($1_TARGET) $$(NEWLINE) \
+                $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+                $(CD) $$($1_OUTPUT_DIR) && \
+                    $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$($1_DEBUGINFO_FILES) $$($1_TARGET)
+            $1_DEBUGINFO_EXTRA_DEPS := $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
 
           else ifeq ($(OPENJDK_TARGET_OS), linux)
             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
-            $$($1_DEBUGINFO_FILES): $$($1_TARGET)
-                        $(RM) $$@
-                        $(OBJCOPY) --only-keep-debug $$< $$@
-                        $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$<
-                        $(TOUCH) $$@
+            # Setup the command line creating debuginfo files, to be run after linking.
+            # It cannot be run separately since it updates the original target file
+            $1_CREATE_DEBUGINFO_CMDS := \
+                $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
+                $(CD) $$($1_OUTPUT_DIR) && \
+                    $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
 
           endif # No MacOS X support
 
+          # This dependency dance ensures that debug info files get rebuilt
+          # properly if deleted.
+          $$($1_TARGET): $$($1_DEBUGINFO_FILES)
+          $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS)
+
           ifeq ($(ZIP_DEBUGINFO_FILES), true)
             $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
             $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
 
-            # The dependency on TARGET is needed on windows for debuginfo files
+            # The dependency on TARGET is needed for debuginfo files
             # to be rebuilt properly.
             $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
                 $(CD) $$($1_OBJECT_DIR) \
                 && $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES))
 

@@ -502,43 +505,46 @@
     endif # $1_DEBUG_SYMBOLS
   endif # !STATIC_LIBRARY
 
   ifneq (,$$($1_LIBRARY))
     # Generating a dynamic library.
-    $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
+    $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
     ifeq ($(OPENJDK_TARGET_OS), windows)
-      $1_EXTRA_LDFLAGS+="-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
+      $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
     endif
 
     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
 
-    $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE)
+    $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
+        $$($1_DEBUGINFO_EXTRA_DEPS)
         $$(call LINKING_MSG,$$($1_BASENAME))
         $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \
         $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
         $$($1_EXTRA_LDFLAGS_SUFFIX)
+                $$($1_CREATE_DEBUGINFO_CMDS)
         # Touch target to make sure it has a later time stamp than the debug
         # symbol files to avoid unnecessary relinking on rebuild.
         ifeq ($(OPENJDK_TARGET_OS), windows)
           $(TOUCH) $$@
         endif
 
   endif
 
   ifneq (,$$($1_STATIC_LIBRARY))
     # Generating a static library, ie object file archive.
-    $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES)
+    $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES)
         $$(call ARCHIVING_MSG,$$($1_LIBRARY))
         $(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \
             $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)
   endif
 
   ifneq (,$$($1_PROGRAM))
     # A executable binary has been specified, setup the target for it.
     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
 
-    $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST)
+    $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) \
+        $$($1_DEBUGINFO_EXTRA_DEPS)
         $$(call LINKING_EXE_MSG,$$($1_BASENAME))
         $$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \
         $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
         $$($1_EXTRA_LDFLAGS_SUFFIX)
         ifneq (,$$($1_GEN_MANIFEST))

@@ -549,10 +555,11 @@
         ifneq (,$(CODESIGN))
           ifneq (,$$($1_CODESIGN))
             $(CODESIGN) -s openjdk_codesign $$@
           endif
         endif
+                $$($1_CREATE_DEBUGINFO_CMDS)
         # Touch target to make sure it has a later time stamp than the debug
         # symbol files to avoid unnecessary relinking on rebuild.
         ifeq ($(OPENJDK_TARGET_OS), windows)
           $(TOUCH) $$@
         endif