Skip to content

C++20 modules: fragility with renaming module files #933

Open

Description

@rdong8

Create the following files.

BUILD.bazel:

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "tmp",
    features = ["cpp_modules"],
    module_interfaces = glob(
        include = ["**/*.cppm"],
    ),
)

mod.cppm:

export module tmp;

export import :backend;
export import :frontend;
export import :utility;

backend/mod.cppm:

export module tmp:backend;

frontend/mod.cppm:

export module tmp:frontend;

import :utility;

utility/mod.cppm:

export module tmp:utility;

Run bazel build :tmp. It should work correctly. Then rename frontend/mod.cppm to frontend/frontend.cppm and rebuild:

INFO: Analyzed target //src/tmp:tmp (2 packages loaded, 43 targets configured).
ERROR: /home/dev/projects/monorepo/src/tmp/BUILD.bazel:3:11: in cc_library rule //src/tmp:tmp: cycle in dependency graph:
    configured target: //src/tmp:tmp
    action from: ActionLookupDataN{actionLookupKey=ConfiguredTargetKey{label=//src/tmp:tmp, config=BuildConfigurationKey[806b22ad4a3c03c6eb7140f5709122e4027d3e4480c7edeb92ef1f946e78abb9]}, actionIndex=15}
.-> action from: ActionLookupDataN{actionLookupKey=ConfiguredTargetKey{label=//src/tmp:tmp, config=BuildConfigurationKey[806b22ad4a3c03c6eb7140f5709122e4027d3e4480c7edeb92ef1f946e78abb9]}, actionIndex=13}
|   action from: ActionLookupDataN{actionLookupKey=ConfiguredTargetKey{label=//src/tmp:tmp, config=BuildConfigurationKey[806b22ad4a3c03c6eb7140f5709122e4027d3e4480c7edeb92ef1f946e78abb9]}, actionIndex=11}
`-- action from: ActionLookupDataN{actionLookupKey=ConfiguredTargetKey{label=//src/tmp:tmp, config=BuildConfigurationKey[806b22ad4a3c03c6eb7140f5709122e4027d3e4480c7edeb92ef1f946e78abb9]}, actionIndex=13}
Target //src/tmp:tmp failed to build
INFO: Elapsed time: 1.013s, Critical Path: 0.18s
INFO: 9 processes: 4 action cache hit, 1 internal, 8 processwrapper-sandbox.
ERROR: Build did NOT complete successfully

Doing bazel clean will fix it however.

Activity

  1. fmeum commented on Oct 14, 2026

    @fmeum
    Collaborator

    This is caused by a limitation of Bazel's way of checking for up-to-dateness of action outputs. bazelbuild/bazel#29925 would fix this, I'll get back to it after BazelCon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions