Files
carbon-lang/bazel/cc_toolchains/cc_toolchain_optimization.bzl
T
Chandler Carruth 2bbcfa5e1a Remove ASan from the default build mode (#7003)
Also increases the default optimization to `-Og` which is likely to give
faster turn-around time which is what we want to optimize for here. This
should also _substantially_ shrink binary sizes, etc.

ASan is still available via `--config=asan`, and is added to the CI
infrastructure. However, my current thought is to only run it after push
rather than in PRs and in the merge queue.
2026-04-01 16:45:53 +00:00

72 lines
2.1 KiB
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Definitions of optimization `cc_toolchain_config` features."""
load(
"@rules_cc//cc:cc_toolchain_config_lib.bzl",
"feature",
"feature_set",
"flag_group",
"flag_set",
"with_feature_set",
)
load(
":cc_toolchain_actions.bzl",
"all_compile_actions",
"all_link_actions",
"codegen_compile_actions",
)
# Handle different levels of optimization with individual features so that
# they can be ordered and the defaults can override the minimal settings if
# both are enabled.
minimal_optimization_flags = feature(
name = "minimal_optimization_flags",
flag_sets = [flag_set(
actions = codegen_compile_actions,
flag_groups = [flag_group(flags = ["-Og"])],
)],
)
default_optimization_flags = feature(
name = "default_optimization_flags",
enabled = True,
requires = [feature_set(["opt"])],
flag_sets = [
flag_set(
actions = all_compile_actions,
flag_groups = [flag_group(flags = ["-DNDEBUG"])],
),
flag_set(
actions = codegen_compile_actions,
flag_groups = [flag_group(flags = ["-O3"])],
),
],
)
cpu_flags = feature(
name = "aarch64_cpu_flags",
enabled = True,
flag_sets = [
flag_set(
actions = all_compile_actions + all_link_actions,
flag_groups = [flag_group(flags = ["-march=armv8.2-a"])],
with_features = [with_feature_set(["aarch64_target"])],
),
flag_set(
actions = all_compile_actions + all_link_actions,
flag_groups = [flag_group(flags = ["-march=x86-64-v2"])],
with_features = [with_feature_set(["x86_64_target"])],
),
],
)
# Note that the order of features is significant in this list and determines the
# relative order of flags from the features listed.
optimization_features = [
minimal_optimization_flags,
default_optimization_flags,
cpu_flags,
]