1 #
   2 # Copyright (c) 2013, 2019, 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 $(eval $(call IncludeCustomExtension, hotspot/lib/JvmOverrideFiles.gmk))
  27 
  28 ################################################################################
  29 # This file contains explicit overrides of CFLAGS and/or precompiled header
  30 # status for individual files on specific platforms.
  31 
  32 ifeq ($(TOOLCHAIN_TYPE), gcc)
  33   BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments
  34   BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments
  35   BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_CXXFLAGS := -fno-var-tracking-assignments
  36   BUILD_LIBJVM_assembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized
  37   BUILD_LIBJVM_cardTableBarrierSetAssembler_x86.cpp_CXXFLAGS := -Wno-maybe-uninitialized
  38   BUILD_LIBJVM_interp_masm_x86.cpp_CXXFLAGS := -Wno-uninitialized
  39   ifeq ($(DEBUG_LEVEL), release)
  40     # Need extra inlining to collapse all marking code into the hot marking loop
  41     BUILD_LIBJVM_shenandoahConcurrentMark.cpp_CXXFLAGS := --param inline-unit-growth=1000
  42     BUILD_LIBJVM_shenandoahTraversalGC.cpp_CXXFLAGS := --param inline-unit-growth=1000
  43   endif
  44 endif
  45 
  46 LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NONE)
  47 # If the FDLIBM_CFLAGS variable is non-empty we know
  48 # that the fdlibm-fork in hotspot can get optimized
  49 # by using -ffp-contract=off on GCC/Clang platforms.
  50 ifneq ($(FDLIBM_CFLAGS), )
  51   LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NORM)
  52 endif
  53 
  54 ifeq ($(call isTargetOs, linux), true)
  55   BUILD_LIBJVM_ostream.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64
  56   BUILD_LIBJVM_logFileOutput.cpp_CXXFLAGS := -D_FILE_OFFSET_BITS=64
  57 
  58   BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
  59   BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := -DNO_PCH $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
  60 
  61   ifeq ($(TOOLCHAIN_TYPE), clang)
  62     JVM_PRECOMPILED_HEADER_EXCLUDE := \
  63         sharedRuntimeTrig.cpp \
  64         sharedRuntimeTrans.cpp \
  65         #
  66   endif
  67 
  68   ifeq ($(call isTargetCpu, x86), true)
  69     # Performance measurements show that by compiling GC related code, we could
  70     # significantly reduce the GC pause time on 32 bit Linux/Unix platforms by
  71     # compiling without the PIC flag (-fPIC on linux).
  72     # See 6454213 for more details.
  73     ALL_SRC := $(call FindFiles, $(TOPDIR)/src/hotspot/share, *.cpp)
  74     NONPIC_FILTER := $(addsuffix %, $(addprefix $(TOPDIR)/src/hotspot/share/, \
  75         memory oops gc))
  76     # Due to what looks like a bug in the old build implementation of this, add a
  77     # couple of more files that were accidentally matched as substrings of GC related
  78     # files.
  79     NONPIC_SRC := $(filter $(NONPIC_FILTER), $(ALL_SRC)) globals.cpp location.cpp
  80     # Declare variables for each source file that needs the pic flag like this:
  81     # BUILD_JVM_<srcfile>_CXXFLAGS := -fno-PIC
  82     # This will get implicitly picked up by SetupNativeCompilation below.
  83     $(foreach s, $(NONPIC_SRC), $(eval BUILD_LIBJVM_$(notdir $s)_CXXFLAGS := -fno-PIC))
  84   endif
  85 
  86 else ifeq ($(call isTargetOs, macosx), true)
  87   # The copied fdlibm routines in these files must not be optimized
  88   BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
  89   BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(FDLIBM_CFLAGS) $(LIBJVM_FDLIBM_COPY_OPT_FLAG)
  90   ifeq ($(TOOLCHAIN_TYPE), clang)
  91     # NOTE: The old build tested clang version to make sure this workaround
  92     # for the clang bug was still needed.
  93     BUILD_LIBJVM_loopTransform.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE)
  94     ifneq ($(DEBUG_LEVEL), slowdebug)
  95       BUILD_LIBJVM_unsafe.cpp_CXXFLAGS := -O1
  96     endif
  97 
  98     # The following files are compiled at various optimization
  99     # levels due to optimization issues encountered at the
 100     # default level. The Clang compiler issues a compile
 101     # time error if there is an optimization level specification
 102     # skew between the PCH file and the C++ file.  Especially if the
 103     # PCH file is compiled at a higher optimization level than
 104     # the C++ file.  One solution might be to prepare extra optimization
 105     # level specific PCH files for the opt build and use them here, but
 106     # it's probably not worth the effort as long as only a few files
 107     # need this special handling.
 108     JVM_PRECOMPILED_HEADER_EXCLUDE := \
 109         sharedRuntimeTrig.cpp \
 110         sharedRuntimeTrans.cpp \
 111         loopTransform.cpp \
 112         unsafe.cpp \
 113         jvmciCompilerToVM.cpp \
 114         #
 115   endif
 116 
 117 else ifeq ($(call isTargetOs, aix), true)
 118   BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -qnoinline
 119   BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE)
 120   # Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp
 121   # and sharedRuntimeTrans.cpp on ppc64.
 122   # -qstrict turns off the following optimizations:
 123   #   * Performing code motion and scheduling on computations such as loads
 124   #     and floating-point computations that may trigger an exception.
 125   #   * Relaxing conformance to IEEE rules.
 126   #   * Reassociating floating-point expressions.
 127   # When using '-qstrict' there still remains one problem
 128   # in javasoft.sqe.tests.api.java.lang.Math.sin5Tests when run in compile-all
 129   # mode, so don't optimize sharedRuntimeTrig.cpp at all.
 130   BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE)
 131 
 132   ifneq ($(DEBUG_LEVEL),slowdebug)
 133     # Compiling jvmtiEnterTrace.cpp with full optimization needs more than 30min
 134     # (mostly because of '-qhot=level=1' and the more than 1300 'log_trace' calls
 135     # which cause a lot of template expansion).
 136     BUILD_LIBJVM_jvmtiEnterTrace.cpp_OPTIMIZATION := LOW
 137   endif
 138 
 139   # Disable ELF decoder on AIX (AIX uses XCOFF).
 140   JVM_EXCLUDE_PATTERNS += elf
 141 
 142 else ifeq ($(call isTargetOs, windows), true)
 143   JVM_PRECOMPILED_HEADER_EXCLUDE := \
 144       bytecodeInterpreter.cpp \
 145       bytecodeInterpreterWithChecks.cpp \
 146       opcodes.cpp \
 147       os_windows.cpp \
 148       os_windows_x86.cpp \
 149       osThread_windows.cpp \
 150       jvmciCompilerToVMInit.cpp \
 151       #
 152 
 153   # Workaround for jvmciCompilerToVM.cpp long compilation time
 154   BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_OPTIMIZATION := NONE
 155 
 156 endif