382 |
386 |
383 # |
387 # |
384 # Different "levels" of optimization. |
388 # Different "levels" of optimization. |
385 # |
389 # |
386 ifeq ($(CC_VERSION),gcc) |
390 ifeq ($(CC_VERSION),gcc) |
387 CC_HIGHEST_OPT = -O3 |
391 |
388 CC_HIGHER_OPT = -O3 |
392 CC_OPT/NONE = |
389 CC_LOWER_OPT = -O2 |
393 CC_OPT/LOWER = -O2 |
|
394 CC_OPT/HIGHER = -O3 |
|
395 CC_OPT/HIGHEST = -O3 |
|
396 |
|
397 CXX_OPT/NONE = |
|
398 CXX_OPT/LOWER = -O2 |
|
399 CXX_OPT/HIGHER = -O3 |
|
400 CXX_OPT/HIGHEST = -O3 |
|
401 |
390 CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer |
402 CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer |
391 CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer |
403 CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer |
|
404 |
392 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) |
405 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) |
393 # (See Rules.gmk) May need to wait for gcc 5? |
406 # (See Rules.gmk) May need to wait for gcc 5? |
394 AUTOMATIC_PCH_OPTION = |
407 AUTOMATIC_PCH_OPTION = |
|
408 |
395 else |
409 else |
|
410 |
396 # Highest could be -xO5, but indications are that -xO5 should be reserved |
411 # Highest could be -xO5, but indications are that -xO5 should be reserved |
397 # for a per-file use, on sources with known performance impacts. |
412 # for a per-file use, on sources with known performance impacts. |
398 CC_HIGHEST_OPT = -xO4 |
413 OPT_LEVEL/LOWER = 2 |
399 CC_HIGHER_OPT = -xO4 |
414 OPT_LEVEL/HIGHER = 4 |
400 CC_LOWER_OPT = -xO2 |
415 OPT_LEVEL/HIGHEST = 4 |
|
416 |
|
417 CC_OPT/NONE = |
|
418 CC_OPT/LOWER = $(OPT_LEVEL/LOWER:%=-xO%) |
|
419 CC_OPT/HIGHER = $(OPT_LEVEL/HIGHER:%=-xO%) |
|
420 CC_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%) |
|
421 |
|
422 CXX_OPT/NONE = |
|
423 CXX_OPT/LOWER = $(OPT_LEVEL/LOWER:%=-xO%) |
|
424 CXX_OPT/HIGHER = $(OPT_LEVEL/HIGHER:%=-xO%) |
|
425 CXX_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%) |
|
426 |
|
427 # We need stack frames at all times |
|
428 USE_XKEEPFRAME_OPTION = false |
|
429 ifeq ($(USE_XKEEPFRAME_OPTION),true) |
|
430 |
|
431 # Unknown spelling on this option at this time (Maybe in SS13?) |
|
432 CC_XKEEPFRAME_OPTIONS = -xkeepframe |
|
433 CXX_XKEEPFRAME_OPTIONS = -xkeepframe |
|
434 |
|
435 else |
|
436 |
|
437 # On X86, make sure tail call optimization is off |
|
438 # The z and y are the tail call optimizations. |
|
439 ifeq ($(ARCH_FAMILY), i586) |
|
440 ifeq ($(shell $(EXPR) $(CC_VER) \> 5.8), 1) |
|
441 # Somehow, tail call optimization is creeping in. |
|
442 # Make sure it is off. |
|
443 # WARNING: These may cause compiler warnings about duplicate -O options |
|
444 CC_XKEEPFRAME_OPTIONS += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz |
|
445 CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz |
|
446 endif |
|
447 endif |
|
448 |
|
449 # On i586 we need to tell the code generator to ALWAYS use a |
|
450 # frame pointer. |
|
451 ifeq ($(ARCH_FAMILY), i586) |
|
452 # Note that in 5.7, this is done with -xregs=no%frameptr |
|
453 ifeq ($(CC_VER), 5.5) |
|
454 # It's not exactly clear when this optimization kicks in, the |
|
455 # current assumption is -xO4 or greater and for C++ with |
|
456 # the -features=no%except option and -xO4 and greater. |
|
457 # Bottom line is, we ALWAYS want a frame pointer! |
|
458 CC_XKEEPFRAME_OPTIONS += -Wu,-Z~B |
|
459 CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B |
|
460 endif |
|
461 ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1) |
|
462 # Do NOT use frame pointer register as a general purpose opt register |
|
463 CC_OPT/NONE += -xregs=no%frameptr |
|
464 CXX_OPT/NONE += -xregs=no%frameptr |
|
465 CC_XKEEPFRAME_OPTIONS += -xregs=no%frameptr |
|
466 CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr |
|
467 endif |
|
468 endif |
|
469 |
|
470 # Optimizer for sparc needs to be told not to do certain things |
|
471 # related to frames or save instructions. |
|
472 ifeq ($(ARCH_FAMILY), sparc) |
|
473 # Do not use save instructions instead of add instructions |
|
474 # This was an optimization starting in SC5.0 that made it hard for us to |
|
475 # find the "save" instruction (which got turned into an "add") |
|
476 CC_XKEEPFRAME_OPTIONS += -Wc,-Qrm-s |
|
477 CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qrm-s |
|
478 # Don't allow tail call code optimization. Started in SC5.0. |
|
479 # We don't like code of this form: |
|
480 # save |
|
481 # <code> |
|
482 # call foo |
|
483 # restore |
|
484 # because we can't tell if the method will have a stack frame |
|
485 # and register windows or not. |
|
486 CC_XKEEPFRAME_OPTIONS += -Wc,-Qiselect-T0 |
|
487 CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qiselect-T0 |
|
488 endif |
|
489 |
|
490 endif |
|
491 |
|
492 # Extra options used with HIGHEST |
401 # |
493 # |
402 # WARNING: Use of _OPT=$(CC_HIGHEST_OPT) in your Makefile needs to be |
494 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be |
403 # done with care, there are some assumptions below that need to |
495 # done with care, there are some assumptions below that need to |
404 # be understood about the use of pointers, and IEEE behavior. |
496 # be understood about the use of pointers, and IEEE behavior. |
405 # |
497 # |
406 # Use non-standard floating point mode (not IEEE 754) |
498 # Use non-standard floating point mode (not IEEE 754) |
407 CC_HIGHEST_OPT += -fns |
499 CC_HIGHEST_EXTRAS += -fns |
408 # Do some simplification of floating point arithmetic (not IEEE 754) |
500 # Do some simplification of floating point arithmetic (not IEEE 754) |
409 CC_HIGHEST_OPT += -fsimple |
501 CC_HIGHEST_EXTRAS += -fsimple |
410 # Use single precision floating point with 'float' |
502 # Use single precision floating point with 'float' |
411 CC_HIGHEST_OPT += -fsingle |
503 CC_HIGHEST_EXTRAS += -fsingle |
412 # Assume memory references via basic pointer types do not alias |
504 # Assume memory references via basic pointer types do not alias |
413 # (Source with excessing pointer casting and data access with mixed |
505 # (Source with excessing pointer casting and data access with mixed |
414 # pointer types are not recommended) |
506 # pointer types are not recommended) |
415 CC_HIGHEST_OPT += -xalias_level=basic |
507 CC_HIGHEST_EXTRAS += -xalias_level=basic |
416 # Use intrinsic or inline versions for math/std functions |
508 # Use intrinsic or inline versions for math/std functions |
417 # (If you expect perfect errno behavior, do not use this) |
509 # (If you expect perfect errno behavior, do not use this) |
418 CC_HIGHEST_OPT += -xbuiltin=%all |
510 CC_HIGHEST_EXTRAS += -xbuiltin=%all |
419 # Loop data dependency optimizations (need -xO3 or higher) |
511 # Loop data dependency optimizations (need -xO3 or higher) |
420 CC_HIGHEST_OPT += -xdepend |
512 CC_HIGHEST_EXTRAS += -xdepend |
421 # Pointer parameters to functions do not overlap |
513 # Pointer parameters to functions do not overlap |
422 # (Similar to -xalias_level=basic usage, but less obvious sometimes. |
514 # (Similar to -xalias_level=basic usage, but less obvious sometimes. |
423 # If you pass in multiple pointers to the same data, do not use this) |
515 # If you pass in multiple pointers to the same data, do not use this) |
424 CC_HIGHEST_OPT += -xrestrict |
516 CC_HIGHEST_EXTRAS += -xrestrict |
425 # Inline some library routines |
517 # Inline some library routines |
426 # (If you expect perfect errno behavior, do not use this) |
518 # (If you expect perfect errno behavior, do not use this) |
427 CC_HIGHEST_OPT += -xlibmil |
519 CC_HIGHEST_EXTRAS += -xlibmil |
428 # Use optimized math routines |
520 # Use optimized math routines |
429 # (If you expect perfect errno behavior, do not use this) |
521 # (If you expect perfect errno behavior, do not use this) |
430 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now |
522 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now |
431 # CC_HIGHEST_OPT += -xlibmopt |
523 # CC_HIGHEST_EXTRAS += -xlibmopt |
432 ifeq ($(ARCH_FAMILY), sparc) |
524 ifeq ($(ARCH_FAMILY), sparc) |
433 # Assume at most 8byte alignment, raise SIGBUS on error |
525 # Assume at most 8byte alignment, raise SIGBUS on error |
434 ### Presents an ABI issue with customer JNI libs? |
526 ### Presents an ABI issue with customer JNI libs? |
435 ####CC_HIGHEST_OPT += -xmemalign=8s |
527 ####CC_HIGHEST_EXTRAS += -xmemalign=8s |
436 # Automatic prefetch instructions, explicit prefetch macros |
528 # Automatic prefetch instructions, explicit prefetch macros |
437 CC_HIGHEST_OPT += -xprefetch=auto,explicit |
529 CC_HIGHEST_EXTRAS += -xprefetch=auto,explicit |
438 # Pick ultra as the chip to optimize to |
530 # Pick ultra as the chip to optimize to |
439 CC_HIGHEST_OPT += -xchip=ultra |
531 CC_HIGHEST_EXTRAS += -xchip=ultra |
440 endif |
532 endif |
441 ifeq ($(ARCH), i586) |
533 ifeq ($(ARCH), i586) |
442 # Pick pentium as the chip to optimize to |
534 # Pick pentium as the chip to optimize to |
443 CC_HIGHEST_OPT += -xchip=pentium |
535 CC_HIGHEST_EXTRAS += -xchip=pentium |
444 endif |
536 endif |
445 ifdef LIBRARY |
537 ifdef LIBRARY |
446 # The Solaris CBE (Common Build Environment) requires that the use |
538 # The Solaris CBE (Common Build Environment) requires that the use |
447 # of appl registers be disabled when compiling a public library (or |
539 # of appl registers be disabled when compiling a public library (or |
448 # a library that's loaded by a public library) on sparc. |
540 # a library that's loaded by a public library) on sparc. |
449 CFLAGS_REQUIRED_sparc += -xregs=no%appl |
541 CFLAGS_REQUIRED_sparc += -xregs=no%appl |
450 CFLAGS_REQUIRED_sparcv9 += -xregs=no%appl |
542 CFLAGS_REQUIRED_sparcv9 += -xregs=no%appl |
451 endif |
543 endif |
452 ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1) |
544 ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1) |
453 # Do NOT use the frame pointer register as a general purpose opt register |
|
454 CFLAGS_REQUIRED_i586 += -xregs=no%frameptr |
|
455 CFLAGS_REQUIRED_amd64 += -xregs=no%frameptr |
|
456 # We MUST allow data alignment of 4 for sparc V8 (32bit) |
545 # We MUST allow data alignment of 4 for sparc V8 (32bit) |
457 # Presents an ABI issue with customer JNI libs? We must be able to |
546 # Presents an ABI issue with customer JNI libs? We must be able to |
458 # to handle 4byte aligned objects? (rare occurance, but possible?) |
547 # to handle 4byte aligned objects? (rare occurance, but possible?) |
459 CFLAGS_REQUIRED_sparc += -xmemalign=4s |
548 CFLAGS_REQUIRED_sparc += -xmemalign=4s |
460 endif |
549 endif |
464 CFLAGS_REQUIRED_sparc += -xmemalign=4s |
553 CFLAGS_REQUIRED_sparc += -xmemalign=4s |
465 endif |
554 endif |
466 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) |
555 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) |
467 # (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken. |
556 # (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken. |
468 AUTOMATIC_PCH_OPTION = |
557 AUTOMATIC_PCH_OPTION = |
469 endif |
558 |
470 CC_NO_OPT = |
559 # Add in keep frame options |
471 |
560 CC_OPT/LOWER += $(CC_XKEEPFRAME_OPTIONS) |
472 # If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off |
561 CC_OPT/HIGHER += $(CC_XKEEPFRAME_OPTIONS) |
473 ifdef NO_OPTIMIZATIONS |
562 CC_OPT/HIGHEST += $(CC_XKEEPFRAME_OPTIONS) |
474 CC_HIGHEST_OPT = $(CC_NO_OPT) |
563 CXX_OPT/LOWER += $(CXX_XKEEPFRAME_OPTIONS) |
475 CC_HIGHER_OPT = $(CC_NO_OPT) |
564 CXX_OPT/HIGHER += $(CXX_XKEEPFRAME_OPTIONS) |
476 CC_LOWER_OPT = $(CC_NO_OPT) |
565 CXX_OPT/HIGHEST += $(CXX_XKEEPFRAME_OPTIONS) |
477 endif |
566 |
|
567 # Add in highest optimization settings |
|
568 CC_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS) |
|
569 CXX_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS) |
|
570 |
|
571 endif |
|
572 |
|
573 # Default optimization settings based on level. |
|
574 CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL)) |
|
575 CXX_OPT = $(CXX_OPT/$(OPTIMIZATION_LEVEL)) |
478 |
576 |
479 # Flags required all the time |
577 # Flags required all the time |
480 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH)) |
578 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH)) |
481 |
|
482 # Add processor specific options for optimizations |
|
483 CC_HIGHEST_OPT += $(_OPT_$(ARCH)) |
|
484 CC_HIGHER_OPT += $(_OPT_$(ARCH)) |
|
485 CC_LOWER_OPT += $(_OPT_$(ARCH)) |
|
486 |
|
487 # Secret compiler optimization options that should be in the above macros |
|
488 # but since they differ in format from C to C++, are added into the C or |
|
489 # C++ specific macros for compiler flags. |
|
490 # |
|
491 # On i586 we need to tell the code generator to ALWAYS use a |
|
492 # frame pointer. |
|
493 ifeq ($(ARCH_FAMILY), i586) |
|
494 # Note that in 5.7, this is done with -xregs=no%frameptr |
|
495 ifeq ($(CC_VER), 5.5) |
|
496 # It's not exactly clear when this optimization kicks in, the |
|
497 # current assumption is -xO4 or greater and for C++ with |
|
498 # the -features=no%except option and -xO4 and greater. |
|
499 # Bottom line is, we ALWAYS want a frame pointer! |
|
500 CXXFLAGS_OPT += -Qoption ube -Z~B |
|
501 CFLAGS_OPT += -Wu,-Z~B |
|
502 ifeq ($(FASTDEBUG), true) |
|
503 CXXFLAGS_DBG += -Qoption ube -Z~B |
|
504 CFLAGS_DBG += -Wu,-Z~B |
|
505 endif |
|
506 endif |
|
507 endif |
|
508 # |
|
509 # Optimizer for sparc needs to be told not to do certain things |
|
510 # related to frames or save instructions. |
|
511 ifeq ($(ARCH_FAMILY), sparc) |
|
512 # NOTE: Someday the compilers will provide a high-level option for this. |
|
513 # Use save instructions instead of add instructions |
|
514 # This was an optimization starting in SC5.0 that made it hard for us to |
|
515 # find the "save" instruction (which got turned into an "add") |
|
516 CXXFLAGS_OPT += -Qoption cg -Qrm-s |
|
517 CFLAGS_OPT += -Wc,-Qrm-s |
|
518 ifeq ($(FASTDEBUG), true) |
|
519 CXXFLAGS_DBG += -Qoption cg -Qrm-s |
|
520 CFLAGS_DBG += -Wc,-Qrm-s |
|
521 endif |
|
522 # |
|
523 # NOTE: Someday the compilers will provide a high-level option for this. |
|
524 # Don't allow tail call code optimization. Started in SC5.0. |
|
525 # We don't like code of this form: |
|
526 # save |
|
527 # <code> |
|
528 # call foo |
|
529 # restore |
|
530 # because we can't tell if the method will have a stack frame |
|
531 # and register windows or not. |
|
532 CXXFLAGS_OPT += -Qoption cg -Qiselect-T0 |
|
533 CFLAGS_OPT += -Wc,-Qiselect-T0 |
|
534 ifeq ($(FASTDEBUG), true) |
|
535 CXXFLAGS_DBG += -Qoption cg -Qiselect-T0 |
|
536 CFLAGS_DBG += -Wc,-Qiselect-T0 |
|
537 endif |
|
538 endif |
|
539 |
579 |
540 # |
580 # |
541 # Path and option to link against the VM, if you have to. Note that |
581 # Path and option to link against the VM, if you have to. Note that |
542 # there are libraries that link against only -ljava, but they do get |
582 # there are libraries that link against only -ljava, but they do get |
543 # -L to the -ljvm, this is because -ljava depends on -ljvm, whereas |
583 # -L to the -ljvm, this is because -ljava depends on -ljvm, whereas |