pw_preprocessor: Add internal Cortex-M arch defines

Instead of forking build rules to be arch specific, which does not
scale well with the number of CortexM arches, use a common place to
determine the arch macros which can be used by other macros.

Note that these defines are private and internal to Pigweed and
should not be used by downstream projects, they are expected to
be moved and renamed in the near future.

The defines default to the format used by CMSIS, GCC, Clang, etc.
but they follow a module compile time configuration paradigm so
different toolchains can also make the following defines work:
- _PW_ARCH_ARM_V6M
- _PW_ARCH_ARM_V7M
- _PW_ARCH_ARM_V7EM
- _PW_ARCH_ARM_V8M_BASELINE
- _PW_ARCH_ARM_V8M_MAINLINE
- _PW_ARCH_ARM_V8_1M_MAINLINE

Lastly a helper is provided if any of the above have a value of 1:
- _PW_ARCH_ARM_CORTEX_M

Also updates pw_boot_cortex_m, pw_cpu_exception_cortex_m, and
pw_interrupt_cortex_m to use this source of architecture selection
deprecating the previously independent build targets.

Change-Id: Ie0ed3fb976ea3520c4f7f84debf3d598cf5ca559
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/75540
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_boot_cortex_m/BUILD.bazel b/pw_boot_cortex_m/BUILD.bazel
index 542e7e9..33220df 100644
--- a/pw_boot_cortex_m/BUILD.bazel
+++ b/pw_boot_cortex_m/BUILD.bazel
@@ -21,39 +21,43 @@
 licenses(["notice"])
 
 pw_cc_library(
-    name = "armv7m",
+    name = "pw_boot_cortex_m",
     srcs = [
         "core_init.c",
         "public/pw_boot_cortex_m/boot.h",
     ],
-    defines = ["PW_BOOT_CORTEX_M_ARMV7M"],
     includes = ["public"],
     target_compatible_with = select({
-        "@platforms//cpu:armv7e-m": [],
         "@platforms//cpu:armv7-m": [],
-        "//conditions:default": ["@platforms//:incompatible"],
-    }),
-    deps = [
-        "//pw_boot:facade",
-        "//pw_preprocessor",
-    ],
-)
-
-pw_cc_library(
-    name = "armv8m",
-    srcs = [
-        "core_init.c",
-        "public/pw_boot_cortex_m/boot.h",
-    ],
-    defines = ["PW_BOOT_CORTEX_M_ARMV8M"],
-    includes = ["public"],
-    target_compatible_with = select({
-        "@platforms//cpu:armv8e-m": [],
+        "@platforms//cpu:armv7e-m": [],
+        "@platforms//cpu:armv7e-mf": [],
         "@platforms//cpu:armv8-m": [],
         "//conditions:default": ["@platforms//:incompatible"],
     }),
     deps = [
         "//pw_boot:facade",
         "//pw_preprocessor",
+        "//pw_preprocessor:arch",
     ],
 )
+
+# The following targets are deprecated, depend on ":pw_boot_cortex_m" instead.
+pw_cc_library(
+    name = "armv7m",
+    target_compatible_with = select({
+        "@platforms//cpu:armv7-m": [],
+        "@platforms//cpu:armv7e-m": [],
+        "@platforms//cpu:armv7e-mf": [],
+        "//conditions:default": ["@platforms//:incompatible"],
+    }),
+    deps = [":pw_boot_cortex_m"],
+)
+
+pw_cc_library(
+    name = "armv8m",
+    target_compatible_with = select({
+        "@platforms//cpu:armv8-m": [],
+        "//conditions:default": ["@platforms//:incompatible"],
+    }),
+    deps = [":pw_boot_cortex_m"],
+)
diff --git a/pw_boot_cortex_m/BUILD.gn b/pw_boot_cortex_m/BUILD.gn
index 0bebd2d..d28da4f 100644
--- a/pw_boot_cortex_m/BUILD.gn
+++ b/pw_boot_cortex_m/BUILD.gn
@@ -28,8 +28,16 @@
   pw_boot_cortex_m_LINKER_SCRIPT = ":cortex_m_linker_script"
 }
 
-if (pw_boot_BACKEND == "$dir_pw_boot_cortex_m:armv7m" ||
-    pw_boot_BACKEND == "$dir_pw_boot_cortex_m:armv8m") {
+if (pw_boot_BACKEND != "$dir_pw_boot_cortex_m" &&
+    pw_boot_BACKEND != "$dir_pw_boot_cortex_m:armv7m" &&
+    pw_boot_BACKEND != "$dir_pw_boot_cortex_m:armv8m") {
+  group("pw_boot_cortex_m") {
+  }
+  group("armv7m") {
+  }
+  group("armv8m") {
+  }
+} else {
   config("default_config") {
     include_dirs = [ "public" ]
   }
@@ -40,39 +48,25 @@
     defines = pw_boot_cortex_m_LINK_CONFIG_DEFINES
     linker_script = "basic_cortex_m.ld"
   }
-}
 
-if (pw_boot_BACKEND == "$dir_pw_boot_cortex_m:armv7m") {
-  pw_source_set("armv7m") {
-    defines = [ "PW_BOOT_CORTEX_M_ARMV7M" ]
+  pw_source_set("pw_boot_cortex_m") {
     public_configs = [ ":default_config" ]
     public = [ "public/pw_boot_cortex_m/boot.h" ]
     public_deps = [ "$dir_pw_preprocessor" ]
     deps = [
       "$dir_pw_boot:facade",
+      "$dir_pw_preprocessor:arch",
       pw_boot_cortex_m_LINKER_SCRIPT,
     ]
     sources = [ "core_init.c" ]
   }
-} else {
+
+  # These targets are deprecated, use ":pw_boot_cortex_m" directly.
   group("armv7m") {
+    public_deps = [ ":pw_boot_cortex_m" ]
   }
-}
-
-if (pw_boot_BACKEND == "$dir_pw_boot_cortex_m:armv8m") {
-  pw_source_set("armv8m") {
-    defines = [ "PW_BOOT_CORTEX_M_ARMV8M" ]
-    public_configs = [ ":default_config" ]
-    public = [ "public/pw_boot_cortex_m/boot.h" ]
-    public_deps = [ "$dir_pw_preprocessor" ]
-    deps = [
-      "$dir_pw_boot:facade",
-      pw_boot_cortex_m_LINKER_SCRIPT,
-    ]
-    sources = [ "core_init.c" ]
-  }
-} else {
   group("armv8m") {
+    public_deps = [ ":pw_boot_cortex_m" ]
   }
 }
 
diff --git a/pw_boot_cortex_m/core_init.c b/pw_boot_cortex_m/core_init.c
index 1122a09..cbb8af3 100644
--- a/pw_boot_cortex_m/core_init.c
+++ b/pw_boot_cortex_m/core_init.c
@@ -57,8 +57,20 @@
 
 #include "pw_boot/boot.h"
 #include "pw_boot_cortex_m/boot.h"
+#include "pw_preprocessor/arch.h"
 #include "pw_preprocessor/compiler.h"
 
+#if !_PW_ARCH_ARM_CORTEX_M
+#error You can only build this for ARM Cortex-M architectures. If you are \
+       trying to do this and are still seeing this error, see \
+       pw_preprocessor/arch.h
+#endif  // !_PW_ARCH_ARM_CORTEX_M
+
+#if !_PW_ARCH_ARM_V6M && !_PW_ARCH_ARM_V7M && !_PW_ARCH_ARM_V7EM && \
+    !_PW_ARCH_ARM_V8M_MAINLINE && !_PW_ARCH_ARM_V8_1M_MAINLINE
+#error "Your selected Cortex-M arch is not yet supported by this module."
+#endif
+
 // Extern symbols provided by linker script.
 // These symbols tell us where various memory sections start and end.
 extern uint8_t _pw_static_init_ram_start;
@@ -109,7 +121,7 @@
   // not safe to run handlers until after this function returns.
   asm volatile("cpsid i");
 
-#ifdef PW_BOOT_CORTEX_M_ARMV8M
+#if _PW_ARCH_ARM_V8M_MAINLINE || _PW_ARCH_ARM_V8_1M_MAINLINE
   // Configure MSP and MSPLIM.
   asm volatile(
       "msr msp, %0    \n"
@@ -120,7 +132,7 @@
       : /*clobbers=*/
       // clang-format on
   );
-#endif
+#endif  // _PW_ARCH_ARM_V8M_MAINLINE || _PW_ARCH_ARM_V8_1M_MAINLINE
 
   // Run any init that must be done before static init of RAM which preps the
   // .data (static values not yet loaded into ram) and .bss sections (not yet
diff --git a/pw_cpu_exception_cortex_m/BUILD.gn b/pw_cpu_exception_cortex_m/BUILD.gn
index b1de665..0e4cfd0 100644
--- a/pw_cpu_exception_cortex_m/BUILD.gn
+++ b/pw_cpu_exception_cortex_m/BUILD.gn
@@ -29,7 +29,10 @@
 }
 
 pw_source_set("config") {
-  public_deps = [ pw_cpu_exception_cortex_m_CONFIG ]
+  public_deps = [
+    "$dir_pw_preprocessor:arch",
+    pw_cpu_exception_cortex_m_CONFIG,
+  ]
   public = [ "pw_cpu_exception_cortex_m_private/config.h" ]
   visibility = [ ":*" ]
 }
@@ -44,21 +47,11 @@
   visibility = [ ":*" ]
 }
 
-config("armv7m") {
-  defines = [ "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1" ]
-}
-
-config("armv8m") {
-  defines = [ "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1" ]
-}
-
-pw_source_set("support_armv7m") {
-  public_configs = [ ":public_include_path" ]
-  configs = [ ":armv7m" ]
+pw_source_set("support") {
   deps = [
     ":config",
-    ":cortex_m_constants_armv7m",
-    ":cpu_exception_armv7m",
+    ":cortex_m_constants",
+    ":cpu_exception",
     "$dir_pw_cpu_exception:support.facade",
     dir_pw_log,
     dir_pw_string,
@@ -66,23 +59,16 @@
   sources = [ "cpu_state.cc" ]
 }
 
-pw_source_set("support_armv8m") {
-  public_configs = [ ":public_include_path" ]
-  configs = [ ":armv8m" ]
-  deps = [
-    ":config",
-    ":cortex_m_constants_armv8m",
-    ":cpu_exception_armv8m",
-    "$dir_pw_cpu_exception:support.facade",
-    dir_pw_log,
-    dir_pw_string,
-  ]
-  sources = [ "cpu_state.cc" ]
+# The following targets are deprecated, use ":support" instead.
+group("support_armv7m") {
+  public_deps = [ ":support" ]
+}
+group("support_armv8m") {
+  public_deps = [ ":support" ]
 }
 
-pw_source_set("proto_dump_armv7m") {
+pw_source_set("proto_dump") {
   public_configs = [ ":public_include_path" ]
-  configs = [ ":armv7m" ]
   public_deps = [
     ":cpu_exception_armv7m",
     dir_pw_protobuf,
@@ -97,30 +83,23 @@
   sources = [ "proto_dump.cc" ]
 }
 
-pw_source_set("proto_dump_armv8m") {
-  public_configs = [ ":public_include_path" ]
-  configs = [ ":armv8m" ]
-  public_deps = [
-    ":cpu_exception_armv8m",
-    dir_pw_protobuf,
-    dir_pw_status,
-    dir_pw_stream,
-  ]
-  public = [ "public/pw_cpu_exception_cortex_m/proto_dump.h" ]
-  deps = [
-    ":config",
-    ":cpu_state_protos.pwpb",
-  ]
-  sources = [ "proto_dump.cc" ]
+# The following targets are deprecated, use ":proto_dump" instead.
+group("proto_dump_armv7m") {
+  public_deps = [ ":proto_dump" ]
+}
+group("proto_dump_armv8m") {
+  public_deps = [ ":proto_dump" ]
 }
 
 pw_proto_library("cpu_state_protos") {
   sources = [ "pw_cpu_exception_cortex_m_protos/cpu_state.proto" ]
 }
 
-pw_source_set("cpu_exception_armv7m") {
+# TODO(pwbug/296): The *_armv7m libraries work on ARMv8-M, but needs some minor
+# patches for complete correctness. Add *_armv8m targets that use the same files
+# but provide preprocessor defines to enable/disable architecture specific code.
+pw_source_set("cpu_exception") {
   public_configs = [
-    ":armv7m",
     ":backend_config",
     ":public_include_path",
   ]
@@ -131,58 +110,42 @@
   public_deps = [ "$dir_pw_preprocessor" ]
 }
 
-# TODO(pwbug/296): The *_armv7m libraries work on ARMv8-M, but needs some minor
-# patches for complete correctness. Add *_armv8m targets that use the same files
-# but provide preprocessor defines to enable/disable architecture specific code.
-pw_source_set("cpu_exception_armv8m") {
-  public_configs = [
-    ":armv8m",
-    ":backend_config",
-    ":public_include_path",
-  ]
-  public = [
-    "public/pw_cpu_exception_cortex_m/cpu_state.h",
-    "public_overrides/pw_cpu_exception_backend/state.h",
-  ]
-  public_deps = [ "$dir_pw_preprocessor" ]
+# The following targets are deprecated, use ":cpu_exception" instead.
+group("cpu_exception_armv7m") {
+  public_deps = [ ":cpu_exception" ]
 }
-
-pw_source_set("cpu_exception_armv7m.impl") {
-  configs = [ ":armv7m" ]
-  sources = [ "entry.cc" ]
-  deps = [
-    ":config",
-    ":cortex_m_constants_armv7m",
-    "$dir_pw_cpu_exception:entry.facade",
-    "$dir_pw_cpu_exception:handler",
-  ]
+group("cpu_exception_armv8m") {
+  public_deps = [ ":cpu_exception" ]
 }
 
 # TODO(pwbug/296): The *_armv7m libraries work on ARMv8-M, but needs some minor
 # patches for complete correctness. Add *_armv8m targets that use the same files
 # but provide preprocessor defines to enable/disable architecture specific code.
-pw_source_set("cpu_exception_armv8m.impl") {
-  configs = [ ":armv8m" ]
+pw_source_set("cpu_exception.impl") {
   sources = [ "entry.cc" ]
   deps = [
     ":config",
-    ":cortex_m_constants_armv8m",
+    ":cortex_m_constants",
     "$dir_pw_cpu_exception:entry.facade",
     "$dir_pw_cpu_exception:handler",
   ]
 }
 
-# TODO(ewout): Deprecate this once customers have been migrated to the arch
-# specific one.
-group("snapshot") {
-  public_deps = [ ":snapshot_armv7m" ]
+# The following targets are deprecated, use ":cpu_exception.impl" instead.
+group("cpu_exception_armv7m.impl") {
+  public_deps = [ ":cpu_exception.impl" ]
+}
+group("cpu_exception_armv8m.impl") {
+  public_deps = [ ":cpu_exception.impl" ]
 }
 
-pw_source_set("snapshot_armv7m") {
+# TODO(pwbug/296): The *_armv7m libraries work on ARMv8-M, but needs some minor
+# patches for complete correctness. Add *_armv8m targets that use the same files
+# but provide preprocessor defines to enable/disable architecture specific code.
+pw_source_set("snapshot") {
   public_configs = [ ":public_include_path" ]
-  configs = [ ":armv7m" ]
   public_deps = [
-    ":cpu_exception_armv7m",
+    ":cpu_exception",
     ":cpu_state_protos.pwpb",
     "$dir_pw_thread:protos.pwpb",
     "$dir_pw_thread:snapshot",
@@ -193,61 +156,47 @@
   sources = [ "snapshot.cc" ]
   deps = [
     ":config",
-    ":cortex_m_constants_armv7m",
-    ":proto_dump_armv7m",
+    ":cortex_m_constants",
+    ":proto_dump",
     "$dir_pw_cpu_exception:support",
     dir_pw_log,
   ]
 }
 
-# TODO(pwbug/296): The *_armv7m libraries work on ARMv8-M, but needs some minor
-# patches for complete correctness. Add *_armv8m targets that use the same files
-# but provide preprocessor defines to enable/disable architecture specific code.
-pw_source_set("snapshot_armv8m") {
-  public_configs = [ ":public_include_path" ]
-  configs = [ ":armv8m" ]
-  public_deps = [
-    ":cpu_exception_armv8m",
-    ":cpu_state_protos.pwpb",
-    "$dir_pw_thread:protos.pwpb",
-    "$dir_pw_thread:snapshot",
-    dir_pw_protobuf,
-    dir_pw_status,
-  ]
-  public = [ "public/pw_cpu_exception_cortex_m/snapshot.h" ]
-  sources = [ "snapshot.cc" ]
-  deps = [
-    ":config",
-    ":cortex_m_constants_armv8m",
-    ":proto_dump_armv8m",
-    "$dir_pw_cpu_exception:support",
-    dir_pw_log,
-  ]
+# The following targets are deprecated, use ":snapshot" instead.
+group("snapshot_armv7m") {
+  public_deps = [ ":snapshot" ]
+}
+group("snapshot_armv8m") {
+  public_deps = [ ":snapshot" ]
 }
 
-pw_source_set("cortex_m_constants_armv7m") {
-  public_configs = [ ":armv7m" ]
+pw_source_set("cortex_m_constants") {
   public = [ "pw_cpu_exception_cortex_m_private/cortex_m_constants.h" ]
   visibility = [ ":*" ]
 }
 
-pw_source_set("cortex_m_constants_armv8m") {
-  public_configs = [ ":armv8m" ]
-  public = [ "pw_cpu_exception_cortex_m_private/cortex_m_constants.h" ]
+# The following targets are deprecated, use ":cortex_m_constants" instead.
+group("cortex_m_constants_armv7m") {
+  public_deps = [ ":cortex_m_constants" ]
+  visibility = [ ":*" ]
+}
+group("cortex_m_constants_armv8m") {
+  public_deps = [ ":cortex_m_constants" ]
   visibility = [ ":*" ]
 }
 
 pw_test_group("tests") {
-  tests = [ ":cpu_exception_entry_test_armv7m" ]
+  tests = [ ":cpu_exception_entry_test" ]
 }
 
-# TODO(pwbug/583): Add an ARMv8-M entry test.
-pw_test("cpu_exception_entry_test_armv7m") {
+# TODO(pwbug/583): Add ARMv8-M mainline coverage.
+pw_test("cpu_exception_entry_test") {
   enable_if = pw_cpu_exception_ENTRY_BACKEND ==
-              "$dir_pw_cpu_exception_cortex_m:cpu_exception_armv7m"
+              "$dir_pw_cpu_exception_cortex_m:cpu_exception"
   deps = [
-    ":cortex_m_constants_armv7m",
-    ":cpu_exception_armv7m",
+    ":cortex_m_constants",
+    ":cpu_exception",
     "$dir_pw_cpu_exception:entry",
     "$dir_pw_cpu_exception:handler",
     "$dir_pw_cpu_exception:support",
diff --git a/pw_cpu_exception_cortex_m/CMakeLists.txt b/pw_cpu_exception_cortex_m/CMakeLists.txt
index c8d31fb..83edccd 100644
--- a/pw_cpu_exception_cortex_m/CMakeLists.txt
+++ b/pw_cpu_exception_cortex_m/CMakeLists.txt
@@ -24,68 +24,33 @@
     pw_cpu_exception_cortex_m_private/config.h
 )
 
-pw_add_module_library(pw_cpu_exception_cortex_m.cpu_exception_armv7m
+pw_add_module_library(pw_cpu_exception_cortex_m.cpu_exception
   IMPLEMENTS_FACADES
     pw_cpu_exception.entry
   PUBLIC_DEPS
     pw_preprocessor
+    pw_preprocessor.arch
   PRIVATE_DEPS
     pw_cpu_exception.handler
     pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv7m
+    pw_cpu_exception_cortex_m.constants
   SOURCES
     entry.cc
   HEADERS
     public/pw_cpu_exception_cortex_m/cpu_state.h
     public_overrides/pw_cpu_exception_backend/state.h
-  PUBLIC_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1"
 )
 
-pw_add_module_library(pw_cpu_exception_cortex_m.cpu_exception_armv8m
-  IMPLEMENTS_FACADES
-    pw_cpu_exception.entry
-  PUBLIC_DEPS
-    pw_preprocessor
-  PRIVATE_DEPS
-    pw_cpu_exception.handler
-    pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv8m
-  SOURCES
-    entry.cc
-  HEADERS
-    public/pw_cpu_exception_cortex_m/cpu_state.h
-    public_overrides/pw_cpu_exception_backend/state.h
-  PUBLIC_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1"
-)
-
-pw_add_module_library(pw_cpu_exception_cortex_m.support_armv7m
+pw_add_module_library(pw_cpu_exception_cortex_m.support
   IMPLEMENTS_FACADES
     pw_cpu_exception.support
   PRIVATE_DEPS
     pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv7m
+    pw_cpu_exception_cortex_m.constants
     pw_log
     pw_string
   SOURCES
     cpu_state.cc
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1"
-)
-
-pw_add_module_library(pw_cpu_exception_cortex_m.support_armv8m
-  IMPLEMENTS_FACADES
-    pw_cpu_exception.support
-  PRIVATE_DEPS
-    pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv8m
-    pw_log
-    pw_string
-  SOURCES
-    cpu_state.cc
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1"
 )
 
 pw_proto_library(pw_cpu_exception_cortex_m.cpu_state_protos
@@ -93,7 +58,7 @@
     pw_cpu_exception_cortex_m_protos/cpu_state.proto
 )
 
-pw_add_module_library(pw_cpu_exception_cortex_m.proto_dump_armv7m
+pw_add_module_library(pw_cpu_exception_cortex_m.proto_dump
   PUBLIC_DEPS
     pw_cpu_exception.entry
     pw_protobuf
@@ -106,75 +71,26 @@
     proto_dump.cc
   HEADERS
     public/pw_cpu_exception_cortex_m/proto_dump.h
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1"
 )
 
-pw_add_module_library(pw_cpu_exception_cortex_m.proto_dump_armv8m
-  PUBLIC_DEPS
-    pw_cpu_exception.entry
-    pw_protobuf
-    pw_status
-    pw_stream
-  PRIVATE_DEPS
-    pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.cpu_state_protos.pwpb
-  SOURCES
-    proto_dump.cc
-  HEADERS
-    public/pw_cpu_exception_cortex_m/proto_dump.h
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1"
-)
-
-pw_add_module_library(pw_cpu_exception_cortex_m.snapshot_armv7m
+pw_add_module_library(pw_cpu_exception_cortex_m.snapshot
   PUBLIC_DEPS
     pw_cpu_exception_cortex_m.cpu_state_protos.pwpb
-    pw_cpu_exception_cortex_m.cpu_exception_armv7m
+    pw_cpu_exception_cortex_m.cpu_exception
     pw_protobuf
     pw_status
   PRIVATE_DEPS
     pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv7m
-    pw_cpu_exception_cortex_m.proto_dump_armv7m
+    pw_cpu_exception_cortex_m.constants
+    pw_cpu_exception_cortex_m.proto_dump
     pw_log
   SOURCES
     snapshot.cc
   HEADERS
     public/pw_cpu_exception_cortex_m/snapshot.h
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1"
 )
 
-pw_add_module_library(pw_cpu_exception_cortex_m.snapshot_armv8m
-  PUBLIC_DEPS
-    pw_cpu_exception_cortex_m.cpu_state_protos.pwpb
-    pw_cpu_exception_cortex_m.cpu_exception_armv8m
-    pw_protobuf
-    pw_status
-  PRIVATE_DEPS
-    pw_cpu_exception_cortex_m.config
-    pw_cpu_exception_cortex_m.constants_armv8m
-    pw_cpu_exception_cortex_m.proto_dump_armv8m
-    pw_log
-  SOURCES
-    snapshot.cc
-  HEADERS
-    public/pw_cpu_exception_cortex_m/snapshot.h
-  PRIVATE_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1"
-)
-
-pw_add_module_library(pw_cpu_exception_cortex_m.constants_armv7m
+pw_add_module_library(pw_cpu_exception_cortex_m.constants
   HEADERS
     pw_cpu_exception_cortex_m_private/cortex_m_constants.h
-  PUBLIC_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV7M=1"
-)
-
-pw_add_module_library(pw_cpu_exception_cortex_m.constants_armv8m
-  HEADERS
-    pw_cpu_exception_cortex_m_private/cortex_m_constants.h
-  PUBLIC_DEFINES
-    "PW_CPU_EXCEPTION_CORTEX_M_ARMV8M=1"
 )
diff --git a/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_private/config.h b/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_private/config.h
index cf0d184..c34a49b 100644
--- a/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_private/config.h
+++ b/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_private/config.h
@@ -13,6 +13,19 @@
 // the License.
 #pragma once
 
+#include "pw_preprocessor/arch.h"
+
+#if !_PW_ARCH_ARM_CORTEX_M
+#error You can only build this for ARM Cortex-M architectures. If you are \
+       trying to do this and are still seeing this error, see \
+       pw_preprocessor/arch.h
+#endif  // !_PW_ARCH_ARM_CORTEX_M
+
+#if !_PW_ARCH_ARM_V7M && !_PW_ARCH_ARM_V7EM && !_PW_ARCH_ARM_V8M_MAINLINE && \
+    !_PW_ARCH_ARM_V8_1M_MAINLINE
+#error "Your selected ARM Cortex-M arch is not yet supported by this module."
+#endif
+
 // Which log level to use for this module.
 #ifndef PW_CPU_EXCEPTION_CORTEX_M_LOG_LEVEL
 #define PW_CPU_EXCEPTION_CORTEX_M_LOG_LEVEL PW_LOG_LEVEL_DEBUG
diff --git a/pw_interrupt_cortex_m/BUILD.bazel b/pw_interrupt_cortex_m/BUILD.bazel
index 711a218..8020084 100644
--- a/pw_interrupt_cortex_m/BUILD.bazel
+++ b/pw_interrupt_cortex_m/BUILD.bazel
@@ -22,45 +22,53 @@
 licenses(["notice"])
 
 pw_cc_library(
-    name = "context_armv7m_headers",
+    name = "context_headers",
     hdrs = [
         "public/pw_interrupt_cortex_m/context_inline.h",
         "public_overrides/pw_interrupt_backend/context_inline.h",
     ],
-    copts = ["-DPW_INTERRUPT_CORTEX_M_ARMV7M=1"],
     includes = [
         "public",
         "public_overrides",
     ],
+    deps = [
+        "//pw_preprocessor:arch",
+    ],
+)
+
+pw_cc_library(
+    name = "context",
+    deps = [
+        ":context_headers",
+        "//pw_interrupt:context_facade",
+    ],
+)
+
+# The following targets are deprecated, depend on ":context" instead.
+pw_cc_library(
+    name = "context_armv7m_headers",
+    deps = [
+        ":context_headers",
+    ],
 )
 
 pw_cc_library(
     name = "context_armv7m",
-    copts = ["-DPW_INTERRUPT_CORTEX_M_ARMV7M=1"],
     deps = [
-        ":context_armv7m_headers",
-        "//pw_interrupt:context_facade",
+        ":context",
     ],
 )
 
 pw_cc_library(
     name = "context_armv8m_headers",
-    hdrs = [
-        "public/pw_interrupt_cortex_m/context.h",
-        "public_overrides/pw_interrupt_backend/context_backend.h",
-    ],
-    copts = ["-DPW_INTERRUPT_CORTEX_M_ARMV8M=1"],
-    includes = [
-        "public",
-        "public_overrides",
+    deps = [
+        ":context_headers",
     ],
 )
 
 pw_cc_library(
     name = "context_armv8m",
-    copts = ["-DPW_INTERRUPT_CORTEX_M_ARMV8M=1"],
     deps = [
-        ":context_armv8m_headers",
-        "//pw_interrupt:context_facade",
+        ":context",
     ],
 )
diff --git a/pw_interrupt_cortex_m/BUILD.gn b/pw_interrupt_cortex_m/BUILD.gn
index c4fc14d..fed8d29 100644
--- a/pw_interrupt_cortex_m/BUILD.gn
+++ b/pw_interrupt_cortex_m/BUILD.gn
@@ -27,20 +27,11 @@
   visibility = [ ":*" ]
 }
 
-config("armv6m") {
-  defines = [ "PW_INTERRUPT_CORTEX_M_ARMV6M=1" ]
-}
-
-config("armv7m") {
-  defines = [ "PW_INTERRUPT_CORTEX_M_ARMV7M=1" ]
-}
-
-config("armv8m") {
-  defines = [ "PW_INTERRUPT_CORTEX_M_ARMV8M=1" ]
-}
-
-_context_common = {
-  public_deps = [ "$dir_pw_interrupt:context.facade" ]
+pw_source_set("context") {
+  public_deps = [
+    "$dir_pw_interrupt:context.facade",
+    "$dir_pw_preprocessor:arch",
+  ]
   public_configs = [
     ":public_include_path",
     ":backend_config",
@@ -51,22 +42,15 @@
   ]
 }
 
-# This targets provides the ARMv6-M backend for pw_interrupt's context facade.
-pw_source_set("context_armv6m") {
-  forward_variables_from(_context_common, "*")
-  public_configs += [ ":armv6m" ]
+# These targets are deprecated, use ":context" directly.
+group("context_armv6m") {
+  public_deps = [ ":context" ]
 }
-
-# This targets provides the ARMv7-M backend for pw_interrupt's context facade.
-pw_source_set("context_armv7m") {
-  forward_variables_from(_context_common, "*")
-  public_configs += [ ":armv7m" ]
+group("context_armv7m") {
+  public_deps = [ ":context" ]
 }
-
-# This targets provides the ARMv8-M backend for pw_interrupt's context facade.
-pw_source_set("context_armv8m") {
-  forward_variables_from(_context_common, "*")
-  public_configs += [ ":armv8m" ]
+group("context_armv8m") {
+  public_deps = [ ":context" ]
 }
 
 pw_doc_group("docs") {
diff --git a/pw_interrupt_cortex_m/public/pw_interrupt_cortex_m/context_inline.h b/pw_interrupt_cortex_m/public/pw_interrupt_cortex_m/context_inline.h
index ad20f40..8d25f14 100644
--- a/pw_interrupt_cortex_m/public/pw_interrupt_cortex_m/context_inline.h
+++ b/pw_interrupt_cortex_m/public/pw_interrupt_cortex_m/context_inline.h
@@ -15,11 +15,19 @@
 
 #include <cstdint>
 
+#include "pw_preprocessor/arch.h"
+
 namespace pw::interrupt {
 
-#if defined(PW_INTERRUPT_CORTEX_M_ARMV6M) || \
-    defined(PW_INTERRUPT_CORTEX_M_ARMV7M) || \
-    defined(PW_INTERRUPT_CORTEX_M_ARMV8M)
+#if !_PW_ARCH_ARM_CORTEX_M
+#error You can only build this for ARM Cortex-M architectures. If you are \
+       trying to do this and are still seeing this error, see \
+       pw_preprocessor/arch.h
+#endif  // !_PW_ARCH_ARM_CORTEX_M
+
+#if _PW_ARCH_ARM_V6M || _PW_ARCH_ARM_V7M || _PW_ARCH_ARM_V7EM || \
+    _PW_ARCH_ARM_V8M_BASELINE || _PW_ARCH_ARM_V8M_MAINLINE ||    \
+    _PW_ARCH_ARM_V8_1M_MAINLINE
 inline bool InInterruptContext() {
   // ARMv7M Reference manual section B1.4.2 describes how the Interrupt
   // Program Status Register (IPSR) is zero if there is no exception (interrupt)
@@ -29,7 +37,7 @@
   return ipsr != 0;
 }
 #else
-#error "Please select an architecture specific backend."
+#error "Your selected ARM Cortex-M arch is not yet supported by this module."
 #endif
 
 }  // namespace pw::interrupt
diff --git a/pw_preprocessor/BUILD.bazel b/pw_preprocessor/BUILD.bazel
index 2b00bd3..76cf4ac 100644
--- a/pw_preprocessor/BUILD.bazel
+++ b/pw_preprocessor/BUILD.bazel
@@ -24,8 +24,24 @@
 
 pw_cc_library(
     name = "pw_preprocessor",
-    srcs = ["public/pw_preprocessor/internal/arg_count_impl.h"],
-    hdrs = glob(["public/pw_preprocessor/*.h"]),
+    srcs = [
+        "public/pw_preprocessor/internal/arg_count_impl.h",
+    ],
+    hdrs = [
+        "public/pw_preprocessor/arguments.h",
+        "public/pw_preprocessor/boolean.h",
+        "public/pw_preprocessor/compiler.h",
+        "public/pw_preprocessor/concat.h",
+        "public/pw_preprocessor/util.h",
+    ],
+    includes = ["public"],
+)
+
+pw_cc_library(
+    name = "cortex_m",
+    hdrs = [
+        "public/pw_preprocessor/arch.h",
+    ],
     includes = ["public"],
 )
 
diff --git a/pw_preprocessor/BUILD.gn b/pw_preprocessor/BUILD.gn
index 95459e4..f9cc222 100644
--- a/pw_preprocessor/BUILD.gn
+++ b/pw_preprocessor/BUILD.gn
@@ -14,16 +14,24 @@
 
 import("//build_overrides/pigweed.gni")
 
+import("$dir_pw_build/module_config.gni")
 import("$dir_pw_build/target_types.gni")
 import("$dir_pw_docgen/docs.gni")
 import("$dir_pw_unit_test/test.gni")
 
-config("default_config") {
+declare_args() {
+  # The build target that overrides the default configuration options for this
+  # module. This should point to a source set that provides defines through a
+  # public config (which may -include a file or add defines directly).
+  pw_preprocessor_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
+}
+
+config("public_include_path") {
   include_dirs = [ "public" ]
 }
 
 pw_source_set("pw_preprocessor") {
-  public_configs = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   public = [
     "public/pw_preprocessor/arguments.h",
     "public/pw_preprocessor/boolean.h",
@@ -34,6 +42,12 @@
   sources = [ "public/pw_preprocessor/internal/arg_count_impl.h" ]
 }
 
+pw_source_set("arch") {
+  public_configs = [ ":public_include_path" ]
+  public = [ "public/pw_preprocessor/arch.h" ]
+  public_deps = [ pw_preprocessor_CONFIG ]
+}
+
 pw_doc_group("docs") {
   sources = [ "docs.rst" ]
 }
diff --git a/pw_preprocessor/CMakeLists.txt b/pw_preprocessor/CMakeLists.txt
index b2f6f50..1df11f9 100644
--- a/pw_preprocessor/CMakeLists.txt
+++ b/pw_preprocessor/CMakeLists.txt
@@ -14,7 +14,20 @@
 
 include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
 
-pw_auto_add_simple_module(pw_preprocessor)
+pw_add_module_library(pw_preprocessor
+  HEADERS
+    public/pw_preprocessor/arguments.h
+    public/pw_preprocessor/boolean.h
+    public/pw_preprocessor/compiler.h
+    public/pw_preprocessor/concat.h
+    public/pw_preprocessor/util.h
+    public/pw_preprocessor/internal/arg_count_impl.h
+)
+
+pw_add_module_library(pw_preprocessor.arch
+  HEADERS
+    public/pw_preprocessor/arch.h
+)
 
 if(Zephyr_FOUND AND CONFIG_PIGWEED_PREPROCESSOR)
   zephyr_link_libraries(pw_preprocessor)
diff --git a/pw_preprocessor/public/pw_preprocessor/arch.h b/pw_preprocessor/public/pw_preprocessor/arch.h
new file mode 100644
index 0000000..45b7ff4
--- /dev/null
+++ b/pw_preprocessor/public/pw_preprocessor/arch.h
@@ -0,0 +1,95 @@
+// Copyright 2021 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.
+#pragma once
+
+// TODO(pwbug/594): arch.h should be refactored out of pw_preprocessor as the
+// scope is outside of the module. The intended scope of arch.h is only to
+// provide architecture targeting and not any added utilities and capabilities.
+// Perhaps it should be placed under pw_compiler along with pwbug/593, e.g.
+// pw_compiler/arch.h?
+// Regardless, the arch defines should likely move to a trait system in Pigweed
+// before making them public defines for others to use.
+
+// WARNING: These are all internal to Pigweed, do not use these in downstream
+// projects as they expected to move and be renamed in the near future.
+
+// _PW_ARCH_ARM_V6M should be set to 1 for Cortex M0, M0+, M1.
+//
+// Defaults to 0 unless __ARM_ARCH_6M__ is defined as provided by GCC, Clang,
+// CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V6M) && defined(__ARM_ARCH_6M__)
+#define _PW_ARCH_ARM_V6M 1
+#else
+#define _PW_ARCH_ARM_V6M 0
+#endif  // _PW_ARCH_ARM_V6M
+
+// _PW_ARCH_ARM_V7M should be set to 1 for Cortex M3.
+//
+// Defaults to 0 unless __ARM_ARCH_7M__ is defined as provided by GCC, Clang,
+// CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V7M) && defined(__ARM_ARCH_7M__)
+#define _PW_ARCH_ARM_V7M 1
+#else
+#define _PW_ARCH_ARM_V7M 0
+#endif  // _PW_ARCH_ARM_V7M
+
+// _PW_ARCH_ARM_V7EM should be set to 1 for Cortex M4, M7.
+//
+// Defaults to 0 unless __ARM_ARCH_7EM__ is defined as provided by GCC, Clang,
+// CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V7EM) && defined(__ARM_ARCH_7EM__)
+#define _PW_ARCH_ARM_V7EM 1
+#else
+#define _PW_ARCH_ARM_V7EM 0
+#endif  // _PW_ARCH_ARM_V7EM
+
+// _PW_ARCH_ARM_V8M_BASELINE should be set to 1 for Cortex M23.
+//
+// Defaults to 0 unless __ARM_ARCH_8M_BASE__ is defined as provided by GCC,
+// Clang, CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V8M_BASELINE) && defined(__ARM_ARCH_8M_BASE__)
+#define _PW_ARCH_ARM_V8M_BASELINE 1
+#else
+#define _PW_ARCH_ARM_V8M_BASELINE 0
+#endif  // _PW_ARCH_ARM_V8M_BASELINE
+
+// _PW_ARCH_ARM_V8M_MAINLINE should be set to 1 for Cortex M33, M33P.
+//
+// Defaults to 0 unless __ARM_ARCH_8M_MAIN__ is defined as provided by GCC,
+// Clang, CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V8M_MAINLINE) && defined(__ARM_ARCH_8M_MAIN__)
+#define _PW_ARCH_ARM_V8M_MAINLINE 1
+#else
+#define _PW_ARCH_ARM_V8M_MAINLINE 0
+#endif  // _PW_ARCH_ARM_V8M_MAINLINE
+
+// _PW_ARCH_ARM_V8_1M_MAINLINE should be set to 1 for Cortex M55.
+//
+// Defaults to 0 unless __ARM_ARCH_8_1M_MAIN__ is defined as provided by GCC,
+// Clang, CMSIS's headers, etc.
+#if !defined(_PW_ARCH_ARM_V8_1M_MAINLINE) && defined(__ARM_ARCH_8_1M_MAIN__)
+#define _PW_ARCH_ARM_V8_1M_MAINLINE 1
+#else
+#define _PW_ARCH_ARM_V8_1M_MAINLINE 0
+#endif  // _PW_ARCH_ARM_V8_1M_MAINLINE
+
+#define _PW_ARCH_ARM_CORTEX_M_ACTIVE_COUNT                   \
+  (_PW_ARCH_ARM_V6M + _PW_ARCH_ARM_V7M + _PW_ARCH_ARM_V7EM + \
+   _PW_ARCH_ARM_V8M_BASELINE + _PW_ARCH_ARM_V8M_MAINLINE +   \
+   _PW_ARCH_ARM_V8_1M_MAINLINE)
+#if _PW_ARCH_ARM_CORTEX_M_ACTIVE_COUNT > 1
+#error "More than one ARM Cortex M architecture is active."
+#elif _PW_ARCH_ARM_CORTEX_M_ACTIVE_COUNT == 1
+#define _PW_ARCH_ARM_CORTEX_M 1
+#endif
diff --git a/pw_preprocessor/public/pw_preprocessor/compiler.h b/pw_preprocessor/public/pw_preprocessor/compiler.h
index 05089a3..d682260 100644
--- a/pw_preprocessor/public/pw_preprocessor/compiler.h
+++ b/pw_preprocessor/public/pw_preprocessor/compiler.h
@@ -18,6 +18,10 @@
 
 #include <assert.h>
 
+// TODO(pwbug/593): compiler.h should be refactored out of pw_preprocessor as
+// the scope is outside of the module. Perhaps it should be split up and placed
+// under pw_compiler, e.g. pw_compiler/attributes.h & pw_compiler/builtins.h.
+
 // Marks a struct or class as packed.
 #define PW_PACKED(declaration) declaration __attribute__((packed))
 
diff --git a/targets/lm3s6965evb_qemu/BUILD.bazel b/targets/lm3s6965evb_qemu/BUILD.bazel
index c99c5b8..533460f 100644
--- a/targets/lm3s6965evb_qemu/BUILD.bazel
+++ b/targets/lm3s6965evb_qemu/BUILD.bazel
@@ -29,7 +29,7 @@
     ],
     deps = [
         "//pw_boot",
-        "//pw_boot_cortex_m:armv7m",
+        "//pw_boot_cortex_m",
         "//pw_preprocessor",
         "//pw_sys_io_baremetal_lm3s6965evb",
     ],
diff --git a/targets/lm3s6965evb_qemu/BUILD.gn b/targets/lm3s6965evb_qemu/BUILD.gn
index 71f2475..230221c 100644
--- a/targets/lm3s6965evb_qemu/BUILD.gn
+++ b/targets/lm3s6965evb_qemu/BUILD.gn
@@ -27,7 +27,7 @@
   pw_source_set("pre_init") {
     public_deps = [
       "$dir_pw_boot",
-      "$dir_pw_boot_cortex_m:armv7m",
+      "$dir_pw_boot_cortex_m",
       "$dir_pw_sys_io_baremetal_lm3s6965evb",
     ]
     deps = [ "$dir_pw_preprocessor" ]
diff --git a/targets/lm3s6965evb_qemu/target_toolchains.gni b/targets/lm3s6965evb_qemu/target_toolchains.gni
index 5293bc4..3a271b7 100644
--- a/targets/lm3s6965evb_qemu/target_toolchains.gni
+++ b/targets/lm3s6965evb_qemu/target_toolchains.gni
@@ -37,7 +37,7 @@
 
   # Facade backends
   pw_assert_BACKEND = dir_pw_assert_basic
-  pw_boot_BACKEND = "$dir_pw_boot_cortex_m:armv7m"
+  pw_boot_BACKEND = "$dir_pw_boot_cortex_m"
   pw_log_BACKEND = dir_pw_log_basic
   pw_sys_io_BACKEND = dir_pw_sys_io_baremetal_lm3s6965evb
   pw_sync_INTERRUPT_SPIN_LOCK_BACKEND =
diff --git a/targets/mimxrt595_evk/BUILD.bazel b/targets/mimxrt595_evk/BUILD.bazel
index 1d4c10d..6f70ddd 100644
--- a/targets/mimxrt595_evk/BUILD.bazel
+++ b/targets/mimxrt595_evk/BUILD.bazel
@@ -31,7 +31,7 @@
     ],
     deps = [
         "//pw_boot",
-        "//pw_boot_cortex_m:armv8m",
+        "//pw_boot_cortex_m",
         "//pw_preprocessor",
         "//pw_sys_io_mcuxpresso",
     ],
diff --git a/targets/mimxrt595_evk/BUILD.gn b/targets/mimxrt595_evk/BUILD.gn
index e4337bf..9d60034 100644
--- a/targets/mimxrt595_evk/BUILD.gn
+++ b/targets/mimxrt595_evk/BUILD.gn
@@ -99,7 +99,7 @@
     public_configs = [ ":pw_malloc_active" ]
     deps = [
       "$dir_pw_boot",
-      "$dir_pw_boot_cortex_m:armv8m",
+      "$dir_pw_boot_cortex_m",
       "$dir_pw_preprocessor",
       "$dir_pw_sys_io_mcuxpresso",
       pw_third_party_mcuxpresso_SDK,
diff --git a/targets/mimxrt595_evk/target_toolchains.gni b/targets/mimxrt595_evk/target_toolchains.gni
index 7da8875..ff34402 100644
--- a/targets/mimxrt595_evk/target_toolchains.gni
+++ b/targets/mimxrt595_evk/target_toolchains.gni
@@ -33,7 +33,7 @@
 
   # Facade backends
   pw_assert_BACKEND = dir_pw_assert_basic
-  pw_boot_BACKEND = "$dir_pw_boot_cortex_m:armv8m"
+  pw_boot_BACKEND = "$dir_pw_boot_cortex_m"
   pw_sync_INTERRUPT_SPIN_LOCK_BACKEND =
       "$dir_pw_sync_baremetal:interrupt_spin_lock"
   pw_sync_MUTEX_BACKEND = "$dir_pw_sync_baremetal:mutex"
diff --git a/targets/stm32f429i_disc1/BUILD.bazel b/targets/stm32f429i_disc1/BUILD.bazel
index 41158b6..f43dd19 100644
--- a/targets/stm32f429i_disc1/BUILD.bazel
+++ b/targets/stm32f429i_disc1/BUILD.bazel
@@ -29,7 +29,7 @@
     ],
     deps = [
         "//pw_boot",
-        "//pw_boot_cortex_m:armv7m",
+        "//pw_boot_cortex_m",
         "//pw_malloc",
         "//pw_preprocessor",
         "//pw_sys_io_baremetal_stm32f429",
diff --git a/targets/stm32f429i_disc1/BUILD.gn b/targets/stm32f429i_disc1/BUILD.gn
index 0460ba4..8bfec70 100644
--- a/targets/stm32f429i_disc1/BUILD.gn
+++ b/targets/stm32f429i_disc1/BUILD.gn
@@ -35,7 +35,7 @@
     configs = [ ":pw_malloc_active" ]
     public_deps = [
       "$dir_pw_boot",
-      "$dir_pw_boot_cortex_m:armv7m",
+      "$dir_pw_boot_cortex_m",
       "$dir_pw_sys_io_baremetal_stm32f429",
     ]
     deps = [
diff --git a/targets/stm32f429i_disc1/target_toolchains.gni b/targets/stm32f429i_disc1/target_toolchains.gni
index e5d5bbe..61012a7 100644
--- a/targets/stm32f429i_disc1/target_toolchains.gni
+++ b/targets/stm32f429i_disc1/target_toolchains.gni
@@ -44,12 +44,11 @@
 
   # Facade backends
   pw_assert_BACKEND = dir_pw_assert_basic
-  pw_boot_BACKEND = "$dir_pw_boot_cortex_m:armv7m"
+  pw_boot_BACKEND = "$dir_pw_boot_cortex_m"
   pw_cpu_exception_ENTRY_BACKEND =
-      "$dir_pw_cpu_exception_cortex_m:cpu_exception_armv7m"
+      "$dir_pw_cpu_exception_cortex_m:cpu_exception"
   pw_cpu_exception_HANDLER_BACKEND = "$dir_pw_cpu_exception:basic_handler"
-  pw_cpu_exception_SUPPORT_BACKEND =
-      "$dir_pw_cpu_exception_cortex_m:support_armv7m"
+  pw_cpu_exception_SUPPORT_BACKEND = "$dir_pw_cpu_exception_cortex_m:support"
   pw_sync_INTERRUPT_SPIN_LOCK_BACKEND =
       "$dir_pw_sync_baremetal:interrupt_spin_lock"
   pw_sync_MUTEX_BACKEND = "$dir_pw_sync_baremetal:mutex"
diff --git a/targets/stm32f429i_disc1_stm32cube/BUILD.bazel b/targets/stm32f429i_disc1_stm32cube/BUILD.bazel
index 45275cf..891d890 100644
--- a/targets/stm32f429i_disc1_stm32cube/BUILD.bazel
+++ b/targets/stm32f429i_disc1_stm32cube/BUILD.bazel
@@ -34,7 +34,7 @@
     ],
     deps = [
         "//pw_boot",
-        "//pw_boot_cortex_m:armv7m",
+        "//pw_boot_cortex_m",
         "//pw_malloc",
         "//pw_preprocessor",
         "//pw_string",
diff --git a/targets/stm32f429i_disc1_stm32cube/BUILD.gn b/targets/stm32f429i_disc1_stm32cube/BUILD.gn
index 8b858df..0e55048 100644
--- a/targets/stm32f429i_disc1_stm32cube/BUILD.gn
+++ b/targets/stm32f429i_disc1_stm32cube/BUILD.gn
@@ -33,7 +33,7 @@
     configs = [ ":pw_malloc_active" ]
     deps = [
       "$dir_pw_boot",
-      "$dir_pw_boot_cortex_m:armv7m",
+      "$dir_pw_boot_cortex_m",
       "$dir_pw_malloc",
       "$dir_pw_preprocessor",
       "$dir_pw_string",