Skip to content

Conversation

@PikachuHyA
Copy link
Contributor

This patch adds compiler_input_flags_feature and compiler_output_flags_feature to the features.

follow #22717

By default, the features compiler_input_flags_feature and compiler_output_flags_feature are included through CppActionConfigs.java in the getFeaturesToAppearLastInFeaturesList method.

For reference, see the relevant code here:

if (!existingFeatureNames.contains("compiler_input_flags")) {
featureBuilder.add(
getFeature(
Joiner.on("\n")
.join(
" name: 'compiler_input_flags'",
" enabled: true",
" flag_set {",
" action: 'assemble'",
" action: 'preprocess-assemble'",
" action: 'c-compile'",
" action: 'c++-compile'",
" action: 'linkstamp-compile'",
" action: 'c++-module-compile'",
" action: 'c++-module-codegen'",
" action: 'objc-compile'",
" action: 'objc++-compile'",
" action: 'c++-header-parsing'",
" action: 'lto-backend'",
" flag_group {",
" expand_if_all_available: 'source_file'",
" flag: '-c'",
" flag: '%{source_file}'",
" }",
" }")));
}
if (!existingFeatureNames.contains("compiler_output_flags")) {
featureBuilder.add(
getFeature(
Joiner.on("\n")
.join(
" name: 'compiler_output_flags'",
" enabled: true",
" flag_set {",
" action: 'assemble'",
" action: 'preprocess-assemble'",
" action: 'c-compile'",
" action: 'c++-compile'",
" action: 'linkstamp-compile'",
" action: 'c++-module-compile'",
" action: 'c++-module-codegen'",
" action: 'objc-compile'",
" action: 'objc++-compile'",
" action: 'c++-header-parsing'",
" action: 'lto-backend'",
" flag_group {",
" expand_if_all_available: 'output_assembly_file'",
" flag: '-S'",
" }",
" flag_group {",
" expand_if_all_available: 'output_preprocess_file'",
" flag: '-E'",
" }",
" flag_group {",
" expand_if_all_available: 'output_file'",
" flag: '-o'",
" flag: '%{output_file}'",
" }",
" }")));
}

Background

I modified tools/cpp/unix_cc_toolchain_config.bzl and found no input and output on macOS when testing #19940 with the new action names c++20-deps-scanning and c++20-module-compile.

As discussed in #22429 (comment), I added these two features to unix_cc_toolchain_config.bzl.

the Windows toolchains already have these features, so no modifications were necessary for windows_cc_toolchain_config.bzl.

  • Windows input flags:

compiler_input_flags_feature = feature(
name = "compiler_input_flags",
flag_sets = [
flag_set(
actions = [
ACTION_NAMES.assemble,
ACTION_NAMES.preprocess_assemble,
ACTION_NAMES.c_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.cpp_module_compile,
ACTION_NAMES.cpp_module_codegen,
],
flag_groups = [
flag_group(
flags = ["/c", "%{source_file}"],
expand_if_available = "source_file",
),
],
),
],
)

  • Windows output flags:

compiler_output_flags_feature = feature(
name = "compiler_output_flags",
flag_sets = [
flag_set(
actions = [ACTION_NAMES.assemble],
flag_groups = [
flag_group(
flag_groups = [
flag_group(
flags = ["/Fo%{output_file}", "/Zi"],
expand_if_available = "output_file",
expand_if_not_available = "output_assembly_file",
),
],
expand_if_not_available = "output_preprocess_file",
),
],
),
flag_set(
actions = [
ACTION_NAMES.preprocess_assemble,
ACTION_NAMES.c_compile,
ACTION_NAMES.linkstamp_compile,
ACTION_NAMES.cpp_compile,
ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.cpp_module_compile,
ACTION_NAMES.cpp_module_codegen,
],
flag_groups = [
flag_group(
flag_groups = [
flag_group(
flags = ["/Fo%{output_file}"],
expand_if_not_available = "output_preprocess_file",
),
],
expand_if_available = "output_file",
expand_if_not_available = "output_assembly_file",
),
flag_group(
flag_groups = [
flag_group(
flags = ["/Fa%{output_file}"],
expand_if_available = "output_assembly_file",
),
],
expand_if_available = "output_file",
),
flag_group(
flag_groups = [
flag_group(
flags = ["/P", "/Fi%{output_file}"],
expand_if_available = "output_preprocess_file",
),
],
expand_if_available = "output_file",
),
],
),
],
)

cc @comius

@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Jun 14, 2024
@comius comius added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jun 14, 2024
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants