mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:40:11 +01:00
Rather than defining our own action groups, work to re-use the `rules_cc` ones, as they are (much) more comprehensive. Also, completely eliminate the `codegen` action group as it was not well used. For example, `-march` flags and `-O` flags change the preprocessor macros defined. There isn't a really great "codegen" heuristic, so just pass those flags to all compiles which is simpler anyways. I'm tempted to do the same with preprocessor actions, but maybe it makes sense to have that one stay separate. Assisted-by: Antigravity with Gemini
67 lines
2.2 KiB
Python
67 lines
2.2 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:action_names.bzl", "ACTION_NAME_GROUPS")
|
|
load(
|
|
"@rules_cc//cc:cc_toolchain_config_lib.bzl",
|
|
"feature",
|
|
"feature_set",
|
|
"flag_group",
|
|
"flag_set",
|
|
"with_feature_set",
|
|
)
|
|
|
|
# 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 = ACTION_NAME_GROUPS.all_cc_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 = ACTION_NAME_GROUPS.all_cc_compile_actions,
|
|
flag_groups = [flag_group(flags = ["-DNDEBUG"])],
|
|
),
|
|
flag_set(
|
|
actions = ACTION_NAME_GROUPS.all_cc_compile_actions,
|
|
flag_groups = [flag_group(flags = ["-O3"])],
|
|
),
|
|
],
|
|
)
|
|
|
|
cpu_flags = feature(
|
|
name = "aarch64_cpu_flags",
|
|
enabled = True,
|
|
flag_sets = [
|
|
flag_set(
|
|
actions = ACTION_NAME_GROUPS.all_cc_compile_actions + ACTION_NAME_GROUPS.all_cc_link_actions,
|
|
flag_groups = [flag_group(flags = ["-march=armv8.2-a"])],
|
|
with_features = [with_feature_set(["aarch64_target"])],
|
|
),
|
|
flag_set(
|
|
actions = ACTION_NAME_GROUPS.all_cc_compile_actions + ACTION_NAME_GROUPS.all_cc_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,
|
|
]
|