Skip to content

Action fails on projects using C++20 module interface units (.ixx files) #44

@gdr-at-ms

Description

@gdr-at-ms

Problem

The action fails when the CMake project contains C++20 named module interface units (.ixx files) registered via FILE_SET CXX_MODULES. The action collects source files from the CMake file API's compileGroups and passes each to cl.exe /analyze:only, but does not account for the module-specific compilation requirements of .ixx files.

Observed behavior

The Analysis CI job fails on PR GabrielDosReis/ipr#322, while all 10 build-and-test jobs (MSVC, GCC, Clang) pass.

The project (GabrielDosReis/ipr, branch modules/cxx-ipr) uses CMake's FILE_SET CXX_MODULES to register three module interface units:

target_sources(${PROJECT_NAME}
   PUBLIC
      FILE_SET CXX_MODULES FILES
         src/cxx-ipr-vocabulary.ixx
         src/cxx-ipr-syntax.ixx
         src/cxx-ipr.ixx
)

The workflow file (.github/workflows/analysis.yml) invokes:

uses: microsoft/msvc-code-analysis-action@v0.1.1
with:
  cmakeBuildDirectory: build
  buildConfiguration: Release

Root cause

In index.js, loadCompileCommands iterates over target.compileGroups[].sourceIndexes and creates a CompileCommand for each source. When the source is a .ixx module interface unit, the action passes it to cl.exe /analyze:only without the flags required to compile a module interface unit:

  • No /interface flag (required for MSVC to treat .ixx as a module interface)
  • No /ifcOutput or module mapper flags
  • No awareness of inter-module dependencies (module interfaces must be compiled in dependency order before their consumers)

As a result, cl.exe fails when processing the .ixx files, and the action reports compilation errors.

Steps to reproduce

  1. Clone https://github.com/GabrielDosReis/ipr, branch modules/cxx-ipr
  2. Configure with CMake and MSVC (VS 18 Preview): cmake -S . -B build -G Ninja
  3. Run the action against the build directory

Or observe the failing Analysis job on PR GabrielDosReis/ipr#322.

Environment

  • Action version: microsoft/msvc-code-analysis-action@v0.1.1
  • Compiler: MSVC 19.50 (Visual Studio 18 IntPreview)
  • CMake: 3.31+
  • Build generator: Ninja
  • OS: windows-latest (GitHub Actions runner)

Relevant code

The source enumeration in index.js (loadCompileCommands function, around line 330) does not distinguish between regular .cxx/.cpp source files and .ixx module interface units. The CompileCommand constructor captures group.compileCommandFragments but these fragments from CMake's codemodel API for module sources may include module-specific flags that the action does not forward or understand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions