aoqi@0: # dbuck@9186: # Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: # aoqi@0: aoqi@1: # aoqi@1: # This file has been modified by Loongson Technology in 2015. These aoqi@1: # modifications are Copyright (c) 2015 Loongson Technology, and are made aoqi@1: # available on the same license terms set forth above. aoqi@1: # aoqi@1: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # CC, CXX & AS aoqi@0: aoqi@0: # If a SPEC is not set already, then use these defaults. aoqi@0: ifeq ($(SPEC),) aoqi@0: # When cross-compiling the ALT_COMPILER_PATH points aoqi@0: # to the cross-compilation toolset aoqi@0: ifdef CROSS_COMPILE_ARCH aoqi@0: CXX = $(ALT_COMPILER_PATH)/g++ aoqi@0: CC = $(ALT_COMPILER_PATH)/gcc aoqi@0: HOSTCXX = g++ aoqi@0: HOSTCC = gcc aoqi@0: STRIP = $(ALT_COMPILER_PATH)/strip aoqi@0: else aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: CXX = clang++ aoqi@0: CC = clang aoqi@0: else aoqi@0: CXX = g++ aoqi@0: CC = gcc aoqi@0: endif aoqi@0: aoqi@0: HOSTCXX = $(CXX) aoqi@0: HOSTCC = $(CC) aoqi@0: STRIP = strip aoqi@0: endif aoqi@0: AS = $(CC) -c aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) aoqi@0: CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) aoqi@0: else aoqi@0: # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only aoqi@0: # prints the numbers (e.g. "2.95", "3.2.1") aoqi@0: CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) aoqi@0: CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: # Clang has precompiled headers support by default, but the user can switch aoqi@0: # it off by using 'USE_PRECOMPILED_HEADER=0'. aoqi@0: ifdef LP64 aoqi@0: ifeq ($(USE_PRECOMPILED_HEADER),) aoqi@0: USE_PRECOMPILED_HEADER=1 aoqi@0: endif aoqi@0: else aoqi@0: # We don't support precompiled headers on 32-bit builds because there some files are aoqi@0: # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) aoqi@0: # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. aoqi@0: USE_PRECOMPILED_HEADER=0 aoqi@0: endif aoqi@0: aoqi@0: ifeq ($(USE_PRECOMPILED_HEADER),1) aoqi@0: aoqi@0: ifndef LP64 aoqi@0: $(error " Precompiled Headers only supported on 64-bit platforms!") aoqi@0: endif aoqi@0: aoqi@0: PRECOMPILED_HEADER_DIR=. aoqi@0: PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp aoqi@0: PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch aoqi@0: aoqi@0: PCH_FLAG = -include precompiled.hpp aoqi@0: PCH_FLAG/DEFAULT = $(PCH_FLAG) aoqi@0: PCH_FLAG/NO_PCH = -DNO_PCH aoqi@0: PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) aoqi@0: aoqi@0: VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) aoqi@0: VM_PCH_FLAG/AOUT = aoqi@0: VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) aoqi@0: aoqi@0: # We only use precompiled headers for the JVM build aoqi@0: CFLAGS += $(VM_PCH_FLAG) aoqi@0: aoqi@0: # There are some files which don't like precompiled headers aoqi@0: # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build. aoqi@0: # But Clang doesn't support a precompiled header which was compiled with -O3 aoqi@0: # to be used in a compilation unit which uses '-O0'. We could also prepare an aoqi@0: # extra '-O0' PCH file for the opt build and use it here, but it's probably aoqi@0: # not worth the effoert as long as only two files need this special handling. aoqi@0: PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) aoqi@0: PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) aoqi@0: PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) aoqi@0: aoqi@0: endif aoqi@0: else # ($(USE_CLANG), true) aoqi@0: # check for precompiled headers support aoqi@0: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" aoqi@0: # Allow the user to turn off precompiled headers from the command line. aoqi@0: ifneq ($(USE_PRECOMPILED_HEADER),0) aoqi@0: PRECOMPILED_HEADER_DIR=. aoqi@0: PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp aoqi@0: PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch aoqi@0: endif aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. aoqi@0: ifeq ($(USE_PRECOMPILED_HEADER),0) aoqi@0: CFLAGS += -DDONT_USE_PRECOMPILED_HEADER aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Compiler flags aoqi@0: aoqi@0: # position-independent code aoqi@0: PICFLAG = -fPIC aoqi@0: aoqi@0: VM_PICFLAG/LIBJVM = $(PICFLAG) aoqi@0: VM_PICFLAG/AOUT = aoqi@0: VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) aoqi@0: aoqi@0: ifeq ($(JVM_VARIANT_ZERO), true) aoqi@0: CFLAGS += $(LIBFFI_CFLAGS) aoqi@0: endif aoqi@0: ifeq ($(JVM_VARIANT_ZEROSHARK), true) aoqi@0: CFLAGS += $(LIBFFI_CFLAGS) aoqi@0: CFLAGS += $(LLVM_CFLAGS) aoqi@0: endif aoqi@0: CFLAGS += $(VM_PICFLAG) aoqi@0: CFLAGS += -fno-rtti aoqi@0: CFLAGS += -fno-exceptions aoqi@0: CFLAGS += -D_REENTRANT aoqi@0: ifeq ($(USE_CLANG),) aoqi@0: CFLAGS += -fcheck-new aoqi@0: # version 4 and above support fvisibility=hidden (matches jni_x86.h file) aoqi@0: # except 4.1.2 gives pointless warnings that can't be disabled (afaik) aoqi@0: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" aoqi@0: CFLAGS += -fvisibility=hidden aoqi@0: endif aoqi@0: else aoqi@0: CFLAGS += -fvisibility=hidden aoqi@0: endif aoqi@0: aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' aoqi@0: # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') aoqi@0: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" aoqi@0: STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 aoqi@0: else aoqi@0: STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) aoqi@0: ARCHFLAG/i486 = -m32 -march=i586 aoqi@0: ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) aoqi@0: ARCHFLAG/ia64 = aoqi@0: ARCHFLAG/sparc = -m32 -mcpu=v9 aoqi@0: ARCHFLAG/sparcv9 = -m64 -mcpu=v9 aoqi@183: ARCHFLAG/mips64 = -mabi=64 aoqi@0: ARCHFLAG/zero = $(ZERO_ARCHFLAG) aoqi@0: ARCHFLAG/ppc64 = -m64 aoqi@0: aoqi@0: CFLAGS += $(ARCHFLAG) aoqi@0: AOUT_FLAGS += $(ARCHFLAG) aoqi@0: LFLAGS += $(ARCHFLAG) aoqi@0: ASFLAGS += $(ARCHFLAG) aoqi@0: sgehwolf@9484: ifeq ($(DEBUG_BINARIES), true) sgehwolf@9484: ASFLAGS += $(ASFLAGS_DEBUG_SYMBOLS) sgehwolf@9484: endif sgehwolf@9484: aoqi@0: # Use C++ Interpreter aoqi@0: ifdef CC_INTERP aoqi@0: CFLAGS += -DCC_INTERP aoqi@0: endif aoqi@0: aoqi@0: # Keep temporary files (.ii, .s) aoqi@0: ifdef NEED_ASM aoqi@0: CFLAGS += -save-temps aoqi@0: else aoqi@0: CFLAGS += -pipe aoqi@0: endif aoqi@0: aoqi@0: # Compiler warnings are treated as errors aoqi@1: #WARNINGS_ARE_ERRORS = -Werror aoqi@0: aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: # However we need to clean the code up before we can unrestrictedly enable this option with Clang aoqi@0: WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses aoqi@0: WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare aoqi@0: WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess aoqi@0: WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body aoqi@0: endif aoqi@0: aoqi@0: WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value aoqi@0: aoqi@0: ifeq ($(USE_CLANG),) aoqi@0: # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit aoqi@0: # conversions which might affect the values. Only enable it in earlier versions. aoqi@0: ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" aoqi@0: WARNING_FLAGS += -Wconversion aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) aoqi@0: # Special cases aoqi@0: CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) aoqi@0: aoqi@0: # The flags to use for an Optimized g++ build aoqi@0: OPT_CFLAGS/SIZE=-Os aoqi@0: OPT_CFLAGS/SPEED=-O3 aoqi@0: aoqi@0: # Hotspot uses very unstrict aliasing turn this optimization off aoqi@0: # This option is added to CFLAGS rather than OPT_CFLAGS aoqi@0: # so that OPT_CFLAGS overrides get this option too. aoqi@0: CFLAGS += -fno-strict-aliasing aoqi@0: aoqi@0: OPT_CFLAGS_DEFAULT ?= SPEED aoqi@0: aoqi@0: ifdef OPT_CFLAGS aoqi@0: ifneq ("$(origin OPT_CFLAGS)", "command line") aoqi@0: $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) aoqi@0: aoqi@0: # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp aoqi@0: # if we use expensive-optimizations aoqi@0: ifeq ($(BUILDARCH), ia64) aoqi@0: OPT_CFLAGS += -fno-expensive-optimizations aoqi@0: endif aoqi@0: aoqi@0: OPT_CFLAGS/NOOPT=-O0 aoqi@0: aoqi@0: # Work around some compiler bugs. aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) aoqi@0: OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) aoqi@0: endif aoqi@0: else aoqi@0: # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. aoqi@0: ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) aoqi@0: OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: # Flags for generating make dependency flags. aoqi@0: DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) aoqi@0: ifeq ($(USE_CLANG),) aoqi@0: ifneq ("${CC_VER_MAJOR}", "2") aoqi@0: DEPFLAGS += -fpch-deps aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Linker flags aoqi@0: aoqi@0: # statically link libstdc++.so, work with gcc but ignored by g++ aoqi@0: STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic kevinw@9516: # While the VM needs the above line, adlc needs a separate setting: kevinw@9516: ADLC_STATIC_STDCXX = -static-libstdc++ aoqi@0: aoqi@0: ifeq ($(USE_CLANG),) aoqi@0: # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. aoqi@0: ifneq ("${CC_VER_MAJOR}", "2") aoqi@0: STATIC_LIBGCC += -static-libgcc aoqi@0: endif aoqi@0: aoqi@0: ifeq ($(BUILDARCH), ia64) aoqi@0: LFLAGS += -Wl,-relax aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: # Enable linker optimization aoqi@0: LFLAGS += -Xlinker -O1 aoqi@0: aoqi@0: ifeq ($(USE_CLANG),) aoqi@0: # If this is a --hash-style=gnu system, use --hash-style=both aoqi@0: # The gnu .hash section won't work on some Linux systems like SuSE 10. aoqi@0: _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') aoqi@0: ifneq ($(_HAS_HASH_STYLE_GNU),) aoqi@0: LDFLAGS_HASH_STYLE = -Wl,--hash-style=both aoqi@0: endif aoqi@0: else aoqi@0: # Don't know how to find out the 'hash style' of a system as '-dumpspecs' aoqi@0: # doesn't work for Clang. So for now we'll alwys use --hash-style=both aoqi@0: LDFLAGS_HASH_STYLE = -Wl,--hash-style=both aoqi@0: endif aoqi@0: aoqi@0: LFLAGS += $(LDFLAGS_HASH_STYLE) aoqi@0: dbuck@9186: LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack" dbuck@9186: aoqi@0: # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. aoqi@0: MAPFLAG = -Xlinker --version-script=FILENAME aoqi@0: aoqi@0: # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj aoqi@0: SONAMEFLAG = -Xlinker -soname=SONAME aoqi@0: aoqi@0: # Build shared library aoqi@0: SHARED_FLAG = -shared aoqi@0: aoqi@0: # Keep symbols even they are not used aoqi@0: AOUT_FLAGS += -Xlinker -export-dynamic aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Debug flags aoqi@0: aoqi@0: ifeq ($(USE_CLANG), true) aoqi@0: # Restrict the debug information created by Clang to avoid aoqi@0: # too big object files and speed the build up a little bit aoqi@0: # (see http://llvm.org/bugs/show_bug.cgi?id=7554) aoqi@0: CFLAGS += -flimit-debug-info aoqi@0: endif aoqi@0: aoqi@0: # DEBUG_BINARIES uses full -g debug information for all configs aoqi@0: ifeq ($(DEBUG_BINARIES), true) aoqi@0: CFLAGS += -g aoqi@0: else aoqi@0: DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) aoqi@0: ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) dbuck@9426: DEBUG_CFLAGS += -g aoqi@0: endif aoqi@0: aoqi@0: ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) dlong@7615: FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH)) aoqi@0: ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) dbuck@9426: FASTDEBUG_CFLAGS/$(BUILDARCH) = -g aoqi@0: endif aoqi@0: aoqi@0: OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) aoqi@0: ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) dbuck@9426: OPT_CFLAGS/$(BUILDARCH) = -g aoqi@0: endif aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: # If we are building HEADLESS, pass on to VM aoqi@0: # so it can set the java.awt.headless property aoqi@0: ifdef HEADLESS aoqi@0: CFLAGS += -DHEADLESS aoqi@0: endif aoqi@0: aoqi@0: # We are building Embedded for a small device aoqi@0: # favor code space over speed aoqi@0: ifdef MINIMIZE_RAM_USAGE aoqi@0: CFLAGS += -DMINIMIZE_RAM_USAGE aoqi@0: endif aoqi@0: aoqi@0: # Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack. aoqi@0: # Explicitly specify -fno-omit-frame-pointer because it is off by default aoqi@0: # starting with gcc 4.6. aoqi@0: ifndef USE_SUNCC aoqi@0: CFLAGS += -fno-omit-frame-pointer aoqi@0: endif dlong@7598: dlong@7598: -include $(HS_ALT_MAKE)/linux/makefiles/gcc.make