Repository navigation
[tools] Fix race condition in assembly-preparer Makefile - #25762
Conversation
When MSBuild builds assembly-preparer for multiple target frameworks in parallel, both TFMs invoke 'make generated-files' concurrently. Each make invocation tries to rebuild assembly-preparer.csproj.inc (via the pattern rule in mk/rules.mk), which runs create-makefile-fragment.sh. Two concurrent instances of this script share intermediate files (.inputs), causing one to delete files the other needs, resulting in a corrupt .inc file and a 'missing separator' make error. Fix by skipping the -include of the .inc file when the target is generated-files, since that target doesn't need the dependency variable from the .inc file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR addresses a build race in tools/assembly-preparer where MSBuild can invoke make generated-files concurrently for multiple TFMs, causing assembly-preparer.csproj.inc regeneration to collide and produce a corrupt .inc file / Make parse error.
Changes:
- Adds a
MAKECMDGOALSguard to avoid-include assembly-preparer.csproj.incwhen the requested goal isgenerated-files. - Documents why the include is conditionally skipped (concurrent MSBuild invocations + non-concurrent-safe generator script intermediates).
✅ [PR Build #61c5eac] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #61c5eac] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #61c5eac] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #61c5eac] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 207 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
The
assembly-preparer.csprojbuilds for two target frameworks (netstandard2.0andnet10.0) in parallel. Both TFMs invokemake generated-filesconcurrently via aBeforeTargets="CoreCompile"target. Eachmakeinvocation triggers a rebuild ofassembly-preparer.csproj.inc(via the pattern rule inmk/rules.mk), which runscreate-makefile-fragment.sh. Two concurrent instances of this script share the same intermediate files (.inputs), causing one to corrupt or delete files the other needs. This results in a corrupt.incfile and a*** missing separatormake error.The fix wraps the
-include assembly-preparer.csproj.incin anifneq ($(MAKECMDGOALS),generated-files)guard, so the.incfile is not rebuilt when the target isgenerated-files-- since it is not needed for that target anyway.🤖 Pull request created by Copilot