hotspot/make/bsd/makefiles/gcc.make
author twisti
Sat, 28 Sep 2013 12:42:22 -0700
changeset 20295 a5dd1b071c32
parent 19956 9065fbafee8d
child 20686 1fa9a75192c3
permissions -rw-r--r--
8025613: clang: remove -Wno-unused-value Reviewed-by: iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
#
18431
f801ce7e5c12 8014326: [OSX] All libjvm symbols are exported
dholmes
parents: 17880
diff changeset
     2
# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
# published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
# accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
# questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
#  
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
OS_VENDOR = $(shell uname -s)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
#------------------------------------------------------------------------
11721
dcd1f62c9caf 7141242: build-infra merge: Rename CPP->CXX and LINK->LD
erikj
parents: 11205
diff changeset
    28
# CC, CXX & AS
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
11955
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    30
# If a SPEC is not set already, then use these defaults.
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    31
ifeq ($(SPEC),)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    32
  # When cross-compiling the ALT_COMPILER_PATH points
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    33
  # to the cross-compilation toolset
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    34
  ifdef CROSS_COMPILE_ARCH
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    35
    CXX = $(ALT_COMPILER_PATH)/g++
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    36
    CC  = $(ALT_COMPILER_PATH)/gcc
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    37
    HOSTCXX = g++
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    38
    HOSTCC  = gcc
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    39
  else ifneq ($(OS_VENDOR), Darwin)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    40
    CXX = g++
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    41
    CC  = gcc
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    42
    HOSTCXX = $(CXX)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    43
    HOSTCC  = $(CC)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    44
  endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    45
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    46
  # i486 hotspot requires -mstackrealign on Darwin.
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    47
  # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    48
  # gcc-4.0 supports this on earlier versions.
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    49
  # Prefer llvm-gcc where available.
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    50
  ifeq ($(OS_VENDOR), Darwin)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    51
    ifeq ($(origin CXX), default)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    52
      CXX = llvm-g++
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    53
    endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    54
    ifeq ($(origin CC), default)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    55
      CC  = llvm-gcc
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    56
    endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    57
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    58
    ifeq ($(ARCH), i486)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    59
      LLVM_SUPPORTS_STACKREALIGN := $(shell \
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    60
       [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    61
       && echo true || echo false)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    62
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    63
      ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    64
        CXX32 ?= llvm-g++
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    65
        CC32  ?= llvm-gcc
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    66
      else
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    67
        CXX32 ?= g++-4.0
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    68
        CC32  ?= gcc-4.0
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    69
      endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    70
      CXX = $(CXX32)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    71
      CC  = $(CC32)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    72
    endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    73
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    74
    ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    75
      CXX = clang++
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    76
      CC  = clang
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    77
    endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    78
11955
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    79
    HOSTCXX = $(CXX)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    80
    HOSTCC  = $(CC)
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    81
  endif
aeca8151886e 7141244: build-infra merge: Include $(SPEC) in makefiles and make variables overridable
erikj
parents: 11721
diff changeset
    82
19956
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
    83
  AS   = $(CC) -c 
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
    84
endif
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
    85
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    86
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    87
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    88
  CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    89
  CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    90
else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    91
  # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    92
  # prints the numbers (e.g. "2.95", "3.2.1")
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    93
  CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    94
  CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    97
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    98
  # clang has precompiled headers support by default, but the user can switch
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
    99
  # it off by using 'USE_PRECOMPILED_HEADER=0'.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   100
  ifdef LP64
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   101
    ifeq ($(USE_PRECOMPILED_HEADER),)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   102
      USE_PRECOMPILED_HEADER=1
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   103
    endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   104
  else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   105
    # We don't support precompiled headers on 32-bit builds because there some files are
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   106
    # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   107
    # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   108
    USE_PRECOMPILED_HEADER=0
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   109
  endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   110
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   111
  ifeq ($(USE_PRECOMPILED_HEADER),1)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   112
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   113
    ifndef LP64
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   114
      $(error " Precompiled Headers only supported on 64-bit platforms!")
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   115
    endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   116
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   117
    PRECOMPILED_HEADER_DIR=.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   118
    PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   119
    PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   120
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   121
    PCH_FLAG = -include precompiled.hpp
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   122
    PCH_FLAG/DEFAULT = $(PCH_FLAG)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   123
    PCH_FLAG/NO_PCH = -DNO_PCH
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   124
    PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   125
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   126
    VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   127
    VM_PCH_FLAG/AOUT =
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   128
    VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   129
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   130
    # We only use precompiled headers for the JVM build
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   131
    CFLAGS += $(VM_PCH_FLAG)
19701
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   132
 
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   133
    # The following files are compiled at various optimization
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   134
    # levels due to optimization issues encountered at the
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   135
    # 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   136
    # time error if there is an optimization level specification
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   137
    # skew between the PCH file and the C++ file.  Especially if the
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   138
    # PCH file is compiled at a higher optimization level than
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   139
    # the C++ file.  One solution might be to prepare extra optimization
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   140
    # level specific PCH files for the opt build and use them here, but
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   141
    # it's probably not worth the effort as long as only a few files
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   142
    # need this special handling.
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   143
    PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   144
    PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   145
    PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
19693
633580a41062 8022407: sun/misc/CopyMemory.java fails with SIGSEGV in Unsafe_SetByte+0x35
hseigel
parents: 19336
diff changeset
   146
    PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   147
  
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   148
  endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   149
else # ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   150
  # check for precompiled headers support
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   151
  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   152
    # Allow the user to turn off precompiled headers from the command line.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   153
    ifneq ($(USE_PRECOMPILED_HEADER),0)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   154
      PRECOMPILED_HEADER_DIR=.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   155
      PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   156
      PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   157
    endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   158
  endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   159
endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   160
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   161
# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   162
ifeq ($(USE_PRECOMPILED_HEADER),0)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   163
  CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   164
endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   165
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
#------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
# Compiler flags
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
# position-independent code
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   170
PICFLAG = -fPIC
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   171
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
VM_PICFLAG/LIBJVM = $(PICFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
VM_PICFLAG/AOUT   =
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   175
12156
fb31de03f649 7141246: build-infra merge: Introduce new JVM_VARIANT* to control which kind of jvm gets built
erikj
parents: 11955
diff changeset
   176
ifeq ($(JVM_VARIANT_ZERO), true)
fb31de03f649 7141246: build-infra merge: Introduce new JVM_VARIANT* to control which kind of jvm gets built
erikj
parents: 11955
diff changeset
   177
  CFLAGS += $(LIBFFI_CFLAGS)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   178
endif
12156
fb31de03f649 7141246: build-infra merge: Introduce new JVM_VARIANT* to control which kind of jvm gets built
erikj
parents: 11955
diff changeset
   179
ifeq ($(JVM_VARIANT_ZEROSHARK), true)
fb31de03f649 7141246: build-infra merge: Introduce new JVM_VARIANT* to control which kind of jvm gets built
erikj
parents: 11955
diff changeset
   180
  CFLAGS += $(LIBFFI_CFLAGS)
fb31de03f649 7141246: build-infra merge: Introduce new JVM_VARIANT* to control which kind of jvm gets built
erikj
parents: 11955
diff changeset
   181
  CFLAGS += $(LLVM_CFLAGS)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   182
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   183
CFLAGS += $(VM_PICFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   184
CFLAGS += -fno-rtti
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   185
CFLAGS += -fno-exceptions
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   186
ifeq ($(USE_CLANG),)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   187
  CFLAGS += -pthread
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   188
  CFLAGS += -fcheck-new
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   189
  # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   190
  # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   191
  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   192
    CFLAGS += -fvisibility=hidden
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   193
  endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   194
else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   195
  CFLAGS += -fvisibility=hidden
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   196
endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   197
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   198
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   199
  # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   200
  # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   201
  ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   202
    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   203
  else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   204
    STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   205
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   206
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   207
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   208
ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   209
ARCHFLAG/i486    = -m32 -march=i586
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   210
ARCHFLAG/amd64   = -m64 $(STACK_ALIGNMENT_OPT)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   211
ARCHFLAG/ia64    =
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   212
ARCHFLAG/sparc   = -m32 -mcpu=v9
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   213
ARCHFLAG/sparcv9 = -m64 -mcpu=v9
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   214
ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   215
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   216
# Darwin-specific build flags
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   217
ifeq ($(OS_VENDOR), Darwin)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   218
  # Ineffecient 16-byte stack re-alignment on Darwin/IA32
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   219
  ARCHFLAG/i486 += -mstackrealign
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   220
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   221
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   222
CFLAGS     += $(ARCHFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   223
AOUT_FLAGS += $(ARCHFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   224
LFLAGS     += $(ARCHFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   225
ASFLAGS    += $(ARCHFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   226
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   227
ifdef E500V2
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   228
CFLAGS += -DE500V2
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   229
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   230
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   231
# Use C++ Interpreter
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   232
ifdef CC_INTERP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   233
  CFLAGS += -DCC_INTERP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   234
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   235
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   236
# Keep temporary files (.ii, .s)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   237
ifdef NEED_ASM
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   238
  CFLAGS += -save-temps
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   239
else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   240
  CFLAGS += -pipe
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   241
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   242
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   243
# Compiler warnings are treated as errors
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   244
ifneq ($(COMPILER_WARNINGS_FATAL),false)
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   245
  WARNINGS_ARE_ERRORS = -Werror
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   246
endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   247
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   248
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   249
  # However we need to clean the code up before we can unrestrictedly enable this option with Clang
20295
a5dd1b071c32 8025613: clang: remove -Wno-unused-value
twisti
parents: 19956
diff changeset
   250
  WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   251
  WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   252
# Not yet supported by clang in Xcode 4.6.2
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   253
#  WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   254
  WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 18431
diff changeset
   255
  WARNINGS_ARE_ERRORS += -Wno-empty-body
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   256
endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   257
15938
fb5f9016ddbc 8008474: Add -Wundef to warning flags.
jprovino
parents: 14815
diff changeset
   258
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   259
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   260
ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   261
  # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   262
  # conversions which might affect the values. Only enable it in earlier versions.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   263
  WARNING_FLAGS = -Wunused-function
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   264
  ifeq ($(USE_CLANG),)
20295
a5dd1b071c32 8025613: clang: remove -Wno-unused-value
twisti
parents: 19956
diff changeset
   265
    WARNING_FLAGS += -Wconversion
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   266
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   267
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   268
15938
fb5f9016ddbc 8008474: Add -Wundef to warning flags.
jprovino
parents: 14815
diff changeset
   269
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   270
# Special cases
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   271
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   272
# XXXDARWIN: for _dyld_bind_fully_image_containing_address
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   273
ifeq ($(OS_VENDOR), Darwin)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   274
  CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   275
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   276
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   277
OPT_CFLAGS/SIZE=-Os
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   278
OPT_CFLAGS/SPEED=-O3
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   279
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   280
# Hotspot uses very unstrict aliasing turn this optimization off
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   281
# This option is added to CFLAGS rather than OPT_CFLAGS
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   282
# so that OPT_CFLAGS overrides get this option too.
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   283
CFLAGS += -fno-strict-aliasing
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   284
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   285
# The flags to use for an Optimized g++ build
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   286
ifeq ($(OS_VENDOR), Darwin)
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   287
  # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   288
  # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   289
  OPT_CFLAGS_DEFAULT ?= SIZE
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   290
else
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   291
  OPT_CFLAGS_DEFAULT ?= SPEED
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   292
endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   293
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   294
ifdef OPT_CFLAGS
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   295
  ifneq ("$(origin OPT_CFLAGS)", "command line")
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   296
    $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   297
  endif
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   298
endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   299
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   300
OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   301
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 12943
diff changeset
   302
# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   303
# if we use expensive-optimizations
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   304
ifeq ($(BUILDARCH), ia64)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   305
OPT_CFLAGS += -fno-expensive-optimizations
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   306
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   307
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   308
OPT_CFLAGS/NOOPT=-O0
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   309
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   310
# Work around some compiler bugs.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   311
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   312
  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   313
    OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
19701
8dfde6242cd1 8024050: Incorrect optimization level and comment specified for unsafe.cpp
hseigel
parents: 19693
diff changeset
   314
    OPT_CFLAGS/unsafe.o += -O1
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   315
  endif
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   316
else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   317
  # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   318
  ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   319
    OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   320
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   321
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   322
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   323
# Flags for generating make dependency flags.
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   324
DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   325
ifeq ($(USE_CLANG),)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   326
  ifneq ($(CC_VER_MAJOR), 2)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   327
    DEPFLAGS += -fpch-deps
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   328
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   329
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   330
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   331
# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
11205
f07e6dd70a1f 7116081: USE_PRECOMPILED_HEADER=0 triggers a single threaded build of the JVM
stefank
parents: 10830
diff changeset
   332
ifeq ($(USE_PRECOMPILED_HEADER),0)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   333
CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   334
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   335
15862
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   336
ifeq ($(OS_VENDOR), Darwin)
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   337
  # Setting these parameters makes it an error to link to macosx APIs that are 
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   338
  # newer than the given OS version and makes the linked binaries compatible even
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   339
  # if built on a newer version of the OS.
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   340
  # The expected format is X.Y.Z
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   341
  ifeq ($(MACOSX_VERSION_MIN),)
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   342
    MACOSX_VERSION_MIN=10.7.0
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   343
  endif
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   344
  # The macro takes the version with no dots, ex: 1070
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   345
  CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   346
            -mmacosx-version-min=$(MACOSX_VERSION_MIN)
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   347
  LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   348
endif
1d605801c9a6 8008451: Make mac builds on 10.8 work on 10.7
erikj
parents: 14815
diff changeset
   349
19956
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   350
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   351
#------------------------------------------------------------------------
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   352
# Assembler flags
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   353
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   354
# Enforce prerpocessing of .s files
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   355
ASFLAGS += -x assembler-with-cpp
9065fbafee8d 8022617: Openjdk hotspot build is broken on BSD platforms using gcc
dsamersoff
parents: 19701
diff changeset
   356
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   357
#------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   358
# Linker flags
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   359
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   360
# statically link libstdc++.so, work with gcc but ignored by g++
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   361
STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   362
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   363
ifeq ($(USE_CLANG),)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   364
  # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   365
  ifneq ("${CC_VER_MAJOR}", "2")
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   366
    STATIC_LIBGCC += -static-libgcc
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   367
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   368
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   369
  ifeq ($(BUILDARCH), ia64)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   370
    LFLAGS += -Wl,-relax
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   371
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   372
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   373
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   374
# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   375
MAPFLAG = -Xlinker --version-script=FILENAME
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   376
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   377
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   378
# Shared Library
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   379
#
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   380
ifeq ($(OS_VENDOR), Darwin)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   381
  # Standard linker flags
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   382
  LFLAGS +=
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   383
18431
f801ce7e5c12 8014326: [OSX] All libjvm symbols are exported
dholmes
parents: 17880
diff changeset
   384
  # The apple linker has its own variant of mapfiles/version-scripts
f801ce7e5c12 8014326: [OSX] All libjvm symbols are exported
dholmes
parents: 17880
diff changeset
   385
  MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   386
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   387
  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   388
  SONAMEFLAG =
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   389
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   390
  # Build shared library
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 10565
diff changeset
   391
  SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   392
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   393
  # Keep symbols even they are not used
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   394
  #AOUT_FLAGS += -Xlinker -export-dynamic
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   395
else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   396
  # Enable linker optimization
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   397
  LFLAGS += -Xlinker -O1
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   398
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   399
  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   400
  SONAMEFLAG = -Xlinker -soname=SONAME
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   401
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   402
  # Build shared library
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   403
  SHARED_FLAG = -shared $(VM_PICFLAG)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   404
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   405
  # Keep symbols even they are not used
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   406
  AOUT_FLAGS += -Xlinker -export-dynamic
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   407
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   408
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   409
#------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   410
# Debug flags
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   411
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   412
ifeq ($(USE_CLANG), true)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   413
  # Restrict the debug information created by Clang to avoid
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   414
  # too big object files and speed the build up a little bit
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   415
  # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   416
  CFLAGS += -flimit-debug-info
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   417
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   418
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   419
# DEBUG_BINARIES uses full -g debug information for all configs
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   420
ifeq ($(DEBUG_BINARIES), true)
17880
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   421
  CFLAGS += -g
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   422
else
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   423
  # Use the stabs format for debugging information (this is the default
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   424
  # on gcc-2.91). It's good enough, has all the information about line
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   425
  # numbers and local variables, and libjvm.so is only about 16M.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   426
  # Change this back to "-g" if you want the most expressive format.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   427
  # (warning: that could easily inflate libjvm.so to 150M!)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   428
  # Note: The Itanium gcc compiler crashes when using -gstabs.
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   429
  DEBUG_CFLAGS/ia64  = -g
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   430
  DEBUG_CFLAGS/amd64 = -g
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   431
  DEBUG_CFLAGS/arm   = -g
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   432
  DEBUG_CFLAGS/ppc   = -g
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   433
  DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   434
  ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   435
  DEBUG_CFLAGS += -gstabs
17f3d10c297f 8015252: Enable HotSpot build with Clang
simonis
parents: 15939
diff changeset
   436
  endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   437
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   438
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   439
# If we are building HEADLESS, pass on to VM
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   440
# so it can set the java.awt.headless property
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   441
ifdef HEADLESS
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   442
CFLAGS += -DHEADLESS
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   443
endif
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   444
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   445
# We are building Embedded for a small device
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   446
# favor code space over speed
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   447
ifdef MINIMIZE_RAM_USAGE
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   448
CFLAGS += -DMINIMIZE_RAM_USAGE
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   449
endif