mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8339480: Build static-jdk image with a statically linked launcher
Co-authored-by: Magnus Ihse Bursie <ihse@openjdk.org> Co-authored-by: Jiangli Zhou <jiangli@openjdk.org> Reviewed-by: dholmes, erikj, coleenp
This commit is contained in:
parent
d589bafee3
commit
1ca764454b
@ -281,27 +281,6 @@ else
|
||||
endif
|
||||
CMDS_TARGET_SUBDIR := bin
|
||||
|
||||
# Param 1 - dir to find debuginfo files in
|
||||
FindDebuginfoFiles = \
|
||||
$(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
|
||||
$(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
|
||||
$(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
|
||||
|
||||
# Pick the correct debug info files to copy, either zipped or not.
|
||||
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
|
||||
DEBUGINFO_SUFFIXES += .diz
|
||||
else
|
||||
DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
|
||||
# On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
|
||||
# dirs.
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
$(call FillFindCache, \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds)
|
||||
FindDebuginfoFiles = \
|
||||
$(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1)))
|
||||
endif
|
||||
endif
|
||||
|
||||
# Param 1 - either JDK or JRE
|
||||
SetupCopyDebuginfo = \
|
||||
$(foreach m, $(ALL_$1_MODULES), \
|
||||
|
||||
@ -454,6 +454,18 @@ $(eval $(call SetupTarget, symbols-image, \
|
||||
TARGET := symbols, \
|
||||
))
|
||||
|
||||
$(eval $(call SetupTarget, static-launcher, \
|
||||
MAKEFILE := StaticLibs, \
|
||||
TARGET := static-launcher, \
|
||||
DEPS := hotspot-static-libs static-libs, \
|
||||
))
|
||||
|
||||
$(eval $(call SetupTarget, static-jdk-image, \
|
||||
MAKEFILE := StaticLibs, \
|
||||
TARGET := static-jdk-image, \
|
||||
DEPS := static-exploded-image jdk-image, \
|
||||
))
|
||||
|
||||
$(eval $(call SetupTarget, static-libs-image, \
|
||||
MAKEFILE := StaticLibsImage, \
|
||||
TARGET := static-libs-image, \
|
||||
@ -1086,9 +1098,9 @@ else
|
||||
|
||||
symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS)
|
||||
|
||||
static-libs-image: hotspot-static-libs $(STATIC_LIBS_TARGETS)
|
||||
static-libs-image: hotspot-static-libs static-libs
|
||||
|
||||
static-libs-graal-image: $(STATIC_LIBS_TARGETS)
|
||||
static-libs-graal-image: static-libs
|
||||
|
||||
bootcycle-images: jdk-image
|
||||
|
||||
@ -1254,6 +1266,8 @@ ifeq ($(call isTargetOs, macosx), true)
|
||||
legacy-images: mac-legacy-jre-bundle
|
||||
endif
|
||||
|
||||
static-exploded-image: static-launcher exploded-image
|
||||
|
||||
# These targets build the various documentation images
|
||||
docs-jdk-image: docs-jdk
|
||||
docs-javase-image: docs-javase
|
||||
@ -1296,7 +1310,7 @@ endif
|
||||
################################################################################
|
||||
|
||||
# all-images builds all our deliverables as images.
|
||||
all-images: product-images test-image all-docs-images
|
||||
all-images: product-images static-jdk-image test-image all-docs-images
|
||||
|
||||
# all-bundles packages all our deliverables as tar.gz bundles.
|
||||
all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles
|
||||
@ -1309,7 +1323,7 @@ ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-static-libs \
|
||||
create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \
|
||||
docs-javase docs-reference docs-javadoc mac-bundles product-images legacy-images \
|
||||
docs-image docs-javase-image docs-reference-image all-docs-images \
|
||||
docs-bundles all-docs-bundles test-image all-images \
|
||||
docs-bundles all-docs-bundles test-image all-images static-exploded-image \
|
||||
all-bundles
|
||||
|
||||
################################################################################
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 2024, 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
|
||||
@ -45,6 +45,23 @@ TARGETS :=
|
||||
# Include the file being wrapped.
|
||||
include $(MAKEFILE_PREFIX).gmk
|
||||
|
||||
ifeq ($(MAKEFILE_PREFIX), Lib)
|
||||
# We need to keep track of what libraries are generated/needed by this
|
||||
# module. This information is required when doing static linking, to know
|
||||
# which static library files to include. The variable $(MODULE)_INCLUDED_LIBS is
|
||||
# added to for each call to SetupJdkLibrary. The file module-included-libs.txt is then
|
||||
# read in StaticLibs.gmk.
|
||||
ifneq ($($(MODULE)_JDK_LIBS), )
|
||||
LIBLIST := $(SUPPORT_OUTPUTDIR)/modules_static-libs/$(MODULE)/module-included-libs.txt
|
||||
|
||||
$(LIBLIST): $(TARGETS)
|
||||
$(call MakeDir, $(@D))
|
||||
$(ECHO) $($(MODULE)_INCLUDED_LIBS) > $@
|
||||
|
||||
TARGETS += $(LIBLIST)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Setup copy rules from the modules directories to the jdk image directory.
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map
|
||||
|
||||
191
make/StaticLibs.gmk
Normal file
191
make/StaticLibs.gmk
Normal file
@ -0,0 +1,191 @@
|
||||
#
|
||||
# Copyright (c) 2024, 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
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
default: all
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include Modules.gmk
|
||||
include modules/LauncherCommon.gmk
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Create the static java launcher
|
||||
#
|
||||
################################################################################
|
||||
|
||||
STATIC_JDK_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/static-jdk
|
||||
STATIC_LAUNCHER_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/static-native/launcher
|
||||
HOTSPOT_STATIC_LIB_PATH := $(HOTSPOT_OUTPUTDIR)/*/libjvm/objs/static
|
||||
|
||||
ifneq ($(word 2, $(wildcard $(HOTSPOT_STATIC_LIB_PATH))), )
|
||||
$(error Cannot perform static linking when building more than one JVM library)
|
||||
endif
|
||||
|
||||
# Find all modules with static libraries
|
||||
STATIC_LIB_MODULES := $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \
|
||||
%, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*))
|
||||
|
||||
# Filter out known broken libraries. This is a temporary measure until
|
||||
# proper support for these libraries can be provided.
|
||||
ifeq ($(call isTargetOs, linux), true)
|
||||
# libsplashscreen has a name conflict with libawt in the function
|
||||
# BitmapToYXBandedRectangles, so we exclude it for now.
|
||||
BROKEN_STATIC_LIBS += splashscreen
|
||||
else ifeq ($(call isTargetOs, macosx), true)
|
||||
# libosxsecurity has a name conflict with libosxapp in the function
|
||||
# JavaStringToNSString, so we exclude it for now.
|
||||
BROKEN_STATIC_LIBS += osxsecurity
|
||||
else ifeq ($(call isTargetOs, windows), true)
|
||||
# libsplashscreen has a name conflict with libawt in the function
|
||||
# BitmapToYXBandedRectangles, so we exclude it for now.
|
||||
BROKEN_STATIC_LIBS += splashscreen
|
||||
# libsspi_bridge has name conflicts with sunmscapi
|
||||
BROKEN_STATIC_LIBS += sspi_bridge
|
||||
# These libs define DllMain which conflict with Hotspot
|
||||
BROKEN_STATIC_LIBS += awt dt_shmem dt_socket
|
||||
# These libs are dependent on any of the above disabled libs
|
||||
BROKEN_STATIC_LIBS += fontmanager jawt lcms net nio
|
||||
endif
|
||||
|
||||
$(foreach module, $(STATIC_LIB_MODULES), \
|
||||
$(eval LIBS_$(module) := $(filter-out $(BROKEN_STATIC_LIBS), $(shell cat \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_static-libs/$(module)/module-included-libs.txt))) \
|
||||
)
|
||||
|
||||
STATIC_LIB_FILES := $(foreach module, $(STATIC_LIB_MODULES), \
|
||||
$(foreach lib, $(LIBS_$(module)), \
|
||||
$(SUPPORT_OUTPUTDIR)/native/$(module)/lib$(lib)/static/$(LIBRARY_PREFIX)$(lib)$(STATIC_LIBRARY_SUFFIX)))
|
||||
|
||||
# Add Hotspot
|
||||
STATIC_LIB_FILES += $(wildcard $(HOTSPOT_STATIC_LIB_PATH)/$(LIBRARY_PREFIX)jvm$(STATIC_LIBRARY_SUFFIX))
|
||||
|
||||
# Figure out what external libraries are required to link these static JDK
|
||||
# libraries.
|
||||
LIB_FLAGS_FILES := $(addsuffix .lib-flags.txt, $(STATIC_LIB_FILES))
|
||||
|
||||
# Gather the lib flags from all individual libraries. There are many duplicates,
|
||||
# so sort and just keep unique instances. On macOS, a common pattern is
|
||||
# "-framework FooFramework", so we must make sure we keep the two words together.
|
||||
EXTERNAL_LIBS := $(strip $(shell $(CAT) $(LIB_FLAGS_FILES) | \
|
||||
$(SED) -e 's/-framework /-framework_/g' | $(TR) ' ' '\n' | $(SORT) -u | \
|
||||
$(SED) -e 's/-framework_/-framework /g'))
|
||||
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
STATIC_LIBS := $(addprefix -force_load$(SPACE), $(STATIC_LIB_FILES))
|
||||
STANDARD_LIBS += -lstdc++
|
||||
else ifeq ($(call isTargetOs, linux), true)
|
||||
STATIC_LIBS := -Wl,--export-dynamic -Wl,--whole-archive $(STATIC_LIB_FILES) -Wl,--no-whole-archive
|
||||
STANDARD_LIBS := -l:libstdc++.a
|
||||
else ifeq ($(call isTargetOs, windows), true)
|
||||
STATIC_LIBS := $(addprefix -wholearchive:, $(STATIC_LIB_FILES))
|
||||
else
|
||||
$(error Unsupported platform)
|
||||
endif
|
||||
|
||||
$(eval $(call SetupBuildLauncher, java, \
|
||||
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
|
||||
EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
|
||||
VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
|
||||
OPTIMIZATION := HIGH, \
|
||||
STATIC_LAUNCHER := true, \
|
||||
LDFLAGS := $(LDFLAGS_STATIC_JDK), \
|
||||
LIBS := $(STATIC_LIBS) $(EXTERNAL_LIBS) $(STANDARD_LIBS), \
|
||||
OUTPUT_DIR := $(STATIC_LAUNCHER_OUTPUT_DIR), \
|
||||
OBJECT_DIR := $(STATIC_LAUNCHER_OUTPUT_DIR), \
|
||||
))
|
||||
|
||||
$(java): $(STATIC_LIB_FILES)
|
||||
|
||||
TARGETS += $(java)
|
||||
|
||||
JAVA_LAUNCHER := $(BUILD_LAUNCHER_java_TARGET)
|
||||
|
||||
static-launcher: $(java)
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Create the static-jdk image with the statically built java launcher
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Until we get proper support in jlink for generating an image with static
|
||||
# builds, we need to create the image ourselves. We base it on a normal
|
||||
# dynamically linked JDK image.
|
||||
|
||||
# All these files/dirs should be copied as-is
|
||||
JDK_IMAGE_COPY_FILES := $(addprefix $(JDK_IMAGE_DIR)/, conf demo include jmods \
|
||||
legal man/man1/java.1 release README)
|
||||
|
||||
# We need to copy some files from lib, but not the dynamic libraries themselves
|
||||
ALL_LIB_FILES := $(call FindFiles, $(JDK_IMAGE_DIR)/lib)
|
||||
|
||||
# Remove all dynamic libraries from the list
|
||||
JDK_IMAGE_COPY_LIB_FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(ALL_LIB_FILES))
|
||||
# Remove all debug files from the list
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
JDK_IMAGE_COPY_LIB_FILES := $(call not-containing, .dSYM, $(JDK_IMAGE_COPY_LIB_FILES))
|
||||
else
|
||||
JDK_IMAGE_COPY_LIB_FILES := $(filter-out %.debuginfo %.pdb %.map, $(JDK_IMAGE_COPY_LIB_FILES))
|
||||
endif
|
||||
|
||||
static-jdk-info:
|
||||
$(call LogWarn, Creating static-jdk image)
|
||||
|
||||
$(eval $(call SetupCopyFiles, copy-from-jdk-image, \
|
||||
SRC := $(JDK_IMAGE_DIR), \
|
||||
DEST := $(STATIC_JDK_IMAGE_DIR), \
|
||||
FILES := $(call FindFiles, $(JDK_IMAGE_COPY_FILES)) \
|
||||
$(JDK_IMAGE_COPY_LIB_FILES), \
|
||||
))
|
||||
|
||||
TARGETS += $(copy-from-jdk-image)
|
||||
|
||||
$(copy-from-jdk-image): | static-jdk-info
|
||||
|
||||
$(eval $(call SetupCopyFiles, copy-static-launcher, \
|
||||
FILES := $(JAVA_LAUNCHER), \
|
||||
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
|
||||
))
|
||||
|
||||
TARGETS += $(copy-static-launcher)
|
||||
|
||||
$(eval $(call SetupCopyFiles, copy-static-launcher-debuginfo, \
|
||||
SRC := $(STATIC_LAUNCHER_OUTPUT_DIR), \
|
||||
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
|
||||
FILES := $(call FindDebuginfoFiles, $(STATIC_LAUNCHER_OUTPUT_DIR)), \
|
||||
))
|
||||
|
||||
TARGETS += $(copy-static-launcher-debuginfo)
|
||||
|
||||
static-jdk-image: $(copy-from-jdk-image) $(copy-static-launcher) $(copy-static-launcher-debuginfo)
|
||||
|
||||
TARGETS += static-jdk-image
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
.PHONY: all static-launcher static-jdk-image
|
||||
@ -192,18 +192,23 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP],
|
||||
# Export variables according to old definitions, prefix with $2 if present.
|
||||
LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \
|
||||
$OS_LDFLAGS $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}"
|
||||
$2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \
|
||||
$2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON \
|
||||
$SHARED_LIBRARY_FLAGS $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
|
||||
$2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \
|
||||
${$1_CPU_EXECUTABLE_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
|
||||
|
||||
$2LDFLAGS_STATIC_JDK="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY \
|
||||
$OS_LDFLAGS ${$2EXTRA_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
|
||||
|
||||
$2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS $OS_LDFLAGS_JVM_ONLY \
|
||||
$DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \
|
||||
$DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY \
|
||||
${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS} \
|
||||
$REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS"
|
||||
|
||||
AC_SUBST($2LDFLAGS_JDKLIB)
|
||||
AC_SUBST($2LDFLAGS_JDKEXE)
|
||||
|
||||
AC_SUBST($2LDFLAGS_STATIC_JDK)
|
||||
|
||||
AC_SUBST($2JVM_LDFLAGS)
|
||||
])
|
||||
|
||||
@ -369,6 +369,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
|
||||
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
|
||||
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
|
||||
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
|
||||
LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $GCOV_LDFLAGS"
|
||||
])
|
||||
AC_SUBST(GCOV_ENABLED)
|
||||
|
||||
@ -463,6 +464,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
|
||||
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS"
|
||||
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS"
|
||||
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS"
|
||||
LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $ASAN_LDFLAGS"
|
||||
])
|
||||
AC_SUBST(ASAN_ENABLED)
|
||||
])
|
||||
@ -496,6 +498,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER],
|
||||
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $LSAN_CFLAGS"
|
||||
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $LSAN_LDFLAGS"
|
||||
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $LSAN_LDFLAGS"
|
||||
LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $LSAN_LDFLAGS"
|
||||
])
|
||||
AC_SUBST(LSAN_ENABLED)
|
||||
])
|
||||
@ -538,6 +541,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
|
||||
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $UBSAN_CFLAGS"
|
||||
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $UBSAN_LDFLAGS"
|
||||
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $UBSAN_LDFLAGS"
|
||||
LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $UBSAN_LDFLAGS"
|
||||
])
|
||||
if test "x$UBSAN_ENABLED" = xfalse; then
|
||||
UBSAN_CFLAGS=""
|
||||
|
||||
@ -559,6 +559,9 @@ LDFLAGS_JDKLIB := @LDFLAGS_JDKLIB@
|
||||
# LDFLAGS used to link the jdk native launchers (C-code)
|
||||
LDFLAGS_JDKEXE := @LDFLAGS_JDKEXE@
|
||||
|
||||
# LDFLAGS used to link the static jdk library
|
||||
LDFLAGS_STATIC_JDK := @LDFLAGS_STATIC_JDK@
|
||||
|
||||
# LDFLAGS specific to C++ linking.
|
||||
LDFLAGS_CXX_JDK := @LDFLAGS_CXX_JDK@
|
||||
|
||||
|
||||
@ -307,3 +307,26 @@ ifeq ($(DISABLE_CACHE_FIND), true)
|
||||
else
|
||||
FindFiles = $(CacheFindFiles)
|
||||
endif
|
||||
|
||||
# Find native debuginfo files in a directory
|
||||
#
|
||||
# Param 1 - dir to find debuginfo files in
|
||||
FindDebuginfoFiles = \
|
||||
$(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \
|
||||
$(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \
|
||||
$(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES)))
|
||||
|
||||
# Pick the correct debug info files to copy, either zipped or not.
|
||||
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
|
||||
DEBUGINFO_SUFFIXES += .diz
|
||||
else
|
||||
DEBUGINFO_SUFFIXES := .debuginfo .pdb .map
|
||||
# On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
|
||||
# dirs.
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
$(call FillFindCache, \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds)
|
||||
FindDebuginfoFiles = \
|
||||
$(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1)))
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -275,6 +275,8 @@ JDK_RCFLAGS=$(RCFLAGS) \
|
||||
# and EXTRA_HEADER_DIRS will be added.
|
||||
# JDK_LIBS_<os> or JDK_LIBS_<osType> -- additional JDK_LIBS for the given OS
|
||||
# or OS type only
|
||||
# ONLY_EXPORTED -- if true, this library will be flagged as not
|
||||
# to be included for this module when building static libs
|
||||
# EXTRA_RCFLAGS -- additional RCFLAGS to append.
|
||||
# RC_FILEDESC -- override the default FILEDESC for Windows version.rc
|
||||
# DEFAULT_LIBCXX -- if false, do not add LIBCXX to LIBS for C++ compilations
|
||||
@ -303,6 +305,15 @@ define SetupJdkNativeCompilationBody
|
||||
$1_RC_FTYPE := 0x2L
|
||||
endif
|
||||
|
||||
ifneq ($$(MODULE), )
|
||||
# Record the fact that this native library is part of the current module
|
||||
# (unless told otherwise). This variable stores information about all
|
||||
# created libraries, and is read by ModuleWrapper.
|
||||
ifneq ($$($1_ONLY_EXPORTED), true)
|
||||
$$(MODULE)_INCLUDED_LIBS += $$($1_NAME)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$($1_OUTPUT_DIR), )
|
||||
ifneq ($$(MODULE), )
|
||||
ifeq ($$($1_TYPE), STATIC_LIBRARY)
|
||||
@ -422,10 +433,10 @@ define SetupJdkNativeCompilationBody
|
||||
ifneq ($$($1_DEFAULT_LDFLAGS), false)
|
||||
ifeq ($$($1_TYPE), EXECUTABLE)
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE)) $$($1_LDFLAGS)
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE) $$($1_LDFLAGS))
|
||||
else
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB)) $$($1_LDFLAGS)
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB) $$($1_LDFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@ JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest
|
||||
# OPTIMIZATION Override default optimization level (LOW)
|
||||
# OUTPUT_DIR Override default output directory
|
||||
# VERSION_INFO_RESOURCE Override default Windows resource file
|
||||
# STATIC_LAUNCHER If true, will use settings for building a static launcher
|
||||
SetupBuildLauncher = $(NamedParamsMacroTemplate)
|
||||
define SetupBuildLauncherBody
|
||||
# Setup default values (unless overridden)
|
||||
@ -120,6 +121,15 @@ define SetupBuildLauncherBody
|
||||
$1_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.c
|
||||
endif
|
||||
|
||||
ifneq ($$($1_STATIC_LAUNCHER), true)
|
||||
$1_JDK_LIBS := java.base:libjli
|
||||
$1_JDK_LIBS_windows := java.base:libjava
|
||||
else
|
||||
ifneq ($(findstring $(TOOLCHAIN_TYPE), gcc clang), )
|
||||
$1_LDFLAGS_FILTER_OUT := -Wl$(COMMA)--exclude-libs$(COMMA)ALL
|
||||
endif
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
## Build launcher "$1"
|
||||
##############################################################################
|
||||
@ -140,8 +150,9 @@ define SetupBuildLauncherBody
|
||||
LDFLAGS := $$($1_LDFLAGS), \
|
||||
LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
|
||||
LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
|
||||
JDK_LIBS := java.base:libjli, \
|
||||
JDK_LIBS_windows := java.base:libjava, \
|
||||
LDFLAGS_FILTER_OUT := $$($1_LDFLAGS_FILTER_OUT), \
|
||||
JDK_LIBS := $$($1_JDK_LIBS), \
|
||||
JDK_LIBS_windows := $$($1_JDK_LIBS_windows), \
|
||||
LIBS := $$($1_LIBS), \
|
||||
LIBS_unix := $(LIBZ_LIBS), \
|
||||
LIBS_linux := $(LIBDL) -lpthread, \
|
||||
@ -150,6 +161,7 @@ define SetupBuildLauncherBody
|
||||
-framework Cocoa \
|
||||
-framework Security, \
|
||||
OUTPUT_DIR := $$($1_OUTPUT_DIR), \
|
||||
OBJECT_DIR := $$($1_OBJECT_DIR), \
|
||||
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \
|
||||
EXTRA_RCFLAGS := $$($1_EXTRA_RCFLAGS), \
|
||||
MANIFEST := $(JAVA_MANIFEST), \
|
||||
|
||||
@ -119,6 +119,7 @@ define CreateStaticLibrary
|
||||
$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
|
||||
$$($1_AR) $$(ARFLAGS) -r -cs $$($1_TARGET) \
|
||||
$$($1_AR_OBJ_ARG) $$($1_RES))
|
||||
$$(ECHO) $$(strip $$($1_LIBS) $$($1_EXTRA_LIBS)) > $$($1_TARGET).lib-flags.txt
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
|
||||
@ -54,7 +54,8 @@ define CreateStaticLibraryMicrosoft
|
||||
$$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
|
||||
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_run_lib, \
|
||||
$$($1_LIB) -nologo $$(LIBFLAGS) -out:$$($1_TARGET) \
|
||||
$$($1_LD_OBJ_ARG) $$($1_RES))
|
||||
$$($1_LD_OBJ_ARG))
|
||||
$$(ECHO) $$(strip $$($1_LIBS) $$($1_EXTRA_LIBS)) > $$($1_TARGET).lib-flags.txt
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
|
||||
@ -168,10 +168,16 @@ ifeq ($(call isTargetOs, windows macosx), false)
|
||||
# static libraries cause linking errors due to duplicate symbols.
|
||||
LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS := systemScale.o
|
||||
|
||||
ifneq ($(ENABLE_HEADLESS_ONLY), true)
|
||||
# We cannot link with both awt_headless and awt_xawt at the same time
|
||||
LIBAWT_HEADLESS_ONLY_EXPORTED := true
|
||||
endif
|
||||
|
||||
$(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \
|
||||
NAME := awt_headless, \
|
||||
EXTRA_SRC := $(LIBAWT_HEADLESS_EXTRA_SRC), \
|
||||
EXCLUDES := medialib, \
|
||||
ONLY_EXPORTED := $(LIBAWT_HEADLESS_ONLY_EXPORTED), \
|
||||
OPTIMIZATION := LOW, \
|
||||
CFLAGS := -DHEADLESS=true $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) \
|
||||
$(X_CFLAGS), \
|
||||
@ -308,6 +314,8 @@ ifeq ($(call isTargetOs, macosx), true)
|
||||
LIBAWT_LWAWT_EXCLUDE_FILES := fontpath.c awt_Font.c X11Color.c
|
||||
LIBAWT_LWAWT_EXCLUDES := $(TOPDIR)/src/$(MODULE)/unix/native/common/awt/medialib
|
||||
|
||||
LIBAWT_LWAWT_STATIC_EXCLUDE_OBJS := systemScale.o
|
||||
|
||||
$(eval $(call SetupJdkLibrary, BUILD_LIBAWT_LWAWT, \
|
||||
NAME := awt_lwawt, \
|
||||
EXTRA_SRC := $(LIBAWT_LWAWT_EXTRA_SRC), \
|
||||
@ -346,6 +354,7 @@ ifeq ($(call isTargetOs, macosx), true)
|
||||
-framework OpenGL \
|
||||
-framework QuartzCore \
|
||||
-framework Security, \
|
||||
STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_LWAWT_STATIC_EXCLUDE_OBJS), \
|
||||
))
|
||||
|
||||
TARGETS += $(BUILD_LIBAWT_LWAWT)
|
||||
|
||||
@ -155,6 +155,9 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
|
||||
|
||||
ifeq ($(USE_EXTERNAL_LIBJPEG), false)
|
||||
LIBSPLASHSCREEN_EXTRA_SRC += libjavajpeg
|
||||
LIBJAVA_JPEG_OBJS := $(sort $(patsubst %.c,%.o, $(filter-out imageioJPEG.c, \
|
||||
$(notdir $(wildcard $(TOPDIR)/src/java.desktop/share/native/libjavajpeg/*.c)))))
|
||||
LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += $(LIBJAVA_JPEG_OBJS)
|
||||
endif
|
||||
|
||||
ifeq ($(USE_EXTERNAL_LIBPNG), false)
|
||||
@ -165,6 +168,10 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
|
||||
|
||||
ifeq ($(USE_EXTERNAL_LIBZ), false)
|
||||
LIBSPLASHSCREEN_EXTRA_SRC += java.base:libzip/zlib
|
||||
LIBZIP_SRC_PATH := $(TOPDIR)/src/java.base/share/native/libzip
|
||||
LIBZIP_OBJS := $(sort $(patsubst %.c,%.o, $(notdir \
|
||||
$(wildcard $(LIBZIP_SRC_PATH)/*.c $(LIBZIP_SRC_PATH)/zlib/*.c))))
|
||||
LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += $(LIBZIP_OBJS)
|
||||
endif
|
||||
|
||||
LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \
|
||||
@ -207,6 +214,8 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
|
||||
LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS)
|
||||
endif
|
||||
|
||||
LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += systemScale.o
|
||||
|
||||
$(eval $(call SetupJdkLibrary, BUILD_LIBSPLASHSCREEN, \
|
||||
NAME := splashscreen, \
|
||||
EXTRA_SRC := $(LIBSPLASHSCREEN_EXTRA_SRC), \
|
||||
@ -257,6 +266,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
|
||||
-framework Security, \
|
||||
LIBS_aix := $(LIBDL) -liconv $(X_LIBS) -lX11 -lXext, \
|
||||
LIBS_windows := delayimp.lib gdi32.lib kernel32.lib user32.lib, \
|
||||
STATIC_LIB_EXCLUDE_OBJS := $(LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS), \
|
||||
))
|
||||
|
||||
TARGETS += $(BUILD_LIBSPLASHSCREEN)
|
||||
|
||||
@ -38,6 +38,7 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
NAME := javaaccessbridge, \
|
||||
EXTRA_SRC := common, \
|
||||
OPTIMIZATION := LOW, \
|
||||
ONLY_EXPORTED := true, \
|
||||
DISABLED_WARNINGS_microsoft := 4311 4302 4312, \
|
||||
CXXFLAGS_FILTER_OUT := -MD, \
|
||||
CXXFLAGS := -MT -DACCESSBRIDGE_ARCH_64, \
|
||||
@ -67,6 +68,7 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
CXXFLAGS := -DACCESSBRIDGE_ARCH_64, \
|
||||
EXTRA_HEADER_DIRS := \
|
||||
include/bridge, \
|
||||
ONLY_EXPORTED := true, \
|
||||
LDFLAGS := \
|
||||
-def:$(ACCESSIBILITY_SRCDIR)/libwindowsaccessbridge/WinAccessBridge.DEF, \
|
||||
LIBS_windows := advapi32.lib comdlg32.lib gdi32.lib kernel32.lib \
|
||||
|
||||
@ -49,6 +49,7 @@ $(eval $(call SetupJdkExecutable, BUILD_JPACKAGEAPPLAUNCHER, \
|
||||
LINK_TYPE := $(JPACKAGEAPPLAUNCHER_LINK_TYPE), \
|
||||
OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \
|
||||
SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jpackageapplauncher, \
|
||||
ONLY_EXPORTED := true, \
|
||||
SRC := applauncher, \
|
||||
EXTRA_SRC := common, \
|
||||
INCLUDE_FILES := $(JPACKAGEAPPLAUNCHER_INCLUDE_FILES), \
|
||||
@ -83,6 +84,7 @@ ifeq ($(call isTargetOs, linux), true)
|
||||
OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \
|
||||
SYMBOLS_DIR := \
|
||||
$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjpackageapplauncheraux, \
|
||||
ONLY_EXPORTED := true, \
|
||||
SRC := libapplauncher, \
|
||||
EXTRA_SRC := \
|
||||
applauncher \
|
||||
@ -127,6 +129,7 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
NAME := wixhelper, \
|
||||
OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \
|
||||
SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libwixhelper, \
|
||||
ONLY_EXPORTED := true, \
|
||||
OPTIMIZATION := LOW, \
|
||||
EXTRA_SRC := common, \
|
||||
CXXFLAGS_FILTER_OUT := -MD, \
|
||||
@ -146,6 +149,7 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
NAME := msiwrapper, \
|
||||
OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \
|
||||
SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/msiwrapper, \
|
||||
ONLY_EXPORTED := true, \
|
||||
EXTRA_SRC := common, \
|
||||
CXXFLAGS_FILTER_OUT := -MD, \
|
||||
CXXFLAGS_windows := -MT $(JPACKAGE_CXXFLAGS_windows), \
|
||||
@ -164,6 +168,7 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \
|
||||
SYMBOLS_DIR := \
|
||||
$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jpackageapplauncherw, \
|
||||
ONLY_EXPORTED := true, \
|
||||
SRC := applauncher, \
|
||||
EXTRA_SRC := common, \
|
||||
OPTIMIZATION := LOW, \
|
||||
|
||||
@ -562,6 +562,7 @@ void os::init_system_properties_values() {
|
||||
// Base path of extensions installed on the system.
|
||||
#define SYS_EXT_DIR "/usr/java/packages"
|
||||
#define EXTENSIONS_DIR "/lib/ext"
|
||||
#define JVM_LIB_NAME "libjvm.so"
|
||||
|
||||
// Buffer that fits several snprintfs.
|
||||
// Note that the space for the colon and the trailing null are provided
|
||||
@ -576,22 +577,32 @@ void os::init_system_properties_values() {
|
||||
char *pslash;
|
||||
os::jvm_path(buf, bufsize);
|
||||
|
||||
// Found the full path to libjvm.so.
|
||||
// Now cut the path to <java_home>/jre if we can.
|
||||
// Found the full path to the binary. It is normally of this structure:
|
||||
// <jdk_path>/lib/<hotspot_variant>/libjvm.so
|
||||
// but can also be like this for a statically linked binary:
|
||||
// <jdk_path>/bin/<executable>
|
||||
pslash = strrchr(buf, '/');
|
||||
if (pslash != nullptr) {
|
||||
*pslash = '\0'; // Get rid of /libjvm.so.
|
||||
}
|
||||
pslash = strrchr(buf, '/');
|
||||
if (pslash != nullptr) {
|
||||
*pslash = '\0'; // Get rid of /{client|server|hotspot}.
|
||||
if (strncmp(pslash + 1, JVM_LIB_NAME, strlen(JVM_LIB_NAME)) == 0) {
|
||||
// Binary name is libjvm.so. Get rid of /libjvm.so.
|
||||
*pslash = '\0';
|
||||
}
|
||||
|
||||
// Get rid of /<hotspot_variant>, if binary is libjvm.so,
|
||||
// or cut off /<executable>, if it is a statically linked binary.
|
||||
pslash = strrchr(buf, '/');
|
||||
if (pslash != nullptr) {
|
||||
*pslash = '\0';
|
||||
}
|
||||
}
|
||||
Arguments::set_dll_dir(buf);
|
||||
|
||||
// Get rid of /lib, if binary is libjvm.so,
|
||||
// or cut off /bin, if it is a statically linked binary.
|
||||
if (pslash != nullptr) {
|
||||
pslash = strrchr(buf, '/');
|
||||
if (pslash != nullptr) {
|
||||
*pslash = '\0'; // Get rid of /lib.
|
||||
*pslash = '\0';
|
||||
}
|
||||
}
|
||||
Arguments::set_java_home(buf);
|
||||
|
||||
@ -854,6 +854,12 @@ void os::dll_unload(void *lib) {
|
||||
LINUX_ONLY(os::free(l_pathdup));
|
||||
}
|
||||
|
||||
void* os::lookup_function(const char* name) {
|
||||
// This returns the global symbol in the main executable and its dependencies,
|
||||
// as well as shared objects dynamically loaded with RTLD_GLOBAL flag.
|
||||
return dlsym(RTLD_DEFAULT, name);
|
||||
}
|
||||
|
||||
jlong os::lseek(int fd, jlong offset, int whence) {
|
||||
return (jlong) ::lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
@ -1401,6 +1401,12 @@ void* os::dll_lookup(void *lib, const char *name) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* os::lookup_function(const char* name) {
|
||||
// This is needed only for static builds which are not supported on Windows
|
||||
ShouldNotReachHere();
|
||||
return nullptr; // Satisfy compiler
|
||||
}
|
||||
|
||||
// Directory routines copied from src/win32/native/java/io/dirent_md.c
|
||||
// * dirent_md.c 1.15 00/02/02
|
||||
//
|
||||
|
||||
@ -949,16 +949,35 @@ void* ClassLoader::dll_lookup(void* lib, const char* name, const char* path) {
|
||||
|
||||
void ClassLoader::load_java_library() {
|
||||
assert(CanonicalizeEntry == nullptr, "should not load java library twice");
|
||||
if (is_vm_statically_linked()) {
|
||||
CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::lookup_function("JDK_Canonicalize"));
|
||||
assert(CanonicalizeEntry != nullptr, "could not lookup JDK_Canonicalize");
|
||||
return;
|
||||
}
|
||||
|
||||
void *javalib_handle = os::native_java_library();
|
||||
if (javalib_handle == nullptr) {
|
||||
vm_exit_during_initialization("Unable to load java library", nullptr);
|
||||
}
|
||||
|
||||
CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", nullptr));
|
||||
assert(CanonicalizeEntry != nullptr, "could not lookup JDK_Canonicalize in java library");
|
||||
}
|
||||
|
||||
void ClassLoader::load_jimage_library() {
|
||||
assert(JImageOpen == nullptr, "should not load jimage library twice");
|
||||
|
||||
if (is_vm_statically_linked()) {
|
||||
JImageOpen = CAST_TO_FN_PTR(JImageOpen_t, os::lookup_function("JIMAGE_Open"));
|
||||
JImageClose = CAST_TO_FN_PTR(JImageClose_t, os::lookup_function("JIMAGE_Close"));
|
||||
JImageFindResource = CAST_TO_FN_PTR(JImageFindResource_t, os::lookup_function("JIMAGE_FindResource"));
|
||||
JImageGetResource = CAST_TO_FN_PTR(JImageGetResource_t, os::lookup_function("JIMAGE_GetResource"));
|
||||
assert(JImageOpen != nullptr && JImageClose != nullptr &&
|
||||
JImageFindResource != nullptr && JImageGetResource != nullptr,
|
||||
"could not lookup all jimage library functions");
|
||||
return;
|
||||
}
|
||||
|
||||
char path[JVM_MAXPATHLEN];
|
||||
char ebuf[1024];
|
||||
void* handle = nullptr;
|
||||
@ -973,6 +992,9 @@ void ClassLoader::load_jimage_library() {
|
||||
JImageClose = CAST_TO_FN_PTR(JImageClose_t, dll_lookup(handle, "JIMAGE_Close", path));
|
||||
JImageFindResource = CAST_TO_FN_PTR(JImageFindResource_t, dll_lookup(handle, "JIMAGE_FindResource", path));
|
||||
JImageGetResource = CAST_TO_FN_PTR(JImageGetResource_t, dll_lookup(handle, "JIMAGE_GetResource", path));
|
||||
assert(JImageOpen != nullptr && JImageClose != nullptr &&
|
||||
JImageFindResource != nullptr && JImageGetResource != nullptr,
|
||||
"could not lookup all jimage library functions in jimage library");
|
||||
}
|
||||
|
||||
int ClassLoader::crc32(int crc, const char* buf, int len) {
|
||||
|
||||
@ -85,15 +85,20 @@ static verify_byte_codes_fn_t verify_byte_codes_fn() {
|
||||
if (_verify_byte_codes_fn != nullptr)
|
||||
return _verify_byte_codes_fn;
|
||||
|
||||
void *lib_handle = nullptr;
|
||||
// Load verify dll
|
||||
char buffer[JVM_MAXPATHLEN];
|
||||
char ebuf[1024];
|
||||
if (!os::dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify"))
|
||||
return nullptr; // Caller will throw VerifyError
|
||||
if (is_vm_statically_linked()) {
|
||||
lib_handle = os::get_default_process_handle();
|
||||
} else {
|
||||
char buffer[JVM_MAXPATHLEN];
|
||||
char ebuf[1024];
|
||||
if (!os::dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify"))
|
||||
return nullptr; // Caller will throw VerifyError
|
||||
|
||||
void *lib_handle = os::dll_load(buffer, ebuf, sizeof(ebuf));
|
||||
if (lib_handle == nullptr)
|
||||
return nullptr; // Caller will throw VerifyError
|
||||
lib_handle = os::dll_load(buffer, ebuf, sizeof(ebuf));
|
||||
if (lib_handle == nullptr)
|
||||
return nullptr; // Caller will throw VerifyError
|
||||
}
|
||||
|
||||
void *fn = os::dll_lookup(lib_handle, "VerifyClassForMajorVersion");
|
||||
if (fn == nullptr)
|
||||
|
||||
@ -513,6 +513,11 @@ static void* _native_java_library = nullptr;
|
||||
|
||||
void* os::native_java_library() {
|
||||
if (_native_java_library == nullptr) {
|
||||
if (is_vm_statically_linked()) {
|
||||
_native_java_library = get_default_process_handle();
|
||||
return _native_java_library;
|
||||
}
|
||||
|
||||
char buffer[JVM_MAXPATHLEN];
|
||||
char ebuf[1024];
|
||||
|
||||
|
||||
@ -763,6 +763,9 @@ class os: AllStatic {
|
||||
// Unload library
|
||||
static void dll_unload(void *lib);
|
||||
|
||||
// Lookup the named function. This is used by the static JDK.
|
||||
static void* lookup_function(const char* name);
|
||||
|
||||
// Callback for loaded module information
|
||||
// Input parameters:
|
||||
// char* module_file_name,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2024, 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
|
||||
@ -60,6 +60,10 @@ static inline bool not_loaded() {
|
||||
}
|
||||
|
||||
static void* dll_lookup(const char* name, const char* path, bool vm_exit_on_failure) {
|
||||
if (is_vm_statically_linked()) {
|
||||
return os::lookup_function(name);
|
||||
}
|
||||
|
||||
assert(_zip_handle != nullptr, "invariant");
|
||||
void* func = os::dll_lookup(_zip_handle, name);
|
||||
if (func == nullptr && vm_exit_on_failure) {
|
||||
@ -87,16 +91,23 @@ static void store_function_pointers(const char* path, bool vm_exit_on_failure) {
|
||||
static void load_zip_library(bool vm_exit_on_failure) {
|
||||
assert(!is_loaded(), "should not load zip library twice");
|
||||
char path[JVM_MAXPATHLEN];
|
||||
if (os::dll_locate_lib(&path[0], sizeof path, Arguments::get_dll_dir(), "zip")) {
|
||||
char ebuf[1024];
|
||||
_zip_handle = os::dll_load(&path[0], &ebuf[0], sizeof ebuf);
|
||||
}
|
||||
if (_zip_handle == nullptr) {
|
||||
if (vm_exit_on_failure) {
|
||||
vm_exit_during_initialization("Unable to load zip library", &path[0]);
|
||||
|
||||
if (is_vm_statically_linked()) {
|
||||
_zip_handle = os::get_default_process_handle();
|
||||
} else {
|
||||
// Load the libzip shared library and lookup the needed functions.
|
||||
if (os::dll_locate_lib(&path[0], sizeof path, Arguments::get_dll_dir(), "zip")) {
|
||||
char ebuf[1024];
|
||||
_zip_handle = os::dll_load(&path[0], &ebuf[0], sizeof ebuf);
|
||||
}
|
||||
if (_zip_handle == nullptr) {
|
||||
if (vm_exit_on_failure) {
|
||||
vm_exit_during_initialization("Unable to load zip library", &path[0]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
store_function_pointers(&path[0], vm_exit_on_failure);
|
||||
Atomic::release_store(&_loaded, true);
|
||||
assert(is_loaded(), "invariant");
|
||||
|
||||
@ -336,29 +336,31 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||
int argc = *pargc;
|
||||
char **argv = *pargv;
|
||||
|
||||
/* Find out where the JDK is that we will be using. */
|
||||
if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE) ) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR1);
|
||||
exit(2);
|
||||
}
|
||||
JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
|
||||
jdkroot, FILESEP, FILESEP);
|
||||
/* Find the specified JVM type */
|
||||
if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR7);
|
||||
exit(1);
|
||||
}
|
||||
if (!JLI_IsStaticallyLinked()) {
|
||||
/* Find out where the JDK is that we will be using. */
|
||||
if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE) ) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR1);
|
||||
exit(2);
|
||||
}
|
||||
JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
|
||||
jdkroot, FILESEP, FILESEP);
|
||||
/* Find the specified JVM type */
|
||||
if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR7);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
jvmpath[0] = '\0';
|
||||
jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
|
||||
if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR9);
|
||||
exit(4);
|
||||
}
|
||||
jvmpath[0] = '\0';
|
||||
jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
|
||||
if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR9);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
|
||||
exit(4);
|
||||
if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) {
|
||||
JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
|
||||
exit(4);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -276,6 +276,13 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||
char jdkroot[], jint so_jdkroot,
|
||||
char jvmpath[], jint so_jvmpath,
|
||||
char jvmcfg[], jint so_jvmcfg) {
|
||||
if (JLI_IsStaticallyLinked()) {
|
||||
// With static builds, all JDK and VM natives are statically linked
|
||||
// with the launcher executable. No need to manipulate LD_LIBRARY_PATH
|
||||
// by adding <jdk_path>/lib and etc. The 'jrepath', 'jvmpath' and
|
||||
// 'jvmcfg' are not used by the caller for static builds. Simply return.
|
||||
return;
|
||||
}
|
||||
|
||||
char * jvmtype = NULL;
|
||||
char **argv = *pargv;
|
||||
@ -318,6 +325,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
|
||||
JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
/*
|
||||
* we seem to have everything we need, so without further ado
|
||||
* we return back, otherwise proceed to set the environment.
|
||||
@ -519,11 +527,15 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
|
||||
|
||||
JLI_TraceLauncher("JVM path is %s\n", jvmpath);
|
||||
|
||||
libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
|
||||
if (libjvm == NULL) {
|
||||
JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
|
||||
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
|
||||
return JNI_FALSE;
|
||||
if (JLI_IsStaticallyLinked()) {
|
||||
libjvm = dlopen(NULL, RTLD_NOW + RTLD_GLOBAL);
|
||||
} else {
|
||||
libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
|
||||
if (libjvm == NULL) {
|
||||
JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
|
||||
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
|
||||
return JNI_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ifn->CreateJavaVM = (CreateJavaVM_t)
|
||||
@ -600,22 +612,26 @@ void* SplashProcAddress(const char* name) {
|
||||
char jdkRoot[MAXPATHLEN];
|
||||
char splashPath[MAXPATHLEN];
|
||||
|
||||
if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR1);
|
||||
return NULL;
|
||||
}
|
||||
ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s",
|
||||
if (JLI_IsStaticallyLinked()) {
|
||||
hSplashLib = dlopen(NULL, RTLD_LAZY);
|
||||
} else {
|
||||
if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR1);
|
||||
return NULL;
|
||||
}
|
||||
ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s",
|
||||
jdkRoot, SPLASHSCREEN_SO);
|
||||
|
||||
if (ret >= (int) sizeof(splashPath)) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR3);
|
||||
return NULL;
|
||||
if (ret >= (int) sizeof(splashPath)) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR3);
|
||||
return NULL;
|
||||
}
|
||||
if (ret < 0) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR5);
|
||||
return NULL;
|
||||
}
|
||||
hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL);
|
||||
}
|
||||
if (ret < 0) {
|
||||
JLI_ReportErrorMessage(LAUNCHER_ERROR5);
|
||||
return NULL;
|
||||
}
|
||||
hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL);
|
||||
JLI_TraceLauncher("Info: loaded %s\n", splashPath);
|
||||
}
|
||||
if (hSplashLib) {
|
||||
|
||||
@ -132,7 +132,9 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!JVM_IsStaticallyLinked()) {
|
||||
if (JVM_IsStaticallyLinked()) {
|
||||
awtHandle = dlopen(NULL, RTLD_LAZY);
|
||||
} else {
|
||||
/* Get address of this library and the directory containing it. */
|
||||
dladdr((void *)AWT_OnLoad, &dlinfo);
|
||||
realpath((char *)dlinfo.dli_fname, buf);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user