make/common/NativeCompilation.gmk
changeset 27560 adc258b13e2c
parent 25882 bd4315f0084b
child 27602 236555ddac42
equal deleted inserted replaced
27559:23d1529db8c7 27560:adc258b13e2c
   448             $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
   448             $1_EXTRA_LDFLAGS += "-pdb:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb" \
   449                 "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
   449                 "-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
   450             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
   450             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
   451                 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
   451                 $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
   452 
   452 
   453             # This dependency dance ensures that windows debug info files get rebuilt
       
   454             # properly if deleted.
       
   455             $$($1_TARGET): $$($1_DEBUGINFO_FILES)
       
   456             $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS)
       
   457 
       
   458           else ifeq ($(OPENJDK_TARGET_OS), solaris)
   453           else ifeq ($(OPENJDK_TARGET_OS), solaris)
   459             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
   454             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
       
   455             # Setup the command line creating debuginfo files, to be run after linking.
       
   456             # It cannot be run separately since it updates the original target file
       
   457             #
   460             # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
   458             # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
   461             # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
   459             # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
   462             # empty section headers until a fixed $(OBJCOPY) is available.
   460             # empty section headers until a fixed $(OBJCOPY) is available.
   463             # An empty section header has sh_addr == 0 and sh_size == 0.
   461             # An empty section header has sh_addr == 0 and sh_size == 0.
   464             # This problem has only been seen on Solaris X64, but we call this tool
   462             # This problem has only been seen on Solaris X64, but we call this tool
   465             # on all Solaris builds just in case.
   463             # on all Solaris builds just in case.
   466             #
   464             #
   467             # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
   465             # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
   468             # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
   466             # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
   469             $$($1_DEBUGINFO_FILES): $$($1_TARGET) \
   467             $1_CREATE_DEBUGINFO_CMDS := \
   470                 $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
   468                 $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$($1_TARGET) $$(NEWLINE) \
   471 			$(RM) $$@
   469                 $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
   472 			$(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$<
   470                 $(CD) $$($1_OUTPUT_DIR) && \
   473 			$(OBJCOPY) --only-keep-debug $$< $$@
   471                     $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$($1_DEBUGINFO_FILES) $$($1_TARGET)
   474 			$(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$<
   472             $1_DEBUGINFO_EXTRA_DEPS := $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK)
   475 			$(TOUCH) $$@
       
   476 
   473 
   477           else ifeq ($(OPENJDK_TARGET_OS), linux)
   474           else ifeq ($(OPENJDK_TARGET_OS), linux)
   478             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
   475             $1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
   479             $$($1_DEBUGINFO_FILES): $$($1_TARGET)
   476             # Setup the command line creating debuginfo files, to be run after linking.
   480 			$(RM) $$@
   477             # It cannot be run separately since it updates the original target file
   481 			$(OBJCOPY) --only-keep-debug $$< $$@
   478             $1_CREATE_DEBUGINFO_CMDS := \
   482 			$(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$<
   479                 $(OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
   483 			$(TOUCH) $$@
   480                 $(CD) $$($1_OUTPUT_DIR) && \
       
   481                     $(OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
   484 
   482 
   485           endif # No MacOS X support
   483           endif # No MacOS X support
       
   484 
       
   485           # This dependency dance ensures that debug info files get rebuilt
       
   486           # properly if deleted.
       
   487           $$($1_TARGET): $$($1_DEBUGINFO_FILES)
       
   488           $$($1_DEBUGINFO_FILES): $$($1_EXPECTED_OBJS)
   486 
   489 
   487           ifeq ($(ZIP_DEBUGINFO_FILES), true)
   490           ifeq ($(ZIP_DEBUGINFO_FILES), true)
   488             $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
   491             $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz
   489             $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
   492             $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP))
   490 
   493 
   491             # The dependency on TARGET is needed on windows for debuginfo files
   494             # The dependency on TARGET is needed for debuginfo files
   492             # to be rebuilt properly.
   495             # to be rebuilt properly.
   493             $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
   496             $$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
   494 		$(CD) $$($1_OBJECT_DIR) \
   497 		$(CD) $$($1_OBJECT_DIR) \
   495 		&& $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES))
   498 		&& $(ZIP) -q $$@ $$(notdir $$($1_DEBUGINFO_FILES))
   496 
   499 
   502     endif # $1_DEBUG_SYMBOLS
   505     endif # $1_DEBUG_SYMBOLS
   503   endif # !STATIC_LIBRARY
   506   endif # !STATIC_LIBRARY
   504 
   507 
   505   ifneq (,$$($1_LIBRARY))
   508   ifneq (,$$($1_LIBRARY))
   506     # Generating a dynamic library.
   509     # Generating a dynamic library.
   507     $1_EXTRA_LDFLAGS+=$$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
   510     $1_EXTRA_LDFLAGS += $$(call SET_SHARED_LIBRARY_NAME,$$($1_BASENAME))
   508     ifeq ($(OPENJDK_TARGET_OS), windows)
   511     ifeq ($(OPENJDK_TARGET_OS), windows)
   509       $1_EXTRA_LDFLAGS+="-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
   512       $1_EXTRA_LDFLAGS += "-implib:$$($1_OBJECT_DIR)/$$($1_LIBRARY).lib"
   510     endif
   513     endif
   511 
   514 
   512     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
   515     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
   513 
   516 
   514     $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE)
   517     $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
   515 	$$(call LINKING_MSG,$$($1_BASENAME))
   518         $$($1_DEBUGINFO_EXTRA_DEPS)
   516 	$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \
   519 		$$(call LINKING_MSG,$$($1_BASENAME))
   517 	$$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
   520 		$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(LD_OUT_OPTION)$$@ \
   518 	$$($1_EXTRA_LDFLAGS_SUFFIX)
   521 		    $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
   519         # Touch target to make sure it has a later time stamp than the debug
   522 		    $$($1_EXTRA_LDFLAGS_SUFFIX)
   520         # symbol files to avoid unnecessary relinking on rebuild.
   523 		$$($1_CREATE_DEBUGINFO_CMDS)
   521         ifeq ($(OPENJDK_TARGET_OS), windows)
   524                 # Touch target to make sure it has a later time stamp than the debug
   522 	  $(TOUCH) $$@
   525                 # symbol files to avoid unnecessary relinking on rebuild.
   523         endif
   526                 ifeq ($(OPENJDK_TARGET_OS), windows)
       
   527 		  $(TOUCH) $$@
       
   528                 endif
   524 
   529 
   525   endif
   530   endif
   526 
   531 
   527   ifneq (,$$($1_STATIC_LIBRARY))
   532   ifneq (,$$($1_STATIC_LIBRARY))
   528     # Generating a static library, ie object file archive.
   533     # Generating a static library, ie object file archive.
   529     $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES)
   534     $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES)
   530 	$$(call ARCHIVING_MSG,$$($1_LIBRARY))
   535 	$$(call ARCHIVING_MSG,$$($1_LIBRARY))
   531 	$(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \
   536 	$(AR) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_EXPECTED_OBJS) \
   532 	    $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)
   537 	    $$($1_RES) $$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)
   533   endif
   538   endif
   534 
   539 
   535   ifneq (,$$($1_PROGRAM))
   540   ifneq (,$$($1_PROGRAM))
   536     # A executable binary has been specified, setup the target for it.
   541     # A executable binary has been specified, setup the target for it.
   537     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
   542     $1_EXTRA_LDFLAGS_SUFFIX += $(GLOBAL_LDFLAGS_SUFFIX)
   538 
   543 
   539     $$($1_TARGET) : $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST)
   544     $$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_GEN_MANIFEST) \
   540 	$$(call LINKING_EXE_MSG,$$($1_BASENAME))
   545         $$($1_DEBUGINFO_EXTRA_DEPS)
   541 	$$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \
   546 		$$(call LINKING_EXE_MSG,$$($1_BASENAME))
   542 	$$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
   547 		$$($1_LDEXE) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $(EXE_OUT_OPTION)$$($1_TARGET) \
   543 	$$($1_EXTRA_LDFLAGS_SUFFIX)
   548 		    $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_LDFLAGS_SUFFIX) \
   544         ifneq (,$$($1_GEN_MANIFEST))
   549 		    $$($1_EXTRA_LDFLAGS_SUFFIX)
   545 	  $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1
   550                 ifneq (,$$($1_GEN_MANIFEST))
   546         endif
   551 		  $(MT) -nologo -manifest $$($1_GEN_MANIFEST) -outputresource:$$@;#1
   547         # This only works if the openjdk_codesign identity is present on the system. Let
   552                 endif
   548         # silently fail otherwise.
   553                 # This only works if the openjdk_codesign identity is present on the system. Let
   549         ifneq (,$(CODESIGN))
   554                 # silently fail otherwise.
   550           ifneq (,$$($1_CODESIGN))
   555                 ifneq (,$(CODESIGN))
   551 	    $(CODESIGN) -s openjdk_codesign $$@
   556                   ifneq (,$$($1_CODESIGN))
   552           endif
   557 		    $(CODESIGN) -s openjdk_codesign $$@
   553         endif
   558                   endif
   554         # Touch target to make sure it has a later time stamp than the debug
   559                 endif
   555         # symbol files to avoid unnecessary relinking on rebuild.
   560 		$$($1_CREATE_DEBUGINFO_CMDS)
   556         ifeq ($(OPENJDK_TARGET_OS), windows)
   561                 # Touch target to make sure it has a later time stamp than the debug
   557 	  $(TOUCH) $$@
   562                 # symbol files to avoid unnecessary relinking on rebuild.
   558         endif
   563                 ifeq ($(OPENJDK_TARGET_OS), windows)
       
   564 		  $(TOUCH) $$@
       
   565                 endif
   559 
   566 
   560   endif
   567   endif
   561 endef
   568 endef
   562 
   569 
   563 endif # _NATIVE_COMPILATION_GMK
   570 endif # _NATIVE_COMPILATION_GMK