blob: 84546b731c16bd84f001f7b4d3fd594323773957 [file] [log] [blame]
Serge Bazanski385c12f2020-06-17 12:12:42 +02001load(":cc_toolchain_config.bzl", "host_cc_toolchain_config")
2
3# Toolchain definitions.
4#
Serge Bazanski9e861a82020-09-16 13:46:41 +02005# We currently define two toolchains:
6#
Leopoldbc93c2b2023-01-14 13:12:23 +01007# - //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 Bazanski662b5b32020-12-21 13:49:00 +010011# 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
Leopoldbc93c2b2023-01-14 13:12:23 +010013# Metropolis node image or on the (unknown) host operating system outside the sandbox.
Serge Bazanski9e861a82020-09-16 13:46:41 +020014
Leopoldbc93c2b2023-01-14 13:12:23 +010015# This file defines //build/toolchain:host_cc_toolchain.
Serge Bazanski9e861a82020-09-16 13:46:41 +020016#
Leopoldbc93c2b2023-01-14 13:12:23 +010017# 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 Bazanski385c12f2020-06-17 12:12:42 +020020# 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#
Leopoldbc93c2b2023-01-14 13:12:23 +010024# The host_cc toolchain suite is enabled for all cc_* targets whose
25# platform isn't matching a more specific toolchain.
Serge Bazanski385c12f2020-06-17 12:12:42 +020026#
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
30package(default_visibility = ["//visibility:public"])
31
32filegroup(name = "empty")
33
Serge Bazanski385c12f2020-06-17 12:12:42 +020034cc_toolchain(
35 name = "host_cc_k8_toolchain",
Serge Bazanski385c12f2020-06-17 12:12:42 +020036 all_files = ":empty",
Leopoldbc93c2b2023-01-14 13:12:23 +010037 ar_files = ":empty",
38 as_files = ":empty",
Serge Bazanski385c12f2020-06-17 12:12:42 +020039 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 Bazanskif12bedf2021-01-15 16:58:50 +010045 toolchain_config = ":host_cc_k8_toolchain_config",
46 toolchain_identifier = "host-k8-toolchain",
Serge Bazanski385c12f2020-06-17 12:12:42 +020047)
48
49host_cc_toolchain_config(name = "host_cc_k8_toolchain_config")
Leopoldbc93c2b2023-01-14 13:12:23 +010050
51toolchain(
52 name = "host_cc_toolchain",
53 exec_compatible_with = [
Tim Windelschmidt2d1ebd32023-05-23 01:53:12 +020054 "@platforms//os:linux",
55 "@platforms//cpu:x86_64",
Leopoldbc93c2b2023-01-14 13:12:23 +010056 ],
57 target_compatible_with = [
Tim Windelschmidt2d1ebd32023-05-23 01:53:12 +020058 "@platforms//os:linux",
59 "@platforms//cpu:x86_64",
Leopoldbc93c2b2023-01-14 13:12:23 +010060 ],
61 toolchain = ":host_cc_k8_toolchain",
62 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
63)