From 13446e506fb94bcf4345bbf74b7987cff0fe0e3a Mon Sep 17 00:00:00 2001 From: Erik Gilling Date: Mon, 16 Dec 2024 10:34:55 -0800 Subject: [PATCH] pw_toolchain: Add Cortex M3 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I41ec2fd136c722baa9a0cde0ff003c28bf5d977e Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/254474 Reviewed-by: Armando Montanez Docs-Not-Needed: Erik Gilling Commit-Queue: Auto-Submit Pigweed-Auto-Submit: Erik Gilling Lint: Lint 🤖 Presubmit-Verified: CQ Bot Account --- pw_toolchain/BUILD.bazel | 9 +++++++++ pw_toolchain/arm_clang/BUILD.bazel | 32 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/pw_toolchain/BUILD.bazel b/pw_toolchain/BUILD.bazel index 1df791934..09bfa799e 100644 --- a/pw_toolchain/BUILD.bazel +++ b/pw_toolchain/BUILD.bazel @@ -73,6 +73,15 @@ toolchain( toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) +toolchain( + name = "cc_toolchain_cortex-m3", + target_compatible_with = [ + "@pw_toolchain//constraints/arm_mcpu:cortex-m3", + ], + toolchain = ":cortex-m_cc_toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + cc_library( name = "no_destructor", hdrs = ["public/pw_toolchain/no_destructor.h"], diff --git a/pw_toolchain/arm_clang/BUILD.bazel b/pw_toolchain/arm_clang/BUILD.bazel index 7f6104d27..fbb4d3c03 100644 --- a/pw_toolchain/arm_clang/BUILD.bazel +++ b/pw_toolchain/arm_clang/BUILD.bazel @@ -62,6 +62,19 @@ cc_args( ], ) +cc_args( + name = "armv7m-none-eabi", + actions = [ + "@rules_cc//cc/toolchains/actions:assembly_actions", + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + "@rules_cc//cc/toolchains/actions:link_actions", + ], + args = [ + "--target=armv7m-none-eabi", + ], +) + cc_args( name = "armv8m.main-none-eabi", actions = [ @@ -151,6 +164,20 @@ cc_args( ], ) +cc_args( + name = "cortex-m3", + actions = [ + "@rules_cc//cc/toolchains/actions:assembly_actions", + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + "@rules_cc//cc/toolchains/actions:link_actions", + ], + args = [ + "-mcpu=cortex-m3", + "-mfloat-abi=soft", + ], +) + cc_toolchain( name = "arm_clang_toolchain_cortex-m", args = [ @@ -178,6 +205,10 @@ cc_toolchain( ":cortex-m0plus", ":armv6m-none-eabi", ], + "@pw_toolchain//constraints/arm_mcpu:cortex-m3": [ + ":cortex-m3", + ":armv7m-none-eabi", + ], "@pw_toolchain//constraints/arm_mcpu:cortex-m33": [ ":cortex-m33", ":armv8m.main-none-eabi", @@ -199,6 +230,7 @@ cc_toolchain( 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"], }),