BUILD 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. # Build rules supporting the install data tree for the Carbon toolchain.
  6. #
  7. # This populates a synthetic Carbon toolchain installation rooted at this
  8. # package in the output tree.
  9. #
  10. # We use a `toolchain_files` rule organize the files in in the installation and
  11. # handle cases where we need to symlink existing files or build outputs
  12. # into the correct location.
  13. #
  14. # This package also includes the logic for building Carbon's runtimes, and Bazel
  15. # `cc_toolchain`s for using the installation as a C++ toolchain in Bazel. This
  16. # allows multi-stage bootstrapping to occur entirely within Bazel. Note that the
  17. # specific stage will be in a _configuration specific_ output tree, but always
  18. # rooted under the install package.
  19. #
  20. # Last but ont least, we provide rules to build packages of the installation in
  21. # conventional layouts for directly extracting and using a binary build. The
  22. # packaged installation includes custom Bazel files to handle a pre-built and
  23. # installed toolchain in the same way as these handle the just-built toolchain.
  24. load(
  25. "@llvm-project//:vars.bzl",
  26. "LLVM_VERSION_MAJOR",
  27. )
  28. load(
  29. "@llvm-project//compiler-rt:compiler-rt.bzl",
  30. "builtins_copts",
  31. "crt_copts",
  32. )
  33. load("@llvm-project//libcxx:libcxx_library.bzl", "libcxx_and_abi_copts")
  34. load("@llvm-project//libunwind:libunwind_library.bzl", "libunwind_copts")
  35. load("@rules_python//python:defs.bzl", "py_test")
  36. load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
  37. load(
  38. "//bazel/cc_toolchains:carbon_cc_toolchain_config.bzl",
  39. "carbon_cc_toolchain_suite",
  40. "filegroup_with_stage",
  41. )
  42. load("//bazel/manifest:defs.bzl", "manifest")
  43. load(
  44. "//toolchain/base:runtimes_build_info.bzl",
  45. "generate_runtimes_build_vars",
  46. )
  47. load("//toolchain/runtimes:carbon_runtimes.bzl", "carbon_runtimes_config")
  48. load("bazel/make_include_copts.bzl", "make_include_copts")
  49. load(
  50. "install_filegroups.bzl",
  51. "filtered_toolchain_files",
  52. "toolchain_files",
  53. "toolchain_llvm_binaries",
  54. "toolchain_pkg_filegroup",
  55. )
  56. load("pkg_helpers.bzl", "pkg_naming_variables", "pkg_tar_and_test")
  57. package(default_visibility = ["//visibility:public"])
  58. config_setting(
  59. name = "is_runtimes_build",
  60. flag_values = {"//:runtimes_build": "True"},
  61. )
  62. config_setting(
  63. name = "not_runtimes_build",
  64. flag_values = {"//:runtimes_build": "False"},
  65. )
  66. config_setting(
  67. name = "is_bootstrap_stage_0",
  68. flag_values = {"//:bootstrap_stage": "0"},
  69. )
  70. config_setting(
  71. name = "is_bootstrap_stage_1",
  72. flag_values = {"//:bootstrap_stage": "1"},
  73. )
  74. config_setting(
  75. name = "is_bootstrap_stage_2",
  76. flag_values = {"//:bootstrap_stage": "2"},
  77. )
  78. cc_library(
  79. name = "busybox_info",
  80. srcs = ["busybox_info.cpp"],
  81. hdrs = ["busybox_info.h"],
  82. deps = [
  83. "//common:error",
  84. "//common:exe_path",
  85. "//common:filesystem",
  86. "@llvm-project//llvm:Support",
  87. ],
  88. )
  89. cc_test(
  90. name = "busybox_info_test",
  91. size = "small",
  92. srcs = ["busybox_info_test.cpp"],
  93. deps = [
  94. ":busybox_info",
  95. "//common:check",
  96. "//common:filesystem",
  97. "//testing/base:gtest_main",
  98. "@googletest//:gtest",
  99. "@llvm-project//llvm:Support",
  100. ],
  101. )
  102. # This target doesn't include prelude libraries. To get a target that has the
  103. # prelude available, use //toolchain.
  104. cc_binary(
  105. name = "carbon-busybox",
  106. srcs = ["busybox_main.cpp"],
  107. deps = [
  108. ":busybox_info",
  109. "//common:all_llvm_targets",
  110. "//common:bazel_working_dir",
  111. "//common:error",
  112. "//common:exe_path",
  113. "//common:init_llvm",
  114. "//common:version_stamp",
  115. "//toolchain/base:install_paths",
  116. "//toolchain/base:llvm_tools_def",
  117. "//toolchain/driver",
  118. "@llvm-project//clang:driver",
  119. "@llvm-project//llvm:Support",
  120. ],
  121. )
  122. toolchain_files(
  123. name = "install_marker",
  124. srcs = ["carbon_install.txt"],
  125. )
  126. toolchain_llvm_binaries(
  127. name = "llvm_bins",
  128. carbon_binary = ":carbon-busybox",
  129. )
  130. toolchain_files(
  131. name = "core",
  132. srcs = ["//core:prelude"],
  133. prefix = "core/",
  134. )
  135. toolchain_files(
  136. name = "clang_builtin_hdrs",
  137. srcs = ["@llvm-project//clang:builtin_headers_gen"],
  138. prefix = "llvm/lib/clang/{0}/include/".format(LLVM_VERSION_MAJOR),
  139. remove_prefix = "staging/include/",
  140. )
  141. toolchain_files(
  142. name = "fuzzer_runtime_hdrs",
  143. srcs = ["@llvm-project//compiler-rt:fuzzer_installed_hdrs"],
  144. prefix = "llvm/lib/clang/{0}/include/".format(LLVM_VERSION_MAJOR),
  145. remove_prefix = "include/",
  146. )
  147. toolchain_files(
  148. name = "profile_runtime_hdrs",
  149. srcs = ["@llvm-project//compiler-rt:profile_installed_hdrs"],
  150. prefix = "llvm/lib/clang/{0}/include/".format(LLVM_VERSION_MAJOR),
  151. remove_prefix = "include/",
  152. )
  153. toolchain_files(
  154. name = "sanitizer_runtime_hdrs",
  155. srcs = ["@llvm-project//compiler-rt:sanitizer_installed_hdrs"],
  156. prefix = "llvm/lib/clang/{0}/include/".format(LLVM_VERSION_MAJOR),
  157. remove_prefix = "include/",
  158. )
  159. filegroup(
  160. name = "clang_hdrs",
  161. srcs = [
  162. ":clang_builtin_hdrs",
  163. ":fuzzer_runtime_hdrs",
  164. ":profile_runtime_hdrs",
  165. ":sanitizer_runtime_hdrs",
  166. ],
  167. )
  168. filtered_toolchain_files(
  169. name = "builtins_srcs",
  170. prefix = "runtimes/builtins/",
  171. remove_prefix = "lib/builtins/",
  172. srcs_groups = [
  173. "@llvm-project//compiler-rt:builtins_aarch64_srcs",
  174. "@llvm-project//compiler-rt:builtins_aarch64_textual_srcs",
  175. "@llvm-project//compiler-rt:builtins_crtbegin_src",
  176. "@llvm-project//compiler-rt:builtins_crtend_src",
  177. "@llvm-project//compiler-rt:builtins_i386_srcs",
  178. "@llvm-project//compiler-rt:builtins_i386_textual_srcs",
  179. "@llvm-project//compiler-rt:builtins_x86_64_srcs",
  180. "@llvm-project//compiler-rt:builtins_x86_64_textual_srcs",
  181. ],
  182. )
  183. toolchain_files(
  184. name = "libcxx_basic_hdrs",
  185. srcs = ["@llvm-project//libcxx:libcxx_hdrs"],
  186. prefix = "runtimes/libcxx/include/",
  187. remove_prefix = "include/",
  188. )
  189. toolchain_files(
  190. name = "libcxx_gen_hdrs",
  191. srcs = ["//toolchain/runtimes:libcxx_gen_files"],
  192. prefix = "runtimes/libcxx/include/",
  193. remove_prefix = "staging_libcxx/include/",
  194. )
  195. filegroup(
  196. name = "libcxx_hdrs",
  197. srcs = [
  198. ":libcxx_basic_hdrs",
  199. ":libcxx_gen_hdrs",
  200. ],
  201. )
  202. filtered_toolchain_files(
  203. name = "libcxx_srcs",
  204. prefix = "runtimes/libcxx/src/",
  205. remove_prefix = "src/",
  206. srcs_groups = [
  207. "@llvm-project//libcxx:libcxx_linux_srcs",
  208. "@llvm-project//libcxx:libcxx_macos_srcs",
  209. "@llvm-project//libcxx:libcxx_win32_srcs",
  210. ],
  211. )
  212. toolchain_files(
  213. name = "libcxxabi_hdrs",
  214. srcs = ["@llvm-project//libcxxabi:libcxxabi_hdrs"],
  215. prefix = "runtimes/libcxxabi/include/",
  216. remove_prefix = "include/",
  217. )
  218. toolchain_files(
  219. name = "libcxxabi_srcs",
  220. srcs = ["@llvm-project//libcxxabi:libcxxabi_srcs"],
  221. prefix = "runtimes/libcxxabi/src/",
  222. remove_prefix = "src/",
  223. )
  224. toolchain_files(
  225. name = "libcxxabi_textual_srcs",
  226. srcs = ["@llvm-project//libcxxabi:libcxxabi_textual_srcs"],
  227. prefix = "runtimes/libcxxabi/src/",
  228. remove_prefix = "src/",
  229. )
  230. toolchain_files(
  231. name = "libc_internal_libcxx_hdrs",
  232. srcs = ["@llvm-project//libc:libcxx_shared_headers_hdrs"],
  233. prefix = "runtimes/libc/internal/",
  234. )
  235. toolchain_files(
  236. name = "libunwind_hdrs",
  237. srcs = ["@llvm-project//libunwind:libunwind_hdrs"],
  238. prefix = "runtimes/libunwind/include/",
  239. remove_prefix = "include/",
  240. )
  241. toolchain_files(
  242. name = "libunwind_srcs",
  243. srcs = ["@llvm-project//libunwind:libunwind_srcs"],
  244. prefix = "runtimes/libunwind/src/",
  245. remove_prefix = "src/",
  246. )
  247. filegroup(
  248. name = "cc_toolchain_all_files",
  249. srcs = [
  250. ":carbon-busybox",
  251. ":clang_hdrs",
  252. ":core",
  253. ":install_marker",
  254. ":libcxx_hdrs",
  255. ":libcxxabi_hdrs",
  256. ":libunwind_hdrs",
  257. ":llvm_bins",
  258. ],
  259. )
  260. # The toolchain configuration starlark needs to switch from referencing the
  261. # `carbon_runtimes.bzl` starlark in the toolchain layout to the `bazel` tree
  262. # within the installation.
  263. #
  264. # TODO: Maybe we should move the `carbon_runtimes.bzl` to the same directory as
  265. # the other starlark so we can use relative load lines and avoid this?
  266. genrule(
  267. name = "carbon_cc_toolchain_config_for_install",
  268. srcs = ["//bazel/cc_toolchains:carbon_cc_toolchain_config.bzl"],
  269. outs = ["carbon_cc_toolchain_config.bzl"],
  270. cmd = "sed 's|//toolchain/runtimes:carbon_runtimes.bzl|//bazel:carbon_runtimes.bzl|' $< > $@",
  271. )
  272. toolchain_files(
  273. name = "bazel_common_srcs",
  274. srcs = [
  275. ":carbon_cc_toolchain_config_for_install",
  276. "//bazel/cc_toolchains:installed_cc_toolchain_starlark",
  277. ],
  278. prefix = "bazel/",
  279. )
  280. toolchain_files(
  281. name = "bazel_install_srcs",
  282. srcs = [
  283. "bazel/carbon_clang_variables.bzl",
  284. "bazel/carbon_detected_variables.tpl.bzl",
  285. "bazel/carbon_toolchain.bzl",
  286. "bazel/make_include_copts.bzl",
  287. ],
  288. )
  289. toolchain_files(
  290. name = "carbon_runtimes_installed",
  291. srcs = ["//toolchain/runtimes:carbon_runtimes.bzl"],
  292. prefix = "bazel/",
  293. )
  294. toolchain_files(
  295. name = "bazel_build_and_module",
  296. srcs = [
  297. "bazel/empty.BUILD",
  298. "bazel/install.BUILD",
  299. "bazel/install.MODULE.bazel",
  300. ],
  301. remove_prefix = "bazel/",
  302. renames = {
  303. "empty.BUILD": "bazel/BUILD.bazel",
  304. "install.BUILD": "BUILD.bazel",
  305. "install.MODULE.bazel": "MODULE.bazel",
  306. },
  307. )
  308. # Generate a Starlark file with all the build variables needed for our runtimes.
  309. generate_runtimes_build_vars(
  310. name = "bazel/runtimes_build_vars.bzl",
  311. )
  312. filegroup(
  313. name = "installed_bazel_files",
  314. srcs = [
  315. ":bazel_build_and_module",
  316. ":bazel_common_srcs",
  317. ":bazel_install_srcs",
  318. ":carbon_runtimes_installed",
  319. # Note that we have to put this here and not in one of the
  320. # `toolchain_files` because it is a generated file.
  321. "bazel/runtimes_build_vars.bzl",
  322. ],
  323. )
  324. filegroup(
  325. name = "all_data_files",
  326. srcs = [
  327. ":builtins_all_srcs",
  328. ":clang_hdrs",
  329. ":core",
  330. ":install_marker",
  331. ":installed_bazel_files",
  332. ":libc_internal_libcxx_hdrs",
  333. ":libcxx_all_srcs",
  334. ":libcxx_hdrs",
  335. ":libcxxabi_hdrs",
  336. ":libcxxabi_srcs",
  337. ":libcxxabi_textual_srcs",
  338. ":libunwind_hdrs",
  339. ":libunwind_srcs",
  340. ],
  341. )
  342. # A list of clang's installed builtin header files.
  343. # This is consumed by //toolchain/testing:file_test.
  344. manifest(
  345. name = "clang_headers_manifest.txt",
  346. srcs = [":clang_hdrs"],
  347. strip_package_dir = True,
  348. )
  349. filegroup(
  350. name = "all_digest_files",
  351. srcs = [
  352. ":all_data_files",
  353. ":carbon-busybox",
  354. ],
  355. )
  356. manifest(
  357. name = "install_digest_manifest.txt",
  358. srcs = [":all_digest_files"],
  359. )
  360. cc_binary(
  361. name = "make-installation-digest",
  362. srcs = ["make_installation_digest.cpp"],
  363. deps = [
  364. "//common:bazel_working_dir",
  365. "//common:error",
  366. "//common:exe_path",
  367. "//common:filesystem",
  368. "//common:init_llvm",
  369. "//common:map",
  370. "//common:vlog",
  371. "@llvm-project//llvm:Support",
  372. ],
  373. )
  374. genrule(
  375. name = "gen_digest",
  376. srcs = [
  377. ":all_digest_files",
  378. "install_digest_manifest.txt",
  379. ],
  380. outs = ["install_digest.txt"],
  381. cmd = "{0} {1} $@".format(
  382. "$(location :make-installation-digest)",
  383. "$(location install_digest_manifest.txt)",
  384. ),
  385. tools = [":make-installation-digest"],
  386. )
  387. filegroup(
  388. name = "install_data",
  389. srcs = [
  390. "install_digest.txt",
  391. ":all_digest_files",
  392. ":llvm_bins",
  393. ],
  394. )
  395. manifest(
  396. name = "install_data_manifest.txt",
  397. srcs = [":install_data"],
  398. )
  399. cc_library(
  400. name = "builtins_internal",
  401. hdrs_check = "strict",
  402. textual_hdrs = select({
  403. "@platforms//cpu:aarch64": [":builtins_aarch64_textual_srcs"],
  404. "@platforms//cpu:i386": [":builtins_i386_textual_srcs"],
  405. "@platforms//cpu:x86_64": [":builtins_x86_64_textual_srcs"],
  406. "//conditions:default": [],
  407. }),
  408. )
  409. cc_library(
  410. name = "builtins",
  411. srcs = select({
  412. "@platforms//cpu:aarch64": [":builtins_aarch64_srcs"],
  413. "@platforms//cpu:i386": [":builtins_i386_srcs"],
  414. "@platforms//cpu:x86_64": [":builtins_x86_64_srcs"],
  415. "//conditions:default": [],
  416. }),
  417. copts = builtins_copts + make_include_copts([
  418. "runtimes/builtins",
  419. ]) + [
  420. # TODO: Remove this once we are building sanitizer runtime libraries.
  421. "-fno-sanitize=all",
  422. ],
  423. hdrs_check = "strict",
  424. target_compatible_with = select({
  425. ":is_runtimes_build": [],
  426. "//conditions:default": ["@platforms//:incompatible"],
  427. }),
  428. deps = [":builtins_internal"],
  429. )
  430. filegroup(
  431. name = "builtins_archive",
  432. srcs = [":builtins"],
  433. output_group = "archive",
  434. )
  435. cc_library(
  436. name = "libunwind",
  437. srcs = [":libunwind_srcs"],
  438. hdrs = [":libunwind_hdrs"],
  439. copts = libunwind_copts + [
  440. # We disable all warnings as upstream isn't clean with the common
  441. # warning flags Carbon uses by default.
  442. "-w",
  443. # TODO: Remove this once we are building sanitizer runtime libraries.
  444. "-fno-sanitize=all",
  445. ],
  446. hdrs_check = "strict",
  447. includes = ["runtimes/libunwind/include"],
  448. linkstatic = 1,
  449. target_compatible_with = select({
  450. ":is_runtimes_build": [],
  451. "//conditions:default": ["@platforms//:incompatible"],
  452. }),
  453. )
  454. filegroup(
  455. name = "libunwind_archive",
  456. srcs = [":libunwind"],
  457. output_group = "archive",
  458. )
  459. cc_library(
  460. name = "libcxxabi_internal",
  461. hdrs_check = "strict",
  462. target_compatible_with = select({
  463. ":is_runtimes_build": [],
  464. "//conditions:default": ["@platforms//:incompatible"],
  465. }),
  466. textual_hdrs = [":libcxxabi_textual_srcs"],
  467. )
  468. cc_library(
  469. name = "libc_internal_libcxx",
  470. hdrs = [":libc_internal_libcxx_hdrs"],
  471. hdrs_check = "strict",
  472. target_compatible_with = select({
  473. ":is_runtimes_build": [],
  474. "//conditions:default": ["@platforms//:incompatible"],
  475. }),
  476. )
  477. cc_library(
  478. name = "libcxx",
  479. srcs = select({
  480. "@platforms//os:macos": [":libcxx_macos_srcs"],
  481. "@platforms//os:windows": [":libcxx_win32_srcs"],
  482. "//conditions:default": [":libcxx_linux_srcs"],
  483. }) + [":libcxxabi_srcs"],
  484. hdrs = [
  485. ":libcxx_hdrs",
  486. ":libcxxabi_hdrs",
  487. ],
  488. copts = libcxx_and_abi_copts + make_include_copts([
  489. "runtimes/libcxx/src",
  490. "runtimes/libc/internal",
  491. ]) + [
  492. # We disable all warnings as upstream isn't clean with the common
  493. # warning flags Carbon uses by default.
  494. "-w",
  495. # TODO: Remove this once we are building sanitizer runtime libraries.
  496. "-fno-sanitize=all",
  497. ],
  498. hdrs_check = "strict",
  499. includes = [
  500. "runtimes/libcxx/include",
  501. "runtimes/libcxxabi/include",
  502. ],
  503. target_compatible_with = select({
  504. ":is_runtimes_build": [],
  505. "//conditions:default": ["@platforms//:incompatible"],
  506. }),
  507. deps = [
  508. ":libc_internal_libcxx",
  509. ":libcxxabi_internal",
  510. ],
  511. )
  512. filegroup(
  513. name = "libcxx_archive",
  514. srcs = [":libcxx"],
  515. output_group = "archive",
  516. )
  517. carbon_runtimes_config(
  518. name = "runtimes_cfg",
  519. builtins_archive = ":builtins_archive",
  520. clang_hdrs_prefix = "llvm/lib/clang/{0}/include/".format(LLVM_VERSION_MAJOR),
  521. crt_copts = crt_copts + [
  522. # Disable all sanitizers for CRT objects.
  523. "-fno-sanitize=all",
  524. ],
  525. crtbegin_src = select({
  526. "@platforms//os:linux": ":builtins_crtbegin_src",
  527. "//conditions:default": None,
  528. }),
  529. crtend_src = select({
  530. "@platforms//os:linux": ":builtins_crtend_src",
  531. "//conditions:default": None,
  532. }),
  533. darwin_os_suffix = select({
  534. # TODO: Add support for tvOS, watchOS, and iOS variants with the
  535. # relevant Bazel constraints.
  536. ":is_macos_arm64": "osx",
  537. ":is_macos_x86_64": "osx",
  538. "//conditions:default": None,
  539. }),
  540. libcxx_archive = ":libcxx_archive",
  541. libunwind_archive = ":libunwind_archive",
  542. target_triple = select({
  543. # TODO: Add other triples (and if needed, constraints) so that we can
  544. # build the correct Clang resource-dir structure for each.
  545. ":is_freebsd_x86_64": "x86_64-unknown-freebsd",
  546. ":is_linux_aarch64": "aarch64-unknown-linux-gnu",
  547. ":is_linux_x86_64": "x86_64-unknown-linux-gnu",
  548. # Note that Darwin OSes are handled by the `darwin_os_suffix` attribute.
  549. "//conditions:default": None,
  550. }),
  551. )
  552. platforms = {
  553. "freebsd": ["x86_64"],
  554. "linux": [
  555. "aarch64",
  556. "x86_64",
  557. ],
  558. "macos": [
  559. "arm64",
  560. "x86_64",
  561. ],
  562. }
  563. [
  564. config_setting(
  565. name = "is_{0}_{1}".format(os, cpu),
  566. constraint_values = [
  567. "@platforms//os:{}".format(os),
  568. "@platforms//cpu:{}".format(cpu),
  569. ],
  570. )
  571. for os, cpus in platforms.items()
  572. for cpu in cpus
  573. ]
  574. carbon_cc_toolchain_suite(
  575. name = "carbon_stage1",
  576. all_hdrs = [
  577. ":clang_hdrs",
  578. ":libunwind_hdrs",
  579. ":libcxx_hdrs",
  580. ":libcxxabi_hdrs",
  581. ],
  582. base_files = [
  583. ":install_marker",
  584. ":carbon-busybox",
  585. ":llvm_bins",
  586. ],
  587. build_stage = 1,
  588. clang_hdrs = [":clang_hdrs"],
  589. platforms = platforms,
  590. runtimes_cfg = ":runtimes_cfg",
  591. )
  592. carbon_cc_toolchain_suite(
  593. name = "carbon_stage2",
  594. all_hdrs = [
  595. ":clang_hdrs",
  596. ":libunwind_hdrs",
  597. ":libcxx_hdrs",
  598. ":libcxxabi_hdrs",
  599. ],
  600. base_files = [
  601. ":install_marker",
  602. ":carbon-busybox",
  603. ":llvm_bins",
  604. ],
  605. base_stage = 1,
  606. build_stage = 2,
  607. clang_hdrs = [":clang_hdrs"],
  608. platforms = platforms,
  609. runtimes_cfg = ":runtimes_cfg",
  610. tags = ["manual"],
  611. )
  612. pkg_naming_variables(
  613. name = "packaging_variables",
  614. )
  615. toolchain_pkg_filegroup(
  616. name = "stage1_pkg_data",
  617. srcs = [
  618. "install_digest.txt",
  619. ":all_data_files",
  620. ],
  621. carbon_busybox = ":carbon-busybox",
  622. )
  623. # We build both a compressed and uncompressed tar file with the same code here.
  624. # This lets us use the tar file in testing as it is fast to create, but ship the
  625. # compressed version as a release.
  626. #
  627. # For manual tests, the tar rules are `carbon_toolchain_tar` and
  628. # `carbon_toolchain_tar_gz`.
  629. pkg_tar_and_test(
  630. name = "carbon_toolchain",
  631. srcs = [":stage1_pkg_data"],
  632. install_data_manifest = ":install_data_manifest.txt",
  633. package_dir = "carbon_toolchain-$(version)",
  634. package_file_name_base = "carbon_toolchain-$(version)",
  635. package_variables = ":packaging_variables",
  636. stamp = -1, # Allow `--stamp` builds to produce file timestamps.
  637. )
  638. filegroup_with_stage(
  639. name = "stage2_pkg_files",
  640. srcs = [
  641. ":all_data_files",
  642. ":gen_digest",
  643. ],
  644. stage = 1,
  645. tags = ["manual"],
  646. )
  647. filegroup_with_stage(
  648. name = "stage2_busybox",
  649. srcs = [":carbon-busybox"],
  650. stage = 1,
  651. tags = ["manual"],
  652. )
  653. toolchain_pkg_filegroup(
  654. name = "stage2_pkg_data",
  655. srcs = [":stage2_pkg_files"],
  656. carbon_busybox = ":stage2_busybox",
  657. tags = ["manual"],
  658. )
  659. pkg_tar_and_test(
  660. name = "carbon_bootstrapped_toolchain",
  661. srcs = [":stage2_pkg_data"],
  662. install_data_manifest = ":install_data_manifest.txt",
  663. package_dir = "carbon_toolchain-$(version)",
  664. package_file_name_base = "carbon_bootstrapped_toolchain-$(version)",
  665. package_variables = ":packaging_variables",
  666. stamp = -1, # Allow `--stamp` builds to produce file timestamps.
  667. tags = ["manual"],
  668. )
  669. filegroup(
  670. name = "built_runtimes",
  671. srcs = [":carbon_stage1_runtimes"],
  672. )
  673. py_test(
  674. name = "install_test",
  675. size = "large",
  676. srcs = ["install_test.py"],
  677. data = [
  678. ":built_runtimes",
  679. ":carbon-busybox",
  680. ":install_data",
  681. ],
  682. deps = ["@bazel_tools//tools/python/runfiles"],
  683. )