8333301: Remove static builds using --enable-static-build

Reviewed-by: sgehwolf, erikj
This commit is contained in:
Magnus Ihse Bursie 2024-06-03 10:03:42 +00:00
parent b10158624b
commit f0bffbce35
14 changed files with 12 additions and 214 deletions

View File

@ -1,54 +0,0 @@
#
# Copyright (c) 2015, 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
# 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
################################################################################
#
# Concatenate exported.symbols files for modules into a single global file.
#
GLOBAL_SYMBOLS_FILE := $(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
EXPORTED_SYMBOLS_MODULES := java.base jdk.jdwp.agent
MODULES_SYMBOLS_FILES := $(foreach module, $(EXPORTED_SYMBOLS_MODULES), \
$(SUPPORT_OUTPUTDIR)/modules_libs/$(module)/$(module).symbols)
$(GLOBAL_SYMBOLS_FILE): $(MODULES_SYMBOLS_FILES)
$(call LogInfo, Generating global exported.symbols file)
$(call MakeTargetDir)
$(CAT) $^ > $@
TARGETS += $(GLOBAL_SYMBOLS_FILE)
################################################################################
all: $(TARGETS)
.PHONY: default all

View File

@ -96,14 +96,6 @@ $(eval $(call SetupTarget, buildtools-hotspot, \
MAKEFILE := CompileToolsHotspot, \
))
################################################################################
# Special targets for certain modules
$(eval $(call SetupTarget, generate-exported-symbols, \
MAKEFILE := BuildStatic, \
DEPS := java.base-libs jdk.jdwp.agent-libs, \
))
################################################################################
# Gensrc targets, generating source before java compilation can be done
#
@ -905,10 +897,6 @@ else
$(LAUNCHER_TARGETS): java.base-libs
ifeq ($(STATIC_BUILD), true)
$(LAUNCHER_TARGETS): generate-exported-symbols
endif
# Declare dependency from <module>-java to <module>-gensrc
$(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))

View File

@ -641,12 +641,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
JDK_PICFLAG="$PICFLAG"
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
# Linking is different on MacOSX
JDK_PICFLAG=''
if test "x$STATIC_BUILD" = xtrue; then
# Linking is different on macOS
JVM_PICFLAG=""
fi
fi
# Extra flags needed when building optional static versions of certain
# JDK libraries.

View File

@ -267,11 +267,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
fi
],
[
if test "x$STATIC_BUILD" = xtrue; then
with_native_debug_symbols="none"
else
with_native_debug_symbols="external"
fi
])
AC_MSG_RESULT([$with_native_debug_symbols])
@ -543,24 +539,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
#
AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
[
UTIL_ARG_ENABLE(NAME: static-build, DEFAULT: false, RESULT: STATIC_BUILD,
DESC: [enable static library build],
CHECKING_MSG: [if static build is enabled],
CHECK_AVAILABLE: [
AC_MSG_CHECKING([if static build is available])
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AVAILABLE=false
fi
],
IF_ENABLED: [
STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1"
CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS"
])
AC_SUBST(STATIC_BUILD)
UTIL_DEPRECATED_ARG_ENABLE(static-build)
])
################################################################################

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
@ -46,7 +46,7 @@ m4_define(jvm_features_valid, m4_normalize( \
\
cds compiler1 compiler2 dtrace epsilongc g1gc jfr jni-check \
jvmci jvmti link-time-opt management minimal opt-size parallelgc \
serialgc services shenandoahgc static-build vm-structs zero zgc \
serialgc services shenandoahgc vm-structs zero zgc \
))
# Deprecated JVM features (these are ignored, but with a warning)
@ -309,22 +309,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_SHENANDOAHGC],
])
])
###############################################################################
# Check if the feature 'static-build' is available on this platform.
#
AC_DEFUN_ONCE([JVM_FEATURES_CHECK_STATIC_BUILD],
[
JVM_FEATURES_CHECK_AVAILABILITY(static-build, [
AC_MSG_CHECKING([if static-build is enabled in configure])
if test "x$STATIC_BUILD" = "xtrue"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, use --enable-static-build to enable static build.])
AVAILABLE=false
fi
])
])
###############################################################################
# Check if the feature 'zgc' is available on this platform.
#
@ -395,7 +379,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_PREPARE_PLATFORM],
JVM_FEATURES_CHECK_DTRACE
JVM_FEATURES_CHECK_JVMCI
JVM_FEATURES_CHECK_SHENANDOAHGC
JVM_FEATURES_CHECK_STATIC_BUILD
JVM_FEATURES_CHECK_ZGC
])

View File

@ -632,7 +632,6 @@ SHARED_LIBRARY_SUFFIX := @SHARED_LIBRARY_SUFFIX@
STATIC_LIBRARY_SUFFIX := @STATIC_LIBRARY_SUFFIX@
EXECUTABLE_SUFFIX := @EXECUTABLE_SUFFIX@
OBJ_SUFFIX := @OBJ_SUFFIX@
STATIC_BUILD := @STATIC_BUILD@
STRIPFLAGS := @STRIPFLAGS@

View File

@ -178,23 +178,14 @@ AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
EXECUTABLE_SUFFIX='.exe'
else
LIBRARY_PREFIX=lib
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
SHARED_LIBRARY_SUFFIX='.dylib'
else
SHARED_LIBRARY_SUFFIX='.so'
fi
STATIC_LIBRARY_SUFFIX='.a'
OBJ_SUFFIX='.o'
EXECUTABLE_SUFFIX=''
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
# For full static builds, we're overloading the shared library suffix
# in order to limit the amount of changes required.
# It would be better to remove SHARED and just use LIBRARY and
# LIBRARY_SUFFIX for libraries that can be built either
# shared or static and use STATIC_* for libraries that are
# always built statically.
if test "x$STATIC_BUILD" = xtrue; then
SHARED_LIBRARY_SUFFIX='.a'
else
SHARED_LIBRARY_SUFFIX='.dylib'
fi
fi
fi
AC_SUBST(LIBRARY_PREFIX)

View File

@ -194,9 +194,6 @@ define AddJdkLibrary
endif
# Determine if the library in question is static.
ifeq ($(STATIC_BUILD), true)
$1_$2_STATIC_LIBRARY := true
endif
# Ideally, we should not hardcode these
ifeq ($(call isTargetOs, aix)+$$($1_$2_MODULE):$$($1_$2_NAME), true+java.base:jli)
$1_$2_STATIC_LIBRARY := true

View File

@ -259,14 +259,6 @@ define SetupBasicVariables
$1_TYPE := LIBRARY
endif
# If we're doing a static build and producing a library
# force it to be a static library and remove the -l libraries
ifeq ($(STATIC_BUILD), true)
ifeq ($$($1_TYPE), LIBRARY)
$1_TYPE := STATIC_LIBRARY
endif
endif
# STATIC_LIBS is set from Main.gmk when building static versions of certain
# native libraries.
ifeq ($(STATIC_LIBS), true)

View File

@ -108,19 +108,6 @@ define SetupBuildLauncherBody
))
$1_LDFLAGS += -sectcreate __TEXT __info_plist $$($1_PLIST_FILE)
ifeq ($(STATIC_BUILD), true)
$1_LDFLAGS += -exported_symbols_list \
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
$1_LIBS += \
$$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \
-framework CoreFoundation \
-framework Foundation \
-framework SystemConfiguration \
-lstdc++ -liconv
endif
endif
$1_EXTRA_FILES := $(LAUNCHER_SRC)/main.c

View File

@ -114,13 +114,6 @@ define CreateStaticLibrary
$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
$$($1_AR) $$(ARFLAGS) -r -cs $$($1_TARGET) \
$$($1_AR_OBJ_ARG) $$($1_RES))
ifeq ($(STATIC_BUILD), true)
$(RM) $$(@D)/$$(basename $$(@F)).symbols; \
$(ECHO) "Getting symbols from nm"; \
$(NM) $(NMFLAGS) -m $$($1_TARGET) | $(GREP) "__TEXT" | \
$(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \
$(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols
endif
endef
################################################################################

View File

@ -78,10 +78,6 @@ ifeq ($(call check-jvm-feature, dtrace), true)
JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
endif
ifeq ($(call check-jvm-feature, static-build), true)
JVM_CFLAGS_FEATURES += -DSTATIC_BUILD=1
endif
ifneq ($(call check-jvm-feature, jvmti), true)
JVM_CFLAGS_FEATURES += -DINCLUDE_JVMTI=0
JVM_EXCLUDE_FILES += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \

View File

@ -107,7 +107,7 @@ ifeq ($(call isTargetOs, macosx), true)
TARGETS += $(BUILD_LIBOSXSECURITY)
endif
ifeq ($(call isTargetOsType, unix)+$(STATIC_BUILD), true+false)
ifeq ($(call isTargetOsType, unix), true)
##############################################################################
## Build libjsig
##############################################################################
@ -145,35 +145,6 @@ ifeq ($(call isTargetOsType, unix)+$(STATIC_BUILD), true+false)
endif
endif
################################################################################
# Create the symbols file for static builds.
ifeq ($(STATIC_BUILD), true)
STATIC_SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
JAVA_BASE_EXPORT_SYMBOLS_SRC := \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)jli.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)java.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)net.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)nio.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)verify.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)zip.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)jimage.symbols \
$(STATIC_SYMBOLS_DIR)/server/$(LIBRARY_PREFIX)jvm.symbols \
#
JAVA_BASE_EXPORT_SYMBOL_FILE := $(STATIC_SYMBOLS_DIR)/java.base.symbols
$(JAVA_BASE_EXPORT_SYMBOL_FILE): $(JAVA_BASE_EXPORT_SYMBOLS_SRC)
$(call LogInfo, Generating java.base.symbols file)
$(CAT) $^ > $@
# The individual symbol files is generated when the respective lib is built
$(JAVA_BASE_EXPORT_SYMBOLS_SRC): $(BUILD_LIBJLI) $(BUILD_LIBJAVA) \
$(BUILD_LIBNET) $(BUILD_LIBNIO) $(BUILD_LIBVERIFY) $(BUILD_LIBZIP) \
$(BUILD_LIBJIMAGE)
TARGETS += $(JAVA_BASE_EXPORT_SYMBOL_FILE)
endif
################################################################################
## Build libsyslookup
################################################################################

View File

@ -68,24 +68,3 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \
))
TARGETS += $(BUILD_LIBJDWP)
################################################################################
# Setup static build symbols
ifeq ($(STATIC_BUILD), true)
STATIC_SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent
JDK_JDWP_AGENT_EXPORT_SYMBOLS_SRC := \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)dt_socket.symbols \
$(STATIC_SYMBOLS_DIR)/$(LIBRARY_PREFIX)jdwp.symbols
JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE := $(STATIC_SYMBOLS_DIR)/jdk.jdwp.agent.symbols
$(JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE): $(JDK_JDWP_AGENT_EXPORT_SYMBOLS_SRC)
$(call LogInfo, Generating jdk.jdwp.agent symbols file)
$(CAT) $^ > $@
# The individual symbol files is generated when the respective lib is built
$(JDK_JDWP_AGENT_EXPORT_SYMBOLS_SRC): $(BUILD_LIBDT_SOCKET) $(BUILD_LIBJDWP)
TARGETS += $(JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE)
endif