microsoft / microsoft/msbuild-extractor-sample

--deduplicate unions /Fp (PCH output path) across merged entries, producing invalid multi- /Fp command lines

Open
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
30
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When  --deduplicate  collapses the multiple compile entries for a source file that is built in more than one project,  MergeEntries  treats the PCH switches ( /Fp ,  /Yu ,  /Yc ) as generic "other" flags and unions them. Because each project emits a distinct  /Fp , the merged entry ends up carrying multiple conflicting  /Fp  switches.  /Fp  is a single-valued, last-wins cl.exe switch (it names the PCH file), so the resulting command line cannot be honored coherently by a compiler or an IntelliSense engine.

Repro

  1. A repo where source files are compiled in multiple projects with PCH (e.g. Windows Terminal  OpenConsole.slnx ).
  2. Run the extractor with dedup:
    dotnet run --project msbuild-extractor-sample.csproj -c Release --
    --solution \OpenConsole.slnx -c Debug -a x64
    --deduplicate --prefer-configuration Debug --prefer-platform x64
    --msbuild-path <...> --vc-tools-install-dir <...> --cl-path <...>
    -o .mscppls\compile_commands.json
  3. Inspect the output for entries with more than one  /Fp .

Expected

Each deduplicated entry has at most one PCH identity: a single  /Fp  and its matching  /Yu  or  /Yc , taken from the preferred (config/platform-winning) entry, consistent with how  IsPreferred  already selects the base command.

Actual

Merged entries carry multiple distinct  /Fp  paths. In a Windows Terminal Debug/x64 extraction (extractor  msbuild-extractor-sample/1.0.0 ): 562 deduplicated entries, 53 entries with more than one  /Fp , max 5 on a single entry. Worst case is a PCH-create source:

precomp.cpp (/Yc) 5 x /Fp:
/Fp...\Host.EXE\OpenConsole.pch
/Fp...\Host.FuzzWrapper\OpenConsoleFuzzer.pch
/Fp...\Host\ConhostV2Lib.pch
/Fp...\Host.Tests.Unit\Conhost.Unit.Tests.pch
/Fp...\Host.unittest\ConhostV2Lib.unittest.pch

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating MergeEntries and IsPreferred in the extractor, then reproduce the issue with the provided OpenConsole.slnx deduplication command. Compare the preferred base command with the merged PCH switches. Done means deduplicated entries contain at most one /Fp path and its matching /Yu or /Yc, without conflicting paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.