1 #
   2 # Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   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.
  10 #
  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).
  16 #
  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.
  20 #
  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
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 # This file builds Graal component of the JTReg tests for Hotspot.
  28 # It also covers the test-image part, where the built files are copied to the
  29 # test image.
  30 ################################################################################
  31 
  32 default: all
  33 
  34 include $(SPEC)
  35 include MakeBase.gmk
  36 include JavaCompilation.gmk
  37 
  38 TARGETS_BUILD :=
  39 TARGETS_IMAGE :=
  40 TARGETS_EXTRA_LIB :=
  41 
  42 ifeq ($(INCLUDE_GRAAL), true)
  43   ifneq ($(GRAALUNIT_LIB), )
  44 
  45     SRC_DIR := $(TOPDIR)/src/jdk.internal.vm.compiler/share/classes
  46     TEST_DIR := $(TOPDIR)/test/hotspot/jtreg/compiler/graalunit
  47     COMPILE_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/test/graalunit
  48     LIB_OUTPUTDIR := $(TEST_IMAGE_DIR)/hotspot/jtreg/graal
  49 
  50     # This evaluation is expensive and should only be done if this target was
  51     # explicitly called.
  52     ifneq ($(filter build-test-hotspot-jtreg-graal, $(MAKECMDGOALS)), )
  53 
  54       TEST_COMPILE_CP := \
  55           $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.compiler \
  56           $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.ci \
  57           $(LIB_OUTPUTDIR)/junit-4.12.jar \
  58           $(LIB_OUTPUTDIR)/asm-5.0.4.jar \
  59           $(LIB_OUTPUTDIR)/asm-tree-5.0.4.jar \
  60           $(LIB_OUTPUTDIR)/java-allocation-instrumenter.jar \
  61           $(LIB_OUTPUTDIR)/hamcrest-core-1.3.jar
  62 
  63       TEST_JAVAC_FLAGS := \
  64           -processorpath $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.replacements.verifier.jar \
  65           --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED \
  66           --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
  67           --add-exports java.base/jdk.internal.module=ALL-UNNAMED \
  68           -Xprefer:newer \
  69           #
  70 
  71       ### Copy 3rd party libs
  72       $(eval $(call SetupCopyFiles, COPY_GRAALUNIT_LIBS, \
  73           FILES := $(wildcard $(GRAALUNIT_LIB)/*.jar), \
  74           DEST := $(LIB_OUTPUTDIR), \
  75       ))
  76 
  77       TARGETS_EXTRA_LIB += $(COPY_GRAALUNIT_LIBS)
  78 
  79       ### Compile graalunit tests
  80       $(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_TESTS, \
  81           TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
  82           SRC := \
  83               $(SRC_DIR)/jdk.internal.vm.compiler.collections.test/src \
  84               $(SRC_DIR)/org.graalvm.compiler.api.directives.test/src \
  85               $(SRC_DIR)/org.graalvm.compiler.api.test/src \
  86               $(SRC_DIR)/org.graalvm.compiler.asm.aarch64.test/src \
  87               $(SRC_DIR)/org.graalvm.compiler.asm.amd64.test/src \
  88               $(SRC_DIR)/org.graalvm.compiler.asm.sparc.test/src \
  89               $(SRC_DIR)/org.graalvm.compiler.asm.test/src \
  90               $(SRC_DIR)/org.graalvm.compiler.core.aarch64.test/src \
  91               $(SRC_DIR)/org.graalvm.compiler.core.amd64.test/src \
  92               $(SRC_DIR)/org.graalvm.compiler.core.jdk9.test/src \
  93               $(SRC_DIR)/org.graalvm.compiler.core.test/src \
  94               $(SRC_DIR)/org.graalvm.compiler.debug.test/src \
  95               $(SRC_DIR)/org.graalvm.compiler.graph.test/src \
  96               $(SRC_DIR)/org.graalvm.compiler.hotspot.aarch64.test/src \
  97               $(SRC_DIR)/org.graalvm.compiler.hotspot.amd64.test/src \
  98               $(SRC_DIR)/org.graalvm.compiler.hotspot.jdk15.test/src \
  99               $(SRC_DIR)/org.graalvm.compiler.hotspot.jdk9.test/src \
 100               $(SRC_DIR)/org.graalvm.compiler.hotspot.lir.test/src \
 101               $(SRC_DIR)/org.graalvm.compiler.hotspot.sparc.test/src \
 102               $(SRC_DIR)/org.graalvm.compiler.hotspot.test/src \
 103               $(SRC_DIR)/org.graalvm.compiler.jtt/src \
 104               $(SRC_DIR)/org.graalvm.compiler.lir.jtt/src \
 105               $(SRC_DIR)/org.graalvm.compiler.lir.test/src \
 106               $(SRC_DIR)/org.graalvm.compiler.loop.test/src \
 107               $(SRC_DIR)/org.graalvm.compiler.nodes.test/src \
 108               $(SRC_DIR)/org.graalvm.compiler.options.test/src \
 109               $(SRC_DIR)/org.graalvm.compiler.phases.common.test/src \
 110               $(SRC_DIR)/org.graalvm.compiler.replacements.jdk12.test/src \
 111               $(SRC_DIR)/org.graalvm.compiler.replacements.jdk9.test/src \
 112               $(SRC_DIR)/org.graalvm.compiler.replacements.test/src \
 113               $(SRC_DIR)/org.graalvm.compiler.test/src \
 114               $(SRC_DIR)/org.graalvm.util.test/src \
 115               , \
 116           EXCLUDE_FILES := org/graalvm/compiler/core/test/VerifyDebugUsageTest.java, \
 117           BIN := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
 118           CLASSPATH := $(TEST_COMPILE_CP), \
 119           DISABLED_WARNINGS := processing, \
 120           JAVAC_FLAGS := $(TEST_JAVAC_FLAGS), \
 121           COPY := .input, \
 122       ))
 123 
 124       TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS)
 125 
 126       ### Compile graalunit tests which require -XDstringConcat=inline
 127       $(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_TESTS_SET2, \
 128           TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
 129           DEPENDS := $(BUILD_VM_COMPILER_TESTS), \
 130           SRC := $(SRC_DIR)/org.graalvm.compiler.core.test/src, \
 131           INCLUDE_FILES := org/graalvm/compiler/core/test/VerifyDebugUsageTest.java, \
 132           BIN := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
 133           CLASSPATH := \
 134               $(TEST_COMPILE_CP) \
 135               $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
 136           DISABLED_WARNINGS := processing, \
 137           JAVAC_FLAGS := $(TEST_JAVAC_FLAGS) -XDstringConcat=inline, \
 138       ))
 139 
 140       TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS_SET2)
 141 
 142       ### Generate jdk.vm.compiler.tests.jar
 143       $(eval $(call SetupJarArchive, BUILD_VM_COMPILER_TESTS_JAR, \
 144           DEPENDENCIES := $(BUILD_VM_COMPILER_TESTS) $(BUILD_VM_COMPILER_TESTS_SET2), \
 145           SRCS := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
 146           SUFFIXES:=.class .input, \
 147           JAR := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests.jar, \
 148       ))
 149 
 150       TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS_JAR)
 151 
 152       ### Compile and build mxtool
 153       $(eval $(call SetupJavaCompilation, BUILD_MXTOOL, \
 154           TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
 155           SRC := $(TEST_DIR)/com.oracle.mxtool.junit, \
 156           BIN := $(COMPILE_OUTPUTDIR)/com.oracle.mxtool.junit, \
 157           JAR := $(COMPILE_OUTPUTDIR)/com.oracle.mxtool.junit.jar, \
 158           DISABLED_WARNINGS := processing, \
 159           CLASSPATH := $(LIB_OUTPUTDIR)/junit-4.12.jar, \
 160       ))
 161 
 162       TARGETS_BUILD += $(BUILD_MXTOOL)
 163 
 164       $(TARGETS_BUILD): $(TARGETS_EXTRA_LIB)
 165 
 166     endif # build-test-hotspot-jtreg-graal
 167 
 168     ################################################################################
 169     # Targets for building test-image.
 170     ################################################################################
 171 
 172     # Copy to hotspot jtreg test image
 173     $(eval $(call SetupCopyFiles, COPY_HOTSPOT_JTREG_GRAAL, \
 174         SRC := $(COMPILE_OUTPUTDIR), \
 175         DEST := $(LIB_OUTPUTDIR), \
 176         FILES := jdk.vm.compiler.tests.jar com.oracle.mxtool.junit.jar, \
 177     ))
 178 
 179     TARGETS_IMAGE += $(COPY_HOTSPOT_JTREG_GRAAL)
 180   endif
 181 endif
 182 
 183 build-test-hotspot-jtreg-graal: $(TARGETS_BUILD)
 184 test-image-hotspot-jtreg-graal: $(TARGETS_IMAGE)
 185 
 186 all: build-test-hotspot-jtreg-graal
 187 test-image: test-image-hotspot-jtreg-graal
 188 
 189 .PHONY: default all build-test-hotspot-jtreg-graal test-image-hotspot-jtreg-graal test-image