Guest User

Untitled

a guest
Aug 20th, 2017
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. blitz@inode ~/abs/core/linux % cat gcc_code_generation.patch
  2. Enables native optimizations by default
  3. --- a/arch/x86/Kconfig.cpu
  4. +++ b/arch/x86/Kconfig.cpu
  5. @@ -1,8 +1,8 @@
  6. # Put here option for CPU selection and depending optimization
  7. choice
  8. prompt "Processor family"
  9. - default M686 if X86_32
  10. - default GENERIC_CPU if X86_64
  11. + default MNATIVE if X86_32
  12. + default MNATIVE if X86_64
  13. ---help---
  14. This is the processor type of your CPU. This information is
  15. used for optimizing purposes. In order to compile a kernel
  16.  
  17. Enables alignments optimization
  18. --- a/arch/x86/Makefile
  19. +++ b/arch/x86/Makefile
  20. @@ -87,11 +87,11 @@
  21. KBUILD_AFLAGS += -m64
  22. KBUILD_CFLAGS += -m64
  23.  
  24. - # Align jump targets to 1 byte, not the default 16 bytes:
  25. - KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
  26. -
  27. - # Pack loops tightly as well:
  28. - KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
  29. + # Align to the default 16 bytes:
  30. + KBUILD_CFLAGS += $(call cc-option,-falign-functions=16)
  31. + KBUILD_CFLAGS += $(call cc-option,-falign-jumps=16)
  32. + KBUILD_CFLAGS += $(call cc-option,-falign-labels=16)
  33. + KBUILD_CFLAGS += $(call cc-option,-falign-loops=16)
  34.  
  35. # Don't autogenerate traditional x87 instructions
  36. KBUILD_CFLAGS += $(call cc-option,-mno-80387)
  37.  
  38. Enables gcc -O3 optimization
  39. --- a/Makefile
  40. +++ b/Makefile
  41. @@ -635,6 +635,10 @@
  42. KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
  43. KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
  44.  
  45. +ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED
  46. +KBUILD_CFLAGS += -O3
  47. +KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
  48. +else
  49. ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
  50. KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
  51. KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
  52. @@ -645,6 +649,7 @@
  53. KBUILD_CFLAGS += -O2
  54. endif
  55. endif
  56. +endif
  57.  
  58. KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
  59. $(call cc-disable-warning,maybe-uninitialized,))
  60.  
  61. --- a/init/Kconfig
  62. +++ b/init/Kconfig
  63. @@ -1376,7 +1376,13 @@
  64.  
  65. choice
  66. prompt "Compiler optimization level"
  67. - default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
  68. + default CONFIG_CC_OPTIMIZE_SPEED
  69. +
  70. +config CC_OPTIMIZE_FOR_SPEED
  71. + bool "Optimize for speed"
  72. + help
  73. + Enabling this option will pass "-O3" instead of "-O2"
  74. + to your compiler resulting in a faster kernel.
  75.  
  76. config CC_OPTIMIZE_FOR_PERFORMANCE
  77. bool "Optimize for performance"
RAW Paste Data