1 #
   2 # Copyright (c) 1997, 2013, 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.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #  
  23 #
  24 
  25 # Generic compiler settings
  26 !if "x$(CXX)" == "x"
  27 CXX=cl.exe
  28 !endif
  29 
  30 # CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
  31 #   /nologo   Supress copyright message at every cl.exe startup
  32 #   /W3       Warning level 3
  33 #   /Zi       Include debugging information
  34 #   /WX       Treat any warning error as a fatal error
  35 #   /MD       Use dynamic multi-threaded runtime (msvcrt.dll or msvc*NN.dll)
  36 #   /MTd      Use static multi-threaded runtime debug versions
  37 #   /O1       Optimize for size (/Os), skips /Oi
  38 #   /O2       Optimize for speed (/Ot), adds /Oi to /O1
  39 #   /Ox       Old "all optimizations flag" for VC6 (in /O1)
  40 #   /Oy       Use frame pointer register as GP reg (in /Ox and /O1)
  41 #   /GF       Merge string constants and put in read-only memory (in /O1)
  42 #   /Gy       Func level link (in /O1, allows for link-time func ordering)
  43 #   /Gs       Inserts stack probes (in /O1)
  44 #   /GS       Inserts security stack checks in some functions (VS2005 default)
  45 #   /Oi       Use intrinsics (in /O2)
  46 #   /Od       Disable all optimizations
  47 #   /MP       Use multiple cores for compilation
  48 #
  49 # NOTE: Normally following any of the above with a '-' will turn off that flag
  50 #
  51 # 6655385: For VS2003/2005 we now specify /Oy- (disable frame pointer
  52 # omission.)  This has little to no effect on performance while vastly
  53 # improving the quality of crash log stack traces involving jvm.dll.
  54 
  55 # These are always used in all compiles
  56 CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 /WX
  57 
  58 # Let's add debug information when Full Debug Symbols is enabled
  59 !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
  60 CXX_FLAGS=$(CXX_FLAGS) /Zi
  61 !endif
  62 
  63 # Based on BUILDARCH we add some flags and select the default compiler name
  64 !if "$(BUILDARCH)" == "ia64"
  65 MACHINE=IA64
  66 DEFAULT_COMPILER_NAME=VS2003
  67 CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
  68 !endif
  69 
  70 !if "$(BUILDARCH)" == "amd64"
  71 MACHINE=AMD64
  72 DEFAULT_COMPILER_NAME=VS2005
  73 CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64"
  74 LP64=1
  75 !endif
  76 
  77 !if "$(BUILDARCH)" == "i486"
  78 MACHINE=I386
  79 DEFAULT_COMPILER_NAME=VS2003
  80 CXX_FLAGS=$(CXX_FLAGS) /D "IA32"
  81 !endif
  82 
  83 # Sanity check, this is the default if not amd64, ia64, or i486
  84 !ifndef DEFAULT_COMPILER_NAME
  85 CXX=ARCH_ERROR
  86 !endif
  87 
  88 CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS"
  89 # Must specify this for sharedRuntimeTrig.cpp
  90 CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN"
  91 
  92 # Used for platform dispatching
  93 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_FAMILY_windows
  94 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_$(Platform_arch)
  95 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model)
  96 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch)
  97 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model)
  98 CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP
  99 
 100 
 101 # MSC_VER is a 4 digit number that tells us what compiler is being used
 102 #    and is generated when the local.make file is created by build.make
 103 #    via the script get_msc_ver.sh
 104 #
 105 #    If MSC_VER is set, it overrides the above default setting.
 106 #    But it should be set.
 107 #    Possible values:
 108 #      1200 is for VC6
 109 #      1300 and 1310 is VS2003 or VC7
 110 #      1399 is our fake number for the VS2005 compiler that really isn't 1400
 111 #      1400 is for VS2005
 112 #      1500 is for VS2008
 113 #      1600 is for VS2010
 114 #      1700 is for VS2012
 115 #    Do not confuse this MSC_VER with the predefined macro _MSC_VER that the
 116 #    compiler provides, when MSC_VER==1399, _MSC_VER will be 1400.
 117 #    Normally they are the same, but a pre-release of the VS2005 compilers
 118 #    in the Windows 64bit Platform SDK said it was 1400 when it was really
 119 #    closer to VS2003 in terms of option spellings, so we use 1399 for that
 120 #    1400 version that really isn't 1400.
 121 #    See the file get_msc_ver.sh for more info.
 122 !if "x$(MSC_VER)" == "x"
 123 COMPILER_NAME=$(DEFAULT_COMPILER_NAME)
 124 !else
 125 !if "$(MSC_VER)" == "1200"
 126 COMPILER_NAME=VC6
 127 !endif
 128 !if "$(MSC_VER)" == "1300"
 129 COMPILER_NAME=VS2003
 130 !endif
 131 !if "$(MSC_VER)" == "1310"
 132 COMPILER_NAME=VS2003
 133 !endif
 134 !if "$(MSC_VER)" == "1399"
 135 # Compiler might say 1400, but if it's 14.00.30701, it isn't really VS2005
 136 COMPILER_NAME=VS2003
 137 !endif
 138 !if "$(MSC_VER)" == "1400"
 139 COMPILER_NAME=VS2005
 140 !endif
 141 !if "$(MSC_VER)" == "1500"
 142 COMPILER_NAME=VS2008
 143 !endif
 144 !if "$(MSC_VER)" == "1600"
 145 COMPILER_NAME=VS2010
 146 !endif
 147 !if "$(MSC_VER)" == "1700"
 148 COMPILER_NAME=VS2012
 149 !endif
 150 !if "$(MSC_VER)" == "1800"
 151 COMPILER_NAME=VS2013
 152 !endif
 153 !if "$(MSC_VER)" == "1900"
 154 COMPILER_NAME=VS2015
 155 !endif
 156 !if "$(MSC_VER)" == "1912"
 157 COMPILER_NAME=VS2017
 158 !endif
 159 !if "$(MSC_VER)" == "1913"
 160 COMPILER_NAME=VS2017
 161 !endif
 162 !endif
 163 
 164 # By default, we do not want to use the debug version of the msvcrt.dll file
 165 #   but if MFC_DEBUG is defined in the environment it will be used.
 166 MS_RUNTIME_OPTION = /MD
 167 !if "$(MFC_DEBUG)" == "true"
 168 MS_RUNTIME_OPTION = /MTd /D "_DEBUG"
 169 !endif
 170 
 171 # VS2012 and later won't work with:
 172 #     /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
 173 !if "$(MSC_VER)" < "1700"
 174 # Always add the _STATIC_CPPLIB flag
 175 STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
 176 MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION)
 177 !endif
 178 CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION)
 179 
 180 # How /GX option is spelled
 181 GX_OPTION = /GX
 182 
 183 # Optimization settings for various versions of the compilers and types of
 184 #    builds. Three basic sets of settings: product, fastdebug, and debug.
 185 #    These get added into CXX_FLAGS as needed by other makefiles.
 186 !if "$(COMPILER_NAME)" == "VC6"
 187 PRODUCT_OPT_OPTION   = /Ox /Os /Gy /GF
 188 FASTDEBUG_OPT_OPTION = /Ox /Os /Gy /GF
 189 DEBUG_OPT_OPTION     = /Od
 190 !endif
 191 
 192 !if "$(COMPILER_NAME)" == "VS2003"
 193 PRODUCT_OPT_OPTION   = /O2 /Oy-
 194 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 195 DEBUG_OPT_OPTION     = /Od
 196 SAFESEH_FLAG = /SAFESEH
 197 !endif
 198 
 199 !if "$(COMPILER_NAME)" == "VS2005"
 200 PRODUCT_OPT_OPTION   = /O2 /Oy-
 201 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 202 DEBUG_OPT_OPTION     = /Od
 203 GX_OPTION = /EHsc
 204 # This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib 
 205 #    on the link command line, otherwise we get missing __security_check_cookie
 206 #    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
 207 #    NOTE: Currently we decided to not use /GS-
 208 BUFFEROVERFLOWLIB = bufferoverflowU.lib
 209 LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
 210 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 211 # as resources inside build artifacts.
 212 !if "x$(MT)" == "x"
 213 MT=mt.exe
 214 !endif
 215 SAFESEH_FLAG = /SAFESEH
 216 !endif
 217 
 218 !if "$(COMPILER_NAME)" == "VS2008"
 219 PRODUCT_OPT_OPTION   = /O2 /Oy-
 220 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 221 DEBUG_OPT_OPTION     = /Od
 222 GX_OPTION = /EHsc
 223 LD_FLAGS = /manifest $(LD_FLAGS)
 224 MP_FLAG = /MP
 225 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 226 # as resources inside build artifacts.
 227 !if "x$(MT)" == "x"
 228 MT=mt.exe
 229 !endif
 230 SAFESEH_FLAG = /SAFESEH
 231 !endif
 232 
 233 !if "$(COMPILER_NAME)" == "VS2010"
 234 PRODUCT_OPT_OPTION   = /O2 /Oy-
 235 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 236 DEBUG_OPT_OPTION     = /Od
 237 GX_OPTION = /EHsc
 238 LD_FLAGS = /manifest $(LD_FLAGS)
 239 MP_FLAG = /MP
 240 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 241 # as resources inside build artifacts.
 242 !if "x$(MT)" == "x"
 243 MT=mt.exe
 244 !endif
 245 !if "$(BUILDARCH)" == "i486"
 246 LD_FLAGS = /SAFESEH $(LD_FLAGS)
 247 !endif
 248 !endif
 249 
 250 !if "$(COMPILER_NAME)" == "VS2012"
 251 PRODUCT_OPT_OPTION   = /O2 /Oy-
 252 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 253 DEBUG_OPT_OPTION     = /Od
 254 GX_OPTION = /EHsc
 255 LD_FLAGS = /manifest $(LD_FLAGS)
 256 MP_FLAG = /MP
 257 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 258 # as resources inside build artifacts.
 259 !if "x$(MT)" == "x"
 260 MT=mt.exe
 261 !endif
 262 SAFESEH_FLAG = /SAFESEH
 263 !endif
 264 
 265 !if "$(COMPILER_NAME)" == "VS2013"
 266 PRODUCT_OPT_OPTION   = /O2 /Oy-
 267 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 268 DEBUG_OPT_OPTION     = /Od
 269 GX_OPTION = /EHsc
 270 LD_FLAGS = /manifest $(LD_FLAGS)
 271 MP_FLAG = /MP
 272 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 273 # as resources inside build artifacts.
 274 !if "x$(MT)" == "x"
 275 MT=mt.exe
 276 !endif
 277 SAFESEH_FLAG = /SAFESEH
 278 !endif
 279 
 280 
 281 !if "$(COMPILER_NAME)" == "VS2015"
 282 PRODUCT_OPT_OPTION   = /O2 /Oy-
 283 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 284 DEBUG_OPT_OPTION     = /Od
 285 GX_OPTION = /EHsc
 286 LD_FLAGS = /manifest $(LD_FLAGS)
 287 MP_FLAG = /MP
 288 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 289 # as resources inside build artifacts.
 290 !if "x$(MT)" == "x"
 291 MT=mt.exe
 292 !endif
 293 SAFESEH_FLAG = /SAFESEH
 294 !endif
 295 
 296 !if "$(COMPILER_NAME)" == "VS2017"
 297 PRODUCT_OPT_OPTION   = /O2 /Oy-
 298 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 299 DEBUG_OPT_OPTION     = /Od
 300 GX_OPTION = /EHsc
 301 LD_FLAGS = /manifest $(LD_FLAGS)
 302 MP_FLAG = /MP
 303 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 304 # as resources inside build artifacts.
 305 !if "x$(MT)" == "x"
 306 MT=mt.exe
 307 !endif
 308 SAFESEH_FLAG = /SAFESEH
 309 !endif
 310 
 311 !if "$(BUILDARCH)" == "i486"
 312 LD_FLAGS = $(SAFESEH_FLAG) $(LD_FLAGS)
 313 !endif
 314 
 315 CXX_FLAGS = $(CXX_FLAGS) $(MP_FLAG)
 316 
 317 !if "$(ENABLE_JFR)" == "true"
 318 INCLUDE_JFR=1
 319 !else
 320 INCLUDE_JFR=0
 321 !endif
 322 CXX_FLAGS=$(CXX_FLAGS) /D INCLUDE_JFR=$(INCLUDE_JFR)
 323 
 324 # If NO_OPTIMIZATIONS is defined in the environment, turn everything off
 325 !ifdef NO_OPTIMIZATIONS
 326 PRODUCT_OPT_OPTION   = $(DEBUG_OPT_OPTION)
 327 FASTDEBUG_OPT_OPTION = $(DEBUG_OPT_OPTION)
 328 !endif
 329 
 330 # Generic linker settings
 331 !if "x$(LD)" == "x"
 332 LD=link.exe
 333 !endif
 334 LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
 335  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
 336  uuid.lib Wsock32.lib winmm.lib version.lib /nologo /machine:$(MACHINE) /opt:REF \
 337  /opt:ICF,8
 338 !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
 339 LD_FLAGS= $(LD_FLAGS) /map /debug
 340 !endif
 341 
 342 
 343 !if $(MSC_VER) >= 1600 
 344 LD_FLAGS= $(LD_FLAGS) psapi.lib
 345 !endif
 346 
 347 # Resource compiler settings
 348 !if "x$(RC)" == "x"
 349 RC=rc.exe
 350 !endif
 351 RC_FLAGS=/D "HS_VER=$(HS_VER)" \
 352          /D "HS_DOTVER=$(HS_DOTVER)" \
 353          /D "HS_BUILD_ID=$(HS_BUILD_ID)" \
 354          /D "JDK_VER=$(JDK_VER)" \
 355          /D "JDK_DOTVER=$(JDK_DOTVER)" \
 356          /D "HS_COMPANY=$(HS_COMPANY)" \
 357          /D "HS_FILEDESC=$(HS_FILEDESC)" \
 358          /D "HS_COPYRIGHT=$(HS_COPYRIGHT)" \
 359          /D "HS_FNAME=$(HS_FNAME)" \
 360          /D "HS_INTERNAL_NAME=$(HS_INTERNAL_NAME)" \
 361          /D "HS_NAME=$(HS_NAME)"
 362 
 363 # Need this to match the CXX_FLAGS settings
 364 !if "$(MFC_DEBUG)" == "true"
 365 RC_FLAGS = $(RC_FLAGS) /D "_DEBUG"
 366 !endif