236 # Use C++ Interpreter
237 ifdef CC_INTERP
238 CFLAGS += -DCC_INTERP
239 endif
240
241 # Keep temporary files (.ii, .s)
242 ifdef NEED_ASM
243 CFLAGS += -save-temps
244 else
245 CFLAGS += -pipe
246 endif
247
248 # Compiler warnings are treated as errors
249 ifneq ($(COMPILER_WARNINGS_FATAL),false)
250 WARNINGS_ARE_ERRORS = -Werror
251 endif
252
253 ifeq ($(USE_CLANG), true)
254 # However we need to clean the code up before we can unrestrictedly enable this option with Clang
255 WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
256 WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare
257 # Not yet supported by clang in Xcode 4.6.2
258 # WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
259 WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
260 WARNINGS_ARE_ERRORS += -Wno-empty-body
261 endif
262
263 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2
264
265 ifeq ($(USE_CLANG),)
266 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
267 # conversions which might affect the values. Only enable it in earlier versions.
268 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
269 WARNINGS_FLAGS += -Wconversion
270 endif
271 endif
272
273 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
274 # Special cases
275 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
276 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
277 ifeq ($(OS_VENDOR), Darwin)
278 CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
279 endif
280
281 OPT_CFLAGS/SIZE=-Os
282 OPT_CFLAGS/SPEED=-O3
283
284 # Hotspot uses very unstrict aliasing turn this optimization off
296 endif
297
298 ifdef OPT_CFLAGS
299 ifneq ("$(origin OPT_CFLAGS)", "command line")
300 $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
301 endif
302 endif
303
304 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
305
306 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
307 # if we use expensive-optimizations
308 ifeq ($(BUILDARCH), ia64)
309 OPT_CFLAGS += -fno-expensive-optimizations
310 endif
311
312 OPT_CFLAGS/NOOPT=-O0
313
314 # Work around some compiler bugs.
315 ifeq ($(USE_CLANG), true)
316 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
317 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
318 OPT_CFLAGS/unsafe.o += -O1
319 endif
320 else
321 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
322 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
323 OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
324 endif
325 endif
326
327 # Flags for generating make dependency flags.
328 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
329 ifeq ($(USE_CLANG),)
330 ifneq ($(CC_VER_MAJOR), 2)
331 DEPFLAGS += -fpch-deps
332 endif
333 endif
334
335 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
336 ifeq ($(USE_PRECOMPILED_HEADER),0)
337 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
338 endif
339
340 ifeq ($(OS_VENDOR), Darwin)
341 # Setting these parameters makes it an error to link to macosx APIs that are
342 # newer than the given OS version and makes the linked binaries compatible even
343 # if built on a newer version of the OS.
344 # The expected format is X.Y.Z
345 ifeq ($(MACOSX_VERSION_MIN),)
346 MACOSX_VERSION_MIN=10.7.0
347 endif
348 # The macro takes the version with no dots, ex: 1070
349 CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
350 -mmacosx-version-min=$(MACOSX_VERSION_MIN)
351 LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
352 endif
353
354
355 #------------------------------------------------------------------------
356 # Assembler flags
357
358 # Enforce prerpocessing of .s files
359 ASFLAGS += -x assembler-with-cpp
360
361 #------------------------------------------------------------------------
362 # Linker flags
363
364 # statically link libstdc++.so, work with gcc but ignored by g++
365 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
366
367 # Ensure use libstdc++ on clang, not libc++
368 ifeq ($(USE_CLANG), true)
369 LFLAGS += -stdlib=libstdc++
370 endif
371
372 ifeq ($(USE_CLANG),)
373 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
374 ifneq ("${CC_VER_MAJOR}", "2")
375 STATIC_LIBGCC += -static-libgcc
376 endif
377
378 ifeq ($(BUILDARCH), ia64)
379 LFLAGS += -Wl,-relax
380 endif
381 endif
382
383 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
384 MAPFLAG = -Xlinker --version-script=FILENAME
385
386 #
387 # Shared Library
388 #
389 ifeq ($(OS_VENDOR), Darwin)
390 # Standard linker flags
391 LFLAGS +=
|
236 # Use C++ Interpreter
237 ifdef CC_INTERP
238 CFLAGS += -DCC_INTERP
239 endif
240
241 # Keep temporary files (.ii, .s)
242 ifdef NEED_ASM
243 CFLAGS += -save-temps
244 else
245 CFLAGS += -pipe
246 endif
247
248 # Compiler warnings are treated as errors
249 ifneq ($(COMPILER_WARNINGS_FATAL),false)
250 WARNINGS_ARE_ERRORS = -Werror
251 endif
252
253 ifeq ($(USE_CLANG), true)
254 # However we need to clean the code up before we can unrestrictedly enable this option with Clang
255 WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses
256 WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare -Wno-string-plus-int
257 # Not yet supported by clang in Xcode 4.6.2
258 # WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare
259 WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess
260 WARNINGS_ARE_ERRORS += -Wno-empty-body
261 endif
262
263 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2
264
265 ifeq ($(USE_CLANG), true)
266 WARNING_FLAGS += -Wno-format-nonliteral
267 endif
268
269 ifeq ($(USE_CLANG),)
270 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
271 # conversions which might affect the values. Only enable it in earlier versions.
272 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
273 WARNINGS_FLAGS += -Wconversion
274 endif
275 endif
276
277 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
278 # Special cases
279 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
280 # XXXDARWIN: for _dyld_bind_fully_image_containing_address
281 ifeq ($(OS_VENDOR), Darwin)
282 CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
283 endif
284
285 OPT_CFLAGS/SIZE=-Os
286 OPT_CFLAGS/SPEED=-O3
287
288 # Hotspot uses very unstrict aliasing turn this optimization off
300 endif
301
302 ifdef OPT_CFLAGS
303 ifneq ("$(origin OPT_CFLAGS)", "command line")
304 $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.")
305 endif
306 endif
307
308 OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS)
309
310 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
311 # if we use expensive-optimizations
312 ifeq ($(BUILDARCH), ia64)
313 OPT_CFLAGS += -fno-expensive-optimizations
314 endif
315
316 OPT_CFLAGS/NOOPT=-O0
317
318 # Work around some compiler bugs.
319 ifeq ($(USE_CLANG), true)
320 # Clang 4.2
321 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
322 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
323 OPT_CFLAGS/unsafe.o += -O1
324 endif
325 # Clang 5.0
326 ifeq ($(shell expr $(CC_VER_MAJOR) = 5 \& $(CC_VER_MINOR) = 0), 1)
327 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
328 OPT_CFLAGS/unsafe.o += -O1
329 endif
330 # Clang 5.1
331 ifeq ($(shell expr $(CC_VER_MAJOR) = 5 \& $(CC_VER_MINOR) = 1), 1)
332 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
333 OPT_CFLAGS/unsafe.o += -O1
334 endif
335 else
336 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
337 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
338 OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT)
339 endif
340 endif
341
342 # We want to use libc++ on Clang 5.0
343 ifeq ($(USE_CLANG), true)
344 # Clang 5.x
345 ifeq ($(shell expr $(CC_VER_MAJOR) = 5), 1)
346 CFLAGS += -stdlib=libc++
347 LFLAGS += -stdlib=libc++
348 endif
349 endif
350
351 # Flags for generating make dependency flags.
352 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
353 ifeq ($(USE_CLANG),)
354 ifneq ($(CC_VER_MAJOR), 2)
355 DEPFLAGS += -fpch-deps
356 endif
357 endif
358
359 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
360 ifeq ($(USE_PRECOMPILED_HEADER),0)
361 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
362 endif
363
364 ifeq ($(OS_VENDOR), Darwin)
365 # Setting these parameters makes it an error to link to macosx APIs that are
366 # newer than the given OS version and makes the linked binaries compatible even
367 # if built on a newer version of the OS.
368 # The expected format is X.Y.Z
369 ifeq ($(MACOSX_VERSION_MIN),)
370 MACOSX_VERSION_MIN=10.7.0
371 endif
372 # The macro takes the version with no dots, ex: 1070
373 CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
374 -mmacosx-version-min=$(MACOSX_VERSION_MIN)
375 LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
376 endif
377
378
379 #------------------------------------------------------------------------
380 # Assembler flags
381
382 # Enforce prerpocessing of .s files
383 ASFLAGS += -x assembler-with-cpp
384
385 #------------------------------------------------------------------------
386 # Linker flags
387
388 # statically link libstdc++.so, work with gcc but ignored by g++
389 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
390
391 ifeq ($(USE_CLANG),)
392 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
393 ifneq ("${CC_VER_MAJOR}", "2")
394 STATIC_LIBGCC += -static-libgcc
395 endif
396
397 ifeq ($(BUILDARCH), ia64)
398 LFLAGS += -Wl,-relax
399 endif
400 endif
401
402 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
403 MAPFLAG = -Xlinker --version-script=FILENAME
404
405 #
406 # Shared Library
407 #
408 ifeq ($(OS_VENDOR), Darwin)
409 # Standard linker flags
410 LFLAGS +=
|