annotate make/bsd/makefiles/vm.make @ 4895:2cb5d5f6d5e5

8015252: Enable HotSpot build with Clang Reviewed-by: twisti, dholmes, kvn
author simonis
date Tue, 04 Jun 2013 22:16:15 -0700
parents e484fe2abebd
children 7b772f9e0365
rev   line source
never@2731 1 #
mgerdin@3196 2 # Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
never@2731 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
never@2731 4 #
never@2731 5 # This code is free software; you can redistribute it and/or modify it
never@2731 6 # under the terms of the GNU General Public License version 2 only, as
never@2731 7 # published by the Free Software Foundation.
never@2731 8 #
never@2731 9 # This code is distributed in the hope that it will be useful, but WITHOUT
never@2731 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
never@2731 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
never@2731 12 # version 2 for more details (a copy is included in the LICENSE file that
never@2731 13 # accompanied this code).
never@2731 14 #
never@2731 15 # You should have received a copy of the GNU General Public License version
never@2731 16 # 2 along with this work; if not, write to the Free Software Foundation,
never@2731 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
never@2731 18 #
never@2731 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
never@2731 20 # or visit www.oracle.com if you need additional information or have any
never@2731 21 # questions.
never@2731 22 #
never@2731 23 #
never@2731 24
never@2731 25 # Rules to build JVM and related libraries, included from vm.make in the build
never@2731 26 # directory.
never@2731 27
never@2731 28 # Common build rules.
never@2731 29 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
never@2731 30 include $(MAKEFILES_DIR)/rules.make
never@2731 31 include $(GAMMADIR)/make/altsrc.make
never@2731 32
never@2731 33 default: build
never@2731 34
never@2731 35 #----------------------------------------------------------------------
never@2731 36 # Defs
never@2731 37
never@2731 38 GENERATED = ../generated
never@2731 39 DEP_DIR = $(GENERATED)/dependencies
never@2731 40
never@2731 41 # reads the generated files defining the set of .o's and the .o .h dependencies
never@2731 42 -include $(DEP_DIR)/*.d
never@2731 43
never@2731 44 # read machine-specific adjustments (%%% should do this via buildtree.make?)
erikj@3235 45 ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
never@2731 46 include $(MAKEFILES_DIR)/zeroshark.make
never@2731 47 else
never@2731 48 include $(MAKEFILES_DIR)/$(BUILDARCH).make
never@2731 49 endif
never@2731 50
never@2731 51 # set VPATH so make knows where to look for source files
never@2731 52 # Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
never@2731 53 # The adfiles directory contains ad_<arch>.[ch]pp.
never@2731 54 # The jvmtifiles directory contains jvmti*.[ch]pp
never@2731 55 Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles
never@2731 56 VPATH += $(Src_Dirs_V:%=%:)
never@2731 57
never@2731 58 # set INCLUDES for C preprocessor.
never@2731 59 Src_Dirs_I += $(GENERATED)
never@2731 60 # The order is important for the precompiled headers to work.
never@2731 61 INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
never@2731 62
never@2731 63 ifeq (${VERSION}, debug)
never@2731 64 SYMFLAG = -g
never@2731 65 else
never@2731 66 SYMFLAG =
never@2731 67 endif
never@2731 68
never@2731 69 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
never@2731 70 # in $(GAMMADIR)/make/defs.make
never@2731 71 ifeq ($(HOTSPOT_BUILD_VERSION),)
never@2731 72 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
never@2731 73 else
never@2731 74 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
never@2731 75 endif
never@2731 76
never@2731 77 # The following variables are defined in the generated flags.make file.
never@2731 78 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
never@2731 79 JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
never@2731 80 HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
never@2731 81 BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
never@2731 82 BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
never@2731 83 VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
never@2731 84
erikj@3096 85 CXXFLAGS = \
never@2731 86 ${SYSDEFS} \
never@2731 87 ${INCLUDES} \
never@2731 88 ${BUILD_VERSION} \
never@2731 89 ${BUILD_TARGET} \
never@2731 90 ${BUILD_USER} \
never@2731 91 ${HS_LIB_ARCH} \
never@2731 92 ${VM_DISTRO}
never@2731 93
ohrstrom@3095 94 # This is VERY important! The version define must only be supplied to vm_version.o
ohrstrom@3095 95 # If not, ccache will not re-use the cache at all, since the version string might contain
ohrstrom@3095 96 # a time and date.
mikael@4247 97 CXXFLAGS/vm_version.o += ${JRE_VERSION}
mikael@4247 98
mikael@4247 99 CXXFLAGS/BYFILE = $(CXXFLAGS/$@)
mikael@4247 100
mikael@4247 101 # File specific flags
mikael@4247 102 CXXFLAGS += $(CXXFLAGS/BYFILE)
ohrstrom@3095 103
never@2731 104 ifdef DEFAULT_LIBPATH
erikj@3096 105 CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
never@2731 106 endif
never@2731 107
phh@3005 108 ifndef JAVASE_EMBEDDED
phh@3005 109 CFLAGS += -DINCLUDE_TRACE
phh@3005 110 endif
phh@3005 111
never@2731 112 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
never@2731 113 CFLAGS += $(CFLAGS_WARN/BYFILE)
never@2731 114
never@2731 115 # Do not use C++ exception handling
never@2731 116 CFLAGS += $(CFLAGS/NOEX)
never@2731 117
never@2731 118 # Extra flags from gnumake's invocation or environment
never@2731 119 CFLAGS += $(EXTRA_CFLAGS)
never@2731 120 LFLAGS += $(EXTRA_CFLAGS)
never@2731 121
never@2731 122 # Don't set excutable bit on stack segment
never@2731 123 # the same could be done by separate execstack command
dcubed@2777 124 # Darwin is non-executable-stack by default
never@2731 125 ifneq ($(OS_VENDOR), Darwin)
never@2731 126 LFLAGS += -Xlinker -z -Xlinker noexecstack
never@2731 127 endif
never@2731 128
simonis@4895 129 LIBS += -lm
simonis@4895 130
simonis@4895 131 ifeq ($(USE_CLANG),)
simonis@4895 132 LIBS += -pthread
simonis@4895 133 endif
never@2731 134
never@2731 135 # By default, link the *.o into the library, not the executable.
never@2731 136 LINK_INTO$(LINK_INTO) = LIBJVM
never@2731 137
never@2731 138 JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
never@2731 139
never@2731 140 #----------------------------------------------------------------------
never@2731 141 # jvm_db & dtrace
never@2731 142 include $(MAKEFILES_DIR)/dtrace.make
never@2731 143
never@2731 144 #----------------------------------------------------------------------
never@2731 145 # JVM
never@2731 146
never@2731 147 JVM = jvm
never@2731 148 ifeq ($(OS_VENDOR), Darwin)
never@2731 149 LIBJVM = lib$(JVM).dylib
never@2731 150 CFLAGS += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
minqi@4765 151 ifeq (${VERSION}, $(filter ${VERSION}, debug fastdebug))
minqi@4765 152 CFLAGS += -DALLOW_OPERATOR_NEW_USAGE
minqi@4765 153 endif
never@2731 154 else
never@2731 155 LIBJVM = lib$(JVM).so
never@2731 156 endif
never@2731 157
never@2731 158 SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
never@2731 159
never@2731 160 SOURCE_PATHS=\
never@2731 161 $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
never@2731 162 \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
never@2731 163 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
never@2731 164 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
never@2731 165 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
never@2731 166 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
never@2731 167
phh@3005 168 ifndef JAVASE_EMBEDDED
phh@3005 169 SOURCE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \
phh@3005 170 find $(HS_ALT_SRC)/share/vm/jfr -type d; \
phh@3005 171 fi)
phh@3005 172 endif
phh@3005 173
never@2731 174 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
never@2731 175 CORE_PATHS+=$(GENERATED)/jvmtifiles
never@2731 176
never@2731 177 COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
never@2731 178 COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
never@2731 179
never@2731 180 COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
never@2731 181 COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
never@2731 182 COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
never@2731 183 COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
never@2731 184 COMPILER2_PATHS += $(GENERATED)/adfiles
never@2731 185
never@2731 186 SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
never@2731 187
never@2731 188 # Include dirs per type.
never@2731 189 Src_Dirs/CORE := $(CORE_PATHS)
never@2731 190 Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
never@2731 191 Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
never@2731 192 Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
never@2731 193 Src_Dirs/ZERO := $(CORE_PATHS)
never@2731 194 Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS)
never@2731 195 Src_Dirs := $(Src_Dirs/$(TYPE))
never@2731 196
neliasso@4607 197 COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\*
never@2731 198 COMPILER1_SPECIFIC_FILES := c1_\*
never@2731 199 SHARK_SPECIFIC_FILES := shark
never@2731 200 ZERO_SPECIFIC_FILES := zero
never@2731 201
never@2731 202 # Always exclude these.
jprovino@3796 203 Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
never@2731 204
never@2731 205 # Exclude per type.
never@2731 206 Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
never@2731 207 Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
never@2731 208 Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
never@2731 209 Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
never@2731 210 Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
never@2731 211 Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
never@2731 212
never@2731 213 Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE))
never@2731 214
never@2731 215 # Special handling of arch model.
never@2731 216 ifeq ($(Platform_arch_model), x86_32)
never@2731 217 Src_Files_EXCLUDE += \*x86_64\*
never@2731 218 endif
never@2731 219 ifeq ($(Platform_arch_model), x86_64)
never@2731 220 Src_Files_EXCLUDE += \*x86_32\*
never@2731 221 endif
never@2731 222
never@2731 223 # Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
never@2731 224 define findsrc
never@2731 225 $(notdir $(shell find $(1)/. ! -name . -prune \
never@2731 226 -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
never@2731 227 -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
never@2731 228 endef
never@2731 229
never@2731 230 Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
never@2731 231
never@2731 232 Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
never@2731 233
never@2731 234 JVM_OBJ_FILES = $(Obj_Files)
never@2731 235
never@2731 236 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
never@2731 237
never@2731 238 mapfile : $(MAPFILE) vm.def
never@2731 239 rm -f $@
never@2731 240 awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \
never@2731 241 { system ("cat vm.def"); } \
never@2731 242 else \
never@2731 243 { print $$0 } \
never@2731 244 }' > $@ < $(MAPFILE)
never@2731 245
never@2731 246 mapfile_reorder : mapfile $(REORDERFILE)
never@2731 247 rm -f $@
never@2731 248 cat $^ > $@
never@2731 249
never@2731 250 vm.def: $(Res_Files) $(Obj_Files)
never@2731 251 sh $(GAMMADIR)/make/bsd/makefiles/build_vm_def.sh *.o > $@
never@2731 252
never@2731 253 STATIC_CXX = false
never@2731 254
never@2731 255 ifeq ($(LINK_INTO),AOUT)
never@2731 256 LIBJVM.o =
never@2731 257 LIBJVM_MAPFILE =
never@2731 258 LIBS_VM = $(LIBS)
never@2731 259 else
never@2731 260 LIBJVM.o = $(JVM_OBJ_FILES)
never@2731 261 LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
never@2731 262 LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
never@2731 263 LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM))
never@2731 264
never@2731 265 ifeq ($(OS_VENDOR), Darwin)
never@2731 266 LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/.
never@2731 267 LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/..
never@2731 268 LFLAGS_VM += -Xlinker -install_name -Xlinker @rpath/$(@F)
never@2731 269 endif
never@2731 270
never@2731 271 # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
never@2731 272 # get around library dependency and compatibility issues. Must use gcc not
never@2731 273 # g++ to link.
never@2731 274 ifeq ($(STATIC_CXX), true)
never@2731 275 LFLAGS_VM += $(STATIC_LIBGCC)
never@2731 276 LIBS_VM += $(STATIC_STDCXX)
erikj@3096 277 LINK_VM = $(LINK_LIB.CC)
never@2731 278 else
erikj@3096 279 LINK_VM = $(LINK_LIB.CXX)
never@2731 280 endif
never@2731 281
never@2731 282 LIBS_VM += $(LIBS)
never@2731 283 endif
erikj@3235 284 ifeq ($(JVM_VARIANT_ZERO), true)
never@2731 285 LIBS_VM += $(LIBFFI_LIBS)
never@2731 286 endif
erikj@3235 287 ifeq ($(JVM_VARIANT_ZEROSHARK), true)
erikj@3235 288 LIBS_VM += $(LIBFFI_LIBS) $(LLVM_LIBS)
never@2731 289 LFLAGS_VM += $(LLVM_LDFLAGS)
never@2731 290 endif
never@2731 291
never@2731 292
never@2731 293 # rule for building precompiled header
never@2731 294 $(PRECOMPILED_HEADER):
never@2731 295 $(QUIETLY) echo Generating precompiled header $@
never@2731 296 $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
erikj@3096 297 $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
never@2731 298
never@2731 299 # making the library:
never@2731 300
never@2731 301 ifneq ($(JVM_BASE_ADDR),)
never@2731 302 # By default shared library is linked at base address == 0. Modify the
never@2731 303 # linker script if JVM prefers a different base location. It can also be
never@2731 304 # implemented with 'prelink -r'. But 'prelink' is not (yet) available on
never@2731 305 # our build platform (AS-2.1).
never@2731 306 LD_SCRIPT = libjvm.so.lds
never@2731 307 $(LD_SCRIPT): $(LIBJVM_MAPFILE)
never@2731 308 $(QUIETLY) { \
never@2731 309 rm -rf $@; \
never@2731 310 $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \
never@2731 311 sed -e '/^======/,/^======/!d' \
never@2731 312 -e '/^======/d' \
never@2731 313 -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \
never@2731 314 > $@; \
never@2731 315 }
never@2731 316 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
never@2731 317 endif
never@2731 318
never@2731 319 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
never@2731 320 $(QUIETLY) { \
never@2731 321 echo Linking vm...; \
erikj@3096 322 $(LINK_LIB.CXX/PRE_HOOK) \
never@2731 323 $(LINK_VM) $(LD_SCRIPT_FLAG) \
ohair@3691 324 $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \
erikj@3096 325 $(LINK_LIB.CXX/POST_HOOK) \
never@2731 326 rm -f $@.1; ln -s $@ $@.1; \
never@2731 327 }
never@2731 328
never@2731 329 DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
never@2731 330
never@2731 331 install_jvm: $(LIBJVM)
never@2731 332 @echo "Copying $(LIBJVM) to $(DEST_JVM)"
never@2731 333 $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
never@2731 334
never@2731 335 #----------------------------------------------------------------------
never@2731 336 # Other files
never@2731 337
never@2731 338 # Signal interposition library
never@2731 339 include $(MAKEFILES_DIR)/jsig.make
never@2731 340
never@2731 341 # Serviceability agent
never@2731 342 include $(MAKEFILES_DIR)/saproc.make
never@2731 343
never@2731 344 #----------------------------------------------------------------------
never@2731 345
dcubed@2777 346 ifeq ($(OS_VENDOR), Darwin)
dcubed@2777 347 $(LIBJVM).dSYM: $(LIBJVM)
dcubed@2777 348 dsymutil $(LIBJVM)
dcubed@2777 349
phh@3051 350 # no libjvm_db for macosx
mgerdin@4282 351 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(BUILDLIBSAPROC) dtraceCheck $(LIBJVM).dSYM
dcubed@2777 352 echo "Doing vm.make build:"
dcubed@2777 353 else
mgerdin@4282 354 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC)
dcubed@2777 355 endif
never@2731 356
never@2731 357 install: install_jvm install_jsig install_saproc
never@2731 358
never@2731 359 .PHONY: default build install install_jvm