Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .ci/scripts/setup-windows-msvc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
conda create --yes --quiet -n et python=3.12
conda activate et

# Activate the VS environment - this is required for MSVC to work
# There are a bunch of environment variables that it requires.
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64

# Install CI requirements
pip install -r .ci/docker/requirements-ci.txt

# Create build directory
$buildDir = "cmake-out-msvc"
if (Test-Path -Path $buildDir) {
Remove-Item -Path $buildDir -Recurse -Force
}
New-Item -Path $buildDir -ItemType Directory

# Configure CMake with MSVC (not ClangCL) and disable custom/quantized ops
cmake -S . -B $buildDir `
-DCMAKE_BUILD_TYPE=Release `
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON `
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON `
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON `
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON `
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON `
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON `
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON `
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF `
-DEXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=OFF `
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=OFF `
-DEXECUTORCH_BUILD_XNNPACK=ON `
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON `
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON

if ($LASTEXITCODE -ne 0) {
Write-Host "CMake configuration failed. Exit code: $LASTEXITCODE."
exit $LASTEXITCODE
}

# Build with MSVC
cmake --build $buildDir --config Release -j16

if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed. Exit code: $LASTEXITCODE."
exit $LASTEXITCODE
}

Write-Host "MSVC build completed successfully!"
37 changes: 37 additions & 0 deletions .github/workflows/windows-msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Windows MSVC Build

on:
push:
branches:
- main
- release/*
tags:
- ciflow/trunk/*
pull_request:
paths:
- .ci/docker/ci_commit_pins/pytorch.txt
- .ci/scripts/**
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

jobs:
build-windows-msvc:
name: build-windows-msvc
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
with:
submodules: 'recursive'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 60
script: |
conda init powershell

powershell -Command "& {
Set-PSDebug -Trace 1
\$ErrorActionPreference = 'Stop'
\$PSNativeCommandUseErrorActionPreference = \$true

.ci/scripts/setup-windows-msvc.ps1
}"
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,14 @@ def run(self): # noqa C901
f"-DCMAKE_BUILD_TYPE={cmake_build_type}",
]

# Use ClangCL on Windows.
# Use ClangCL on Windows by default, unless EXECUTORCH_USE_MSVC is set.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh these changes arent needed anymore. They are also the wrong idea

if _is_windows():
cmake_configuration_args += ["-T ClangCL"]
if os.environ.get("EXECUTORCH_USE_MSVC"):
# Use default MSVC toolchain
pass
else:
# Use ClangCL toolchain
cmake_configuration_args += ["-T ClangCL"]

# Allow adding extra cmake args through the environment. Used by some
# tests and demos to expand the set of targets included in the pip
Expand Down
Loading