BUILD 20 KB

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