cc_toolchain_config.bzl 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718
  1. # Copyright 2019 The Bazel Authors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """A Starlark cc_toolchain configuration rule"""
  15. load(
  16. "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
  17. "action_config",
  18. "artifact_name_pattern",
  19. "env_entry",
  20. "env_set",
  21. "feature",
  22. "feature_set",
  23. "flag_group",
  24. "flag_set",
  25. "make_variable",
  26. "tool",
  27. "tool_path",
  28. "variable_with_value",
  29. "with_feature_set",
  30. )
  31. load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
  32. all_compile_actions = [
  33. ACTION_NAMES.c_compile,
  34. ACTION_NAMES.cpp_compile,
  35. ACTION_NAMES.linkstamp_compile,
  36. ACTION_NAMES.assemble,
  37. ACTION_NAMES.preprocess_assemble,
  38. ACTION_NAMES.cpp_header_parsing,
  39. ACTION_NAMES.cpp_module_compile,
  40. ACTION_NAMES.cpp_module_codegen,
  41. ACTION_NAMES.clif_match,
  42. ACTION_NAMES.lto_backend,
  43. ]
  44. all_cpp_compile_actions = [
  45. ACTION_NAMES.cpp_compile,
  46. ACTION_NAMES.linkstamp_compile,
  47. ACTION_NAMES.cpp_header_parsing,
  48. ACTION_NAMES.cpp_module_compile,
  49. ACTION_NAMES.cpp_module_codegen,
  50. ACTION_NAMES.clif_match,
  51. ]
  52. preprocessor_compile_actions = [
  53. ACTION_NAMES.c_compile,
  54. ACTION_NAMES.cpp_compile,
  55. ACTION_NAMES.linkstamp_compile,
  56. ACTION_NAMES.preprocess_assemble,
  57. ACTION_NAMES.cpp_header_parsing,
  58. ACTION_NAMES.cpp_module_compile,
  59. ACTION_NAMES.clif_match,
  60. ]
  61. codegen_compile_actions = [
  62. ACTION_NAMES.c_compile,
  63. ACTION_NAMES.cpp_compile,
  64. ACTION_NAMES.linkstamp_compile,
  65. ACTION_NAMES.assemble,
  66. ACTION_NAMES.preprocess_assemble,
  67. ACTION_NAMES.cpp_module_codegen,
  68. ACTION_NAMES.lto_backend,
  69. ]
  70. all_link_actions = [
  71. ACTION_NAMES.cpp_link_executable,
  72. ACTION_NAMES.cpp_link_dynamic_library,
  73. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  74. ]
  75. def _windows_msvc_impl(ctx):
  76. toolchain_identifier = "msvc_x64"
  77. host_system_name = "local"
  78. target_system_name = "local"
  79. target_cpu = "x64_windows"
  80. target_libc = "msvcrt"
  81. compiler = "msvc-cl"
  82. abi_version = "local"
  83. abi_libc_version = "local"
  84. cc_target_os = None
  85. builtin_sysroot = None
  86. cxx_builtin_include_directories = [
  87. # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087.
  88. "C:\\botcode\\w",
  89. "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE",
  90. "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt",
  91. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared",
  92. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um",
  93. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt",
  94. ]
  95. cpp_link_nodeps_dynamic_library_action = action_config(
  96. action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  97. implies = [
  98. "nologo",
  99. "shared_flag",
  100. "linkstamps",
  101. "output_execpath_flags",
  102. "input_param_flags",
  103. "user_link_flags",
  104. "default_link_flags",
  105. "linker_subsystem_flag",
  106. "linker_param_file",
  107. "msvc_env",
  108. "no_stripping",
  109. "has_configured_linker_path",
  110. "def_file",
  111. ],
  112. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")],
  113. )
  114. cpp_link_static_library_action = action_config(
  115. action_name = ACTION_NAMES.cpp_link_static_library,
  116. implies = [
  117. "nologo",
  118. "archiver_flags",
  119. "input_param_flags",
  120. "linker_param_file",
  121. "msvc_env",
  122. ],
  123. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe")],
  124. )
  125. assemble_action = action_config(
  126. action_name = ACTION_NAMES.assemble,
  127. implies = [
  128. "compiler_input_flags",
  129. "compiler_output_flags",
  130. "nologo",
  131. "msvc_env",
  132. "sysroot",
  133. ],
  134. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")],
  135. )
  136. preprocess_assemble_action = action_config(
  137. action_name = ACTION_NAMES.preprocess_assemble,
  138. implies = [
  139. "compiler_input_flags",
  140. "compiler_output_flags",
  141. "nologo",
  142. "msvc_env",
  143. "sysroot",
  144. ],
  145. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe")],
  146. )
  147. c_compile_action = action_config(
  148. action_name = ACTION_NAMES.c_compile,
  149. implies = [
  150. "compiler_input_flags",
  151. "compiler_output_flags",
  152. "default_compile_flags",
  153. "nologo",
  154. "msvc_env",
  155. "parse_showincludes",
  156. "user_compile_flags",
  157. "sysroot",
  158. "unfiltered_compile_flags",
  159. ],
  160. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")],
  161. )
  162. cpp_compile_action = action_config(
  163. action_name = ACTION_NAMES.cpp_compile,
  164. implies = [
  165. "compiler_input_flags",
  166. "compiler_output_flags",
  167. "default_compile_flags",
  168. "nologo",
  169. "msvc_env",
  170. "parse_showincludes",
  171. "user_compile_flags",
  172. "sysroot",
  173. "unfiltered_compile_flags",
  174. ],
  175. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")],
  176. )
  177. cpp_link_executable_action = action_config(
  178. action_name = ACTION_NAMES.cpp_link_executable,
  179. implies = [
  180. "nologo",
  181. "linkstamps",
  182. "output_execpath_flags",
  183. "input_param_flags",
  184. "user_link_flags",
  185. "default_link_flags",
  186. "linker_subsystem_flag",
  187. "linker_param_file",
  188. "msvc_env",
  189. "no_stripping",
  190. ],
  191. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")],
  192. )
  193. cpp_link_dynamic_library_action = action_config(
  194. action_name = ACTION_NAMES.cpp_link_dynamic_library,
  195. implies = [
  196. "nologo",
  197. "shared_flag",
  198. "linkstamps",
  199. "output_execpath_flags",
  200. "input_param_flags",
  201. "user_link_flags",
  202. "default_link_flags",
  203. "linker_subsystem_flag",
  204. "linker_param_file",
  205. "msvc_env",
  206. "no_stripping",
  207. "has_configured_linker_path",
  208. "def_file",
  209. ],
  210. tools = [tool(path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe")],
  211. )
  212. action_configs = [
  213. assemble_action,
  214. preprocess_assemble_action,
  215. c_compile_action,
  216. cpp_compile_action,
  217. cpp_link_executable_action,
  218. cpp_link_dynamic_library_action,
  219. cpp_link_nodeps_dynamic_library_action,
  220. cpp_link_static_library_action,
  221. ]
  222. msvc_link_env_feature = feature(
  223. name = "msvc_link_env",
  224. env_sets = [
  225. env_set(
  226. actions = all_link_actions +
  227. [ACTION_NAMES.cpp_link_static_library],
  228. env_entries = [env_entry(key = "LIB", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.10240.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64;")],
  229. ),
  230. ],
  231. )
  232. shared_flag_feature = feature(
  233. name = "shared_flag",
  234. flag_sets = [
  235. flag_set(
  236. actions = [
  237. ACTION_NAMES.cpp_link_dynamic_library,
  238. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  239. ],
  240. flag_groups = [flag_group(flags = ["/DLL"])],
  241. ),
  242. ],
  243. )
  244. determinism_feature = feature(
  245. name = "determinism",
  246. enabled = True,
  247. flag_sets = [
  248. flag_set(
  249. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  250. flag_groups = [
  251. flag_group(
  252. flags = [
  253. "/wd4117",
  254. "-D__DATE__=\"redacted\"",
  255. "-D__TIMESTAMP__=\"redacted\"",
  256. "-D__TIME__=\"redacted\"",
  257. ],
  258. ),
  259. ],
  260. ),
  261. ],
  262. )
  263. sysroot_feature = feature(
  264. name = "sysroot",
  265. flag_sets = [
  266. flag_set(
  267. actions = [
  268. ACTION_NAMES.assemble,
  269. ACTION_NAMES.preprocess_assemble,
  270. ACTION_NAMES.c_compile,
  271. ACTION_NAMES.cpp_compile,
  272. ACTION_NAMES.cpp_header_parsing,
  273. ACTION_NAMES.cpp_module_compile,
  274. ACTION_NAMES.cpp_module_codegen,
  275. ACTION_NAMES.cpp_link_executable,
  276. ACTION_NAMES.cpp_link_dynamic_library,
  277. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  278. ],
  279. flag_groups = [
  280. flag_group(
  281. flags = ["--sysroot=%{sysroot}"],
  282. iterate_over = "sysroot",
  283. expand_if_available = "sysroot",
  284. ),
  285. ],
  286. ),
  287. ],
  288. )
  289. unfiltered_compile_flags_feature = feature(
  290. name = "unfiltered_compile_flags",
  291. flag_sets = [
  292. flag_set(
  293. actions = [
  294. ACTION_NAMES.preprocess_assemble,
  295. ACTION_NAMES.c_compile,
  296. ACTION_NAMES.cpp_compile,
  297. ACTION_NAMES.cpp_header_parsing,
  298. ACTION_NAMES.cpp_module_compile,
  299. ACTION_NAMES.cpp_module_codegen,
  300. ],
  301. flag_groups = [
  302. flag_group(
  303. flags = ["%{unfiltered_compile_flags}"],
  304. iterate_over = "unfiltered_compile_flags",
  305. expand_if_available = "unfiltered_compile_flags",
  306. ),
  307. ],
  308. ),
  309. ],
  310. )
  311. compiler_param_file_feature = feature(
  312. name = "compiler_param_file",
  313. )
  314. copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
  315. input_param_flags_feature = feature(
  316. name = "input_param_flags",
  317. flag_sets = [
  318. flag_set(
  319. actions = [
  320. ACTION_NAMES.cpp_link_dynamic_library,
  321. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  322. ],
  323. flag_groups = [
  324. flag_group(
  325. flags = ["/IMPLIB:%{interface_library_output_path}"],
  326. expand_if_available = "interface_library_output_path",
  327. ),
  328. ],
  329. ),
  330. flag_set(
  331. actions = all_link_actions,
  332. flag_groups = [
  333. flag_group(
  334. flags = ["%{libopts}"],
  335. iterate_over = "libopts",
  336. expand_if_available = "libopts",
  337. ),
  338. ],
  339. ),
  340. flag_set(
  341. actions = all_link_actions +
  342. [ACTION_NAMES.cpp_link_static_library],
  343. flag_groups = [
  344. flag_group(
  345. iterate_over = "libraries_to_link",
  346. flag_groups = [
  347. flag_group(
  348. iterate_over = "libraries_to_link.object_files",
  349. flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])],
  350. expand_if_equal = variable_with_value(
  351. name = "libraries_to_link.type",
  352. value = "object_file_group",
  353. ),
  354. ),
  355. flag_group(
  356. flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],
  357. expand_if_equal = variable_with_value(
  358. name = "libraries_to_link.type",
  359. value = "object_file",
  360. ),
  361. ),
  362. flag_group(
  363. flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],
  364. expand_if_equal = variable_with_value(
  365. name = "libraries_to_link.type",
  366. value = "interface_library",
  367. ),
  368. ),
  369. flag_group(
  370. flag_groups = [
  371. flag_group(
  372. flags = ["%{libraries_to_link.name}"],
  373. expand_if_false = "libraries_to_link.is_whole_archive",
  374. ),
  375. flag_group(
  376. flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"],
  377. expand_if_true = "libraries_to_link.is_whole_archive",
  378. ),
  379. ],
  380. expand_if_equal = variable_with_value(
  381. name = "libraries_to_link.type",
  382. value = "static_library",
  383. ),
  384. ),
  385. ],
  386. expand_if_available = "libraries_to_link",
  387. ),
  388. ],
  389. ),
  390. ],
  391. )
  392. fastbuild_feature = feature(
  393. name = "fastbuild",
  394. flag_sets = [
  395. flag_set(
  396. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  397. flag_groups = [flag_group(flags = ["/Od", "/Z7"])],
  398. ),
  399. flag_set(
  400. actions = all_link_actions,
  401. flag_groups = [
  402. flag_group(
  403. flags = ["/DEBUG:FASTLINK", "/INCREMENTAL:NO"],
  404. ),
  405. ],
  406. ),
  407. ],
  408. implies = ["generate_pdb_file"],
  409. )
  410. user_compile_flags_feature = feature(
  411. name = "user_compile_flags",
  412. flag_sets = [
  413. flag_set(
  414. actions = [
  415. ACTION_NAMES.preprocess_assemble,
  416. ACTION_NAMES.c_compile,
  417. ACTION_NAMES.cpp_compile,
  418. ACTION_NAMES.cpp_header_parsing,
  419. ACTION_NAMES.cpp_module_compile,
  420. ACTION_NAMES.cpp_module_codegen,
  421. ],
  422. flag_groups = [
  423. flag_group(
  424. flags = ["%{user_compile_flags}"],
  425. iterate_over = "user_compile_flags",
  426. expand_if_available = "user_compile_flags",
  427. ),
  428. ],
  429. ),
  430. ],
  431. )
  432. archiver_flags_feature = feature(
  433. name = "archiver_flags",
  434. flag_sets = [
  435. flag_set(
  436. actions = [ACTION_NAMES.cpp_link_static_library],
  437. flag_groups = [
  438. flag_group(
  439. flags = ["/OUT:%{output_execpath}"],
  440. expand_if_available = "output_execpath",
  441. ),
  442. flag_group(
  443. flags = ["/MACHINE:X64"],
  444. ),
  445. ],
  446. ),
  447. ],
  448. )
  449. default_link_flags_feature = feature(
  450. name = "default_link_flags",
  451. enabled = True,
  452. flag_sets = [
  453. flag_set(
  454. actions = all_link_actions,
  455. flag_groups = [flag_group(flags = ["/MACHINE:X64"])],
  456. ),
  457. ],
  458. )
  459. static_link_msvcrt_feature = feature(name = "static_link_msvcrt")
  460. dynamic_link_msvcrt_debug_feature = feature(
  461. name = "dynamic_link_msvcrt_debug",
  462. flag_sets = [
  463. flag_set(
  464. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  465. flag_groups = [flag_group(flags = ["/MDd"])],
  466. ),
  467. flag_set(
  468. actions = all_link_actions,
  469. flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])],
  470. ),
  471. ],
  472. requires = [feature_set(features = ["dbg"])],
  473. )
  474. dbg_feature = feature(
  475. name = "dbg",
  476. flag_sets = [
  477. flag_set(
  478. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  479. flag_groups = [flag_group(flags = ["/Od", "/Z7"])],
  480. ),
  481. flag_set(
  482. actions = all_link_actions,
  483. flag_groups = [
  484. flag_group(
  485. flags = ["/DEBUG:FULL", "/INCREMENTAL:NO"],
  486. ),
  487. ],
  488. ),
  489. ],
  490. implies = ["generate_pdb_file"],
  491. )
  492. opt_feature = feature(
  493. name = "opt",
  494. flag_sets = [
  495. flag_set(
  496. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  497. flag_groups = [flag_group(flags = ["/O2"])],
  498. ),
  499. ],
  500. implies = ["frame_pointer"],
  501. )
  502. supports_interface_shared_libraries_feature = feature(
  503. name = "supports_interface_shared_libraries",
  504. enabled = True,
  505. )
  506. user_link_flags_feature = feature(
  507. name = "user_link_flags",
  508. flag_sets = [
  509. flag_set(
  510. actions = all_link_actions,
  511. flag_groups = [
  512. flag_group(
  513. flags = ["%{user_link_flags}"],
  514. iterate_over = "user_link_flags",
  515. expand_if_available = "user_link_flags",
  516. ),
  517. ],
  518. ),
  519. ],
  520. )
  521. default_compile_flags_feature = feature(
  522. name = "default_compile_flags",
  523. enabled = True,
  524. flag_sets = [
  525. flag_set(
  526. actions = [
  527. ACTION_NAMES.assemble,
  528. ACTION_NAMES.preprocess_assemble,
  529. ACTION_NAMES.linkstamp_compile,
  530. ACTION_NAMES.c_compile,
  531. ACTION_NAMES.cpp_compile,
  532. ACTION_NAMES.cpp_header_parsing,
  533. ACTION_NAMES.cpp_module_compile,
  534. ACTION_NAMES.cpp_module_codegen,
  535. ACTION_NAMES.lto_backend,
  536. ACTION_NAMES.clif_match,
  537. ],
  538. flag_groups = [
  539. flag_group(
  540. flags = [
  541. "/DCOMPILER_MSVC",
  542. "/DNOMINMAX",
  543. "/D_WIN32_WINNT=0x0601",
  544. "/D_CRT_SECURE_NO_DEPRECATE",
  545. "/D_CRT_SECURE_NO_WARNINGS",
  546. "/bigobj",
  547. "/Zm500",
  548. "/EHsc",
  549. "/wd4351",
  550. "/wd4291",
  551. "/wd4250",
  552. "/wd4996",
  553. ],
  554. ),
  555. ],
  556. ),
  557. ],
  558. )
  559. msvc_compile_env_feature = feature(
  560. name = "msvc_compile_env",
  561. env_sets = [
  562. env_set(
  563. actions = [
  564. ACTION_NAMES.c_compile,
  565. ACTION_NAMES.cpp_compile,
  566. ACTION_NAMES.cpp_module_compile,
  567. ACTION_NAMES.cpp_module_codegen,
  568. ACTION_NAMES.cpp_header_parsing,
  569. ACTION_NAMES.assemble,
  570. ACTION_NAMES.preprocess_assemble,
  571. ],
  572. env_entries = [env_entry(key = "INCLUDE", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt;")],
  573. ),
  574. ],
  575. )
  576. preprocessor_defines_feature = feature(
  577. name = "preprocessor_defines",
  578. enabled = True,
  579. flag_sets = [
  580. flag_set(
  581. actions = [
  582. ACTION_NAMES.assemble,
  583. ACTION_NAMES.preprocess_assemble,
  584. ACTION_NAMES.c_compile,
  585. ACTION_NAMES.cpp_compile,
  586. ACTION_NAMES.cpp_header_parsing,
  587. ACTION_NAMES.cpp_module_compile,
  588. ],
  589. flag_groups = [
  590. flag_group(
  591. flags = ["/D%{preprocessor_defines}"],
  592. iterate_over = "preprocessor_defines",
  593. ),
  594. ],
  595. ),
  596. ],
  597. )
  598. generate_pdb_file_feature = feature(
  599. name = "generate_pdb_file",
  600. requires = [
  601. feature_set(features = ["dbg"]),
  602. feature_set(features = ["fastbuild"]),
  603. ],
  604. )
  605. output_execpath_flags_feature = feature(
  606. name = "output_execpath_flags",
  607. flag_sets = [
  608. flag_set(
  609. actions = all_link_actions,
  610. flag_groups = [
  611. flag_group(
  612. flags = ["/OUT:%{output_execpath}"],
  613. expand_if_available = "output_execpath",
  614. ),
  615. ],
  616. ),
  617. ],
  618. )
  619. dynamic_link_msvcrt_no_debug_feature = feature(
  620. name = "dynamic_link_msvcrt_no_debug",
  621. flag_sets = [
  622. flag_set(
  623. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  624. flag_groups = [flag_group(flags = ["/MD"])],
  625. ),
  626. flag_set(
  627. actions = all_link_actions,
  628. flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])],
  629. ),
  630. ],
  631. requires = [
  632. feature_set(features = ["fastbuild"]),
  633. feature_set(features = ["opt"]),
  634. ],
  635. )
  636. disable_assertions_feature = feature(
  637. name = "disable_assertions",
  638. enabled = True,
  639. flag_sets = [
  640. flag_set(
  641. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  642. flag_groups = [flag_group(flags = ["/DNDEBUG"])],
  643. with_features = [with_feature_set(features = ["opt"])],
  644. ),
  645. ],
  646. )
  647. has_configured_linker_path_feature = feature(name = "has_configured_linker_path")
  648. supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  649. no_stripping_feature = feature(name = "no_stripping")
  650. linker_param_file_feature = feature(
  651. name = "linker_param_file",
  652. flag_sets = [
  653. flag_set(
  654. actions = all_link_actions +
  655. [ACTION_NAMES.cpp_link_static_library],
  656. flag_groups = [
  657. flag_group(
  658. flags = ["@%{linker_param_file}"],
  659. expand_if_available = "linker_param_file",
  660. ),
  661. ],
  662. ),
  663. ],
  664. )
  665. ignore_noisy_warnings_feature = feature(
  666. name = "ignore_noisy_warnings",
  667. enabled = True,
  668. flag_sets = [
  669. flag_set(
  670. actions = [ACTION_NAMES.cpp_link_static_library],
  671. flag_groups = [flag_group(flags = ["/ignore:4221"])],
  672. ),
  673. ],
  674. )
  675. no_legacy_features_feature = feature(name = "no_legacy_features")
  676. parse_showincludes_feature = feature(
  677. name = "parse_showincludes",
  678. flag_sets = [
  679. flag_set(
  680. actions = [
  681. ACTION_NAMES.preprocess_assemble,
  682. ACTION_NAMES.c_compile,
  683. ACTION_NAMES.cpp_compile,
  684. ACTION_NAMES.cpp_module_compile,
  685. ACTION_NAMES.cpp_header_parsing,
  686. ],
  687. flag_groups = [flag_group(flags = ["/showIncludes"])],
  688. ),
  689. ],
  690. )
  691. static_link_msvcrt_no_debug_feature = feature(
  692. name = "static_link_msvcrt_no_debug",
  693. flag_sets = [
  694. flag_set(
  695. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  696. flag_groups = [flag_group(flags = ["/MT"])],
  697. ),
  698. flag_set(
  699. actions = all_link_actions,
  700. flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])],
  701. ),
  702. ],
  703. requires = [
  704. feature_set(features = ["fastbuild"]),
  705. feature_set(features = ["opt"]),
  706. ],
  707. )
  708. treat_warnings_as_errors_feature = feature(
  709. name = "treat_warnings_as_errors",
  710. flag_sets = [
  711. flag_set(
  712. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  713. flag_groups = [flag_group(flags = ["/WX"])],
  714. ),
  715. ],
  716. )
  717. windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols")
  718. no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols")
  719. include_paths_feature = feature(
  720. name = "include_paths",
  721. enabled = True,
  722. flag_sets = [
  723. flag_set(
  724. actions = [
  725. ACTION_NAMES.assemble,
  726. ACTION_NAMES.preprocess_assemble,
  727. ACTION_NAMES.c_compile,
  728. ACTION_NAMES.cpp_compile,
  729. ACTION_NAMES.cpp_header_parsing,
  730. ACTION_NAMES.cpp_module_compile,
  731. ],
  732. flag_groups = [
  733. flag_group(
  734. flags = ["/I%{quote_include_paths}"],
  735. iterate_over = "quote_include_paths",
  736. ),
  737. flag_group(
  738. flags = ["/I%{include_paths}"],
  739. iterate_over = "include_paths",
  740. ),
  741. flag_group(
  742. flags = ["/I%{system_include_paths}"],
  743. iterate_over = "system_include_paths",
  744. ),
  745. ],
  746. ),
  747. ],
  748. )
  749. linkstamps_feature = feature(
  750. name = "linkstamps",
  751. flag_sets = [
  752. flag_set(
  753. actions = all_link_actions,
  754. flag_groups = [
  755. flag_group(
  756. flags = ["%{linkstamp_paths}"],
  757. iterate_over = "linkstamp_paths",
  758. expand_if_available = "linkstamp_paths",
  759. ),
  760. ],
  761. ),
  762. ],
  763. )
  764. targets_windows_feature = feature(
  765. name = "targets_windows",
  766. enabled = True,
  767. implies = ["copy_dynamic_libraries_to_binary"],
  768. )
  769. linker_subsystem_flag_feature = feature(
  770. name = "linker_subsystem_flag",
  771. flag_sets = [
  772. flag_set(
  773. actions = all_link_actions,
  774. flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])],
  775. ),
  776. ],
  777. )
  778. static_link_msvcrt_debug_feature = feature(
  779. name = "static_link_msvcrt_debug",
  780. flag_sets = [
  781. flag_set(
  782. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  783. flag_groups = [flag_group(flags = ["/MTd"])],
  784. ),
  785. flag_set(
  786. actions = all_link_actions,
  787. flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])],
  788. ),
  789. ],
  790. requires = [feature_set(features = ["dbg"])],
  791. )
  792. frame_pointer_feature = feature(
  793. name = "frame_pointer",
  794. flag_sets = [
  795. flag_set(
  796. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  797. flag_groups = [flag_group(flags = ["/Oy-"])],
  798. ),
  799. ],
  800. )
  801. compiler_output_flags_feature = feature(
  802. name = "compiler_output_flags",
  803. flag_sets = [
  804. flag_set(
  805. actions = [ACTION_NAMES.assemble],
  806. flag_groups = [
  807. flag_group(
  808. flag_groups = [
  809. flag_group(
  810. flags = ["/Fo%{output_file}", "/Zi"],
  811. expand_if_available = "output_file",
  812. expand_if_not_available = "output_assembly_file",
  813. ),
  814. ],
  815. expand_if_not_available = "output_preprocess_file",
  816. ),
  817. ],
  818. ),
  819. flag_set(
  820. actions = [
  821. ACTION_NAMES.preprocess_assemble,
  822. ACTION_NAMES.c_compile,
  823. ACTION_NAMES.cpp_compile,
  824. ACTION_NAMES.cpp_header_parsing,
  825. ACTION_NAMES.cpp_module_compile,
  826. ACTION_NAMES.cpp_module_codegen,
  827. ],
  828. flag_groups = [
  829. flag_group(
  830. flag_groups = [
  831. flag_group(
  832. flags = ["/Fo%{output_file}"],
  833. expand_if_not_available = "output_preprocess_file",
  834. ),
  835. ],
  836. expand_if_available = "output_file",
  837. expand_if_not_available = "output_assembly_file",
  838. ),
  839. flag_group(
  840. flag_groups = [
  841. flag_group(
  842. flags = ["/Fa%{output_file}"],
  843. expand_if_available = "output_assembly_file",
  844. ),
  845. ],
  846. expand_if_available = "output_file",
  847. ),
  848. flag_group(
  849. flag_groups = [
  850. flag_group(
  851. flags = ["/P", "/Fi%{output_file}"],
  852. expand_if_available = "output_preprocess_file",
  853. ),
  854. ],
  855. expand_if_available = "output_file",
  856. ),
  857. ],
  858. ),
  859. ],
  860. )
  861. nologo_feature = feature(
  862. name = "nologo",
  863. flag_sets = [
  864. flag_set(
  865. actions = [
  866. ACTION_NAMES.c_compile,
  867. ACTION_NAMES.cpp_compile,
  868. ACTION_NAMES.cpp_module_compile,
  869. ACTION_NAMES.cpp_module_codegen,
  870. ACTION_NAMES.cpp_header_parsing,
  871. ACTION_NAMES.assemble,
  872. ACTION_NAMES.preprocess_assemble,
  873. ACTION_NAMES.cpp_link_executable,
  874. ACTION_NAMES.cpp_link_dynamic_library,
  875. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  876. ACTION_NAMES.cpp_link_static_library,
  877. ],
  878. flag_groups = [flag_group(flags = ["/nologo"])],
  879. ),
  880. ],
  881. )
  882. smaller_binary_feature = feature(
  883. name = "smaller_binary",
  884. enabled = True,
  885. flag_sets = [
  886. flag_set(
  887. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  888. flag_groups = [flag_group(flags = ["/Gy", "/Gw"])],
  889. with_features = [with_feature_set(features = ["opt"])],
  890. ),
  891. flag_set(
  892. actions = all_link_actions,
  893. flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])],
  894. with_features = [with_feature_set(features = ["opt"])],
  895. ),
  896. ],
  897. )
  898. compiler_input_flags_feature = feature(
  899. name = "compiler_input_flags",
  900. flag_sets = [
  901. flag_set(
  902. actions = [
  903. ACTION_NAMES.assemble,
  904. ACTION_NAMES.preprocess_assemble,
  905. ACTION_NAMES.c_compile,
  906. ACTION_NAMES.cpp_compile,
  907. ACTION_NAMES.cpp_header_parsing,
  908. ACTION_NAMES.cpp_module_compile,
  909. ACTION_NAMES.cpp_module_codegen,
  910. ],
  911. flag_groups = [
  912. flag_group(
  913. flags = ["/c", "%{source_file}"],
  914. expand_if_available = "source_file",
  915. ),
  916. ],
  917. ),
  918. ],
  919. )
  920. def_file_feature = feature(
  921. name = "def_file",
  922. flag_sets = [
  923. flag_set(
  924. actions = all_link_actions,
  925. flag_groups = [
  926. flag_group(
  927. flags = ["/DEF:%{def_file_path}", "/ignore:4070"],
  928. expand_if_available = "def_file_path",
  929. ),
  930. ],
  931. ),
  932. ],
  933. )
  934. msvc_env_feature = feature(
  935. name = "msvc_env",
  936. env_sets = [
  937. env_set(
  938. actions = [
  939. ACTION_NAMES.c_compile,
  940. ACTION_NAMES.cpp_compile,
  941. ACTION_NAMES.cpp_module_compile,
  942. ACTION_NAMES.cpp_module_codegen,
  943. ACTION_NAMES.cpp_header_parsing,
  944. ACTION_NAMES.assemble,
  945. ACTION_NAMES.preprocess_assemble,
  946. ACTION_NAMES.cpp_link_executable,
  947. ACTION_NAMES.cpp_link_dynamic_library,
  948. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  949. ACTION_NAMES.cpp_link_static_library,
  950. ],
  951. env_entries = [
  952. env_entry(key = "PATH", value = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\8.1\\bin\\x86;;C:\\Windows\\system32"),
  953. env_entry(key = "TMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"),
  954. env_entry(key = "TEMP", value = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp"),
  955. ],
  956. ),
  957. ],
  958. implies = ["msvc_compile_env", "msvc_link_env"],
  959. )
  960. features = [
  961. no_legacy_features_feature,
  962. nologo_feature,
  963. has_configured_linker_path_feature,
  964. no_stripping_feature,
  965. targets_windows_feature,
  966. copy_dynamic_libraries_to_binary_feature,
  967. default_compile_flags_feature,
  968. msvc_env_feature,
  969. msvc_compile_env_feature,
  970. msvc_link_env_feature,
  971. include_paths_feature,
  972. preprocessor_defines_feature,
  973. parse_showincludes_feature,
  974. generate_pdb_file_feature,
  975. shared_flag_feature,
  976. linkstamps_feature,
  977. output_execpath_flags_feature,
  978. archiver_flags_feature,
  979. input_param_flags_feature,
  980. linker_subsystem_flag_feature,
  981. user_link_flags_feature,
  982. default_link_flags_feature,
  983. linker_param_file_feature,
  984. static_link_msvcrt_feature,
  985. static_link_msvcrt_no_debug_feature,
  986. dynamic_link_msvcrt_no_debug_feature,
  987. static_link_msvcrt_debug_feature,
  988. dynamic_link_msvcrt_debug_feature,
  989. dbg_feature,
  990. fastbuild_feature,
  991. opt_feature,
  992. frame_pointer_feature,
  993. disable_assertions_feature,
  994. determinism_feature,
  995. treat_warnings_as_errors_feature,
  996. smaller_binary_feature,
  997. ignore_noisy_warnings_feature,
  998. user_compile_flags_feature,
  999. sysroot_feature,
  1000. unfiltered_compile_flags_feature,
  1001. compiler_param_file_feature,
  1002. compiler_output_flags_feature,
  1003. compiler_input_flags_feature,
  1004. def_file_feature,
  1005. windows_export_all_symbols_feature,
  1006. no_windows_export_all_symbols_feature,
  1007. supports_dynamic_linker_feature,
  1008. supports_interface_shared_libraries_feature,
  1009. ]
  1010. artifact_name_patterns = [
  1011. artifact_name_pattern(
  1012. category_name = "object_file",
  1013. prefix = "",
  1014. extension = ".obj",
  1015. ),
  1016. artifact_name_pattern(
  1017. category_name = "static_library",
  1018. prefix = "",
  1019. extension = ".lib",
  1020. ),
  1021. artifact_name_pattern(
  1022. category_name = "alwayslink_static_library",
  1023. prefix = "",
  1024. extension = ".lo.lib",
  1025. ),
  1026. artifact_name_pattern(
  1027. category_name = "executable",
  1028. prefix = "",
  1029. extension = ".exe",
  1030. ),
  1031. artifact_name_pattern(
  1032. category_name = "dynamic_library",
  1033. prefix = "",
  1034. extension = ".dll",
  1035. ),
  1036. artifact_name_pattern(
  1037. category_name = "interface_library",
  1038. prefix = "",
  1039. extension = ".if.lib",
  1040. ),
  1041. ]
  1042. make_variables = []
  1043. tool_paths = [
  1044. tool_path(name = "ar", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/lib.exe"),
  1045. tool_path(name = "ml", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe"),
  1046. tool_path(name = "cpp", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"),
  1047. tool_path(name = "gcc", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe"),
  1048. tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"),
  1049. tool_path(name = "ld", path = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe"),
  1050. tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"),
  1051. tool_path(
  1052. name = "objcopy",
  1053. path = "wrapper/bin/msvc_nop.bat",
  1054. ),
  1055. tool_path(
  1056. name = "objdump",
  1057. path = "wrapper/bin/msvc_nop.bat",
  1058. ),
  1059. tool_path(
  1060. name = "strip",
  1061. path = "wrapper/bin/msvc_nop.bat",
  1062. ),
  1063. ]
  1064. return cc_common.create_cc_toolchain_config_info(
  1065. ctx = ctx,
  1066. features = features,
  1067. action_configs = action_configs,
  1068. artifact_name_patterns = artifact_name_patterns,
  1069. cxx_builtin_include_directories = cxx_builtin_include_directories,
  1070. toolchain_identifier = toolchain_identifier,
  1071. host_system_name = host_system_name,
  1072. target_system_name = target_system_name,
  1073. target_cpu = target_cpu,
  1074. target_libc = target_libc,
  1075. compiler = compiler,
  1076. abi_version = abi_version,
  1077. abi_libc_version = abi_libc_version,
  1078. tool_paths = tool_paths,
  1079. make_variables = make_variables,
  1080. builtin_sysroot = builtin_sysroot,
  1081. cc_target_os = None,
  1082. )
  1083. def _windows_msys_mingw_impl(ctx):
  1084. toolchain_identifier = "msys_x64_mingw"
  1085. host_system_name = "local"
  1086. target_system_name = "local"
  1087. target_cpu = "x64_windows"
  1088. target_libc = "mingw"
  1089. compiler = "mingw-gcc"
  1090. abi_version = "local"
  1091. abi_libc_version = "local"
  1092. cc_target_os = None
  1093. builtin_sysroot = None
  1094. action_configs = []
  1095. targets_windows_feature = feature(
  1096. name = "targets_windows",
  1097. implies = ["copy_dynamic_libraries_to_binary"],
  1098. enabled = True,
  1099. )
  1100. copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
  1101. gcc_env_feature = feature(
  1102. name = "gcc_env",
  1103. enabled = True,
  1104. env_sets = [
  1105. env_set(
  1106. actions = [
  1107. ACTION_NAMES.c_compile,
  1108. ACTION_NAMES.cpp_compile,
  1109. ACTION_NAMES.cpp_module_compile,
  1110. ACTION_NAMES.cpp_module_codegen,
  1111. ACTION_NAMES.cpp_header_parsing,
  1112. ACTION_NAMES.assemble,
  1113. ACTION_NAMES.preprocess_assemble,
  1114. ACTION_NAMES.cpp_link_executable,
  1115. ACTION_NAMES.cpp_link_dynamic_library,
  1116. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1117. ACTION_NAMES.cpp_link_static_library,
  1118. ],
  1119. env_entries = [
  1120. env_entry(key = "PATH", value = "c:/tools/msys64/mingw64/bin"),
  1121. ],
  1122. ),
  1123. ],
  1124. )
  1125. msys_mingw_flags = [
  1126. "-std=gnu++0x",
  1127. ]
  1128. msys_mingw_link_flags = [
  1129. "-lstdc++",
  1130. ]
  1131. default_compile_flags_feature = feature(
  1132. name = "default_compile_flags",
  1133. enabled = True,
  1134. flag_sets = [
  1135. flag_set(
  1136. actions = [
  1137. ACTION_NAMES.assemble,
  1138. ACTION_NAMES.preprocess_assemble,
  1139. ACTION_NAMES.linkstamp_compile,
  1140. ACTION_NAMES.c_compile,
  1141. ACTION_NAMES.cpp_compile,
  1142. ACTION_NAMES.cpp_header_parsing,
  1143. ACTION_NAMES.cpp_module_compile,
  1144. ACTION_NAMES.cpp_module_codegen,
  1145. ACTION_NAMES.lto_backend,
  1146. ACTION_NAMES.clif_match,
  1147. ],
  1148. ),
  1149. flag_set(
  1150. actions = [
  1151. ACTION_NAMES.linkstamp_compile,
  1152. ACTION_NAMES.cpp_compile,
  1153. ACTION_NAMES.cpp_header_parsing,
  1154. ACTION_NAMES.cpp_module_compile,
  1155. ACTION_NAMES.cpp_module_codegen,
  1156. ACTION_NAMES.lto_backend,
  1157. ACTION_NAMES.clif_match,
  1158. ],
  1159. flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []),
  1160. ),
  1161. ],
  1162. )
  1163. compiler_param_file_feature = feature(
  1164. name = "compiler_param_file",
  1165. )
  1166. default_link_flags_feature = feature(
  1167. name = "default_link_flags",
  1168. enabled = True,
  1169. flag_sets = [
  1170. flag_set(
  1171. actions = all_link_actions,
  1172. flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []),
  1173. ),
  1174. ],
  1175. )
  1176. supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1177. features = [
  1178. targets_windows_feature,
  1179. copy_dynamic_libraries_to_binary_feature,
  1180. gcc_env_feature,
  1181. default_compile_flags_feature,
  1182. compiler_param_file_feature,
  1183. default_link_flags_feature,
  1184. supports_dynamic_linker_feature,
  1185. ]
  1186. cxx_builtin_include_directories = [
  1187. # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087.
  1188. "C:\\botcode\\w",
  1189. "c:/tools/msys64/mingw64/",
  1190. "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE",
  1191. "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt",
  1192. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared",
  1193. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um",
  1194. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt",
  1195. ]
  1196. artifact_name_patterns = [
  1197. artifact_name_pattern(
  1198. category_name = "executable",
  1199. prefix = "",
  1200. extension = ".exe",
  1201. ),
  1202. ]
  1203. make_variables = []
  1204. tool_paths = [
  1205. tool_path(name = "ar", path = "c:/tools/msys64/mingw64/bin/ar"),
  1206. tool_path(name = "compat-ld", path = "c:/tools/msys64/mingw64/bin/ld"),
  1207. tool_path(name = "cpp", path = "c:/tools/msys64/mingw64/bin/cpp"),
  1208. tool_path(name = "dwp", path = "c:/tools/msys64/mingw64/bin/dwp"),
  1209. tool_path(name = "gcc", path = "c:/tools/msys64/mingw64/bin/gcc"),
  1210. tool_path(name = "gcov", path = "c:/tools/msys64/mingw64/bin/gcov"),
  1211. tool_path(name = "ld", path = "c:/tools/msys64/mingw64/bin/ld"),
  1212. tool_path(name = "nm", path = "c:/tools/msys64/mingw64/bin/nm"),
  1213. tool_path(name = "objcopy", path = "c:/tools/msys64/mingw64/bin/objcopy"),
  1214. tool_path(name = "objdump", path = "c:/tools/msys64/mingw64/bin/objdump"),
  1215. tool_path(name = "strip", path = "c:/tools/msys64/mingw64/bin/strip"),
  1216. ]
  1217. return cc_common.create_cc_toolchain_config_info(
  1218. ctx = ctx,
  1219. features = features,
  1220. action_configs = action_configs,
  1221. artifact_name_patterns = artifact_name_patterns,
  1222. cxx_builtin_include_directories = cxx_builtin_include_directories,
  1223. toolchain_identifier = toolchain_identifier,
  1224. host_system_name = host_system_name,
  1225. target_system_name = target_system_name,
  1226. target_cpu = target_cpu,
  1227. target_libc = target_libc,
  1228. compiler = compiler,
  1229. abi_version = abi_version,
  1230. abi_libc_version = abi_libc_version,
  1231. tool_paths = tool_paths,
  1232. make_variables = make_variables,
  1233. builtin_sysroot = builtin_sysroot,
  1234. cc_target_os = cc_target_os,
  1235. )
  1236. def _armeabi_impl(ctx):
  1237. toolchain_identifier = "stub_armeabi-v7a"
  1238. host_system_name = "armeabi-v7a"
  1239. target_system_name = "armeabi-v7a"
  1240. target_cpu = "armeabi-v7a"
  1241. target_libc = "armeabi-v7a"
  1242. compiler = "compiler"
  1243. abi_version = "armeabi-v7a"
  1244. abi_libc_version = "armeabi-v7a"
  1245. cc_target_os = None
  1246. builtin_sysroot = None
  1247. action_configs = []
  1248. supports_pic_feature = feature(name = "supports_pic", enabled = True)
  1249. supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1250. features = [supports_dynamic_linker_feature, supports_pic_feature]
  1251. cxx_builtin_include_directories = [
  1252. # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087.
  1253. "C:\\botcode\\w",
  1254. ]
  1255. artifact_name_patterns = []
  1256. make_variables = []
  1257. tool_paths = [
  1258. tool_path(name = "ar", path = "/bin/false"),
  1259. tool_path(name = "compat-ld", path = "/bin/false"),
  1260. tool_path(name = "cpp", path = "/bin/false"),
  1261. tool_path(name = "dwp", path = "/bin/false"),
  1262. tool_path(name = "gcc", path = "/bin/false"),
  1263. tool_path(name = "gcov", path = "/bin/false"),
  1264. tool_path(name = "ld", path = "/bin/false"),
  1265. tool_path(name = "nm", path = "/bin/false"),
  1266. tool_path(name = "objcopy", path = "/bin/false"),
  1267. tool_path(name = "objdump", path = "/bin/false"),
  1268. tool_path(name = "strip", path = "/bin/false"),
  1269. ]
  1270. return cc_common.create_cc_toolchain_config_info(
  1271. ctx = ctx,
  1272. features = features,
  1273. action_configs = action_configs,
  1274. artifact_name_patterns = artifact_name_patterns,
  1275. cxx_builtin_include_directories = cxx_builtin_include_directories,
  1276. toolchain_identifier = toolchain_identifier,
  1277. host_system_name = host_system_name,
  1278. target_system_name = target_system_name,
  1279. target_cpu = target_cpu,
  1280. target_libc = target_libc,
  1281. compiler = compiler,
  1282. abi_version = abi_version,
  1283. abi_libc_version = abi_libc_version,
  1284. tool_paths = tool_paths,
  1285. make_variables = make_variables,
  1286. builtin_sysroot = builtin_sysroot,
  1287. cc_target_os = cc_target_os,
  1288. )
  1289. def _impl(ctx):
  1290. if ctx.attr.cpu == "armeabi-v7a":
  1291. return _armeabi_impl(ctx)
  1292. elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "msvc-cl":
  1293. return _windows_msvc_impl(ctx)
  1294. elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc":
  1295. return _windows_msys_mingw_impl(ctx)
  1296. tool_paths = [
  1297. tool_path(name = "ar", path = "c:/tools/msys64/usr/bin/ar"),
  1298. tool_path(name = "compat-ld", path = "c:/tools/msys64/usr/bin/ld"),
  1299. tool_path(name = "cpp", path = "c:/tools/msys64/usr/bin/cpp"),
  1300. tool_path(name = "dwp", path = "c:/tools/msys64/usr/bin/dwp"),
  1301. tool_path(name = "gcc", path = "c:/tools/msys64/usr/bin/gcc"),
  1302. tool_path(name = "gcov", path = "c:/tools/msys64/usr/bin/gcov"),
  1303. tool_path(name = "ld", path = "c:/tools/msys64/usr/bin/ld"),
  1304. tool_path(name = "nm", path = "c:/tools/msys64/usr/bin/nm"),
  1305. tool_path(name = "objcopy", path = "c:/tools/msys64/usr/bin/objcopy"),
  1306. tool_path(name = "objdump", path = "c:/tools/msys64/usr/bin/objdump"),
  1307. tool_path(name = "strip", path = "c:/tools/msys64/usr/bin/strip"),
  1308. ]
  1309. cxx_builtin_include_directories = [
  1310. # This is a workaround for https://github.com/bazelbuild/bazel/issues/5087.
  1311. "C:\\botcode\\w",
  1312. "c:/tools/msys64/usr/",
  1313. "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE",
  1314. "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt",
  1315. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared",
  1316. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um",
  1317. "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt",
  1318. ]
  1319. action_configs = []
  1320. compile_flags = [
  1321. ]
  1322. dbg_compile_flags = [
  1323. ]
  1324. opt_compile_flags = [
  1325. ]
  1326. cxx_flags = [
  1327. "-std=gnu++0x",
  1328. ]
  1329. link_flags = [
  1330. "-lstdc++",
  1331. ]
  1332. opt_link_flags = [
  1333. ]
  1334. unfiltered_compile_flags = [
  1335. ]
  1336. targets_windows_feature = feature(
  1337. name = "targets_windows",
  1338. implies = ["copy_dynamic_libraries_to_binary"],
  1339. enabled = True,
  1340. )
  1341. copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
  1342. gcc_env_feature = feature(
  1343. name = "gcc_env",
  1344. enabled = True,
  1345. env_sets = [
  1346. env_set(
  1347. actions = [
  1348. ACTION_NAMES.c_compile,
  1349. ACTION_NAMES.cpp_compile,
  1350. ACTION_NAMES.cpp_module_compile,
  1351. ACTION_NAMES.cpp_module_codegen,
  1352. ACTION_NAMES.cpp_header_parsing,
  1353. ACTION_NAMES.assemble,
  1354. ACTION_NAMES.preprocess_assemble,
  1355. ACTION_NAMES.cpp_link_executable,
  1356. ACTION_NAMES.cpp_link_dynamic_library,
  1357. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1358. ACTION_NAMES.cpp_link_static_library,
  1359. ],
  1360. env_entries = [
  1361. env_entry(key = "PATH", value = "c:/tools/msys64/usr/bin"),
  1362. ],
  1363. ),
  1364. ],
  1365. )
  1366. windows_features = [
  1367. targets_windows_feature,
  1368. copy_dynamic_libraries_to_binary_feature,
  1369. gcc_env_feature,
  1370. ]
  1371. supports_pic_feature = feature(
  1372. name = "supports_pic",
  1373. enabled = True,
  1374. )
  1375. supports_start_end_lib_feature = feature(
  1376. name = "supports_start_end_lib",
  1377. enabled = True,
  1378. )
  1379. default_compile_flags_feature = feature(
  1380. name = "default_compile_flags",
  1381. enabled = True,
  1382. flag_sets = [
  1383. flag_set(
  1384. actions = [
  1385. ACTION_NAMES.assemble,
  1386. ACTION_NAMES.preprocess_assemble,
  1387. ACTION_NAMES.linkstamp_compile,
  1388. ACTION_NAMES.c_compile,
  1389. ACTION_NAMES.cpp_compile,
  1390. ACTION_NAMES.cpp_header_parsing,
  1391. ACTION_NAMES.cpp_module_compile,
  1392. ACTION_NAMES.cpp_module_codegen,
  1393. ACTION_NAMES.lto_backend,
  1394. ACTION_NAMES.clif_match,
  1395. ],
  1396. flag_groups = ([flag_group(flags = compile_flags)] if compile_flags else []),
  1397. ),
  1398. flag_set(
  1399. actions = [
  1400. ACTION_NAMES.assemble,
  1401. ACTION_NAMES.preprocess_assemble,
  1402. ACTION_NAMES.linkstamp_compile,
  1403. ACTION_NAMES.c_compile,
  1404. ACTION_NAMES.cpp_compile,
  1405. ACTION_NAMES.cpp_header_parsing,
  1406. ACTION_NAMES.cpp_module_compile,
  1407. ACTION_NAMES.cpp_module_codegen,
  1408. ACTION_NAMES.lto_backend,
  1409. ACTION_NAMES.clif_match,
  1410. ],
  1411. flag_groups = ([flag_group(flags = dbg_compile_flags)] if dbg_compile_flags else []),
  1412. with_features = [with_feature_set(features = ["dbg"])],
  1413. ),
  1414. flag_set(
  1415. actions = [
  1416. ACTION_NAMES.assemble,
  1417. ACTION_NAMES.preprocess_assemble,
  1418. ACTION_NAMES.linkstamp_compile,
  1419. ACTION_NAMES.c_compile,
  1420. ACTION_NAMES.cpp_compile,
  1421. ACTION_NAMES.cpp_header_parsing,
  1422. ACTION_NAMES.cpp_module_compile,
  1423. ACTION_NAMES.cpp_module_codegen,
  1424. ACTION_NAMES.lto_backend,
  1425. ACTION_NAMES.clif_match,
  1426. ],
  1427. flag_groups = ([flag_group(flags = opt_compile_flags)] if opt_compile_flags else []),
  1428. with_features = [with_feature_set(features = ["opt"])],
  1429. ),
  1430. flag_set(
  1431. actions = [
  1432. ACTION_NAMES.linkstamp_compile,
  1433. ACTION_NAMES.cpp_compile,
  1434. ACTION_NAMES.cpp_header_parsing,
  1435. ACTION_NAMES.cpp_module_compile,
  1436. ACTION_NAMES.cpp_module_codegen,
  1437. ACTION_NAMES.lto_backend,
  1438. ACTION_NAMES.clif_match,
  1439. ],
  1440. flag_groups = ([flag_group(flags = cxx_flags)] if cxx_flags else []),
  1441. ),
  1442. ],
  1443. )
  1444. default_link_flags_feature = feature(
  1445. name = "default_link_flags",
  1446. enabled = True,
  1447. flag_sets = [
  1448. flag_set(
  1449. actions = all_link_actions,
  1450. flag_groups = ([flag_group(flags = link_flags)] if link_flags else []),
  1451. ),
  1452. flag_set(
  1453. actions = all_link_actions,
  1454. flag_groups = ([flag_group(flags = opt_link_flags)] if opt_link_flags else []),
  1455. with_features = [with_feature_set(features = ["opt"])],
  1456. ),
  1457. ],
  1458. )
  1459. dbg_feature = feature(name = "dbg")
  1460. opt_feature = feature(name = "opt")
  1461. sysroot_feature = feature(
  1462. name = "sysroot",
  1463. enabled = True,
  1464. flag_sets = [
  1465. flag_set(
  1466. actions = [
  1467. ACTION_NAMES.preprocess_assemble,
  1468. ACTION_NAMES.linkstamp_compile,
  1469. ACTION_NAMES.c_compile,
  1470. ACTION_NAMES.cpp_compile,
  1471. ACTION_NAMES.cpp_header_parsing,
  1472. ACTION_NAMES.cpp_module_compile,
  1473. ACTION_NAMES.cpp_module_codegen,
  1474. ACTION_NAMES.lto_backend,
  1475. ACTION_NAMES.clif_match,
  1476. ACTION_NAMES.cpp_link_executable,
  1477. ACTION_NAMES.cpp_link_dynamic_library,
  1478. ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1479. ],
  1480. flag_groups = [
  1481. flag_group(
  1482. flags = ["--sysroot=%{sysroot}"],
  1483. expand_if_available = "sysroot",
  1484. ),
  1485. ],
  1486. ),
  1487. ],
  1488. )
  1489. fdo_optimize_feature = feature(
  1490. name = "fdo_optimize",
  1491. flag_sets = [
  1492. flag_set(
  1493. actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  1494. flag_groups = [
  1495. flag_group(
  1496. flags = [
  1497. "-fprofile-use=%{fdo_profile_path}",
  1498. "-fprofile-correction",
  1499. ],
  1500. expand_if_available = "fdo_profile_path",
  1501. ),
  1502. ],
  1503. ),
  1504. ],
  1505. provides = ["profile"],
  1506. )
  1507. supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1508. user_compile_flags_feature = feature(
  1509. name = "user_compile_flags",
  1510. enabled = True,
  1511. flag_sets = [
  1512. flag_set(
  1513. actions = [
  1514. ACTION_NAMES.assemble,
  1515. ACTION_NAMES.preprocess_assemble,
  1516. ACTION_NAMES.linkstamp_compile,
  1517. ACTION_NAMES.c_compile,
  1518. ACTION_NAMES.cpp_compile,
  1519. ACTION_NAMES.cpp_header_parsing,
  1520. ACTION_NAMES.cpp_module_compile,
  1521. ACTION_NAMES.cpp_module_codegen,
  1522. ACTION_NAMES.lto_backend,
  1523. ACTION_NAMES.clif_match,
  1524. ],
  1525. flag_groups = [
  1526. flag_group(
  1527. flags = ["%{user_compile_flags}"],
  1528. iterate_over = "user_compile_flags",
  1529. expand_if_available = "user_compile_flags",
  1530. ),
  1531. ],
  1532. ),
  1533. ],
  1534. )
  1535. unfiltered_compile_flags_feature = feature(
  1536. name = "unfiltered_compile_flags",
  1537. enabled = True,
  1538. flag_sets = [
  1539. flag_set(
  1540. actions = [
  1541. ACTION_NAMES.assemble,
  1542. ACTION_NAMES.preprocess_assemble,
  1543. ACTION_NAMES.linkstamp_compile,
  1544. ACTION_NAMES.c_compile,
  1545. ACTION_NAMES.cpp_compile,
  1546. ACTION_NAMES.cpp_header_parsing,
  1547. ACTION_NAMES.cpp_module_compile,
  1548. ACTION_NAMES.cpp_module_codegen,
  1549. ACTION_NAMES.lto_backend,
  1550. ACTION_NAMES.clif_match,
  1551. ],
  1552. flag_groups = ([flag_group(flags = unfiltered_compile_flags)] if unfiltered_compile_flags else []),
  1553. ),
  1554. ],
  1555. )
  1556. features = windows_features + [
  1557. supports_pic_feature,
  1558. default_compile_flags_feature,
  1559. default_link_flags_feature,
  1560. fdo_optimize_feature,
  1561. supports_dynamic_linker_feature,
  1562. dbg_feature,
  1563. opt_feature,
  1564. user_compile_flags_feature,
  1565. sysroot_feature,
  1566. unfiltered_compile_flags_feature,
  1567. ]
  1568. artifact_name_patterns = [
  1569. artifact_name_pattern(category_name = "executable", prefix = "", extension = ".exe"),
  1570. ]
  1571. make_variables = []
  1572. return cc_common.create_cc_toolchain_config_info(
  1573. ctx = ctx,
  1574. features = features,
  1575. action_configs = action_configs,
  1576. artifact_name_patterns = artifact_name_patterns,
  1577. cxx_builtin_include_directories = cxx_builtin_include_directories,
  1578. toolchain_identifier = "msys_x64",
  1579. host_system_name = "local",
  1580. target_system_name = "local",
  1581. target_cpu = "x64_windows",
  1582. target_libc = "msys",
  1583. compiler = "msys-gcc",
  1584. abi_version = "local",
  1585. abi_libc_version = "local",
  1586. tool_paths = tool_paths,
  1587. make_variables = make_variables,
  1588. builtin_sysroot = "",
  1589. cc_target_os = None,
  1590. )
  1591. cc_toolchain_config = rule(
  1592. implementation = _impl,
  1593. attrs = {
  1594. "cpu": attr.string(mandatory = True),
  1595. "compiler": attr.string(),
  1596. },
  1597. provides = [CcToolchainConfigInfo],
  1598. )