1 #
   2 # Copyright (c) 2011, 2018, 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 ifndef _SETUP_GMK
  27 _SETUP_GMK := 1
  28 
  29 # Include custom extension hook
  30 $(eval $(call IncludeCustomExtension, common/SetupJavaCompilers.gmk))
  31 
  32 include JavaCompilation.gmk
  33 
  34 DISABLE_WARNINGS ?= -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
  35 
  36 JDK_SOURCE_TARGET_FLAGS := -source $(JDK_SOURCE_TARGET_VERSION) \
  37     -target $(JDK_SOURCE_TARGET_VERSION)
  38 
  39 # If warnings needs to be non-fatal for testing purposes use a command like:
  40 # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
  41 JAVAC_WARNINGS ?= -Xlint:all -Werror
  42 
  43 # The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools
  44 # and the interim javac, to be run by the boot jdk.
  45 $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
  46     JAVAC := $(JAVAC), \
  47     FLAGS := \
  48         $(JAVA_TOOL_FLAGS_SMALL) \
  49         $(BOOT_JDK_SOURCETARGET) \
  50         -XDignore.symbol.file=true -g \
  51         -Xlint:all$(COMMA)-deprecation$(COMMA)-options -Werror, \
  52     DISABLE_SJAVAC := true, \
  53 ))
  54 
  55 # Any java code executed during a JDK build to build other parts of the JDK must be
  56 # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this
  57 # purpose must be built with -target PREVIOUS for bootstrapping purposes, which
  58 # requires restricting to language level and api of previous JDK.
  59 #
  60 # The generate old bytecode javac setup uses the new compiler to compile for the
  61 # boot jdk to generate tools that need to be run with the boot jdk.
  62 # Thus we force the target bytecode to the previous JDK version.
  63 # Add -Xlint:-options to avoid the warning about not setting -bootclasspath. Since
  64 # it's running on the boot jdk, the default bootclasspath is correct.
  65 $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \
  66     JVM := $(JAVA_SMALL), \
  67     JAVAC := $(NEW_JAVAC), \
  68     FLAGS := $(BOOT_JDK_SOURCETARGET) -XDignore.symbol.file=true -XDstringConcat=inline \
  69         $(DISABLE_WARNINGS) -Xlint:-options, \
  70     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
  71     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
  72 
  73 # The generate new bytecode javac setup uses the new compiler to compile for the
  74 # new jdk. This new bytecode might only be possible to run using the new jvm.
  75 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
  76     JVM := $(JAVA_JAVAC), \
  77     JAVAC := $(NEW_JAVAC), \
  78     FLAGS := $(JDK_SOURCE_TARGET_FLAGS) --doclint-format html5 \
  79         -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
  80     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
  81     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
  82 
  83 # The generate new bytecode javac setup uses the new compiler to compile for the
  84 # new jdk. This new bytecode might only be possible to run using the new jvm.
  85 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
  86     JVM := $(JAVA_JAVAC), \
  87     JAVAC := $(NEW_JAVAC), \
  88     FLAGS := $(JDK_SOURCE_TARGET_FLAGS) \
  89         -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
  90     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
  91     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
  92 
  93 # After the jdk is built, we want to build demos using only the recently
  94 # generated jdk classes and nothing else, no jdk source, etc etc.
  95 # I.e. the rt.jar, but since rt.jar has not yet been generated
  96 # (it will be in "make images") therefore we use classes instead.
  97 $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
  98     JVM := $(JAVA_SMALL), \
  99     JAVAC := $(NEW_JAVAC), \
 100     FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \
 101     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
 102     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
 103 
 104 # Use boot javac to generate JDK 8 compatible class files explicitly
 105 $(eval $(call SetupJavaCompiler,GENERATE_8_BYTECODE, \
 106     JAVAC := $(JAVAC), \
 107     FLAGS := \
 108         $(JAVA_TOOL_FLAGS_SMALL) \
 109         --release 8 \
 110         -XDignore.symbol.file=true -g \
 111         -Xlint:all -Werror, \
 112     DISABLE_SJAVAC := true, \
 113 ))
 114 
 115 endif # _SETUP_GMK