8210729: Clean up macosx static library handling
authorihse
Tue, 18 Sep 2018 13:32:40 +0200
changeset 51783 4482acfef2a5
parent 51782 a50956e2368c
child 51784 fbec908e2783
8210729: Clean up macosx static library handling Reviewed-by: erikj
make/autoconf/flags-other.m4
make/autoconf/flags.m4
make/launcher/LauncherCommon.gmk
make/lib/CoreLibraries.gmk
make/lib/Lib-java.instrument.gmk
--- a/make/autoconf/flags-other.m4	Tue Sep 11 18:18:51 2018 +0200
+++ b/make/autoconf/flags-other.m4	Tue Sep 18 13:32:40 2018 +0200
@@ -31,9 +31,7 @@
 AC_DEFUN([FLAGS_SETUP_ARFLAGS],
 [
   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    ARFLAGS="-r -mmacosx-version-min=$MACOSX_VERSION_MIN"
-  elif test "x$OPENJDK_TARGET_OS" = xaix; then
+  if test "x$OPENJDK_TARGET_OS" = xaix; then
     ARFLAGS="-X64"
   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
     # lib.exe is used as AR to create static libraries.
--- a/make/autoconf/flags.m4	Tue Sep 11 18:18:51 2018 +0200
+++ b/make/autoconf/flags.m4	Tue Sep 18 13:32:40 2018 +0200
@@ -336,8 +336,12 @@
     CC_OUT_OPTION='-o$(SPACE)'
     # When linking, how to specify the output
     LD_OUT_OPTION='-o$(SPACE)'
-    # When archiving, how to specify the to be create static archive for object files.
-    AR_OUT_OPTION='rcs$(SPACE)'
+    # When archiving, how to specify the destination static archive.
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+      AR_OUT_OPTION='-r -cs$(SPACE)'
+    else
+      AR_OUT_OPTION='-rcs$(SPACE)'
+    fi
   fi
   AC_SUBST(CC_OUT_OPTION)
   AC_SUBST(LD_OUT_OPTION)
--- a/make/launcher/LauncherCommon.gmk	Tue Sep 11 18:18:51 2018 +0200
+++ b/make/launcher/LauncherCommon.gmk	Tue Sep 18 13:32:40 2018 +0200
@@ -25,19 +25,13 @@
 
 include JdkNativeCompilation.gmk
 
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN)
-else
-  ifeq ($(OPENJDK_TARGET_OS), windows)
-  endif
-  ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli)
+ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli)
 
-  # Applications expect to be able to link against libjawt without invoking
-  # System.loadLibrary("jawt") first. This was the behaviour described in the
-  # devloper documentation of JAWT and what worked with OpenJDK6.
-  ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
-    ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib)
-  endif
+# Applications expect to be able to link against libjawt without invoking
+# System.loadLibrary("jawt") first. This was the behaviour described in the
+# devloper documentation of JAWT and what worked with OpenJDK6.
+ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
+  ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib)
 endif
 
 # Tell the compiler not to export any functions unless declared so in
@@ -153,8 +147,6 @@
           -framework Foundation \
           -framework SystemConfiguration \
           -lstdc++ -liconv
-    else
-      $1_LIBS += $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a
     endif
     $1_LIBS += -framework Cocoa -framework Security \
         -framework ApplicationServices
@@ -195,11 +187,14 @@
           $$($1_LDFLAGS), \
       LDFLAGS_linux := \
           -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
+      LDFLAGS_macosx := \
+          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
       LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \
           -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \
       LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
       LIBS_unix := $$($1_LIBS_unix), \
       LIBS_linux := -lpthread -ljli $(LIBDL), \
+      LIBS_macosx := -ljli, \
       LIBS_solaris := -ljli -lthread $(LIBDL), \
       LIBS_windows := $$($1_WINDOWS_JLI_LIB) \
           $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \
@@ -215,7 +210,7 @@
   $1 += $$(BUILD_LAUNCHER_$1)
   TARGETS += $$($1)
 
-  ifneq (,$(filter $(OPENJDK_TARGET_OS), macosx aix))
+  ifeq ($(OPENJDK_TARGET_OS), aix)
     $$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a
   endif
 
--- a/make/lib/CoreLibraries.gmk	Tue Sep 11 18:18:51 2018 +0200
+++ b/make/lib/CoreLibraries.gmk	Tue Sep 18 13:32:40 2018 +0200
@@ -49,40 +49,20 @@
 LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm
 LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC) $(FDLIBM_CFLAGS)
 
-ifneq ($(OPENJDK_TARGET_OS), macosx)
-  $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
-      NAME := fdlibm, \
-      TYPE := STATIC_LIBRARY, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
-      SRC := $(LIBFDLIBM_SRC), \
-      OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \
-      CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
-      CFLAGS_windows_debug := -DLOGGING, \
-      CFLAGS_aix := -qfloat=nomaf, \
-      DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \
-      DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
-      ARFLAGS := $(ARFLAGS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
-  ))
-
-else
-
-  # On macosx the old build does partial (incremental) linking of fdlibm instead of
-  # a plain static library.
-  $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM_MAC, \
-      NAME := fdlibm, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
-      SRC := $(LIBFDLIBM_SRC), \
-      CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
-      LDFLAGS := -nostdlib $(ARFLAGS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
-  ))
-
-  BUILD_LIBFDLIBM := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
-  $(BUILD_LIBFDLIBM): $(BUILD_LIBFDLIBM_MAC)
-	$(call install-file)
-
-endif
+$(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
+    NAME := fdlibm, \
+    TYPE := STATIC_LIBRARY, \
+    OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
+    SRC := $(LIBFDLIBM_SRC), \
+    OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
+    CFLAGS_windows_debug := -DLOGGING, \
+    CFLAGS_aix := -qfloat=nomaf, \
+    DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \
+    DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
+    ARFLAGS := $(ARFLAGS), \
+    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
+))
 
 ##########################################################################################
 
@@ -131,15 +111,15 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
     LDFLAGS_windows := -delayload:shell32.dll, \
+    LIBS := $(BUILD_LIBFDLIBM_TARGET), \
     LIBS_unix := -ljvm -lverify, \
-    LIBS_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \
-    LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM), \
-    LIBS_aix := $(LIBDL) $(BUILD_LIBFDLIBM) $(LIBM),\
-    LIBS_macosx := -lfdlibm \
-        -framework CoreFoundation \
+    LIBS_linux := $(LIBDL), \
+    LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL), \
+    LIBS_aix := $(LIBDL) $(LIBM),\
+    LIBS_macosx := -framework CoreFoundation \
         -framework Foundation \
         -framework Security -framework SystemConfiguration, \
-    LIBS_windows := jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
+    LIBS_windows := jvm.lib $(WIN_VERIFY_LIB) \
         shell32.lib delayimp.lib \
         advapi32.lib version.lib, \
 ))
@@ -300,33 +280,6 @@
 
   TARGETS += $(BUILD_LIBJLI_STATIC)
 
-else ifeq ($(OPENJDK_TARGET_OS), macosx)
-  #
-  # On macosx they do partial (incremental) linking of libjli_static.a
-  # code it here...rather than add support to NativeCompilation
-  # as this is first time I see it
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
-      NAME := jli_static, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
-      SRC := $(LIBJLI_SRC_DIRS), \
-      EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
-      EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
-      OPTIMIZATION := HIGH, \
-      CFLAGS := $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \
-          $(addprefix -I, $(LIBJLI_SRC_DIRS)), \
-      LDFLAGS := -nostdlib $(ARFLAGS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
-  ))
-
-  ifeq ($(STATIC_BUILD), true)
-    TARGETS += $(BUILD_LIBJLI_STATIC)
-  else
-    $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a: $(BUILD_LIBJLI_STATIC)
-	$(call install-file)
-
-    TARGETS += $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a
-  endif
-
 else ifeq ($(OPENJDK_TARGET_OS), aix)
   # AIX also requires a static libjli because the compiler doesn't support '-rpath'
   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
--- a/make/lib/Lib-java.instrument.gmk	Tue Sep 11 18:18:51 2018 +0200
+++ b/make/lib/Lib-java.instrument.gmk	Tue Sep 18 13:32:40 2018 +0200
@@ -55,21 +55,21 @@
         -L$(call FindLibDirForModule, java.base)/jli, \
     LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/jli) \
         -L$(call FindLibDirForModule, java.base)/jli, \
-    LDFLAGS_macosx := -Wl$(COMMA)-all_load, \
+    LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN,/jli) \
+        -L$(call FindLibDirForModule, java.base)/jli, \
     LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \
     LIBS := $(JDKLIB_LIBS), \
     LIBS_unix := -ljava -ljvm $(LIBZ_LIBS), \
     LIBS_linux := -ljli $(LIBDL), \
     LIBS_solaris := -ljli $(LIBDL), \
     LIBS_aix := -liconv -ljli_static $(LIBDL), \
-    LIBS_macosx := -liconv -framework Cocoa -framework Security \
-        -framework ApplicationServices \
-        $(call FindStaticLib, java.base, jli_static), \
+    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), \
 ))
 
-ifneq ($(filter $(OPENJDK_TARGET_OS), macosx windows aix), )
+ifneq ($(filter $(OPENJDK_TARGET_OS), windows aix), )
   $(BUILD_LIBINSTRUMENT): $(call FindStaticLib, java.base, jli_static)
 else
   $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli, /jli)