Skip to content

Add MSVC precompiled header support - #5301

Merged
randombit merged 2 commits into
jack/precompiled-headersfrom
copilot/sub-pr-5298
Feb 8, 2026
Merged

Add MSVC precompiled header support#5301
randombit merged 2 commits into
jack/precompiled-headersfrom
copilot/sub-pr-5298

Conversation

Copilot AI commented Feb 8, 2026

Copy link
Copy Markdown

Extends PCH support to Microsoft Visual C++. MSVC requires compiling a .cpp stub file to create PCH, unlike GCC/Clang which compile headers directly.

Compiler Configuration (src/build-data/cc/msvc.txt)

  • Added /Yc (create PCH), /Yu (use PCH), and pch suffix

Configure Script (configure.py)

  • Generates stub .cpp files for MSVC: pch_lib.cpp and pch_exe.cpp containing #include "pch_lib.h"
  • Sets compiler-specific variables:
    • MSVC: /Ycpch_lib.h /Fp<path> for creation, /Yupch_lib.h /Fp<path> /FIpch_lib.h for usage
    • GCC/Clang: existing -x c++-header and -include flags

Build Templates (makefile.in, ninja.in)

  • Replaced hardcoded paths with pch_src_for_{lib,exe} and pch_compile_for_{lib,exe} variables
  • Enables compiler-agnostic PCH rules

Example MSVC commands:

# Create PCH
cl /Ycpch_lib.h /Fpbuild/obj/pch/pch_lib.h.pch /c build/obj/pch/pch_lib.cpp

# Use PCH
cl /Yupch_lib.h /Fpbuild/obj/pch/pch_lib.h.pch /FIpch_lib.h /c src/lib/file.cpp

Maintains backward compatibility with GCC/Clang PCH support.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: randombit <469092+randombit@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for precompiled headers Add MSVC precompiled header support Feb 8, 2026
Copilot AI requested a review from randombit February 8, 2026 21:11
@randombit
randombit marked this pull request as ready for review February 8, 2026 21:29
@randombit
randombit merged commit 1a51c2c into jack/precompiled-headers Feb 8, 2026
1 check passed
@randombit
randombit deleted the copilot/sub-pr-5298 branch February 8, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants