Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openjdk/jdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 40a055eb
Choose a base ref
...
head repository: openjdk/jdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0e5ff083
Choose a head ref
  • 12 commits
  • 26 files changed
  • 1 contributor

Commits on Sep 3, 2024

  1. Incorporate changes from leyden/hermetic-java-runtime that allows run…

    …ning a static launcher
    magicus committed Sep 3, 2024
    Copy the full SHA
    6073c8e View commit details
  2. Makefile changes needed for static-launcher and static-jdk-image targets

    magicus committed Sep 3, 2024
    Copy the full SHA
    43f57b8 View commit details

Commits on Oct 15, 2024

  1. Merge branch 'master' into static-jdk-image

    magicus committed Oct 15, 2024
    Copy the full SHA
    0717600 View commit details
  2. Remove superfluous SRC.

    magicus committed Oct 15, 2024
    Copy the full SHA
    fc42982 View commit details
  3. Add lookup asserts

    magicus committed Oct 15, 2024
    Copy the full SHA
    7fb1b40 View commit details
  4. Update GetJREPath comment and remove unnecessary JLI_IsStaticallyLink…

    …ed check
    magicus committed Oct 15, 2024
    Copy the full SHA
    7286bff View commit details
  5. Setup LDFLAGS_STATIC_JDK

    magicus committed Oct 15, 2024
    Copy the full SHA
    53ae477 View commit details
  6. Don't hardcode server variant

    magicus committed Oct 15, 2024
    Copy the full SHA
    03cd917 View commit details

Commits on Oct 29, 2024

  1. Fix bug in filtering out -Wl,--exclude-libs,ALL

    magicus committed Oct 29, 2024
    Copy the full SHA
    1d375bb View commit details

Commits on Nov 1, 2024

  1. Merge branch 'master' into static-jdk-image

    magicus committed Nov 1, 2024
    Copy the full SHA
    971636f View commit details

Commits on Nov 4, 2024

  1. Merge branch 'master' into static-jdk-image

    magicus committed Nov 4, 2024
    Copy the full SHA
    f4f6845 View commit details

Commits on Nov 15, 2024

  1. Merge branch 'master' into static-jdk-image

    magicus committed Nov 15, 2024
    Copy the full SHA
    0e5ff08 View commit details
22 changes: 18 additions & 4 deletions make/Main.gmk
Original file line number Diff line number Diff line change
@@ -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

################################################################################
14 changes: 13 additions & 1 deletion make/ModuleWrapper.gmk
Original file line number Diff line number Diff line change
@@ -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,18 @@ TARGETS :=
# Include the file being wrapped.
include $(MAKEFILE_PREFIX).gmk

ifeq ($(MAKEFILE_PREFIX), Lib)
ifneq ($($(MODULE)_JDK_LIBS), )
LIBLIST := $(SUPPORT_OUTPUTDIR)/modules_static-libs/$(MODULE)/module-libs.txt

$(LIBLIST): $(TARGETS)
$(call MakeDir, $(@D))
$(ECHO) $($(MODULE)_JDK_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
183 changes: 183 additions & 0 deletions make/StaticLibs.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#
# 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
# windowsaccessbridge-64 has multiple collisions and conflicts
BROKEN_STATIC_LIBS += windowsaccessbridge-64
# 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 javaaccessbridge
# 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-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), \
))

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)

static-jdk-image: $(copy-from-jdk-image) $(copy-static-launcher)

TARGETS += static-jdk-image

all: $(TARGETS)

.PHONY: all static-launcher static-jdk-image
1 change: 1 addition & 0 deletions make/autoconf/buildjdk-spec.gmk.template
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ LDFLAGS_JDKLIB := @OPENJDK_BUILD_LDFLAGS_JDKLIB@
CFLAGS_JDKEXE := @OPENJDK_BUILD_CFLAGS_JDKEXE@
CXXFLAGS_JDKEXE := @OPENJDK_BUILD_CXXFLAGS_JDKEXE@
LDFLAGS_JDKEXE := @OPENJDK_BUILD_LDFLAGS_JDKEXE@
LDFLAGS_STATIC_JDK := @OPENJDK_BUILD_LDFLAGS_STATIC_JDK@

JVM_CFLAGS := @OPENJDK_BUILD_JVM_CFLAGS@
JVM_LDFLAGS := @OPENJDK_BUILD_JVM_LDFLAGS@
9 changes: 7 additions & 2 deletions make/autoconf/flags-ldflags.m4
Original file line number Diff line number Diff line change
@@ -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)
])
4 changes: 4 additions & 0 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
@@ -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=""
3 changes: 3 additions & 0 deletions make/autoconf/spec.gmk.template
Original file line number Diff line number Diff line change
@@ -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@

10 changes: 8 additions & 2 deletions make/common/JdkNativeCompilation.gmk
Original file line number Diff line number Diff line change
@@ -303,6 +303,12 @@ define SetupJdkNativeCompilationBody
$1_RC_FTYPE := 0x2L
endif

ifneq ($$(MODULE), )
ifneq ($$($1_EXCLUDE_FROM_STATIC_LIBS), true)
$$(MODULE)_JDK_LIBS += $$($1_NAME)
endif
endif

ifeq ($$($1_OUTPUT_DIR), )
ifneq ($$(MODULE), )
ifeq ($$($1_TYPE), STATIC_LIBRARY)
@@ -422,10 +428,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

Loading