Skip to content

Commit

Permalink
8329672: Only call SetupNativeCompilation from SetupJdkNativeCompilation
Browse files Browse the repository at this point in the history
Reviewed-by: erikj
  • Loading branch information
magicus committed Apr 5, 2024
1 parent 8bc1867 commit 3f4b167
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 65 deletions.
3 changes: 1 addition & 2 deletions make/CompileDemos.gmk
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -32,7 +32,6 @@ default: all
include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include TextFileProcessing.gmk
include ZipArchive.gmk

Expand Down
4 changes: 4 additions & 0 deletions make/Hsdis.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ ifeq ($(HSDIS_BACKEND), binutils)
endif
endif

################################################################################
## Build libhsdis
################################################################################

$(eval $(call SetupJdkLibrary, BUILD_HSDIS, \
NAME := hsdis, \
LINK_TYPE := $(HSDIS_LINK_TYPE), \
Expand Down
22 changes: 13 additions & 9 deletions make/UpdateX11Wrappers.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 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
Expand Down Expand Up @@ -30,7 +30,7 @@ default: all
include $(SPEC)
include MakeBase.gmk
include Execute.gmk
include NativeCompilation.gmk
include JdkNativeCompilation.gmk
include ToolsJdk.gmk

################################################################################
Expand All @@ -47,14 +47,14 @@ ifeq ($(COMPILE_TYPE), cross)
$(error It is not possible to update the x11wrappers when cross-compiling)
endif

BITS := $(OPENJDK_TARGET_CPU_BITS)

X11WRAPPERS_OUTPUT := $(SUPPORT_OUTPUTDIR)/x11wrappers
GENERATOR_SOURCE_FILE := $(X11WRAPPERS_OUTPUT)/src/data_generator.c

GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/src/java.desktop/unix/data/x11wrappergen
WRAPPER_OUTPUT_FILE := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt

BITS := $(OPENJDK_TARGET_CPU_BITS)

# Generate the C code for the program that will output the offset file.
$(eval $(call SetupExecute, gensrc_generator, \
INFO := Generating X11 wrapper data generator source code, \
Expand All @@ -76,14 +76,17 @@ DATA_GENERATOR_INCLUDES := \
-I$(TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
#

################################################################################
## Build data_generator
################################################################################

# Compile the generated C code into an executable.
$(eval $(call SetupNativeCompilation, BUILD_DATA_GENERATOR, \
PROGRAM := data_generator, \
OUTPUT_DIR := $(X11WRAPPERS_OUTPUT)/bin, \
$(eval $(call SetupJdkExecutable, BUILD_DATA_GENERATOR, \
NAME := data_generator, \
EXTRA_FILES := $(GENERATOR_SOURCE_FILE), \
CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES) $(CFLAGS_JDKEXE), \
LDFLAGS := $(LDFLAGS_JDKEXE), \
CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES), \
LIBS := $(X_LIBS), \
OUTPUT_DIR := $(X11WRAPPERS_OUTPUT)/bin, \
OBJECT_DIR := $(X11WRAPPERS_OUTPUT)/objs, \
))

Expand All @@ -92,6 +95,7 @@ $(eval $(call SetupExecute, run_wrappergen, \
INFO := Generating X11 wrapper data files, \
DEPS := $(BUILD_DATA_GENERATOR), \
OUTPUT_FILE := $(WRAPPER_OUTPUT_FILE), \
SUPPORT_DIR := $(X11WRAPPERS_OUTPUT)/run-wrapper, \
COMMAND := $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $(WRAPPER_OUTPUT_FILE), \
))

Expand Down
24 changes: 18 additions & 6 deletions make/common/JdkNativeCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ JDK_RCFLAGS=$(RCFLAGS) \
# JDK_LIBS -- libraries generated by the JDK build system to link against
# JDK_LIBS_<os> or JDK_LIBS_<osType> -- additional JDK_LIBS for the given OS
# or OS type only
# DEFAULT_LIBCXX -- if false, do not add LIBCXX to LIBS for C++ compilations
# DEFAULT_CFLAGS -- if false, do not add default CFLAGS and CXXFLAGS
# DEFAULT_LDFLAGS -- if false, do not add default LDFLAGS
# CFLAGS_FILTER_OUT -- flags to filter out from default CFLAGS
# CXXFLAGS_FILTER_OUT -- flags to filter out from default CXXFLAGS
# LDFLAGS_FILTER_OUT -- flags to filter out from default LDFLAGS
# LD_SET_ORIGIN -- if false, do not add SET_*_ORIGIN flags to LDFLAGS
# APPEND_LDFLAGS -- a quirk to have additional LDFLAGS that will be set after
# the origin flags
# DEFAULT_VERSIONINFO_RESOURCE -- if false, do not set the default
# VERSIONINFO_RESOURCE
#
SetupJdkNativeCompilation = $(NamedParamsMacroTemplate)
define SetupJdkNativeCompilationBody
Expand Down Expand Up @@ -164,15 +168,19 @@ define SetupJdkNativeCompilationBody
endif
endif

ifeq ($$($1_LINK_TYPE), C++)
$1_LIBS += $(LIBCXX)
ifneq ($$($1_DEFAULT_LIBCXX), false)
ifeq ($$($1_LINK_TYPE), C++)
$1_LIBS += $(LIBCXX)
endif
endif

ifeq ($$($1_SRC), )
ifneq ($$(MODULE), )
$1_SRC := $$(call FindSrcDirsForComponent, $$(MODULE), $$($1_NATIVE_DIR_PREFIX)$$($1_NAME))
else
$$(error Must specify SRC in a MODULE free context)
ifeq ($$($1_EXTRA_FILES), )
$$(error Must specify SRC or EXTRA_FILES in a MODULE free context)
endif
endif
else
$1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessDir, $$(dir)))
Expand All @@ -188,8 +196,10 @@ define SetupJdkNativeCompilationBody
$1_SRC := $$(filter-out $$($1_EXCLUDE_SRC), $$($1_SRC))
endif

ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
ifneq ($$($1_DEFAULT_VERSIONINFO_RESOURCE), false)
ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
endif
endif

ifeq ($$($1_RC_FILEDESC), )
Expand All @@ -208,7 +218,9 @@ define SetupJdkNativeCompilationBody
endif

# Add the module specific java header dir
$1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE)))
ifneq ($$(MODULE), )
$1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE)))
endif

$1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS))
$1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS_TYPE))
Expand Down
27 changes: 13 additions & 14 deletions make/common/TestFilesCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ifeq (,$(_MAKEBASE_GMK))
endif


include NativeCompilation.gmk
include JdkNativeCompilation.gmk

# Setup make rules for creating a set of native test files (libraries or
# executables). This will locate native files matching a certain pattern,
Expand All @@ -56,27 +56,20 @@ define SetupTestFilesCompilationBody
$$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES))
endif

# Always include common test functionality
TEST_CFLAGS := -I$(TOPDIR)/test/lib/native

# The list to depend on starts out empty
$1 :=
ifeq ($$($1_TYPE), LIBRARY)
$1_PREFIX = lib
$1_OUTPUT_SUBDIR := lib
$1_BASE_CFLAGS := $(CFLAGS_JDKLIB) $$(TEST_CFLAGS)
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKLIB) $$(TEST_CFLAGS)
$1_LDFLAGS := $(LDFLAGS_JDKLIB) $$(call SET_SHARED_LIBRARY_ORIGIN)
$1_COMPILATION_TYPE := LIBRARY
$1_LOG_TYPE := library
else ifeq ($$($1_TYPE), PROGRAM)
$1_PREFIX = exe
$1_OUTPUT_SUBDIR := bin
$1_BASE_CFLAGS := $(CFLAGS_JDKEXE) $$(TEST_CFLAGS)
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKEXE) $$(TEST_CFLAGS)
$1_LDFLAGS := $(LDFLAGS_JDKEXE) $(LDFLAGS_TESTEXE)
$1_COMPILATION_TYPE := EXECUTABLE
$1_LOG_TYPE := executable
$1_LD_SET_ORIGIN := false
$1_LDFLAGS := $(LDFLAGS_TESTEXE)
else
$$(error Unknown type: $$($1_TYPE))
endif
Expand All @@ -99,24 +92,30 @@ define SetupTestFilesCompilationBody
$1_COPY_DEBUG_SYMBOLS := true
endif

# Always include common test functionality
TEST_CFLAGS := -I$(TOPDIR)/test/lib/native

# Setup a compilation for each and every one of them
$$(foreach file, $$($1_FILTERED_FILE_LIST),\
$$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
$$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
$$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
$$(eval $$(call SetupJdkNativeCompilation, BUILD_TEST_$$(name), \
NAME := $$(unprefixed_name), \
TYPE := $$($1_COMPILATION_TYPE), \
LINK_TYPE := $(if $$(filter %.cpp, $$(file)), C++, C), \
EXTRA_FILES := $$(file) $$($1_EXTRA_FILES), \
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
CFLAGS := $$($1_BASE_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
CXXFLAGS := $$($1_BASE_CXXFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
CFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
CXXFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
LD_SET_ORIGIN := $$($1_LD_SET_ORIGIN), \
LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
DISABLED_WARNINGS_gcc := format undef unused-function unused-value, \
DISABLED_WARNINGS_clang := undef format-nonliteral \
missing-field-initializers sometimes-uninitialized, \
DEFAULT_LIBCXX := false, \
LIBS := $$($1_LIBS_$$(name)), \
DEFAULT_VERSIONINFO_RESOURCE := false, \
OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
COPY_DEBUG_SYMBOLS := $$($1_COPY_DEBUG_SYMBOLS), \
STRIP_SYMBOLS := $$(if $$($1_STRIP_SYMBOLS_$$(name)),$$($1_STRIP_SYMBOLS_$$(name)),false), \
Expand All @@ -129,7 +128,7 @@ define SetupTestFilesCompilationBody

# Setup rule for printing a summary of all the tests being compiled. On Warn
# log level, this replaces the individual build info logging done by
# SetupNativeCompilation.
# SetupJdkNativeCompilation.
$$($1_BUILD_INFO): $$($1_BUILD_INFO_DEPS)
$$(call LogWarn, $$(strip Creating $$(words $$(filter-out %.vardeps, $$?)) \
test $$($1_LOG_TYPE) file(s) for $1))
Expand Down
4 changes: 4 additions & 0 deletions make/common/modules/LauncherCommon.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ define SetupBuildLauncherBody
$1_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.c
endif

##############################################################################
## Build launcher "$1"
##############################################################################

$$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
NAME := $1, \
EXTRA_FILES := $$($1_EXTRA_FILES), \
Expand Down
4 changes: 2 additions & 2 deletions make/hotspot/gensrc/GenerateSources.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 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
Expand Down Expand Up @@ -29,7 +29,7 @@ include $(SPEC)
include MakeBase.gmk
include Execute.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include JdkNativeCompilation.gmk
include TextFileProcessing.gmk

include HotspotCommon.gmk
Expand Down
10 changes: 8 additions & 2 deletions make/hotspot/gensrc/GensrcAdlc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,22 @@ ifeq ($(call check-jvm-feature, compiler2), true)
ADLC_LDFLAGS += $(UBSAN_LDFLAGS)
endif

$(eval $(call SetupNativeCompilation, BUILD_ADLC, \
##############################################################################
## Build adlc
##############################################################################

$(eval $(call SetupJdkExecutable, BUILD_ADLC, \
NAME := adlc, \
TYPE := EXECUTABLE, \
TARGET_TYPE := BUILD, \
LINK_TYPE := C++, \
SRC := $(TOPDIR)/src/hotspot/share/adlc, \
EXTRA_FILES := $(TOPDIR)/src/hotspot/share/opto/opcodes.cpp, \
DEFAULT_CFLAGS := false, \
CFLAGS := $(ADLC_CFLAGS) $(ADLC_CFLAGS_WARNINGS), \
DEFAULT_LDFLAGS := false, \
LDFLAGS := $(ADLC_LDFLAGS), \
LIBS := $(ADLC_LIBS), \
DEFAULT_VERSIONINFO_RESOURCE := false, \
OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc/objs, \
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/adlc, \
DEBUG_SYMBOLS := false, \
Expand Down
9 changes: 7 additions & 2 deletions make/hotspot/lib/CompileGtest.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ else
endif

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

## Build libgtest
################################################################################

$(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBGTEST, \
NAME := gtest, \
Expand Down Expand Up @@ -75,8 +76,10 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBGTEST, \
TARGETS += $(BUILD_GTEST_LIBGTEST)

################################################################################
# Additional disabled warnings are due to code in the test source.
## Build libjvm (for gtest)
################################################################################

# Additional disabled warnings are due to code in the test source.
$(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \
NAME := jvm, \
LINK_TYPE := C++, \
Expand Down Expand Up @@ -128,6 +131,8 @@ endif

TARGETS += $(BUILD_GTEST_LIBJVM)

################################################################################
## Build gtestLauncher
################################################################################

$(eval $(call SetupJdkExecutable, BUILD_GTEST_LAUNCHER, \
Expand Down
5 changes: 3 additions & 2 deletions make/hotspot/lib/CompileJvm.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ endif
JVM_OPTIMIZATION ?= HIGHEST_JVM

# Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
# parameter to SetupNativeCompilation allows an empty value to override the
# parameter to SetupJdkLibrary allows an empty value to override the
# default.
JVM_STRIPFLAGS ?= $(STRIPFLAGS)

Expand Down Expand Up @@ -159,7 +159,8 @@ ifeq ($(call isTargetOs, linux), true)
endif

################################################################################
# Now set up the actual compilation of the main hotspot native library
## Build libjvm
################################################################################

$(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
NAME := jvm, \
Expand Down
4 changes: 2 additions & 2 deletions make/hotspot/lib/JvmOverrideFiles.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 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
Expand Down Expand Up @@ -73,7 +73,7 @@ ifeq ($(call isTargetOs, linux), true)
NONPIC_SRC := $(filter $(NONPIC_FILTER), $(ALL_SRC)) globals.cpp location.cpp
# Declare variables for each source file that needs the pic flag like this:
# BUILD_JVM_<srcfile>_CXXFLAGS := -fno-PIC
# This will get implicitly picked up by SetupNativeCompilation below.
# This will get implicitly picked up by SetupJdkLibrary below.
$(foreach s, $(NONPIC_SRC), $(eval BUILD_LIBJVM_$(notdir $s)_CXXFLAGS := -fno-PIC))
endif

Expand Down
30 changes: 15 additions & 15 deletions make/modules/java.base/Lib.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,21 @@ ifeq ($(call isTargetOs, macosx), true)
## Build libosxsecurity
##############################################################################

$(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \
NAME := osxsecurity, \
OPTIMIZATION := LOW, \
DISABLED_WARNINGS_clang_KeystoreImpl.m := deprecated-declarations, \
LDFLAGS := -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base,\
JDK_LIBS := $(JDKLIB_LIBS), \
LIBS_macosx := -lobjc \
-framework CoreServices \
-framework Foundation \
-framework Security, \
))

$(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA)

TARGETS += $(BUILD_LIBOSXSECURITY)
$(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \
NAME := osxsecurity, \
OPTIMIZATION := LOW, \
DISABLED_WARNINGS_clang_KeystoreImpl.m := deprecated-declarations, \
LDFLAGS := -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base,\
JDK_LIBS := $(JDKLIB_LIBS), \
LIBS_macosx := -lobjc \
-framework CoreServices \
-framework Foundation \
-framework Security, \
))

$(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA)

TARGETS += $(BUILD_LIBOSXSECURITY)
endif

ifeq ($(call isTargetOsType, unix)+$(STATIC_BUILD), true+false)
Expand Down
Loading

1 comment on commit 3f4b167

@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.