Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/make/linux/makefiles/gcc.make
32284 views
#1# Copyright (c) 1999, 2018, 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#2324#------------------------------------------------------------------------25# CC, CXX & AS2627# If a SPEC is not set already, then use these defaults.28ifeq ($(SPEC),)29# When cross-compiling the ALT_COMPILER_PATH points30# to the cross-compilation toolset31ifdef CROSS_COMPILE_ARCH32CXX = $(ALT_COMPILER_PATH)/g++33CC = $(ALT_COMPILER_PATH)/gcc34HOSTCXX = g++35HOSTCC = gcc36STRIP = $(ALT_COMPILER_PATH)/strip37else38ifeq ($(USE_CLANG), true)39CXX = clang++40CC = clang41else42CXX = g++43CC = gcc44endif4546HOSTCXX = $(CXX)47HOSTCC = $(CC)48STRIP = strip49endif50AS = $(CC) -c51endif525354ifeq ($(USE_CLANG), true)55CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1)56CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2)57else58# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only59# prints the numbers (e.g. "2.95", "3.2.1")60CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)61CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)62endif636465ifeq ($(USE_CLANG), true)66# Clang has precompiled headers support by default, but the user can switch67# it off by using 'USE_PRECOMPILED_HEADER=0'.68ifdef LP6469ifeq ($(USE_PRECOMPILED_HEADER),)70USE_PRECOMPILED_HEADER=171endif72else73# We don't support precompiled headers on 32-bit builds because there some files are74# compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make)75# Clang produces an error if the PCH file was compiled with other options than the actual compilation unit.76USE_PRECOMPILED_HEADER=077endif7879ifeq ($(USE_PRECOMPILED_HEADER),1)8081ifndef LP6482$(error " Precompiled Headers only supported on 64-bit platforms!")83endif8485PRECOMPILED_HEADER_DIR=.86PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp87PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch8889PCH_FLAG = -include precompiled.hpp90PCH_FLAG/DEFAULT = $(PCH_FLAG)91PCH_FLAG/NO_PCH = -DNO_PCH92PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@))9394VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE)95VM_PCH_FLAG/AOUT =96VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO))9798# We only use precompiled headers for the JVM build99CFLAGS += $(VM_PCH_FLAG)100101# There are some files which don't like precompiled headers102# The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.103# But Clang doesn't support a precompiled header which was compiled with -O3104# to be used in a compilation unit which uses '-O0'. We could also prepare an105# extra '-O0' PCH file for the opt build and use it here, but it's probably106# not worth the effoert as long as only two files need this special handling.107PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)108PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)109PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)110111endif112else # ($(USE_CLANG), true)113# check for precompiled headers support114ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"115# Allow the user to turn off precompiled headers from the command line.116ifneq ($(USE_PRECOMPILED_HEADER),0)117PRECOMPILED_HEADER_DIR=.118PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp119PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch120endif121endif122endif123124# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.125ifeq ($(USE_PRECOMPILED_HEADER),0)126CFLAGS += -DDONT_USE_PRECOMPILED_HEADER127endif128129130#------------------------------------------------------------------------131# Compiler flags132133# position-independent code134PICFLAG = -fPIC135136VM_PICFLAG/LIBJVM = $(PICFLAG)137VM_PICFLAG/AOUT =138VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))139140ifeq ($(JVM_VARIANT_ZERO), true)141CFLAGS += $(LIBFFI_CFLAGS)142endif143ifeq ($(JVM_VARIANT_ZEROSHARK), true)144CFLAGS += $(LIBFFI_CFLAGS)145CFLAGS += $(LLVM_CFLAGS)146endif147CFLAGS += $(VM_PICFLAG)148CFLAGS += -fno-rtti149CFLAGS += -fno-exceptions150CFLAGS += -D_REENTRANT151ifeq ($(USE_CLANG),)152CFLAGS += -fcheck-new -fstack-protector153# version 4 and above support fvisibility=hidden (matches jni_x86.h file)154# except 4.1.2 gives pointless warnings that can't be disabled (afaik)155ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"156CFLAGS += -fvisibility=hidden157endif158else159CFLAGS += -fvisibility=hidden160endif161162ifeq ($(USE_CLANG), true)163# Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm'164# Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment')165ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0"166STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16167else168STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16169endif170endif171172ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))173ARCHFLAG/i486 = -m32 -march=i586174ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT)175ARCHFLAG/arm =176ARCHFLAG/aarch32 =177ARCHFLAG/aarch64 =178ARCHFLAG/ia64 =179ARCHFLAG/sparc = -m32 -mcpu=v9180ARCHFLAG/sparcv9 = -m64 -mcpu=v9181ARCHFLAG/zero = $(ZERO_ARCHFLAG)182ARCHFLAG/ppc64 = -m64183184CFLAGS += $(ARCHFLAG)185AOUT_FLAGS += $(ARCHFLAG)186LFLAGS += $(ARCHFLAG)187ASFLAGS += $(ARCHFLAG)188189ifeq ($(DEBUG_BINARIES), true)190ASFLAGS += $(ASFLAGS_DEBUG_SYMBOLS)191endif192193# Use C++ Interpreter194ifdef CC_INTERP195CFLAGS += -DCC_INTERP196endif197198# Keep temporary files (.ii, .s)199ifdef NEED_ASM200CFLAGS += -save-temps201else202CFLAGS += -pipe203endif204205# Compiler warnings are treated as errors206# WARNINGS_ARE_ERRORS = -Werror207WARNINGS_ARE_ERRORS = -Werror=implicit-function-declaration208209ifeq ($(USE_CLANG), true)210# However we need to clean the code up before we can unrestrictedly enable this option with Clang211WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses212WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare213WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess214WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body215endif216217WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type218219ifeq ($(USE_CLANG),)220# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit221# conversions which might affect the values. Only enable it in earlier versions.222ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"223WARNING_FLAGS += -Wconversion224endif225endif226227CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)228# Special cases229CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))230231# The flags to use for an Optimized g++ build232OPT_CFLAGS/SIZE=-Os233OPT_CFLAGS/SPEED=-O3234235# Hotspot uses very unstrict aliasing turn this optimization off236# This option is added to CFLAGS rather than OPT_CFLAGS237# so that OPT_CFLAGS overrides get this option too.238CFLAGS += -fno-strict-aliasing239240OPT_CFLAGS_DEFAULT ?= SPEED241242ifdef OPT_CFLAGS243ifneq ("$(origin OPT_CFLAGS)", "command line")244$(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")245endif246endif247248OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)249250# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp251# if we use expensive-optimizations252ifeq ($(BUILDARCH), ia64)253OPT_CFLAGS += -fno-expensive-optimizations254endif255256OPT_CFLAGS/NOOPT=-O0257258# Work around some compiler bugs.259ifeq ($(USE_CLANG), true)260ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)261OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)262endif263else264# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.265ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)266OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)267endif268endif269270# Need extra inlining to collapse all the templated closures into the hot loop271OPT_CFLAGS/shenandoahConcurrentMark.o += $(OPT_CFLAGS) --param inline-unit-growth=1000272273# Flags for generating make dependency flags.274DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)275ifeq ($(USE_CLANG),)276ifneq ("${CC_VER_MAJOR}", "2")277DEPFLAGS += -fpch-deps278endif279endif280281#------------------------------------------------------------------------282# Linker flags283284# statically link libc++.so, work with gcc but ignored by g++285# STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic286287STATIC_STDCXX = -Wl,-Bstatic -lsupc++ -Wl,-Bdynamic288# While the VM needs the above line, adlc needs a separate setting:289ADLC_STATIC_STDCXX = -static-libstdc++290291ifeq ($(USE_CLANG),)292# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.293ifneq ("${CC_VER_MAJOR}", "2")294STATIC_LIBGCC += -static-libgcc295endif296297ifeq ($(BUILDARCH), ia64)298LFLAGS += -Wl,-relax299endif300endif301302# Enable linker optimization303LFLAGS += -Xlinker -O1304305ifeq ($(USE_CLANG),)306# If this is a --hash-style=gnu system, use --hash-style=both307# The gnu .hash section won't work on some Linux systems like SuSE 10.308_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')309ifneq ($(_HAS_HASH_STYLE_GNU),)310LDFLAGS_HASH_STYLE = -Wl,--hash-style=both311endif312else313# Don't know how to find out the 'hash style' of a system as '-dumpspecs'314# doesn't work for Clang. So for now we'll alwys use --hash-style=both315LDFLAGS_HASH_STYLE = -Wl,--hash-style=both316endif317318LFLAGS += $(LDFLAGS_HASH_STYLE)319320LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack"321322# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.323MAPFLAG = -Xlinker --version-script=FILENAME324325# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj326SONAMEFLAG = -Xlinker -soname=SONAME327328# Build shared library329SHARED_FLAG = -shared330331# Keep symbols even they are not used332AOUT_FLAGS += -Xlinker -export-dynamic333334#------------------------------------------------------------------------335# Debug flags336337ifeq ($(USE_CLANG), true)338# Restrict the debug information created by Clang to avoid339# too big object files and speed the build up a little bit340# (see http://llvm.org/bugs/show_bug.cgi?id=7554)341CFLAGS += -flimit-debug-info342endif343344# DEBUG_BINARIES uses full -g debug information for all configs345ifeq ($(DEBUG_BINARIES), true)346CFLAGS += -g347else348DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))349ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)350DEBUG_CFLAGS += -g351endif352353ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)354FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))355ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)356FASTDEBUG_CFLAGS/$(BUILDARCH) = -g357endif358359OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))360ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)361OPT_CFLAGS/$(BUILDARCH) = -g362endif363endif364endif365366# If we are building HEADLESS, pass on to VM367# so it can set the java.awt.headless property368ifdef HEADLESS369CFLAGS += -DHEADLESS370endif371372# We are building Embedded for a small device373# favor code space over speed374ifdef MINIMIZE_RAM_USAGE375CFLAGS += -DMINIMIZE_RAM_USAGE376endif377378# Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.379# Explicitly specify -fno-omit-frame-pointer because it is off by default380# starting with gcc 4.6.381ifndef USE_SUNCC382CFLAGS += -fno-omit-frame-pointer383endif384385-include $(HS_ALT_MAKE)/linux/makefiles/gcc.make386387388