Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/make/bsd/makefiles/gcc.make
83397 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-new193# 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/ia64 =216ARCHFLAG/sparc = -m32 -mcpu=v9217ARCHFLAG/sparcv9 = -m64 -mcpu=v9218ARCHFLAG/zero = $(ZERO_ARCHFLAG)219220# Darwin-specific build flags221ifeq ($(OS_VENDOR), Darwin)222# Ineffecient 16-byte stack re-alignment on Darwin/IA32223ARCHFLAG/i486 += -mstackrealign224endif225226CFLAGS += $(ARCHFLAG)227AOUT_FLAGS += $(ARCHFLAG)228LFLAGS += $(ARCHFLAG)229ASFLAGS += $(ARCHFLAG)230231ifdef E500V2232CFLAGS += -DE500V2233endif234235# Use C++ Interpreter236ifdef CC_INTERP237CFLAGS += -DCC_INTERP238endif239240# Keep temporary files (.ii, .s)241ifdef NEED_ASM242CFLAGS += -save-temps243else244CFLAGS += -pipe245endif246247# Compiler warnings are treated as errors248ifneq ($(COMPILER_WARNINGS_FATAL),false)249WARNINGS_ARE_ERRORS = -Werror250endif251252ifeq ($(USE_CLANG), true)253# However we need to clean the code up before we can unrestrictedly enable this option with Clang254WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses255WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare256# Not yet supported by clang in Xcode 4.6.2257# WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare258WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess259WARNINGS_ARE_ERRORS += -Wno-empty-body260endif261262WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2263264ifeq ($(USE_CLANG),)265# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit266# conversions which might affect the values. Only enable it in earlier versions.267ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"268WARNINGS_FLAGS += -Wconversion269endif270endif271272CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)273# Special cases274CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))275# XXXDARWIN: for _dyld_bind_fully_image_containing_address276ifeq ($(OS_VENDOR), Darwin)277CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations278endif279280OPT_CFLAGS/SIZE=-Os281OPT_CFLAGS/SPEED=-O3282283# Hotspot uses very unstrict aliasing turn this optimization off284# This option is added to CFLAGS rather than OPT_CFLAGS285# so that OPT_CFLAGS overrides get this option too.286CFLAGS += -fno-strict-aliasing287288# The flags to use for an Optimized g++ build289ifeq ($(OS_VENDOR), Darwin)290# use -Os by default, unless -O3 can be proved to be worth the cost, as per policy291# <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>292OPT_CFLAGS_DEFAULT ?= SIZE293else294OPT_CFLAGS_DEFAULT ?= SPEED295endif296297ifdef OPT_CFLAGS298ifneq ("$(origin OPT_CFLAGS)", "command line")299$(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")300endif301endif302303OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)304305# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp306# if we use expensive-optimizations307ifeq ($(BUILDARCH), ia64)308OPT_CFLAGS += -fno-expensive-optimizations309endif310311OPT_CFLAGS/NOOPT=-O0312313# Work around some compiler bugs.314ifeq ($(USE_CLANG), true)315ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)316OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)317OPT_CFLAGS/unsafe.o += -O1318endif319else320# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.321ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)322OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)323endif324endif325326# Flags for generating make dependency flags.327DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)328ifeq ($(USE_CLANG),)329ifneq ($(CC_VER_MAJOR), 2)330DEPFLAGS += -fpch-deps331endif332endif333334# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.335ifeq ($(USE_PRECOMPILED_HEADER),0)336CFLAGS += -DDONT_USE_PRECOMPILED_HEADER337endif338339ifeq ($(OS_VENDOR), Darwin)340# Setting these parameters makes it an error to link to macosx APIs that are341# newer than the given OS version and makes the linked binaries compatible even342# if built on a newer version of the OS.343# The expected format is X.Y.Z344ifeq ($(MACOSX_VERSION_MIN),)345MACOSX_VERSION_MIN=10.7.0346endif347# The macro takes the version with no dots, ex: 1070348CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \349-mmacosx-version-min=$(MACOSX_VERSION_MIN)350LFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)351endif352353354#------------------------------------------------------------------------355# Assembler flags356357# Enforce prerpocessing of .s files358ASFLAGS += -x assembler-with-cpp359360#------------------------------------------------------------------------361# Linker flags362363# statically link libstdc++.so, work with gcc but ignored by g++364STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic365366ifeq ($(USE_CLANG),)367# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.368ifneq ("${CC_VER_MAJOR}", "2")369STATIC_LIBGCC += -static-libgcc370endif371372ifeq ($(BUILDARCH), ia64)373LFLAGS += -Wl,-relax374endif375endif376377# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.378MAPFLAG = -Xlinker --version-script=FILENAME379380#381# Shared Library382#383ifeq ($(OS_VENDOR), Darwin)384# Standard linker flags385LFLAGS +=386387# The apple linker has its own variant of mapfiles/version-scripts388MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME389390# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj391SONAMEFLAG =392393# Build shared library394SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)395396# Keep symbols even they are not used397#AOUT_FLAGS += -Xlinker -export-dynamic398else399# Enable linker optimization400LFLAGS += -Xlinker -O1401402# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj403SONAMEFLAG = -Xlinker -soname=SONAME404405# Build shared library406SHARED_FLAG = -shared $(VM_PICFLAG)407408# Keep symbols even they are not used409AOUT_FLAGS += -Xlinker -export-dynamic410endif411412#------------------------------------------------------------------------413# Debug flags414415ifeq ($(USE_CLANG), true)416# Restrict the debug information created by Clang to avoid417# too big object files and speed the build up a little bit418# (see http://llvm.org/bugs/show_bug.cgi?id=7554)419CFLAGS += -flimit-debug-info420endif421422# DEBUG_BINARIES uses full -g debug information for all configs423ifeq ($(DEBUG_BINARIES), true)424CFLAGS += -g425else426# Use the stabs format for debugging information (this is the default427# on gcc-2.91). It's good enough, has all the information about line428# numbers and local variables, and libjvm.so is only about 16M.429# Change this back to "-g" if you want the most expressive format.430# (warning: that could easily inflate libjvm.so to 150M!)431# Note: The Itanium gcc compiler crashes when using -gstabs.432DEBUG_CFLAGS/ia64 = -g433DEBUG_CFLAGS/amd64 = -g434DEBUG_CFLAGS/arm = -g435DEBUG_CFLAGS/ppc = -g436DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))437ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)438DEBUG_CFLAGS += -gstabs439endif440441ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)442FASTDEBUG_CFLAGS/ia64 = -g443FASTDEBUG_CFLAGS/amd64 = -g444FASTDEBUG_CFLAGS/arm = -g445FASTDEBUG_CFLAGS/ppc = -g446FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH))447ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)448ifeq ($(USE_CLANG), true)449# Clang doesn't understand -gstabs450FASTDEBUG_CFLAGS += -g451else452FASTDEBUG_CFLAGS += -gstabs453endif454endif455456OPT_CFLAGS/ia64 = -g457OPT_CFLAGS/amd64 = -g458OPT_CFLAGS/arm = -g459OPT_CFLAGS/ppc = -g460OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))461ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)462ifeq ($(USE_CLANG), true)463# Clang doesn't understand -gstabs464OPT_CFLAGS += -g465else466OPT_CFLAGS += -gstabs467endif468endif469endif470endif471472# If we are building HEADLESS, pass on to VM473# so it can set the java.awt.headless property474ifdef HEADLESS475CFLAGS += -DHEADLESS476endif477478# We are building Embedded for a small device479# favor code space over speed480ifdef MINIMIZE_RAM_USAGE481CFLAGS += -DMINIMIZE_RAM_USAGE482endif483484485