blob: 464033e348403ba71ba8f90ce3e925d0a515a54f [file] [log] [blame]
# Copyright 2023 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.
load(
"//cc_toolchain:defs.bzl",
"pw_cc_flag_set",
)
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
# Optimization level option
pw_cc_flag_set(
name = "o2",
actions = [
"@pw_toolchain//actions:all_c_compiler_actions",
"@pw_toolchain//actions:all_cpp_compiler_actions",
"@pw_toolchain//actions:all_link_actions",
],
flags = ["-O2"],
)
# Prevent relative paths from being converted to absolute paths.
pw_cc_flag_set(
name = "no_canonical_prefixes",
actions = [
"@pw_toolchain//actions:all_c_compiler_actions",
"@pw_toolchain//actions:all_cpp_compiler_actions",
],
flags = ["-no-canonical-prefixes"],
)
# Compile without runtime type information (RTTI). This produces smaller binaries.
pw_cc_flag_set(
name = "no_rtti",
actions = ["@pw_toolchain//actions:all_cpp_compiler_actions"],
flags = ["-fno-rtti"],
)
# Allow uses of the register keyword, which may appear in C headers.
pw_cc_flag_set(
name = "wno_register",
actions = ["@pw_toolchain//actions:all_cpp_compiler_actions"],
flags = ["-Wno-register"],
)
# Compile for the C++17 standard.
pw_cc_flag_set(
name = "c++17",
actions = [
"@pw_toolchain//actions:all_cpp_compiler_actions",
"@pw_toolchain//actions:all_link_actions",
],
flags = ["-std=c++17"],
)
# Issue a warning when a class appears to be polymorphic, yet it declares a
# non-virtual destructor
pw_cc_flag_set(
name = "wnon_virtual_dtor",
actions = ["@pw_toolchain//actions:all_cpp_compiler_actions"],
flags = ["-Wnon-virtual-dtor"],
)
# Standard compiler flags to reduce output binary size.
pw_cc_flag_set(
name = "reduced_size",
actions = [
"@pw_toolchain//actions:all_c_compiler_actions",
"@pw_toolchain//actions:all_cpp_compiler_actions",
],
flags = [
"-fno-common",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
],
)
pw_cc_flag_set(
name = "debugging",
actions = [
"@pw_toolchain//actions:all_c_compiler_actions",
"@pw_toolchain//actions:all_cpp_compiler_actions",
],
flags = ["-g"],
)