8210919: Remove statically linked libjli on Windows
authorihse
Wed, 19 Sep 2018 22:42:34 +0200
changeset 51808 3f32076a43a6
parent 51807 3221f5e14866
child 51809 61f62fb4d4bf
8210919: Remove statically linked libjli on Windows Reviewed-by: erikj
make/ExplodedImageOptimize.gmk
make/launcher/Launcher-java.base.gmk
make/launcher/LauncherCommon.gmk
make/lib/CoreLibraries.gmk
make/lib/Lib-java.instrument.gmk
--- a/make/ExplodedImageOptimize.gmk	Wed Sep 19 15:25:05 2018 -0400
+++ b/make/ExplodedImageOptimize.gmk	Wed Sep 19 22:42:34 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2018, 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
@@ -38,7 +38,7 @@
 
 $(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES)
 	$(call LogInfo, Optimizing the exploded image)
-	$(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR)
+	$(call ExecuteWithLog, $@, $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR))
 	$(TOUCH) $@
 
 TARGETS := $(PACKAGES_ATTRIBUTE_TARGET)
--- a/make/launcher/Launcher-java.base.gmk	Wed Sep 19 15:25:05 2018 -0400
+++ b/make/launcher/Launcher-java.base.gmk	Wed Sep 19 22:42:34 2018 +0200
@@ -43,8 +43,6 @@
     VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
     OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/java_objs, \
     OPTIMIZATION := HIGH, \
-    WINDOWS_STATIC_LINK := true, \
-    NO_JAVA_MS := true, \
 ))
 
 $(SUPPORT_OUTPUTDIR)/modules_cmds/java.base/java$(EXE_SUFFIX): $(BUILD_LAUNCHER_java)
@@ -60,8 +58,6 @@
       LIBS_windows := user32.lib comctl32.lib, \
       EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
       VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
-      WINDOWS_STATIC_LINK := true, \
-      NO_JAVA_MS := true, \
   ))
 endif
 
--- a/make/launcher/LauncherCommon.gmk	Wed Sep 19 15:25:05 2018 -0400
+++ b/make/launcher/LauncherCommon.gmk	Wed Sep 19 22:42:34 2018 +0200
@@ -91,11 +91,9 @@
 # LDFLAGS_solaris Additional LDFLAGS_solaris
 # RC_FLAGS   Additional RC_FLAGS
 # MACOSX_SIGNED   On macosx, sign this binary
-# WINDOWS_STATIC_LINK   On windows, link statically with C runtime and libjli.
 # OPTIMIZATION   Override default optimization level (LOW)
 # OUTPUT_DIR   Override default output directory
 # VERSION_INFO_RESOURCE   Override default Windows resource file
-# NO_JAVA_MS   Do not add -ms8m to JAVA_ARGS.
 SetupBuildLauncher = $(NamedParamsMacroTemplate)
 define SetupBuildLauncherBody
   # Setup default values (unless overridden)
@@ -103,26 +101,24 @@
     $1_OPTIMIZATION := LOW
   endif
 
-  ifneq ($$($1_NO_JAVA_MS), true)
-    # The norm is to append -ms8m, unless otherwise instructed.
-    $1_JAVA_ARGS += -ms8m
-  endif
-
   ifeq ($$($1_MAIN_MODULE), )
     $1_MAIN_MODULE := $(MODULE)
   endif
 
-  ifneq ($$($1_JAVA_ARGS), )
-    ifneq ($$($1_EXTRA_JAVA_ARGS), )
-      $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
-        $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
-      $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
-    endif
-    $1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
-        $$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }'
-    $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
+  $1_JAVA_ARGS += -ms8m
+  ifneq ($$($1_MAIN_CLASS), )
+    $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
   endif
 
+  ifneq ($$($1_EXTRA_JAVA_ARGS), )
+    $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
+      $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
+    $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
+  endif
+  $1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
+      $$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }'
+  $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
+
   $1_LIBS :=
   ifeq ($(OPENJDK_TARGET_OS), macosx)
     ifeq ($$($1_MACOSX_SIGNED), true)
@@ -161,19 +157,13 @@
     $1_LIBS += -lz
   endif
 
-  ifeq ($$($1_WINDOWS_STATIC_LINK), true)
-    $1_CFLAGS += $(filter-out -MD, $(CFLAGS_JDKEXE))
-    $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib
-  else
-    $1_CFLAGS += $(CFLAGS_JDKEXE)
-    $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib
-  endif
+  $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib
 
   $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
       NAME := $1, \
       EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
       OPTIMIZATION := $$($1_OPTIMIZATION), \
-      CFLAGS := $$($1_CFLAGS) \
+      CFLAGS := $$(CFLAGS_JDKEXE) $$($1_CFLAGS) \
           $(LAUNCHER_CFLAGS) \
           $(VERSION_CFLAGS) \
           -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
@@ -186,11 +176,11 @@
           $$(ORIGIN_ARG) \
           $$($1_LDFLAGS), \
       LDFLAGS_linux := \
-          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
+          -L$(call FindLibDirForModule, java.base)/jli, \
       LDFLAGS_macosx := \
-          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
+          -L$(call FindLibDirForModule, java.base)/jli, \
       LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \
-          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
+          -L$(call FindLibDirForModule, java.base)/jli, \
       LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
       LIBS_unix := $$($1_LIBS_unix), \
       LIBS_linux := -lpthread -ljli $(LIBDL), \
--- a/make/lib/CoreLibraries.gmk	Wed Sep 19 15:25:05 2018 -0400
+++ b/make/lib/CoreLibraries.gmk	Wed Sep 19 22:42:34 2018 +0200
@@ -207,8 +207,6 @@
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
-  # Staticically link with c runtime on windows.
-  LIBJLI_CFLAGS_JDKLIB := $(filter-out -MD, $(CFLAGS_JDKLIB))
   LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)
   # Supply the name of the C runtime lib.
   LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
@@ -216,7 +214,6 @@
     LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
   endif
 else
-  LIBJLI_CFLAGS_JDKLIB := $(CFLAGS_JDKLIB)
   LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli
 endif
 
@@ -240,7 +237,7 @@
     EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
     EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
     OPTIMIZATION := HIGH, \
-    CFLAGS := $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
     DISABLED_WARNINGS_solstudio := \
         E_ASM_DISABLES_OPTIMIZATION \
         E_STATEMENT_NOT_REACHED, \
@@ -260,27 +257,7 @@
 
 LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli)
 
-# On windows, the static library has the same suffix as the import library created by
-# with the shared library, so the static library is given a different name. No harm
-# in doing it for all platform to reduce complexity.
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
-      NAME := jli_static, \
-      TYPE := STATIC_LIBRARY, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
-      SRC := $(LIBJLI_SRC_DIRS), \
-      EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
-      EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
-      OPTIMIZATION := HIGH, \
-      CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \
-          $(addprefix -I, $(LIBJLI_SRC_DIRS)), \
-      ARFLAGS := $(ARFLAGS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
-  ))
-
-  TARGETS += $(BUILD_LIBJLI_STATIC)
-
-else ifeq ($(OPENJDK_TARGET_OS), aix)
+ifeq ($(OPENJDK_TARGET_OS), aix)
   # AIX also requires a static libjli because the compiler doesn't support '-rpath'
   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
       NAME := jli_static, \
--- a/make/lib/Lib-java.instrument.gmk	Wed Sep 19 15:25:05 2018 -0400
+++ b/make/lib/Lib-java.instrument.gmk	Wed Sep 19 22:42:34 2018 +0200
@@ -31,20 +31,15 @@
 ################################################################################
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
-  # Statically link the C runtime so that there are not dependencies on modules
-  # not on the search patch when invoked from the Windows system directory
-  # (or elsewhere).
-  LIBINSTRUMENT_CFLAGS_JDKLIB := $(filter-out -MD, $(CFLAGS_JDKLIB))
   # equivalent of strcasecmp is stricmp on Windows
   LIBINSTRUMENT_CFLAGS := -Dstrcasecmp=stricmp
-else
-  LIBINSTRUMENT_CFLAGS_JDKLIB := $(CFLAGS_JDKLIB)
+  WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib
 endif
 
 $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \
     NAME := instrument, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(LIBINSTRUMENT_CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \
     CFLAGS_debug := -DJPLIS_LOGGING, \
     CFLAGS_release := -DNO_JPLIS_LOGGING, \
     EXTRA_HEADER_DIRS := java.base:libjli, \
@@ -66,11 +61,13 @@
     LIBS_macosx := -ljli -liconv -framework Cocoa -framework Security \
         -framework ApplicationServices, \
     LIBS_windows := jvm.lib $(WIN_JAVA_LIB) advapi32.lib \
-        $(call FindStaticLib, java.base, jli_static), \
+        $(WINDOWS_JLI_LIB), \
 ))
 
-ifneq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
+ifeq ($(OPENJDK_TARGET_OS), aix)
   $(BUILD_LIBINSTRUMENT): $(call FindStaticLib, java.base, jli_static)
+else ifeq ($(OPENJDK_TARGET_OS), windows)
+  $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli)
 else
   $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli, /jli)
 endif