Skip to content

Commit

Permalink
8328824: Clean up java.base native compilation
Browse files Browse the repository at this point in the history
Reviewed-by: erikj
  • Loading branch information
magicus committed Mar 25, 2024
1 parent af15c68 commit 26b2ec4
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 137 deletions.
5 changes: 5 additions & 0 deletions make/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ else
java.base-copy: build-hsdis
endif

# On Windows, we need to copy tzmappings generated by gensrc
ifeq ($(call isTargetOs, windows), true)
java.base-copy: java.base-gensrc
endif

# jdk.accessibility depends on java.desktop
jdk.accessibility-libs: java.desktop-libs

Expand Down
29 changes: 29 additions & 0 deletions make/common/JdkNativeCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ define SetupJdkExecutableBody
$1_LIBS += $(LIBCXX)
endif

ifeq ($$($1_SRC), )
ifneq ($$(MODULE), )
$1_SRC := $$(call FindSrcDirsForComponent, $$(MODULE), $$($1_NAME))
else
$$(error Must specify SRC in a MODULE free context)
endif
else
$1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessDir, $$(dir)))
endif
ifneq ($$($1_EXTRA_SRC), )
$1_SRC += $$(foreach dir, $$($1_EXTRA_SRC), $$(call ProcessDir, $$(dir)))
endif

ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
endif
Expand All @@ -283,6 +296,12 @@ define SetupJdkExecutableBody
# Prepend JDK libs before external libs
$1_LIBS := $$($1_JDK_LIBS) $$($1_LIBS)

ifneq ($$($1_EXTRA_HEADER_DIRS), )
$1_PROCESSED_EXTRA_HEADER_DIRS := $$(foreach dir, $$($1_EXTRA_HEADER_DIRS), \
$$(call ProcessDir, $$(dir)))
$1_EXTRA_HEADER_FLAGS := $$(addprefix -I, $$($1_PROCESSED_EXTRA_HEADER_DIRS))
endif

ifneq ($$($1_DEFAULT_CFLAGS), false)
# Set the default flags first to be able to override
$1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKEXE)) $$($1_CFLAGS)
Expand All @@ -291,6 +310,16 @@ define SetupJdkExecutableBody
$1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKEXE)) $$($1_CXXFLAGS)
endif

ifneq ($$($1_CFLAGS), )
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
ifneq ($$($1_CXXFLAGS), )
$1_CXXFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
ifeq ($$($1_CFLAGS)$$($1_CXXFLAGS), )
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif

ifneq ($$($1_DEFAULT_LDFLAGS), false)
# Set the default flags first to be able to override
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE)) $$($1_LDFLAGS)
Expand Down
9 changes: 5 additions & 4 deletions make/hotspot/lib/CompileGtest.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
$(eval $(call IncludeCustomExtension, hotspot/lib/CompileGtest.gmk))

GTEST_TEST_SRC += $(TOPDIR)/test/hotspot/gtest
GTEST_LAUNCHER_SRC := $(TOPDIR)/test/hotspot/gtest/gtestLauncher.cpp

ifeq ($(ASAN_ENABLED), true)
GTEST_LAUNCHER_SRC += $(TOPDIR)/make/data/asan/asan_default_options.cpp
GTEST_LAUNCHER_EXTRA_FILES += $(TOPDIR)/make/data/asan/asan_default_options.cpp
endif

ifeq ($(LSAN_ENABLED), true)
GTEST_LAUNCHER_SRC += $(TOPDIR)/make/data/lsan/lsan_default_options.cpp
GTEST_LAUNCHER_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.cpp
endif

# On Windows, there are no internal debug symbols so must set copying to true
Expand Down Expand Up @@ -136,7 +135,9 @@ $(eval $(call SetupJdkExecutable, BUILD_GTEST_LAUNCHER, \
TYPE := EXECUTABLE, \
LINK_TYPE := C++, \
OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
EXTRA_FILES := $(GTEST_LAUNCHER_SRC), \
SRC := $(TOPDIR)/test/hotspot/gtest, \
INCLUDE_FILES := gtestLauncher.cpp, \
EXTRA_FILES := $(GTEST_LAUNCHER_EXTRA_FILES), \
OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/launcher-objs, \
DEFAULT_CFLAGS := false, \
CFLAGS := $(JVM_CFLAGS) \
Expand Down
12 changes: 12 additions & 0 deletions make/modules/java.base/Copy.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ ifeq ($(ENABLE_LIBFFI_BUNDLING), true)
TARGETS += $(COPY_LIBFFI)
endif

################################################################################
# Copy tzmappings file for Windows

ifeq ($(call isTargetOs, windows), true)
$(eval $(call SetupCopyFiles, COPY_TZMAPPINGS, \
FILES := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/windows/conf/tzmappings, \
DEST := $(call FindLibDirForModule, $(MODULE)), \
))

TARGETS += $(COPY_TZMAPPINGS)
endif

################################################################################
# Optionally copy hsdis into the image

Expand Down
38 changes: 25 additions & 13 deletions make/modules/java.base/Launcher.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ include LauncherCommon.gmk
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, modules/java.base/Launcher.gmk))

JAVA_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/launcher/java.rc
JAVA_VERSION_INFO_RESOURCE := \
$(TOPDIR)/src/java.base/windows/native/launcher/java.rc

JAVA_RCFLAGS ?= -I$(TOPDIR)/src/java.base/windows/native/launcher/icons

################################################################################
## Build java
################################################################################

$(eval $(call SetupBuildLauncher, java, \
Expand All @@ -41,6 +44,10 @@ $(eval $(call SetupBuildLauncher, java, \
OPTIMIZATION := HIGH, \
))

################################################################################
## Build javaw
################################################################################

ifeq ($(call isTargetOs, windows), true)
$(eval $(call SetupBuildLauncher, javaw, \
CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
Expand All @@ -49,19 +56,24 @@ ifeq ($(call isTargetOs, windows), true)
))
endif

################################################################################
## Build keytool
################################################################################

$(eval $(call SetupBuildLauncher, keytool, \
MAIN_CLASS := sun.security.tools.keytool.Main, \
))

################################################################################

ifeq ($(call isTargetOs, linux), true)
##############################################################################
## Build jexec
##############################################################################

$(eval $(call SetupJdkExecutable, BUILD_JEXEC, \
NAME := jexec, \
SRC := $(TOPDIR)/src/$(MODULE)/unix/native/launcher, \
INCLUDE_FILES := jexec.c, \
OPTIMIZATION := LOW, \
CFLAGS := -I$(TOPDIR)/src/$(MODULE)/share/native/libjli, \
EXTRA_HEADER_DIRS := libjli, \
CFLAGS_linux := -fPIC, \
LD_SET_ORIGIN := false, \
OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
Expand All @@ -70,21 +82,21 @@ ifeq ($(call isTargetOs, linux), true)
TARGETS += $(BUILD_JEXEC)
endif

################################################################################

ifeq ($(call isTargetOsType, unix), true)
##############################################################################
## Build jspawnhelper
##############################################################################

$(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \
NAME := jspawnhelper, \
SRC := $(TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \
OPTIMIZATION := LOW, \
CFLAGS := $(VERSION_CFLAGS) \
-I$(TOPDIR)/src/$(MODULE)/unix/native/libjava, \
EXTRA_OBJECT_FILES := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc$(OBJ_SUFFIX), \
CFLAGS := $(VERSION_CFLAGS), \
EXTRA_HEADER_DIRS := libjava, \
EXTRA_OBJECT_FILES := \
$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc$(OBJ_SUFFIX), \
LD_SET_ORIGIN := false, \
OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
))

TARGETS += $(BUILD_JSPAWNHELPER)
endif

################################################################################
Loading

1 comment on commit 26b2ec4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.