2
# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
26
################################################################################
27
# This file builds the native component of the JTReg tests for JDK.
28
# It also covers the test-image part, where the built files are copied to the
30
################################################################################
38
include TestFilesCompilation.gmk
40
$(eval $(call IncludeCustomExtension, test/JtregNativeJdk.gmk))
42
################################################################################
43
# Targets for building the native tests themselves.
44
################################################################################
46
# This might have been added to by a custom extension.
47
BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk
49
BUILD_JDK_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/jdk/jtreg/native
51
BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
53
BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeJliLaunchTest := \
54
-I$(TOPDIR)/src/java.base/share/native/libjli \
55
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
56
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli
58
BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeJliLaunchTest := java.base:libjli
59
BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeCallerAccessTest := java.base:libjvm
60
BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeNullCallerTest := java.base:libjvm
62
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libstringPlatformChars := java.base:libjava
63
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libTracePinnedThreads := java.base:libjvm
64
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libNewDirectByteBuffer := java.base:libjava
65
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libGetXSpace := java.base:libjava
67
# Platform specific setup
68
ifeq ($(call isTargetOs, windows), true)
69
BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c \
70
libExplicitAttach.c libImplicitAttach.c \
73
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX)
74
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib
75
BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeNullCallerTest := /EHsc
77
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libDirectIO := java.base:libjava
78
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeThread := -pthread
80
# java.lang.foreign tests
81
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncStackWalk := -pthread
82
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncInvokers := -pthread
83
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerUnnamed := -pthread
84
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerModule := -pthread
85
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread
87
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libExplicitAttach := java.base:libjvm
88
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libExplicitAttach := -pthread
89
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libImplicitAttach := -pthread
90
BUILD_JDK_JTREG_EXCLUDE += exerevokeall.c
91
ifeq ($(call isTargetOs, linux), true)
92
BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libInheritedChannel := java.base:libjava
93
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exelauncher := -ldl
95
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX)
98
ifeq ($(call isTargetOs, macosx), true)
99
BUILD_JDK_JTREG_EXCLUDE += exelauncher.c
100
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := \
102
BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeJniInvocationTest := java.base:libjli
103
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestDynamicStore := \
104
-framework Cocoa -framework SystemConfiguration
106
BUILD_JDK_JTREG_EXCLUDE += libTestMainKeyWindow.m
107
BUILD_JDK_JTREG_EXCLUDE += libTestDynamicStore.m
108
BUILD_JDK_JTREG_EXCLUDE += exeJniInvocationTest.c
109
BUILD_JDK_JTREG_EXCLUDE += exeLibraryCache.c
112
ifeq ($(call isTargetOs, linux), true)
113
# Unconditionally compile with debug symbols and don't ever perform
114
# stripping during the test libraries' build.
115
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libFib := -g
116
BUILD_JDK_JTREG_LIBRARIES_STRIP_SYMBOLS_libFib := false
119
ifeq ($(ASAN_ENABLED), true)
120
# Any executable which launches the JVM and uses a custom launcher needs to explicitly link in the
121
# default ASan options.
122
BUILD_JDK_JTREG_EXTRA_FILES += $(TOPDIR)/make/data/asan/asan_default_options.c
125
ifeq ($(LSAN_ENABLED), true)
126
# Any executable which launches the JVM and uses a custom launcher needs to explicitly link in the
127
# default LSan options.
128
BUILD_JDK_JTREG_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.c
131
# This evaluation is expensive and should only be done if this target was
133
ifneq ($(filter build-test-jdk-jtreg-native, $(MAKECMDGOALS)), )
134
$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \
136
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
137
OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
138
EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
141
$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_EXECUTABLES, \
143
SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
144
OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
145
EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
146
EXTRA_FILES := $(BUILD_JDK_JTREG_EXTRA_FILES), \
150
build-test-jdk-jtreg-native: $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES)
152
################################################################################
153
# Targets for building test-image.
154
################################################################################
156
# Copy to jdk jtreg test image
157
$(eval $(call SetupCopyFiles,COPY_JDK_JTREG_NATIVE, \
158
SRC := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
159
DEST := $(TEST_IMAGE_DIR)/jdk/jtreg/native, \
160
FILES := $(wildcard $(addprefix $(BUILD_JDK_JTREG_OUTPUT_DIR), /bin/* /lib/*)), \
164
test-image-jdk-jtreg-native: $(COPY_JDK_JTREG_NATIVE)
166
all: build-test-jdk-jtreg-native
167
test-image: test-image-jdk-jtreg-native
169
.PHONY: default all build-test-jdk-jtreg-native test-image-jdk-jtreg-native test-image