Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/make/linux/makefiles/gcc.make
83397 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-new153# 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/aarch64 =176ARCHFLAG/ia64 =177ARCHFLAG/sparc = -m32 -mcpu=v9178ARCHFLAG/sparcv9 = -m64 -mcpu=v9179ARCHFLAG/zero = $(ZERO_ARCHFLAG)180ARCHFLAG/ppc64 = -m64181ARCHFLAG/aarch32 =182183CFLAGS += $(ARCHFLAG)184AOUT_FLAGS += $(ARCHFLAG)185LFLAGS += $(ARCHFLAG)186ASFLAGS += $(ARCHFLAG)187188ifeq ($(DEBUG_BINARIES), true)189ASFLAGS += $(ASFLAGS_DEBUG_SYMBOLS)190endif191192# Use C++ Interpreter193ifdef CC_INTERP194CFLAGS += -DCC_INTERP195endif196197# Keep temporary files (.ii, .s)198ifdef NEED_ASM199CFLAGS += -save-temps200else201CFLAGS += -pipe202endif203204# Compiler warnings are treated as errors205# WARNINGS_ARE_ERRORS = -Werror206WARNINGS_ARE_ERRORS = -Werror=implicit-function-declaration207208ifeq ($(USE_CLANG), true)209# However we need to clean the code up before we can unrestrictedly enable this option with Clang210WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses211WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare212WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess213WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body214endif215216WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type217218ifeq ($(USE_CLANG),)219# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit220# conversions which might affect the values. Only enable it in earlier versions.221ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"222WARNING_FLAGS += -Wconversion223endif224endif225226CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)227# Special cases228CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))229230# The flags to use for an Optimized g++ build231OPT_CFLAGS/SIZE=-Os232OPT_CFLAGS/SPEED=-O3233234# Hotspot uses very unstrict aliasing turn this optimization off235# This option is added to CFLAGS rather than OPT_CFLAGS236# so that OPT_CFLAGS overrides get this option too.237CFLAGS += -fno-strict-aliasing238239OPT_CFLAGS_DEFAULT ?= SPEED240241ifdef OPT_CFLAGS242ifneq ("$(origin OPT_CFLAGS)", "command line")243$(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")244endif245endif246247OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)248249# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp250# if we use expensive-optimizations251ifeq ($(BUILDARCH), ia64)252OPT_CFLAGS += -fno-expensive-optimizations253endif254255OPT_CFLAGS/NOOPT=-O0256257# Work around some compiler bugs.258ifeq ($(USE_CLANG), true)259ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)260OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)261endif262else263# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.264ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)265OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)266endif267endif268269# Flags for generating make dependency flags.270DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)271ifeq ($(USE_CLANG),)272ifneq ("${CC_VER_MAJOR}", "2")273DEPFLAGS += -fpch-deps274endif275endif276277#------------------------------------------------------------------------278# Linker flags279280# statically link libc++.so, work with gcc but ignored by g++281# STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic282283STATIC_STDCXX = -Wl,-Bstatic -lsupc++ -Wl,-Bdynamic284# While the VM needs the above line, adlc needs a separate setting:285ADLC_STATIC_STDCXX = -static-libstdc++286287ifeq ($(USE_CLANG),)288# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.289ifneq ("${CC_VER_MAJOR}", "2")290STATIC_LIBGCC += -static-libgcc291endif292293ifeq ($(BUILDARCH), ia64)294LFLAGS += -Wl,-relax295endif296endif297298# Enable linker optimization299LFLAGS += -Xlinker -O1300301ifeq ($(USE_CLANG),)302# If this is a --hash-style=gnu system, use --hash-style=both303# The gnu .hash section won't work on some Linux systems like SuSE 10.304_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')305ifneq ($(_HAS_HASH_STYLE_GNU),)306LDFLAGS_HASH_STYLE = -Wl,--hash-style=both307endif308else309# Don't know how to find out the 'hash style' of a system as '-dumpspecs'310# doesn't work for Clang. So for now we'll alwys use --hash-style=both311LDFLAGS_HASH_STYLE = -Wl,--hash-style=both312endif313314LFLAGS += $(LDFLAGS_HASH_STYLE)315316LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack"317318# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.319MAPFLAG = -Xlinker --version-script=FILENAME320321# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj322SONAMEFLAG = -Xlinker -soname=SONAME323324# Build shared library325SHARED_FLAG = -shared326327# Keep symbols even they are not used328AOUT_FLAGS += -Xlinker -export-dynamic329330#------------------------------------------------------------------------331# Debug flags332333ifeq ($(USE_CLANG), true)334# Restrict the debug information created by Clang to avoid335# too big object files and speed the build up a little bit336# (see http://llvm.org/bugs/show_bug.cgi?id=7554)337CFLAGS += -flimit-debug-info338endif339340# DEBUG_BINARIES uses full -g debug information for all configs341ifeq ($(DEBUG_BINARIES), true)342CFLAGS += -g343else344DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))345ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)346DEBUG_CFLAGS += -g347endif348349ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)350FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))351ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)352FASTDEBUG_CFLAGS/$(BUILDARCH) = -g353endif354355OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))356ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)357OPT_CFLAGS/$(BUILDARCH) = -g358endif359endif360endif361362# If we are building HEADLESS, pass on to VM363# so it can set the java.awt.headless property364ifdef HEADLESS365CFLAGS += -DHEADLESS366endif367368# We are building Embedded for a small device369# favor code space over speed370ifdef MINIMIZE_RAM_USAGE371CFLAGS += -DMINIMIZE_RAM_USAGE372endif373374# Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.375# Explicitly specify -fno-omit-frame-pointer because it is off by default376# starting with gcc 4.6.377ifndef USE_SUNCC378CFLAGS += -fno-omit-frame-pointer379endif380381-include $(HS_ALT_MAKE)/linux/makefiles/gcc.make382383384