common_definitions.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # -*- coding: UTF-8 -*-
  2. #----------------------------------------------------------------------------------------------------------------------*
  3. def commonLinkerFlags (usesLTO) :
  4. result = []
  5. result.append ("-nostartfiles")
  6. result.append ("-Wl,--fatal-warnings")
  7. result.append ("-Wl,--warn-common")
  8. result.append ("-Wl,--no-undefined")
  9. if usesLTO :
  10. result.append ("-flto")
  11. result.append ("-ffat-lto-objects")
  12. result.append ("-fuse-linker-plugin")
  13. result.append ("-Wl,--cref")
  14. result.append ("-Wl,-static")
  15. result.append ("-Wl,--gc-sections")
  16. result.append ("-Wl,--sort-common=descending")
  17. result.append ("-Wl,--sort-section=alignment")
  18. # result.append ("-Wl,--print-memory-usage")
  19. result.append ("-Wl,--warn-section-align")
  20. result.append ("-Wl,--warn-shared-textrel")
  21. result.append ("-Wl,--warn-alternate-em")
  22. return result
  23. #----------------------------------------------------------------------------------------------------------------------*
  24. def checkModeOptions () :
  25. result = []
  26. result.append ("-x")
  27. result.append ("c++")
  28. result.append ("-DCHECK_SOFTWARE_MODES")
  29. return result
  30. #----------------------------------------------------------------------------------------------------------------------*
  31. def C_Cpp_optimizationOptions ():
  32. result = []
  33. result.append ("-Os")
  34. # result.append ("-foptimize-register-move")
  35. return result
  36. #----------------------------------------------------------------------------------------------------------------------*
  37. def C_Cpp_commonOptions (usesLTO):
  38. result = []
  39. result.append ("-Wall")
  40. result.append ("-Wextra")
  41. result.append ("-Werror")
  42. result.append ("-Wreturn-type")
  43. result.append ("-Wformat")
  44. result.append ("-Wshadow")
  45. result.append ("-Wsign-compare")
  46. result.append ("-Wpointer-arith")
  47. result.append ("-Wparentheses")
  48. result.append ("-Wcast-align")
  49. result.append ("-Wcast-qual")
  50. result.append ("-Wwrite-strings")
  51. result.append ("-Wswitch")
  52. result.append ("-Wswitch-enum")
  53. result.append ("-Wuninitialized")
  54. result.append ("-Wsign-conversion")
  55. #--- Ordre de ne pas engendrer l'appel des destructeurs des variables globales C++
  56. # et donc d'utiliser des symboles tels que __cxa_exit, __lock___atexit_recursive_mutex, …
  57. result.append ("-fno-use-cxa-atexit")
  58. #--- Engendrer fonctions et variables globales dans des sections spécifiques
  59. # Ceci permet à l'éditeur de liens d'éliminer fonctions et variables inutilisées
  60. result.append ("-ffunction-sections")
  61. result.append ("-fdata-sections")
  62. # result.append ("-fno-stack-protector") # CLANG
  63. # result.append ("-fshort-enums") # CLANG
  64. if usesLTO :
  65. result.append ("-flto")
  66. result.append ("-ffat-lto-objects")
  67. result.append ("-Wno-unused-parameter")
  68. result.append ("-Wshadow")
  69. # result.append ("-Wduplicated-branches")
  70. # result.append ("-Wmisleading-indentation")
  71. # result.append ("-fomit-frame-pointer")
  72. return result
  73. #----------------------------------------------------------------------------------------------------------------------*
  74. def C_actualOptions (usesLTO):
  75. result = C_Cpp_commonOptions (usesLTO)
  76. result.append ("-std=c99")
  77. result.append ("-Wstrict-prototypes")
  78. result.append ("-Wbad-function-cast")
  79. result.append ("-Wmissing-declarations")
  80. result.append ("-Wimplicit-function-declaration")
  81. result.append ("-Wno-int-to-pointer-cast")
  82. result.append ("-Wno-pointer-to-int-cast")
  83. result.append ("-Wmissing-prototypes")
  84. return result
  85. #----------------------------------------------------------------------------------------------------------------------*
  86. def Cpp_actualOptions (usesLTO):
  87. result = C_Cpp_commonOptions (usesLTO)
  88. result.append ("-std=c++14") # c++11 For forwarding enum declarations
  89. result.append ("-fno-rtti")
  90. result.append ("-fno-exceptions")
  91. result.append ("-Woverloaded-virtual")
  92. result.append ("-Weffc++")
  93. result.append ("-fno-threadsafe-statics")
  94. result.append ("-Wmissing-declarations")
  95. result.append ("-Wsuggest-override")
  96. return result
  97. #----------------------------------------------------------------------------------------------------------------------*
  98. def generatedSourceDirectory () :
  99. return "zSOURCES"
  100. #----------------------------------------------------------------------------------------------------------------------*
  101. def buildDirectory () :
  102. return "zBUILDS"
  103. #----------------------------------------------------------------------------------------------------------------------*
  104. def asDirectory () :
  105. return "zASBUILDS"
  106. #----------------------------------------------------------------------------------------------------------------------*
  107. def productDirectory ():
  108. return "zPRODUCTS"
  109. #----------------------------------------------------------------------------------------------------------------------*