Skip to content

feat: Add native Windows compilation support (MSVC & Clang/MinGW) and PowerShell SDK workflows - #1885

Open
dg1474 wants to merge 15 commits into
SVF-tools:masterfrom
dg1474:pr/windows-port
Open

feat: Add native Windows compilation support (MSVC & Clang/MinGW) and PowerShell SDK workflows#1885
dg1474 wants to merge 15 commits into
SVF-tools:masterfrom
dg1474:pr/windows-port

Conversation

@dg1474

@dg1474 dg1474 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

This Pull Request introduces native Windows compatibility to the SVF framework, allowing developers to configure,
build, compile, and test SVF on Windows using either MSVC or the Clang/MinGW-w64 toolchain.

Additionally, this PR modularizes C++ ABI name mangling/demangling to dynamically support both the MSVC C++
ABI
and the Itanium C++ ABI, updates extapi.c with Windows heap API annotations, and configures Windows CI
testing.


Key Changes

  1. Dynamic CXXABI Demangling:

    • Refactored C++ ABI utilities under svf-llvm/lib/CppUtil.cpp into a modular interface (CXXABI) supporting
      multiple ABI layouts.
    • Preserved ItaniumABI as the default for Unix-like platforms and MinGW compiler configurations (utilizing
      _ZTV, _ZTI, and abi::__cxa_demangle).
    • Implemented MSVCABI for Windows MSVC triple configurations, recognizing MSVC-mangled patterns (such as
      ??_7/??_8 for vtables, ??_R for RTTI/TypeInfo, and ??0/??1 for constructors/destructors) and leveraging
      llvm::demangle.
    • The correct ABI class is dynamically selected at runtime based on the target module's triple configuration.
  2. CMake Portability:

    • Replaced UNIX-specific compiler flags (e.g., -fno-rtti, -rdynamic, -fuse-ld=lld) with MSVC equivalents
      (e.g., /GR-) or guarded them to only apply to non-Windows targets.
    • Re-ordered subdirectories in the root CMakeLists.txt so svf and svf-llvm compile before Test-Suite,
      ensuring target binaries are available when CTests are registered.
  3. Standard Windows Heap API Support:

    • Updated extapi.c with allocation rules and annotations for standard Windows heap APIs (HeapAlloc,
      LocalAlloc, GlobalAlloc, etc.), allowing Saber checkers to run correctly on Windows-compiled bitcode.
  4. PowerShell Automation & CI Workflows:

    • Added setup-windows.ps1, build.ps1, and setup.ps1 to handle the installation of dependencies (CMake,
      Ninja, custom Z3 static builds) and configure the local environment PATH automatically.
    • Updated .github/workflows/github-action.yml to run Windows compilation tests in GitHub Actions (both
      msvc and mingw targets) and updated .github/workflows/svf-lib_binaries.yml to replace NTFS-incompatible colon
      separators (:) with hyphens (-) in performance log filename templates (perf-%Y-%m-%dT%H-%M-%S.txt).

Dependencies

dg1474 added 15 commits July 30, 2026 09:18
- Introduced a quickstart guide for compiling SVF on Windows using MSYS2 and the CLANG64 toolchain.
- Added modifications to `setup.sh` to accommodate Windows environment, including handling of DLL paths and logging.
- Created a testing guide for verifying SVF functionality on Windows, detailing both MSYS2 and PowerShell approaches.
- Updated `setup-windows.ps1` to streamline the installation of dependencies and build process without requiring Visual Studio or MSYS2.
- Enhanced `setup.ps1` for proper environment variable configuration on Windows.
- Modified CMakeLists to support static library linking on Windows and ensure compatibility with LLVM.
- Updated LLVMUtil.cpp to handle debugging information extraction for different LLVM versions.
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.20728% with 443 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.51%. Comparing base (dc7da7e) to head (d912bc5).

Files with missing lines Patch % Lines
svf-llvm/tools/AE/ae.cpp 18.18% 171 Missing ⚠️
svf/lib/MemoryModel/PointsTo.cpp 39.52% 127 Missing ⚠️
svf-llvm/lib/CppUtil.cpp 65.07% 73 Missing ⚠️
svf/lib/Util/ThreadAPI.cpp 57.14% 21 Missing ⚠️
svf-llvm/lib/LLVMUtil.cpp 79.76% 17 Missing ⚠️
svf/lib/WPA/Andersen.cpp 90.42% 9 Missing ⚠️
svf-llvm/lib/BreakConstantExpr.cpp 73.33% 8 Missing ⚠️
svf/include/WPA/Andersen.h 75.00% 6 Missing ⚠️
svf/include/SVFIR/SVFVariables.h 85.71% 5 Missing ⚠️
svf/lib/SVFIR/SVFValue.cpp 54.54% 5 Missing ⚠️
... and 1 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1885      +/-   ##
==========================================
- Coverage   67.89%   67.51%   -0.38%     
==========================================
  Files         261      261              
  Lines       26677    26873     +196     
  Branches     5110     5142      +32     
==========================================
+ Hits        18112    18143      +31     
- Misses       8565     8730     +165     
Files with missing lines Coverage Δ
svf-llvm/include/SVF-LLVM/CppUtil.h 100.00% <ø> (ø)
svf-llvm/include/SVF-LLVM/GEPTypeBridgeIterator.h 94.44% <100.00%> (ø)
svf-llvm/lib/CHGBuilder.cpp 83.03% <100.00%> (ø)
svf/include/MemoryModel/PointerAnalysis.h 80.85% <ø> (ø)
svf/include/MemoryModel/PointsTo.h 100.00% <ø> (ø)
svf/include/WPA/TypeAnalysis.h 50.00% <100.00%> (ø)
svf/lib/CFL/GrammarBuilder.cpp 96.66% <100.00%> (+0.05%) ⬆️
svf/lib/SABER/SaberCheckerAPI.cpp 57.14% <100.00%> (ø)
svf/lib/SVFIR/SVFType.cpp 0.00% <ø> (ø)
svf/lib/Util/ExtAPI.cpp 32.71% <ø> (-35.52%) ⬇️
... and 13 more

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yuleisui yuleisui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@dg1474 Thanks for the contribution. I’ve made a few suggestions in the reviews:

  1. Please consider using a separate GitHub CI workflow and defining the version as a macro rather than hardcoding version 22.
  2. Avoid code formatting in this pull request, as it makes the review more difficult.
  3. The #ifndef _WIN32 checks look a bit messy, although there may not be a much cleaner alternative. It would be good to think about whether these can be simplified or the number of macro insertions reduced as much as possible.

@mbarbar could you also help review this pull request?

sudo apt-get install -y cmake gcc g++ nodejs doxygen graphviz lcov libncurses5-dev libtinfo6 libzstd-dev astyle wget
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be good not to specify a particular version here. Using a macro would be better, as SVF will keep evolving and specifying the version would make maintenance more difficult.

I would also suggest moving the Windows build to a separate GitHub Action.

@@ -0,0 +1,207 @@
---

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you remove all the newly introduced windows-port files, it makes the docs folder look quite heavy and unncessary?

Comment thread build.ps1
@@ -0,0 +1,347 @@
<#

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks to me like this build.ps1 and setup-windows.ps1 and setup.ps1 files are not needed. Please remove them from this pull request

Comment on lines -29 to +36
if (type == SBV) new (&sbv) SparseBitVector<>();
else if (type == CBV) new (&cbv) CoreBitVector();
else if (type == BV) new (&bv) BitVector();
else assert(false && "PointsTo::PointsTo: unknown type");
if (type == SBV)
new (&sbv) SparseBitVector<>();
else if (type == CBV)
new (&cbv) CoreBitVector();
else if (type == BV)
new (&bv) BitVector();
else
assert(false && "PointsTo::PointsTo: unknown type");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please leave the code formatting unchanged so that we can know what the key changes are in your pull request?

Please do so in the other parts/files of this pull request.

@mbarbar

mbarbar commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

I believe this PR needs to be split up before it can be reviewed. These all seem to be independent to me:

  1. ABI stuff in CPPUtil (this looks like quite a serious change and would need more than just a glancing review).
  2. Build and CI related changes to allow for Windows support.
  3. extapi changes for Windows stuff.

Additionally, the style changes need to be reverted, it's impossible to review otherwise.

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.

3 participants