jdk-24/make/modules/java.base/lib/CoreLibraries.gmk
Daniel Jeliński 8cbe42b94a 8316421: libjava should load shell32.dll eagerly
Reviewed-by: erikj, jwaters, jvernee
2023-09-21 12:39:03 +00:00

212 lines
7.3 KiB
Plaintext

#
# Copyright (c) 2011, 2023, 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.
#
##########################################################################################
LIBVERIFY_OPTIMIZATION := HIGH
ifeq ($(call isTargetOs, linux), true)
ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
LIBVERIFY_OPTIMIZATION := LOW
endif
endif
$(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
NAME := verify, \
OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
CFLAGS := $(CFLAGS_JDKLIB), \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljvm, \
LIBS_windows := jvm.lib, \
))
TARGETS += $(BUILD_LIBVERIFY)
##########################################################################################
LIBJAVA_CFLAGS := -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
ifeq ($(call isTargetOs, macosx), true)
BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c
endif
$(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
NAME := java, \
OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBJAVA_CFLAGS), \
jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc_ProcessImpl_md.c := unused-result, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
LIBS_unix := -ljvm, \
LIBS_linux := $(LIBDL), \
LIBS_aix := $(LIBDL) $(LIBM),\
LIBS_macosx := -framework CoreFoundation \
-framework Foundation \
-framework SystemConfiguration, \
LIBS_windows := jvm.lib \
shell32.lib ole32.lib \
advapi32.lib version.lib, \
))
TARGETS += $(BUILD_LIBJAVA)
$(BUILD_LIBJAVA): $(BUILD_LIBVERIFY)
##########################################################################################
BUILD_LIBZIP_EXCLUDES :=
ifeq ($(USE_EXTERNAL_LIBZ), true)
LIBZIP_EXCLUDES += zlib
endif
ifeq ($(LIBZIP_CAN_USE_MMAP), true)
BUILD_LIBZIP_MMAP := -DUSE_MMAP
endif
$(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \
NAME := zip, \
OPTIMIZATION := LOW, \
EXCLUDES := $(LIBZIP_EXCLUDES), \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBZ_CFLAGS), \
CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
DISABLED_WARNINGS_gcc_zip_util.c := unused-function, \
DISABLED_WARNINGS_clang := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_gzwrite.c := format-nonliteral, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljvm -ljava $(LIBZ_LIBS), \
LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
))
$(BUILD_LIBZIP): $(BUILD_LIBJAVA)
TARGETS += $(BUILD_LIBZIP)
##########################################################################################
$(eval $(call SetupJdkLibrary, BUILD_LIBJIMAGE, \
NAME := jimage, \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB), \
CXXFLAGS := $(CXXFLAGS_JDKLIB), \
CFLAGS_unix := -UDEBUG, \
LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljvm -ldl $(LIBCXX), \
LIBS_windows := jvm.lib, \
))
$(BUILD_LIBJIMAGE): $(BUILD_LIBJAVA)
TARGETS += $(BUILD_LIBJIMAGE)
##########################################################################################
ifeq ($(call isTargetOs, macosx), true)
LIBJLI_EXCLUDE_FILES += java_md.c
endif
ifeq ($(call isTargetOs, windows), true)
# Supply the name of the C runtime libs.
ifneq ($(MSVCR_DLL), )
LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
endif
ifneq ($(VCRUNTIME_1_DLL), )
LIBJLI_CFLAGS += -DVCRUNTIME_1_DLL_NAME='"$(notdir $(VCRUNTIME_1_DLL))"'
endif
ifneq ($(MSVCP_DLL), )
LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
endif
endif
LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
ifneq ($(USE_EXTERNAL_LIBZ), true)
# Extra files from the zlib.
LIBJLI_EXTRA_FILE_LIST := inflate.c inftrees.c inffast.c zadler32.c zcrc32.c zutil.c
LIBJLI_EXTRA_FILES += \
$(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \
$(LIBJLI_EXTRA_FILE_LIST))
# Do not include these libz objects in the static libjli library.
# When statically linking the java launcher with all JDK and VM
# static libraries, we use the --whole-archive linker option.
# The duplicate objects in different static libraries cause linking
# errors due to duplicate symbols.
LIBJLI_STATIC_EXCLUDE_OBJS := $(subst .c,$(OBJ_SUFFIX),$(LIBJLI_EXTRA_FILE_LIST))
endif
$(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
NAME := jli, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
DISABLED_WARNINGS_gcc := unused-function, \
DISABLED_WARNINGS_clang := format-nonliteral deprecated-non-prototype, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := $(LIBZ_LIBS), \
LIBS_linux := $(LIBDL) -lpthread, \
LIBS_aix := $(LIBDL),\
LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
LIBS_windows := advapi32.lib comctl32.lib user32.lib, \
STATIC_LIB_EXCLUDE_OBJS := $(LIBJLI_STATIC_EXCLUDE_OBJS), \
))
TARGETS += $(BUILD_LIBJLI)
LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli)
ifeq ($(call isTargetOs, aix), true)
# AIX also requires a static libjli because the compiler doesn't support '-rpath'
$(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) $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \
$(addprefix -I, $(LIBJLI_SRC_DIRS)), \
DISABLED_WARNINGS_clang_aix := format-nonliteral deprecated-non-prototype, \
ARFLAGS := $(ARFLAGS), \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static))
TARGETS += $(BUILD_LIBJLI_STATIC)
endif