Bazel: Remove most copts from pw_cc_library macro

Putting the copts in the macro was a workaround while we didn't control
our compiler configuration.

The warnings flags need to stay here until b/300330623 is fixed.  The
problem is that our dependencies trip these warnings, so we can't apply
them at the toolchain level.

Bug: b/267498492
Change-Id: Ia896a1aa20c6a98d0d2292a9fab2eaaf81db421d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/170824
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
diff --git a/pw_build/bazel_internal/pigweed_internal.bzl b/pw_build/bazel_internal/pigweed_internal.bzl
index 10b13af..d7ce6df 100644
--- a/pw_build/bazel_internal/pigweed_internal.bzl
+++ b/pw_build/bazel_internal/pigweed_internal.bzl
@@ -17,18 +17,6 @@
 
 load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
 
-DEBUGGING = [
-    "-g",
-]
-
-# Standard compiler flags to reduce output binary size.
-REDUCED_SIZE_COPTS = [
-    "-fno-common",
-    "-fno-exceptions",
-    "-ffunction-sections",
-    "-fdata-sections",
-]
-
 STRICT_WARNINGS_COPTS = [
     "-Wall",
     "-Wextra",
@@ -38,11 +26,7 @@
     "-Wno-error=deprecated-declarations",  # [[deprecated]] attribute
 ]
 
-PW_DEFAULT_COPTS = (
-    DEBUGGING +
-    REDUCED_SIZE_COPTS +
-    STRICT_WARNINGS_COPTS
-)
+PW_DEFAULT_COPTS = STRICT_WARNINGS_COPTS
 
 KYTHE_COPTS = [
     "-Wno-unknown-warning-option",
diff --git a/pw_toolchain/arm_gcc/BUILD.bazel b/pw_toolchain/arm_gcc/BUILD.bazel
index ff3ea3b..c3402fc 100644
--- a/pw_toolchain/arm_gcc/BUILD.bazel
+++ b/pw_toolchain/arm_gcc/BUILD.bazel
@@ -68,7 +68,6 @@
     ],
     copts = [
         "-ffreestanding",
-        "-fno-common",
         "-Wno-psabi",
         "-specs=nano.specs",
         "-specs=nosys.specs",
@@ -187,6 +186,8 @@
     feature_deps = [
         "@pw_toolchain//features:o2",
         "@pw_toolchain//features:c++17",
+        "@pw_toolchain//features:debugging",
+        "@pw_toolchain//features:reduced_size",
         "@pw_toolchain//features:no_canonical_prefixes",
         "@pw_toolchain//features:no_rtti",
         "@pw_toolchain//features:wno_register",
diff --git a/pw_toolchain/host_clang/BUILD.bazel b/pw_toolchain/host_clang/BUILD.bazel
index b114517..1da0d8a 100644
--- a/pw_toolchain/host_clang/BUILD.bazel
+++ b/pw_toolchain/host_clang/BUILD.bazel
@@ -79,6 +79,8 @@
         ":macos_stdlib",
         "@pw_toolchain//features/macos:macos_sysroot",
         "@pw_toolchain//features:c++17",
+        "@pw_toolchain//features:debugging",
+        "@pw_toolchain//features:reduced_size",
         "@pw_toolchain//features:no_canonical_prefixes",
         "@pw_toolchain//features:no_rtti",
         "@pw_toolchain//features:wno_register",
@@ -131,6 +133,8 @@
     feature_deps = [
         ":linux_sysroot",
         "@pw_toolchain//features:c++17",
+        "@pw_toolchain//features:debugging",
+        "@pw_toolchain//features:reduced_size",
         "@pw_toolchain//features:no_canonical_prefixes",
         "@pw_toolchain//features:no_rtti",
         "@pw_toolchain//features:wno_register",
diff --git a/pw_toolchain_bazel/features/BUILD.bazel b/pw_toolchain_bazel/features/BUILD.bazel
index 49431c4..c41e013 100644
--- a/pw_toolchain_bazel/features/BUILD.bazel
+++ b/pw_toolchain_bazel/features/BUILD.bazel
@@ -69,3 +69,19 @@
     name = "wnon_virtual_dtor",
     cxxopts = ["-Wnon-virtual-dtor"],
 )
+
+# Standard compiler flags to reduce output binary size.
+pw_cc_toolchain_feature(
+    name = "reduced_size",
+    copts = [
+        "-fno-common",
+        "-fno-exceptions",
+        "-ffunction-sections",
+        "-fdata-sections",
+    ],
+)
+
+pw_cc_toolchain_feature(
+    name = "debugging",
+    copts = ["-g"],
+)