blob: 6523d7fed56e810f4af869b409503802e8220183 [file] [log] [blame]
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# AUTO-GENERATED BY update_workspace.py - DO NOT EDIT
# This is a `platform_mappings` file for Bazel.
# See https://bazel.build/concepts/platforms#platform-mappings
# Set the value of --cpu properly when a specific --platforms value is
# used. This is required by the SDK Bazel rules, otherwise weird errors
# will happen, like x64 runtime dependencies being looked up in
# the sysroot for arm64 Fuchsia binaries. See https://fxbug.dev/42067752#c19.
#
# Note that for the arm64 case, the --cpu=aarch64 value is
# required by the SDK Bazel rules, but other rulesets (e.g. rules_go)
# will want to use --cpu=arm64 instead, which may be a problem
# to generate Fuchsia Go binaries in the future.
#
# When setting --cpu, Bazel will try to compute the value of
# --crosstool_top by looking at the toolchains defined in
# @local_config_cc//BUILD, which is *auto-generated* to list C++
# toolchain definitions for the host system (and this happens *even*
# if BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 is set, which should normally
# disable such behavior). For example, it would contain somethine like:
#
# ```
# cc_toolchain_suite(
# name = "toolchain",
# toolchains = {{
# "k8|local": ":local",
# "k8": ":local",
# }},
# )
# ```
#
# When using --cpu=k8, it will typically set --crosstool_top to point
# to `@local_config_cc//:local`, and then continue, the value being ignored
# after that because `--incompatible_enable_cc_toolchain_resolution` is set
# in the .bazelrc file.
#
# However, when using --cpu=aarch64, it will not find a compatible toolchain
# suite and will complain with an error like:
#
# ERROR: .../output_base/external/local_config_cc/BUILD:28:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'aarch64'
# ERROR: .../output_base/external/local_config_cc/BUILD:28:19: Analysis of target '@local_config_cc//:toolchain' failed
#
# To work around this, always set --crosstool_top explicitly as well, even though
# it will never be used, and make it point to the right toolchain definition for
# consistency.
#
platforms:
# Host platform.
//build/bazel/platforms:host
--cpu={bazel_host_cpu}
--crosstool_top=@prebuilt_clang//:host_clang_{host_os}_{host_cpu}
# Linux platforms
//build/bazel/platforms:linux_x64
--cpu=k8
--crosstool_top=@prebuilt_clang//:host_clang_linux_x64
//build/bazel/platforms:linux_arm64
--cpu=aarch64
--crosstool_top=@prebuilt_clang//:host_clang_linux_arm64
# Mac platforms
//build/bazel/platforms:mac_x64
--cpu=k8
--crosstool_top=@prebuilt_clang//:host_clang_mac_x64
//build/bazel/platforms:mac_arm64
--cpu=aarch64
--crosstool_top=@prebuilt_clang//:host_clang_mac_arm64
# Fuchsia platforms
//build/bazel/platforms:fuchsia_x64
--cpu=k8
--crosstool_top=@fuchsia_clang//:cc-compiler-x86_64
//build/bazel/platforms:fuchsia_arm64
--cpu=aarch64
--crosstool_top=@fuchsia_clang//:cc-compiler-aarch64
//build/bazel/platforms:fuchsia_riscv64
--cpu=riscv64
--crosstool_top=@fuchsia_clang//:cc-compiler-riscv64