Skip to content

Commit

Permalink
pw_toolchain_bazel: Move CPU constraints
Browse files Browse the repository at this point in the history
pw_toolchain_bazel has been migrated to rules_cc, so the implementation
in Pigweed is being removed. This moves Pigweed's ARM mcpu constraints
into the main Pigweed repository so pw_toolchain_bazel can be removed.

Bug: b/346388161
Change-Id: Ic85f8502671d8388fd8f01c0d3567f2433a9a8bc
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/252314
Docs-Not-Needed: Armando Montanez <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Reviewed-by: Ted Pudlik <[email protected]>
Lint: Lint 🤖 <[email protected]>
Pigweed-Auto-Submit: Armando Montanez <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
armandomontanez authored and CQ Bot Account committed Dec 16, 2024
1 parent f909776 commit 4f14d74
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 107 deletions.
94 changes: 94 additions & 0 deletions pw_build/constraints/arm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

# The target Arm processor.
#
# The values of this constraint_setting correspond to valid values of the -mcpu
# compiler flag. See
# https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mcpu-2. These
# values are intended to be used in `target_compatible_with` attributes of
# toolchains which specify the corresponding value of -mcpu.
#
# The constraint_values are not currently exhaustively enumerated (only a few
# of the legal -mcpu values have corresponding constraint_values). The intent
# is for additional values to be added when needed.
#
# The intent is to support only the base processor type, not -march
# values (e.g., armv7e-m). This is because it is recommended to use (processor
# type + optional architectural extensions) when configuring Arm GCC (see
# https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu).
# In addition, the march values can already be captured using @platforms//cpu.
#
# Additionally, extensions should be represented via separate constraints to
# prevent the explosion of many variants.
constraint_setting(
name = "mcpu",
default_constraint_value = "none",
)

constraint_value(
name = "none",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-a32",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m0",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m0plus",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m3",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m4",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m4+nofp",
constraint_setting = ":mcpu",
deprecation = "FPU properties should be expressed with different constraints",
)

constraint_value(
name = "cortex-m7",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m33",
constraint_setting = ":mcpu",
)

constraint_value(
name = "cortex-m33+nofp",
constraint_setting = ":mcpu",
deprecation = "FPU properties should be expressed with different constraints",
)
File renamed without changes.
15 changes: 0 additions & 15 deletions pw_build/constraints/cortex_m/BUILD.bazel

This file was deleted.

4 changes: 2 additions & 2 deletions pw_build/platforms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ platform(
platform(
name = "lm3s6965evb",
constraint_values = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m3",
"//pw_build/constraints/arm:cortex-m3",
"//pw_build/constraints/chipset:lm3s6965evb",
"@platforms//cpu:armv7-m",
"@platforms//os:none",
Expand All @@ -65,7 +65,7 @@ platform(
platform(
name = "nrf52833",
constraint_values = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0",
"//pw_build/constraints/arm:cortex-m0",
"//pw_build/constraints/chipset:nrf52833",
"@platforms//cpu:armv6-m",
"@platforms//os:none",
Expand Down
8 changes: 4 additions & 4 deletions pw_toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ alias(
toolchain(
name = "cc_toolchain_cortex-m0",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0",
"//pw_build/constraints/arm:cortex-m0",
],
toolchain = ":cortex-m_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -58,7 +58,7 @@ toolchain(
toolchain(
name = "cc_toolchain_cortex-m0plus",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus",
"//pw_build/constraints/arm:cortex-m0plus",
],
toolchain = ":cortex-m_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -67,7 +67,7 @@ toolchain(
toolchain(
name = "cc_toolchain_cortex-m33",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m33",
"//pw_build/constraints/arm:cortex-m33",
],
toolchain = ":cortex-m_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -76,7 +76,7 @@ toolchain(
toolchain(
name = "cc_toolchain_cortex-m3",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m3",
"//pw_build/constraints/arm:cortex-m3",
],
toolchain = ":cortex-m_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand Down
26 changes: 13 additions & 13 deletions pw_toolchain/arm_clang/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,23 @@ cc_toolchain(
"//pw_toolchain/cc/args:common_warnings",
"//pw_toolchain/cc/args:color_diagnostics",
] + select({
"@pw_toolchain//constraints/arm_mcpu:cortex-m0": [
"//pw_build/constraints/arm:cortex-m0": [
":cortex-m0",
":armv6m-none-eabi",
],
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus": [
"//pw_build/constraints/arm:cortex-m0plus": [
":cortex-m0plus",
":armv6m-none-eabi",
],
"@pw_toolchain//constraints/arm_mcpu:cortex-m3": [
"//pw_build/constraints/arm:cortex-m3": [
":cortex-m3",
":armv7m-none-eabi",
],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33": [
"//pw_build/constraints/arm:cortex-m33": [
":cortex-m33",
":armv8m.main-none-eabi",
],
"@pw_toolchain//constraints/arm_mcpu:none": [],
"//pw_build/constraints/arm:none": [],
}),
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
Expand All @@ -228,11 +228,11 @@ cc_toolchain(
}),
tags = ["manual"], # Don't try to build this in wildcard builds.
target_compatible_with = select({
"@pw_toolchain//constraints/arm_mcpu:cortex-m0": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m3": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33": [],
"@pw_toolchain//constraints/arm_mcpu:none": ["@platforms//:incompatible"],
"//pw_build/constraints/arm:cortex-m0": [],
"//pw_build/constraints/arm:cortex-m0plus": [],
"//pw_build/constraints/arm:cortex-m3": [],
"//pw_build/constraints/arm:cortex-m33": [],
"//pw_build/constraints/arm:none": ["@platforms//:incompatible"],
}),
tool_map = "@llvm_toolchain_device//:all_tools",
visibility = ["//pw_toolchain:__pkg__"],
Expand All @@ -241,7 +241,7 @@ cc_toolchain(
toolchain(
name = "arm_clang_cc_toolchain_cortex-m0",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0",
"//pw_build/constraints/arm:cortex-m0",
],
toolchain = ":arm_clang_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -250,7 +250,7 @@ toolchain(
toolchain(
name = "arm_clang_cc_toolchain_cortex-m0plus",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus",
"//pw_build/constraints/arm:cortex-m0plus",
],
toolchain = ":arm_clang_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -259,7 +259,7 @@ toolchain(
toolchain(
name = "arm_clang_cc_toolchain_cortex-m33",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m33",
"//pw_build/constraints/arm:cortex-m33",
],
toolchain = ":arm_clang_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand Down
52 changes: 26 additions & 26 deletions pw_toolchain/arm_gcc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ cc_toolchain(
"//pw_toolchain/cc/args:common_warnings",
"//pw_toolchain/cc/args:color_diagnostics",
] + select({
"@pw_toolchain//constraints/arm_mcpu:cortex-m0": [":cortex-m0"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus": [":cortex-m0plus"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m3": [":cortex-m3"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33": [":cortex-m33"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33+nofp": [":cortex-m33+nofp"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m4": [":cortex-m4"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m4+nofp": [":cortex-m4+nofp"],
"@pw_toolchain//constraints/arm_mcpu:cortex-m7": [":cortex-m7"],
"@pw_toolchain//constraints/arm_mcpu:none": [],
"//pw_build/constraints/arm:cortex-m0": [":cortex-m0"],
"//pw_build/constraints/arm:cortex-m0plus": [":cortex-m0plus"],
"//pw_build/constraints/arm:cortex-m3": [":cortex-m3"],
"//pw_build/constraints/arm:cortex-m33": [":cortex-m33"],
"//pw_build/constraints/arm:cortex-m33+nofp": [":cortex-m33+nofp"],
"//pw_build/constraints/arm:cortex-m4": [":cortex-m4"],
"//pw_build/constraints/arm:cortex-m4+nofp": [":cortex-m4+nofp"],
"//pw_build/constraints/arm:cortex-m7": [":cortex-m7"],
"//pw_build/constraints/arm:none": [],
}) + [
":thumb_abi",
# TODO(b/353576440): Enable unified assembly syntax.
Expand Down Expand Up @@ -290,15 +290,15 @@ cc_toolchain(
"//pw_toolchain/cc/capability:linker_is_gcc",
],
target_compatible_with = select({
"@pw_toolchain//constraints/arm_mcpu:cortex-m0": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m3": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m33+nofp": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m4": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m4+nofp": [],
"@pw_toolchain//constraints/arm_mcpu:cortex-m7": [],
"@pw_toolchain//constraints/arm_mcpu:none": ["@platforms//:incompatible"],
"//pw_build/constraints/arm:cortex-m0": [],
"//pw_build/constraints/arm:cortex-m0plus": [],
"//pw_build/constraints/arm:cortex-m3": [],
"//pw_build/constraints/arm:cortex-m33": [],
"//pw_build/constraints/arm:cortex-m33+nofp": [],
"//pw_build/constraints/arm:cortex-m4": [],
"//pw_build/constraints/arm:cortex-m4+nofp": [],
"//pw_build/constraints/arm:cortex-m7": [],
"//pw_build/constraints/arm:none": ["@platforms//:incompatible"],
}),
tool_map = "@gcc_arm_none_eabi_toolchain//:all_tools",
visibility = ["//pw_toolchain:__pkg__"],
Expand All @@ -307,7 +307,7 @@ cc_toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m0",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0",
"//pw_build/constraints/arm:cortex-m0",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -316,7 +316,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m0plus",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m0plus",
"//pw_build/constraints/arm:cortex-m0plus",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -325,7 +325,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m3",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m3",
"//pw_build/constraints/arm:cortex-m3",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -334,7 +334,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m4",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m4",
"//pw_build/constraints/arm:cortex-m4",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -343,7 +343,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m4+nofp",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m4+nofp",
"//pw_build/constraints/arm:cortex-m4+nofp",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -352,7 +352,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m7",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m7",
"//pw_build/constraints/arm:cortex-m7",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -361,7 +361,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m33",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m33",
"//pw_build/constraints/arm:cortex-m33",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -370,7 +370,7 @@ toolchain(
toolchain(
name = "arm_gcc_cc_toolchain_cortex-m33+nofp",
target_compatible_with = [
"@pw_toolchain//constraints/arm_mcpu:cortex-m33+nofp",
"//pw_build/constraints/arm:cortex-m33+nofp",
],
toolchain = ":arm_gcc_toolchain_cortex-m",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand Down
2 changes: 1 addition & 1 deletion pw_toolchain/build_external/llvm_clang.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
load("@rules_cc//cc/toolchains:tool_map.bzl", "cc_tool_map")
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
load("@pigweed//pw_build/constraints/cortex_m:lists.bzl", "ALL_CORTEX_M_CPUS")
load("@pigweed//pw_build/constraints/arm:lists.bzl", "ALL_CORTEX_M_CPUS")
load("@pigweed//pw_build:glob_dirs.bzl", "match_dir")
load("@bazel_skylib//lib:selects.bzl", "selects")

Expand Down
5 changes: 5 additions & 0 deletions pw_toolchain_bazel/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ module(
# rules_cc. For that reason, this primarily acts as a FYI. You'll still need
# to explicitly list this dependency in your own project's MODULE.bazel file.
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "pigweed")
local_path_override(
module_name = "pigweed",
path = "../",
)
Loading

0 comments on commit 4f14d74

Please sign in to comment.