toolchain.gypi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. {
  2. 'variables': {
  3. # Clang stuff.
  4. 'make_clang_dir%': 'vendor/llvm-build/Release+Asserts',
  5. # Set this to true when building with Clang.
  6. 'clang%': 1,
  7. # Set this to the absolute path to sccache when building with sccache
  8. 'cc_wrapper%': '',
  9. # Path to mips64el toolchain.
  10. 'make_mips64_dir%': 'vendor/gcc-4.8.3-d197-n64-loongson/usr',
  11. 'variables': {
  12. # The minimum macOS SDK version to use.
  13. 'mac_sdk_min%': '10.12',
  14. # Set ARM architecture version.
  15. 'arm_version%': 7,
  16. # Set NEON compilation flags.
  17. 'arm_neon%': 1,
  18. # Abosulte path to source root.
  19. 'source_root%': '<!(node <(DEPTH)/tools/atom_source_root.js)',
  20. },
  21. # Copy conditionally-set variables out one scope.
  22. 'mac_sdk_min%': '<(mac_sdk_min)',
  23. 'arm_version%': '<(arm_version)',
  24. 'arm_neon%': '<(arm_neon)',
  25. 'source_root%': '<(source_root)',
  26. # Variables to control Link-Time Optimization (LTO).
  27. 'use_lto%': 0,
  28. 'use_lto_o2%': 0,
  29. 'conditions': [
  30. # Do not use Clang on Windows or when building for mips64el.
  31. ['OS=="win" or target_arch=="mips64el"', {
  32. 'clang%': 0,
  33. }], # OS=="win"
  34. # Search for the available version of SDK.
  35. ['OS=="mac"', {
  36. 'mac_sdk%': '<!(python <(DEPTH)/tools/mac/find_sdk.py <(mac_sdk_min))',
  37. }],
  38. ['OS=="linux"', {
  39. 'variables': {
  40. # The system libdir used for this ABI.
  41. 'system_libdir%': 'lib',
  42. # Setting the path to sysroot.
  43. 'conditions': [
  44. ['target_arch=="arm"', {
  45. # sysroot needs to be an absolute path otherwise it generates
  46. # incorrect results when passed to pkg-config
  47. 'sysroot%': '<(source_root)/vendor/debian_stretch_arm-sysroot',
  48. }],
  49. ['target_arch=="arm64"', {
  50. 'sysroot%': '<(source_root)/vendor/debian_stretch_arm64-sysroot',
  51. }],
  52. ['target_arch=="ia32"', {
  53. 'sysroot%': '<(source_root)/vendor/debian_stretch_i386-sysroot',
  54. }],
  55. ['target_arch=="x64"', {
  56. 'sysroot%': '<(source_root)/vendor/debian_stretch_amd64-sysroot',
  57. }],
  58. ['target_arch=="mips64el"', {
  59. 'sysroot%': '<(source_root)/vendor/debian_jessie_mips64-sysroot',
  60. }],
  61. ],
  62. },
  63. # Copy conditionally-set variables out one scope.
  64. 'sysroot%': '<(sysroot)',
  65. 'system_libdir%': '<(system_libdir)',
  66. # Redirect pkg-config to search from sysroot.
  67. 'pkg-config%': '<(source_root)/tools/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
  68. }],
  69. # Set default compiler flags depending on ARM version.
  70. ['arm_version==6', {
  71. 'arm_arch%': 'armv6',
  72. 'arm_tune%': '',
  73. 'arm_fpu%': 'vfp',
  74. 'arm_float_abi%': 'softfp',
  75. 'arm_thumb%': 0,
  76. }], # arm_version==6
  77. ['arm_version==7', {
  78. 'arm_arch%': 'armv7-a',
  79. 'arm_tune%': 'generic-armv7-a',
  80. 'conditions': [
  81. ['arm_neon==1', {
  82. 'arm_fpu%': 'neon',
  83. }, {
  84. 'arm_fpu%': 'vfpv3-d16',
  85. }],
  86. ],
  87. 'arm_float_abi%': 'hard',
  88. 'arm_thumb%': 1,
  89. }], # arm_version==7
  90. ],
  91. },
  92. 'conditions': [
  93. # Setup cc_wrapper
  94. ['cc_wrapper!=""', {
  95. 'make_global_settings': [
  96. ['CC_wrapper', '<(cc_wrapper)'],
  97. ['CXX_wrapper', '<(cc_wrapper)'],
  98. ['CC.host_wrapper', '<(cc_wrapper)'],
  99. ['CXX.host_wrapper', '<(cc_wrapper)']
  100. ],
  101. }],
  102. # Setup building with clang.
  103. ['clang==1', {
  104. 'make_global_settings': [
  105. ['CC', '<(make_clang_dir)/bin/clang'],
  106. ['CXX', '<(make_clang_dir)/bin/clang++'],
  107. ['CC.host', '$(CC)'],
  108. ['CXX.host', '$(CXX)'],
  109. ],
  110. 'target_defaults': {
  111. 'xcode_settings': {
  112. 'CC': '<(make_clang_dir)/bin/clang',
  113. 'LDPLUSPLUS': '<(make_clang_dir)/bin/clang++',
  114. 'OTHER_CFLAGS': [
  115. '-fcolor-diagnostics',
  116. ],
  117. 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
  118. 'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
  119. 'CLANG_CXX_LANGUAGE_STANDARD': 'c++14', # -std=c++14
  120. },
  121. 'target_conditions': [
  122. ['_target_name in ["electron", "brightray"]', {
  123. 'conditions': [
  124. ['OS=="mac"', {
  125. 'xcode_settings': {
  126. 'OTHER_CFLAGS': [
  127. "-Xclang",
  128. "-load",
  129. "-Xclang",
  130. "<(source_root)/<(make_clang_dir)/lib/libFindBadConstructs.dylib",
  131. "-Xclang",
  132. "-add-plugin",
  133. "-Xclang",
  134. "find-bad-constructs",
  135. "-Xclang",
  136. "-plugin-arg-find-bad-constructs",
  137. "-Xclang",
  138. "check-auto-raw-pointer",
  139. ],
  140. },
  141. }, { # OS=="mac"
  142. 'cflags_cc': [
  143. "-Xclang",
  144. "-load",
  145. "-Xclang",
  146. "<(source_root)/<(make_clang_dir)/lib/libFindBadConstructs.so",
  147. "-Xclang",
  148. "-add-plugin",
  149. "-Xclang",
  150. "find-bad-constructs",
  151. "-Xclang",
  152. "-plugin-arg-find-bad-constructs",
  153. "-Xclang",
  154. "check-auto-raw-pointer",
  155. ],
  156. }],
  157. ],
  158. }],
  159. ['OS=="mac" and _type in ["executable", "shared_library"]', {
  160. 'xcode_settings': {
  161. # On some machines setting CLANG_CXX_LIBRARY doesn't work for
  162. # linker.
  163. 'OTHER_LDFLAGS': [ '-stdlib=libc++' ],
  164. },
  165. }],
  166. ['OS=="linux" and _toolset=="target"', {
  167. 'cflags_cc': [
  168. '-std=gnu++14',
  169. '-nostdinc++',
  170. '-isystem<(libchromiumcontent_src_dir)/buildtools/third_party/libc++/trunk/include',
  171. '-isystem<(libchromiumcontent_src_dir)/buildtools/third_party/libc++abi/trunk/include',
  172. ],
  173. 'ldflags': [
  174. '-nostdlib++',
  175. ],
  176. }],
  177. ['OS=="linux" and _toolset=="host"', {
  178. 'cflags_cc': [
  179. '-std=gnu++14',
  180. ],
  181. }],
  182. ],
  183. },
  184. }], # clang==1
  185. ['target_arch=="mips64el"', {
  186. 'make_global_settings': [
  187. ['CC', '<(make_mips64_dir)/bin/mips64el-redhat-linux-gcc'],
  188. ['CXX', '<(make_mips64_dir)/bin/mips64el-redhat-linux-g++'],
  189. ['CC.host', '$(CC)'],
  190. ['CXX.host', '$(CXX)'],
  191. ],
  192. 'target_defaults': {
  193. 'cflags_cc': [
  194. '-std=gnu++14',
  195. ],
  196. },
  197. }],
  198. # Specify the SDKROOT.
  199. ['OS=="mac"', {
  200. 'target_defaults': {
  201. 'xcode_settings': {
  202. 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
  203. },
  204. },
  205. }],
  206. # Setup sysroot environment.
  207. ['OS=="linux" and target_arch in ["arm", "ia32", "x64", "arm64", "mips64el"]', {
  208. 'target_defaults': {
  209. 'target_conditions': [
  210. ['_toolset=="target"', {
  211. # Do not use 'cflags' to make sure sysroot is appended at last.
  212. 'cflags_cc': [
  213. '--sysroot=<(sysroot)',
  214. ],
  215. 'cflags_c': [
  216. '--sysroot=<(sysroot)',
  217. ],
  218. 'ldflags': [
  219. '--sysroot=<(sysroot)',
  220. '<!(<(source_root)/tools/linux/sysroot_ld_path.sh <(sysroot))',
  221. ],
  222. }]
  223. ],
  224. },
  225. }], # sysroot
  226. # Setup cross-compilation on Linux.
  227. ['OS=="linux"', {
  228. 'target_defaults': {
  229. 'target_conditions': [
  230. ['target_arch=="ia32" and _toolset=="target"', {
  231. 'asflags': [
  232. '-32',
  233. ],
  234. 'cflags': [
  235. '-msse2',
  236. '-mfpmath=sse',
  237. '-mmmx', # Allows mmintrin.h for MMX intrinsics.
  238. '-m32',
  239. ],
  240. 'ldflags': [
  241. '-m32',
  242. ],
  243. }], # target_arch=="ia32" and _toolset=="target"
  244. ['target_arch=="x64" and _toolset=="target"', {
  245. 'cflags': [
  246. '-m64',
  247. '-march=x86-64',
  248. ],
  249. 'ldflags': [
  250. '-m64',
  251. ],
  252. }], # target_arch=="x64" and _toolset=="target"
  253. ['target_arch=="arm" and _toolset=="target"', {
  254. 'conditions': [
  255. ['clang==0', {
  256. 'cflags_cc': [
  257. '-Wno-abi',
  258. ],
  259. }],
  260. ['clang==1 and arm_arch!=""', {
  261. 'cflags': [
  262. '-target arm-linux-gnueabihf',
  263. ],
  264. 'ldflags': [
  265. '-target arm-linux-gnueabihf',
  266. ],
  267. }],
  268. ['arm_arch!=""', {
  269. 'cflags': [
  270. '-march=<(arm_arch)',
  271. ],
  272. 'conditions': [
  273. ['use_lto==1 or use_lto_o2==1', {
  274. 'ldflags': [
  275. '-march=<(arm_arch)',
  276. ],
  277. }],
  278. ],
  279. }],
  280. ['arm_tune!=""', {
  281. 'cflags': [
  282. '-mtune=<(arm_tune)',
  283. ],
  284. 'conditions': [
  285. ['use_lto==1 or use_lto_o2==1', {
  286. 'ldflags': [
  287. '-mtune=<(arm_tune)',
  288. ],
  289. }],
  290. ],
  291. }],
  292. ['arm_fpu!=""', {
  293. 'cflags': [
  294. '-mfpu=<(arm_fpu)',
  295. ],
  296. 'conditions': [
  297. ['use_lto==1 or use_lto_o2==1', {
  298. 'ldflags': [
  299. '-mfpu=<(arm_fpu)',
  300. ],
  301. }],
  302. ],
  303. }],
  304. ['arm_float_abi!=""', {
  305. 'cflags': [
  306. '-mfloat-abi=<(arm_float_abi)',
  307. ],
  308. 'conditions': [
  309. ['use_lto==1 or use_lto_o2==1', {
  310. 'ldflags': [
  311. '-mfloat-abi=<(arm_float_abi)',
  312. ],
  313. }],
  314. ],
  315. }],
  316. ['arm_thumb==1', {
  317. 'cflags': [
  318. '-mthumb',
  319. ],
  320. 'conditions': [
  321. ['use_lto==1 or use_lto_o2==1', {
  322. 'ldflags': [
  323. '-mthumb',
  324. ],
  325. }],
  326. ],
  327. }],
  328. ],
  329. }], # target_arch=="arm64" and _toolset=="target"
  330. ['target_arch=="arm64" and _toolset=="target"', {
  331. 'conditions': [
  332. ['clang==0', {
  333. 'cflags_cc': [
  334. '-Wno-abi',
  335. ],
  336. }],
  337. ['clang==1 and arm_arch!=""', {
  338. 'cflags': [
  339. '-target aarch64-linux-gnu',
  340. ],
  341. 'ldflags': [
  342. '-target aarch64-linux-gnu',
  343. ],
  344. }],
  345. ],
  346. }], # target_arch=="arm" and _toolset=="target"
  347. ],
  348. },
  349. }], # OS=="linux"
  350. ],
  351. }