Skip to content

Build a project's TcGlobals with its own path map when the framework imports are cached - #20476

Open
xperiandri wants to merge 3 commits into
dotnet:mainfrom
xperiandri:fix/framework-cache-pathmap
Open

Build a project's TcGlobals with its own path map when the framework imports are cached#20476
xperiandri wants to merge 3 commits into
dotnet:mainfrom
xperiandri:fix/framework-cache-pathmap

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

Description

FrameworkImportsCache caches the framework TcImports together with the TcGlobals built for the first project of a framework set. Its key — framework assemblies, primary assembly, target framework directories, compiler binaries directory, import-reuse key — does not include the path map, and a project reusing the entry got a new TcGlobals only when langVersion or realsig differed, copying pathMap from the cached instance even then. TypedTreePickle.p_range applies tcGlobals.pathMap to every range it writes and EncodeSignatureData applies it to compileTimeWorkingDir, so the in-memory reference data every project exposes to its consumers was mapped with the --pathmap of whichever project filled the cache first: a project without a map lent mapped, relative file names to its consumers, and a project with a map lost it when a sibling came first.

Seen in Visual Studio on a solution with <PathMap>$(MSBuildThisFileDirectory)=.\</PathMap> in Directory.Build.props: symbols imported from a sibling project carried .\backend\Use cases\Circulars\GraphQL\.\backend\Use cases\Circulars\GraphQL\Types\Circular.fs, and Go To Definition opened the generated signature. #20470 keeps the IDE from passing --pathmap at all; this change makes the cache correct for any host that checks mapped and unmapped projects with one FSharpChecker.

Fix: pathMap takes part in the decision like langVersion and realsig, and the new TcGlobals takes it from the project's own TcConfig — in IncrementalBuild.fs and in TransparentCompiler.fs. The cached framework imports themselves do not depend on the map, so the key is unchanged.

Tests: FSharpChecker/PathMap.fs checks, with one checker for both compilers, a project carrying --pathmap:<root>=.\ first and then an application referencing a library without a map; the library function seen from the application must keep the library's absolute file name. Fails without the fix.

Fixes #20474

Checklist

  • Test cases added

  • Performance benchmarks added in case of performance changes

  • Release notes entry updated:

    Please make sure to add an entry with short succinct description of the change as well as link to this pull request to the respective release notes file, if applicable.

    Release notes files:

    • If anything under src/Compiler has been changed, please make sure to make an entry in docs/release-notes/.FSharp.Compiler.Service/<version>.md, where <version> is usually "highest" one, e.g. 42.8.200
    • If language feature was added (i.e. LanguageFeatures.fsi was changed), please add it to docs/release-notes/.Language/preview.md
    • If a change to FSharp.Core was made, please make sure to edit docs/release-notes/.FSharp.Core/<version>.md where version is "highest" one, e.g. 8.0.200.

    Information about the release notes entries format can be found in the documentation.
    Example:

    If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 7, 2026
@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Sep 7, 2026
xperiandri and others added 3 commits September 7, 2026 14:01
…imports are cached

FrameworkImportsCache keys the framework imports, and the TcGlobals built
with them, by the framework set alone. A project reusing the entry got a
fresh TcGlobals only when langVersion or realsig differed, and even then took
pathMap from the cached instance. Since TypedTreePickle applies that map to
every range it writes, the in-memory reference data of each project carried
the --pathmap of whichever project filled the cache first, and a project
without a map handed its consumers file names nothing on disk matches.

pathMap now takes part in the decision like langVersion and realsig, and the
new TcGlobals takes it from the project's own TcConfig, in the incremental
builder and the transparent compiler alike.

Fixes dotnet#20474

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ing project

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@xperiandri
xperiandri force-pushed the fix/framework-cache-pathmap branch from 54a06cf to 0c4b74a Compare September 7, 2026 12:52

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖🕵️ Approved; CI is still running.

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

FrameworkImportsCache lends the first project's --pathmap to every project of the framework set

2 participants