1 #
   2 # Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3 # Copyright (c) 2012, 2015 SAP. All rights reserved.
   4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 #
   6 # This code is free software; you can redistribute it and/or modify it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 #
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 #
  16 # You should have received a copy of the GNU General Public License version
  17 # 2 along with this work; if not, write to the Free Software Foundation,
  18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 #
  20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 #  
  24 #
  25 
  26 #------------------------------------------------------------------------
  27 # CC, CXX & AS
  28 
  29 # Set compiler explicitly
  30 CXX = $(COMPILER_PATH)xlC_r
  31 CC  = $(COMPILER_PATH)xlc_r
  32 HOSTCXX = $(CXX)
  33 HOSTCC  = $(CC)
  34 
  35 AS  = $(CC) -c
  36 
  37 # get xlc version which comes as VV.RR.MMMM.LLLL where 'VV' is the version,
  38 # 'RR' is the release, 'MMMM' is the modification and 'LLLL' is the level.
  39 # We only use 'VV.RR.LLLL' to avoid integer overflows in bash when comparing
  40 # the version numbers (some shells only support 32-bit integer compares!).
  41 CXX_VERSION := $(shell $(CXX) -qversion 2>&1 | \
  42                    sed -n 's/.*Version: \([0-9]\{2\}\).\([0-9]\{2\}\).[0-9]\{4\}.\([0-9]\{4\}\)/\1\2\3/p')
  43 
  44 # xlc 08.00.0000.0023 and higher supports -qtune=balanced
  45 CXX_SUPPORTS_BALANCED_TUNING := $(shell if [ $(CXX_VERSION) -ge 08000023 ] ; then echo "true" ; fi)
  46 # xlc 10.01 is used with aggressive optimizations to boost performance
  47 CXX_IS_V10 := $(shell if [ $(CXX_VERSION) -ge 10010000 ] ; then echo "true" ; fi)
  48 
  49 # check for precompiled headers support
  50 
  51 # Switch off the precompiled header support. Neither xlC 8.0 nor xlC 10.0
  52 # support precompiled headers. Both "understand" the command line switches "-qusepcomp" and 
  53 # "-qgenpcomp" but when we specify them the following message is printed:
  54 # "1506-755 (W) The -qusepcomp option is not supported in this release."
  55 USE_PRECOMPILED_HEADER = 0
  56 ifneq ($(USE_PRECOMPILED_HEADER),0)
  57 PRECOMPILED_HEADER_DIR=.
  58 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
  59 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
  60 endif
  61 
  62 
  63 #------------------------------------------------------------------------
  64 # Compiler flags
  65 
  66 # position-independent code
  67 PICFLAG = -qpic=large
  68 
  69 VM_PICFLAG/LIBJVM = $(PICFLAG)
  70 VM_PICFLAG/AOUT   =
  71 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
  72 
  73 CFLAGS += $(VM_PICFLAG)
  74 CFLAGS += -qnortti
  75 CFLAGS += -qnoeh
  76 
  77 # for compiler-level tls
  78 CFLAGS += -qtls=default
  79 
  80 CFLAGS += -D_REENTRANT
  81 # no xlc counterpart for -fcheck-new
  82 # CFLAGS += -fcheck-new
  83 
  84 # We need to define this on the command line if we want to use the the
  85 # predefined format specifiers from "inttypes.h". Otherwise system headrs
  86 # can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS
  87 # in globalDefinitions.hpp
  88 CFLAGS += -D__STDC_FORMAT_MACROS
  89 
  90 ARCHFLAG = -q64
  91 
  92 CFLAGS     += $(ARCHFLAG)
  93 AOUT_FLAGS += $(ARCHFLAG)
  94 LFLAGS     += $(ARCHFLAG)
  95 ASFLAGS    += $(ARCHFLAG)
  96 
  97 # Use C++ Interpreter
  98 ifdef CC_INTERP
  99   CFLAGS += -DCC_INTERP
 100 endif
 101 
 102 # Keep temporary files (.ii, .s)
 103 # no counterpart on xlc for -save-temps, -pipe
 104 
 105 # Compiler warnings are treated as errors
 106 # Do not treat warnings as errors
 107 # WARNINGS_ARE_ERRORS = -Werror
 108 # Except for a few acceptable ones
 109 # ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
 110 # CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
 111 CFLAGS_WARN/COMMON = 
 112 CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS)
 113 # Special cases
 114 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
 115 
 116 # The flags to use for an optimized build
 117 OPT_CFLAGS += -O3
 118 
 119 # Hotspot uses very unstrict aliasing turn this optimization off
 120 OPT_CFLAGS += -qalias=noansi
 121 
 122 OPT_CFLAGS/NOOPT=-qnoopt
 123 
 124 DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d)
 125 
 126 #------------------------------------------------------------------------
 127 # Linker flags
 128 
 129 # statically link libstdc++.so, work with gcc but ignored by g++
 130 STATIC_STDCXX = -Wl,-lC_r
 131 
 132 # Enable linker optimization
 133 # no counterpart on xlc for this 
 134 # LFLAGS += -Xlinker -O1
 135 
 136 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 137 # MAPFLAG = -Xlinker --version-script=FILENAME
 138 
 139 # Build shared library
 140 SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
 141 
 142 #------------------------------------------------------------------------
 143 # Debug flags
 144 
 145 # Always compile with '-g' to get symbols in the stacktraces in the hs_err file
 146 DEBUG_CFLAGS += -g
 147 FASTDEBUG_CFLAGS += -g
 148 OPT_CFLAGS += -g
 149 
 150 # DEBUG_BINARIES overrides everything, use full -g debug information
 151 ifeq ($(DEBUG_BINARIES), true)
 152   DEBUG_CFLAGS = -g
 153   CFLAGS += $(DEBUG_CFLAGS)
 154 endif
 155 
 156 # If we are building HEADLESS, pass on to VM
 157 # so it can set the java.awt.headless property
 158 ifdef HEADLESS
 159 CFLAGS += -DHEADLESS
 160 endif
 161 
 162 # We are building Embedded for a small device
 163 # favor code space over speed
 164 ifdef MINIMIZE_RAM_USAGE
 165 CFLAGS += -DMINIMIZE_RAM_USAGE
 166 endif
 167 
 168 ifdef CROSS_COMPILE_ARCH
 169   STRIP = $(ALT_COMPILER_PATH)/strip
 170 else
 171   STRIP = strip
 172 endif