Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/make/bsd/makefiles/gcc.make
32285 views
#1# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#22#2324OS_VENDOR = $(shell uname -s)2526#------------------------------------------------------------------------27# CC, CXX & AS2829# If a SPEC is not set already, then use these defaults.30ifeq ($(SPEC),)31# When cross-compiling the ALT_COMPILER_PATH points32# to the cross-compilation toolset33ifdef CROSS_COMPILE_ARCH34CXX = $(ALT_COMPILER_PATH)/g++35CC = $(ALT_COMPILER_PATH)/gcc36HOSTCXX = g++37HOSTCC = gcc38else ifneq ($(OS_VENDOR), Darwin)39CXX = g++40CC = gcc41HOSTCXX = $(CXX)42HOSTCC = $(CC)43endif4445# i486 hotspot requires -mstackrealign on Darwin.46# llvm-gcc supports this in Xcode 3.2.6 and 4.0.47# gcc-4.0 supports this on earlier versions.48# Prefer llvm-gcc where available.49ifeq ($(OS_VENDOR), Darwin)50ifeq ($(origin CXX), default)51CXX = llvm-g++52endif53ifeq ($(origin CC), default)54CC = llvm-gcc55endif5657ifeq ($(ARCH), i486)58LLVM_SUPPORTS_STACKREALIGN := $(shell \59[ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \60&& echo true || echo false)6162ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)63CXX32 ?= llvm-g++64CC32 ?= llvm-gcc65else66CXX32 ?= g++-4.067CC32 ?= gcc-4.068endif69CXX = $(CXX32)70CC = $(CC32)71endif7273ifeq ($(USE_CLANG), true)74CXX = clang++75CC = clang76endif7778HOSTCXX = $(CXX)79HOSTCC = $(CC)80endif8182AS = $(CC) -c83endif8485ifeq ($(OS_VENDOR), Darwin)86ifeq ($(DSYMUTIL),)87DSYMUTIL=dsymutil88endif89endif9091ifeq ($(USE_CLANG), true)92CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)93CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)94else95# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only96# prints the numbers (e.g. "2.95", "3.2.1")97CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)98CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)99endif100101ifeq ($(USE_CLANG), true)102# clang has precompiled headers support by default, but the user can switch103# it off by using 'USE_PRECOMPILED_HEADER=0'.104ifdef LP64105ifeq ($(USE_PRECOMPILED_HEADER),)106USE_PRECOMPILED_HEADER=1107endif108else109# We don't support precompiled headers on 32-bit builds because there some files are110# compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)111# Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.112USE_PRECOMPILED_HEADER=0113endif114115ifeq ($(USE_PRECOMPILED_HEADER),1)116117ifndef LP64118$(error " Precompiled Headers only supported on 64-bit platforms!")119endif120121PRECOMPILED_HEADER_DIR=.122PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp123PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch124125PCH_FLAG = -include precompiled.hpp126PCH_FLAG/DEFAULT = $(PCH_FLAG)127PCH_FLAG/NO_PCH = -DNO_PCH128PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))129130VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)131VM_PCH_FLAG/AOUT =132VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))133134# We only use precompiled headers for the JVM build135CFLAGS += $(VM_PCH_FLAG)136137# The following files are compiled at various optimization138# levels due to optimization issues encountered at the139# 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile140# time error if there is an optimization level specification141# skew between the PCH file and the C++ file. Especially if the142# PCH file is compiled at a higher optimization level than143# the C++ file. One solution might be to prepare extra optimization144# level specific PCH files for the opt build and use them here, but145# it's probably not worth the effort as long as only a few files146# need this special handling.147PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)148PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)149PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)150PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)151152endif153else # ($(USE_CLANG), true)154# check for precompiled headers support155ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"156# Allow the user to turn off precompiled headers from the command line.157ifneq ($(USE_PRECOMPILED_HEADER),0)158PRECOMPILED_HEADER_DIR=.159PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp160PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch161endif162endif163endif164165# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.166ifeq ($(USE_PRECOMPILED_HEADER),0)167CFLAGS += -DDONT_USE_PRECOMPILED_HEADER168endif169170#------------------------------------------------------------------------171# Compiler flags172173# position-independent code174PICFLAG = -fPIC175176VM_PICFLAG/LIBJVM = $(PICFLAG)177VM_PICFLAG/AOUT =178VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))179180ifeq ($(JVM_VARIANT_ZERO), true)181CFLAGS += $(LIBFFI_CFLAGS)182endif183ifeq ($(JVM_VARIANT_ZEROSHARK), true)184CFLAGS += $(LIBFFI_CFLAGS)185CFLAGS += $(LLVM_CFLAGS)186endif187CFLAGS += $(VM_PICFLAG)188CFLAGS += -fno-rtti189CFLAGS += -fno-exceptions190ifeq ($(USE_CLANG),)191CFLAGS += -pthread192CFLAGS += -fcheck-new -fstack-protector193# version 4 and above support fvisibility=hidden (matches jni_x86.h file)194# except 4.1.2 gives pointless warnings that can't be disabled (afaik)195ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"196CFLAGS += -fvisibility=hidden197endif198else199CFLAGS += -fvisibility=hidden200endif201202ifeq ($(USE_CLANG), true)203# Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'204# Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')205ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"206STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16207else208STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16209endif210endif211212ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))213ARCHFLAG/i486 = -m32 -march=i586214ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT)215ARCHFLAG/aarch64 = -arch arm64216ARCHFLAG/ia64 =217ARCHFLAG/sparc = -m32 -mcpu=v9218ARCHFLAG/sparcv9 = -m64 -mcpu=v9219ARCHFLAG/zero = $(ZERO_ARCHFLAG)220221# Darwin-specific build flags222ifeq ($(OS_VENDOR), Darwin)223# Ineffecient 16-byte stack re-alignment on Darwin/IA32224ARCHFLAG/i486 += -mstackrealign225endif226227CFLAGS += $(ARCHFLAG)228AOUT_FLAGS += $(ARCHFLAG)229LFLAGS += $(ARCHFLAG)230ASFLAGS += $(ARCHFLAG)231232ifdef E500V2233CFLAGS += -DE500V2234endif235236# Use C++ Interpreter237ifdef CC_INTERP238CFLAGS += -DCC_INTERP239endif240241# Keep temporary files (.ii, .s)242ifdef NEED_ASM243CFLAGS += -save-temps244else245CFLAGS += -pipe246endif247248# Compiler warnings are treated as errors249ifneq ($(COMPILER_WARNINGS_FATAL),false)250# WARNINGS_ARE_ERRORS = -Werror251WARNINGS_ARE_ERRORS = -Werror=implicit-function-declaration252endif253254ifeq ($(USE_CLANG), true)255# However we need to clean the code up before we can unrestrictedly enable this option with Clang256WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses257WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare258# Not yet supported by clang in Xcode 4.6.2259# WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare260WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess261WARNINGS_ARE_ERRORS += -Wno-empty-body262endif263264WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2265266ifeq ($(USE_CLANG),)267# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit268# conversions which might affect the values. Only enable it in earlier versions.269ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"270WARNINGS_FLAGS += -Wconversion271endif272endif273274CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)275# Special cases276CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))277# XXXDARWIN: for _dyld_bind_fully_image_containing_address278ifeq ($(OS_VENDOR), Darwin)279CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations280endif281282OPT_CFLAGS/SIZE=-Os283OPT_CFLAGS/SPEED=-O3284285# Hotspot uses very unstrict aliasing turn this optimization off286# This option is added to CFLAGS rather than OPT_CFLAGS287# so that OPT_CFLAGS overrides get this option too.288CFLAGS += -fno-strict-aliasing289290# The flags to use for an Optimized g++ build291ifeq ($(OS_VENDOR), Darwin)292# use -Os by default, unless -O3 can be proved to be worth the cost, as per policy293# <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>294OPT_CFLAGS_DEFAULT ?= SIZE295else296OPT_CFLAGS_DEFAULT ?= SPEED297endif298299ifdef OPT_CFLAGS300ifneq ("$(origin OPT_CFLAGS)", "command line")301$(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")302endif303endif304305OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)306307# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp308# if we use expensive-optimizations309ifeq ($(BUILDARCH), ia64)310OPT_CFLAGS += -fno-expensive-optimizations311endif312313OPT_CFLAGS/NOOPT=-O0314315# Work around some compiler bugs.316ifeq ($(USE_CLANG), true)317ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)318OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)319OPT_CFLAGS/unsafe.o += -O1320endif321else322# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.323ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)324OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)325endif326endif327328# Flags for generating make dependency flags.329DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)330ifeq ($(USE_CLANG),)331ifneq ($(CC_VER_MAJOR), 2)332DEPFLAGS += -fpch-deps333endif334endif335336# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.337ifeq ($(USE_PRECOMPILED_HEADER),0)338CFLAGS += -DDONT_USE_PRECOMPILED_HEADER339endif340341ifeq ($(OS_VENDOR), Darwin)342# Setting these parameters makes it an error to link to macosx APIs that are343# newer than the given OS version and makes the linked binaries compatible even344# if built on a newer version of the OS.345# The expected format is X.Y.Z346ifeq ($(MACOSX_VERSION_MIN),)347MACOSX_VERSION_MIN=10.7.0348endif349# The macro takes the version with no dots, ex: 1070350ifdef CROSS_COMPILE_ARCH351HOSTCC += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \352-mmacosx-version-min=$(MACOSX_VERSION_MIN)353HOSTCXX += -mmacosx-version-min=$(MACOSX_VERSION_MIN)354355# Quick way to replace finite() with isfinite()356CXX += -Dfinite\(x\)=isfinite\(x\)357else358CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \359-mmacosx-version-min=$(MACOSX_VERSION_MIN)360LFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)361endif362endif363364365#------------------------------------------------------------------------366# Assembler flags367368# Enforce prerpocessing of .s files369ASFLAGS += -x assembler-with-cpp370371#------------------------------------------------------------------------372# Linker flags373374# statically link libstdc++.so, work with gcc but ignored by g++375STATIC_STDCXX = -Wl,-Bstac -l++ -Wl,-Bdynamic376377ifeq ($(USE_CLANG),)378# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.379ifneq ("${CC_VER_MAJOR}", "2")380STATIC_LIBGCC += -static-libgcc381endif382383ifeq ($(BUILDARCH), ia64)384LFLAGS += -Wl,-relax385endif386endif387388# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.389MAPFLAG = -Xlinker --version-script=FILENAME390391#392# Shared Library393#394ifeq ($(OS_VENDOR), Darwin)395# Standard linker flags396LFLAGS +=397398# The apple linker has its own variant of mapfiles/version-scripts399MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME400401# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj402SONAMEFLAG =403404# Build shared library405SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)406407# Keep symbols even they are not used408#AOUT_FLAGS += -Xlinker -export-dynamic409else410# Enable linker optimization411LFLAGS += -Xlinker -O1412413# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj414SONAMEFLAG = -Xlinker -soname=SONAME415416# Build shared library417SHARED_FLAG = -shared $(VM_PICFLAG)418419# Keep symbols even they are not used420AOUT_FLAGS += -Xlinker -export-dynamic421endif422423#------------------------------------------------------------------------424# Debug flags425426ifeq ($(USE_CLANG), true)427# Restrict the debug information created by Clang to avoid428# too big object files and speed the build up a little bit429# (see http://llvm.org/bugs/show_bug.cgi?id=7554)430CFLAGS += -flimit-debug-info431endif432433# DEBUG_BINARIES uses full -g debug information for all configs434ifeq ($(DEBUG_BINARIES), true)435CFLAGS += -g436else437# Use the stabs format for debugging information (this is the default438# on gcc-2.91). It's good enough, has all the information about line439# numbers and local variables, and libjvm.so is only about 16M.440# Change this back to "-g" if you want the most expressive format.441# (warning: that could easily inflate libjvm.so to 150M!)442# Note: The Itanium gcc compiler crashes when using -gstabs.443DEBUG_CFLAGS/ia64 = -g444DEBUG_CFLAGS/amd64 = -g445DEBUG_CFLAGS/arm = -g446DEBUG_CFLAGS/aarch64 = -g447DEBUG_CFLAGS/ppc = -g448DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))449ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)450DEBUG_CFLAGS += -gstabs451endif452453ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)454FASTDEBUG_CFLAGS/ia64 = -g455FASTDEBUG_CFLAGS/amd64 = -g456FASTDEBUG_CFLAGS/arm = -g457FASTDEBUG_CFLAGS/aarch64 = -g458FASTDEBUG_CFLAGS/ppc = -g459FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))460ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)461ifeq ($(USE_CLANG), true)462# Clang doesn't understand -gstabs463FASTDEBUG_CFLAGS += -g464else465FASTDEBUG_CFLAGS += -gstabs466endif467endif468469OPT_CFLAGS/ia64 = -g470OPT_CFLAGS/amd64 = -g471OPT_CFLAGS/arm = -g472OPT_CFLAGS/aarch64 = -g473OPT_CFLAGS/ppc = -g474OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))475ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)476ifeq ($(USE_CLANG), true)477# Clang doesn't understand -gstabs478OPT_CFLAGS += -g479else480OPT_CFLAGS += -gstabs481endif482endif483endif484endif485486# If we are building HEADLESS, pass on to VM487# so it can set the java.awt.headless property488ifdef HEADLESS489CFLAGS += -DHEADLESS490endif491492# We are building Embedded for a small device493# favor code space over speed494ifdef MINIMIZE_RAM_USAGE495CFLAGS += -DMINIMIZE_RAM_USAGE496endif497498499