hotspot/build/linux/makefiles/gcc.make
changeset 1 489c9b5090e2
equal deleted inserted replaced
0:fd16c54261b3 1:489c9b5090e2
       
     1 #
       
     2 # Copyright 1999-2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20 # CA 95054 USA or visit www.sun.com if you need additional information or
       
    21 # have any questions.
       
    22 #  
       
    23 #
       
    24 
       
    25 #------------------------------------------------------------------------
       
    26 # CC, CPP & AS
       
    27 
       
    28 CPP = g++
       
    29 CC  = gcc
       
    30 AS  = $(CC) -c
       
    31 
       
    32 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
       
    33 # prints the numbers (e.g. "2.95", "3.2.1")
       
    34 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
       
    35 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
       
    36 
       
    37 # check for precompiled headers support
       
    38 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
       
    39 USE_PRECOMPILED_HEADER=1
       
    40 PRECOMPILED_HEADER_DIR=.
       
    41 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/incls/_precompiled.incl.gch
       
    42 endif
       
    43 
       
    44 
       
    45 #------------------------------------------------------------------------
       
    46 # Compiler flags
       
    47 
       
    48 # position-independent code
       
    49 PICFLAG = -fPIC
       
    50 
       
    51 VM_PICFLAG/LIBJVM = $(PICFLAG)
       
    52 VM_PICFLAG/AOUT   =
       
    53 
       
    54 ifneq ($(BUILDARCH), i486)
       
    55 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
       
    56 else
       
    57 # PIC has significant overhead on x86, build nonpic VM for now.
       
    58 # Link JVM at a "good" base location to avoid unnecessary .text patching.
       
    59 JVM_BASE_ADDR     = 0x06000000
       
    60 endif
       
    61 
       
    62 CFLAGS += $(VM_PICFLAG)
       
    63 CFLAGS += -fno-rtti
       
    64 CFLAGS += -fno-exceptions
       
    65 CFLAGS += -D_REENTRANT
       
    66 CFLAGS += -fcheck-new
       
    67 
       
    68 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
       
    69 ARCHFLAG/i486    = -m32 -march=i586
       
    70 ARCHFLAG/amd64   = -m64
       
    71 ARCHFLAG/ia64    =
       
    72 ARCHFLAG/sparc   = -m32 -mcpu=v9
       
    73 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
       
    74 
       
    75 CFLAGS     += $(ARCHFLAG)
       
    76 AOUT_FLAGS += $(ARCHFLAG)
       
    77 LFLAGS     += $(ARCHFLAG)
       
    78 ASFLAGS    += $(ARCHFLAG)
       
    79 
       
    80 # Use C++ Interpreter
       
    81 ifdef CC_INTERP
       
    82   CFLAGS += -DCC_INTERP
       
    83 endif
       
    84 
       
    85 # Keep temporary files (.ii, .s)
       
    86 ifdef NEED_ASM
       
    87   CFLAGS += -save-temps
       
    88 else
       
    89   CFLAGS += -pipe
       
    90 endif
       
    91 
       
    92 # Compiler warnings are treated as errors
       
    93 WARNINGS_ARE_ERRORS = -Werror
       
    94 # Except for a few acceptable ones
       
    95 ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
       
    96 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
       
    97 # Special cases
       
    98 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
       
    99 
       
   100 # The flags to use for an Optimized g++ build
       
   101 OPT_CFLAGS += -O3
       
   102 
       
   103 # Hotspot uses very unstrict aliasing turn this optimization off
       
   104 OPT_CFLAGS += -fno-strict-aliasing
       
   105 
       
   106 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp 
       
   107 # if we use expensive-optimizations
       
   108 ifeq ($(BUILDARCH), ia64)
       
   109 OPT_CFLAGS += -fno-expensive-optimizations
       
   110 endif
       
   111 
       
   112 OPT_CFLAGS/NOOPT=-O0
       
   113 
       
   114 #------------------------------------------------------------------------
       
   115 # Linker flags
       
   116 
       
   117 # statically link libstdc++.so, work with gcc but ignored by g++
       
   118 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
       
   119 
       
   120 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
       
   121 ifneq ("${CC_VER_MAJOR}", "2")
       
   122 STATIC_LIBGCC += -static-libgcc
       
   123 endif
       
   124 
       
   125 ifeq ($(BUILDARCH), ia64)
       
   126 LFLAGS += -Wl,-relax
       
   127 endif
       
   128 
       
   129 # Enable linker optimization
       
   130 LFLAGS += -Xlinker -O1
       
   131 
       
   132 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
       
   133 MAPFLAG = -Xlinker --version-script=FILENAME
       
   134 
       
   135 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
       
   136 SONAMEFLAG = -Xlinker -soname=SONAME
       
   137 
       
   138 # Build shared library
       
   139 SHARED_FLAG = -shared
       
   140 
       
   141 # Keep symbols even they are not used
       
   142 AOUT_FLAGS += -export-dynamic
       
   143 
       
   144 #------------------------------------------------------------------------
       
   145 # Debug flags
       
   146 
       
   147 # Use the stabs format for debugging information (this is the default
       
   148 # on gcc-2.91). It's good enough, has all the information about line
       
   149 # numbers and local variables, and libjvm_g.so is only about 16M.
       
   150 # Change this back to "-g" if you want the most expressive format.
       
   151 # (warning: that could easily inflate libjvm_g.so to 150M!)
       
   152 # Note: The Itanium gcc compiler crashes when using -gstabs.
       
   153 DEBUG_CFLAGS/ia64  = -g
       
   154 DEBUG_CFLAGS/amd64 = -g
       
   155 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
       
   156 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
       
   157 DEBUG_CFLAGS += -gstabs
       
   158 endif