Skip to content

Commit 11f7383

Browse files
fmeumcopybara-github
authored andcommitted
Apply --cxxopt to C++20 module interfaces
Copybara Import from bazelbuild/rules_cc#520 BEGIN_PUBLIC Apply `--cxxopt` to C++20 module interfaces (bazelbuild#520) C++20 module interfaces are not recognizable by fixed extensions, only by their appearance in the `module_interfaces` attribute. Closes bazelbuild#520 END_PUBLIC PiperOrigin-RevId: 829568265 Change-Id: Iee8da3eabdb27b4897e1d39d0ec56e904c3e1040
1 parent 69bfa72 commit 11f7383

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/starlark/builtins_bzl/common/cc/compile/compile.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ def _create_scan_deps_action(
558558
copts = copts,
559559
cxxopts = cxxopts,
560560
label = source_label,
561+
# Treat C++20 module interfaces as C++ source files regardless of their extension.
562+
override_extension = extensions.CC_SOURCE[0],
561563
),
562564
)
563565
compile_variables = _cc_internal.combine_cc_toolchain_variables(
@@ -1609,6 +1611,8 @@ def _create_compile_source_action(
16091611
conlyopts = conlyopts,
16101612
cxxopts = cxxopts,
16111613
label = source_label,
1614+
# Treat C++20 module interfaces as C++ source files regardless of their extension.
1615+
override_extension = extensions.CC_SOURCE[0] if action_name == ACTION_NAMES.cpp20_module_compile else None,
16121616
)
16131617

16141618
compile_variables = get_specific_compile_build_variables(

src/main/starlark/builtins_bzl/common/cc/compile/compile_build_variables.bzl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,14 @@ def get_copts(
385385
conlyopts,
386386
copts,
387387
cxxopts,
388-
label):
389-
extension = "." + source_file.extension if source_file.extension else ""
388+
label,
389+
override_extension = None):
390+
if override_extension != None:
391+
extension = override_extension
392+
elif source_file.extension:
393+
extension = "." + source_file.extension
394+
else:
395+
extension = ""
390396
result = []
391397
result.extend(_copts_from_options(language, cpp_configuration, extension))
392398
result.extend(copts)

0 commit comments

Comments
 (0)