build/linux/makefiles/gcc.make

Wed, 12 Mar 2008 18:37:03 -0700

author
dcubed
date
Wed, 12 Mar 2008 18:37:03 -0700
changeset 485
485d403e94e1
parent 435
a61af66fc99e
permissions
-rw-r--r--

6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
Summary: (for Serguei) Allow for Linux builds with Sun Studio Linux compilers
Reviewed-by: sspitsyn, ohair

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

mercurial