Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 1 | load(":cc_toolchain_config.bzl", "host_cc_toolchain_config") |
| 2 | |
| 3 | # Toolchain definitions. |
| 4 | # |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame] | 5 | # We currently define two toolchains: |
| 6 | # |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 7 | # - //build/toolchain:host_cc_toolchain , which points to our hermetic sandbox |
| 8 | # sysroot default compiler toolchain. It is mainly used to target the execution platform |
| 9 | # inside the sandbox (i.e. build tooling). |
| 10 | # - //build/toolchain/musl-host-gcc:musl_host_toolchain , which combines the sandbox sysroot |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 11 | # gcc compiler with a sysroot tarball that targets the Metropolis node |
| 12 | # runtime. This can be used to build C libraries/tools running within the |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 13 | # Metropolis node image or on the (unknown) host operating system outside the sandbox. |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame] | 14 | |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 15 | # This file defines //build/toolchain:host_cc_toolchain. |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame] | 16 | # |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 17 | # This is a C++ toolchain that uses GCC from the sandbox sysroot at hardcoded paths. We |
| 18 | # can get away with this, as currently the entire build is performed in a hermetic |
| 19 | # sandbox sysroot (see: //third_party/sandboxroot). We define this toolchain so |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 20 | # that we have full control over all configuration of it, which we need as we |
| 21 | # are building some fairly odd C binaries (notably, a qboot bootloader for |
| 22 | # testing). |
| 23 | # |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 24 | # The host_cc toolchain suite is enabled for all cc_* targets whose |
| 25 | # platform isn't matching a more specific toolchain. |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 26 | # |
| 27 | # This, and :cc_toolchain_config.bzl is based on the following tutorial: |
| 28 | # https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html |
| 29 | |
| 30 | package(default_visibility = ["//visibility:public"]) |
| 31 | |
| 32 | filegroup(name = "empty") |
| 33 | |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 34 | cc_toolchain( |
| 35 | name = "host_cc_k8_toolchain", |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 36 | all_files = ":empty", |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 37 | ar_files = ":empty", |
| 38 | as_files = ":empty", |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 39 | compiler_files = ":empty", |
| 40 | dwp_files = ":empty", |
| 41 | linker_files = ":empty", |
| 42 | objcopy_files = ":empty", |
| 43 | strip_files = ":empty", |
| 44 | supports_param_files = 0, |
Serge Bazanski | f12bedf | 2021-01-15 16:58:50 +0100 | [diff] [blame] | 45 | toolchain_config = ":host_cc_k8_toolchain_config", |
| 46 | toolchain_identifier = "host-k8-toolchain", |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 47 | ) |
| 48 | |
| 49 | host_cc_toolchain_config(name = "host_cc_k8_toolchain_config") |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 50 | |
| 51 | toolchain( |
| 52 | name = "host_cc_toolchain", |
| 53 | exec_compatible_with = [ |
Tim Windelschmidt | 2d1ebd3 | 2023-05-23 01:53:12 +0200 | [diff] [blame] | 54 | "@platforms//os:linux", |
| 55 | "@platforms//cpu:x86_64", |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 56 | ], |
| 57 | target_compatible_with = [ |
Tim Windelschmidt | 2d1ebd3 | 2023-05-23 01:53:12 +0200 | [diff] [blame] | 58 | "@platforms//os:linux", |
| 59 | "@platforms//cpu:x86_64", |
Leopold | bc93c2b | 2023-01-14 13:12:23 +0100 | [diff] [blame] | 60 | ], |
| 61 | toolchain = ":host_cc_k8_toolchain", |
| 62 | toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", |
| 63 | ) |