Skip to content

Fix long MSVC linker commands on Windows#2517

Merged
tridao merged 1 commit into
Dao-AILab:mainfrom
jammm:jam/fix_long_linker_paths_windows
Apr 29, 2026
Merged

Fix long MSVC linker commands on Windows#2517
tridao merged 1 commit into
Dao-AILab:mainfrom
jammm:jam/fix_long_linker_paths_windows

Conversation

@jammm
Copy link
Copy Markdown
Contributor

@jammm jammm commented Apr 28, 2026

Similar fix as pypa/distutils#406

Bringing this fix here as new distutils updates may take time to percolate across the community. This PR will immediately unblock users who would like to build flash-attention on RDNA3/4 on windows (#2054)

Use a temporary response file when setuptools emits an oversized link.exe command so Windows builds with many object files can complete.

Made-with: Cursor
@jammm
Copy link
Copy Markdown
Contributor Author

jammm commented Apr 29, 2026

For anyone looking to build flash-attention on Windows on your RDNA3/3.5/4 GPU while this PR is awaiting to be merged, follow the commands below:

# Clone the PR branch:
git clone --recursive https://github.com/jammm/flash-attention -b jam/fix_long_linker_paths_windows

cd flash-attention

# Activate Visual Studio environment
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" >nul 2>&1 && set' | ForEach-Object { if ($_ -match '^([^=]+)=(.*)$') { [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2], 'Process') } }

# Activate the virtual environment
.\venv\Scripts\Activate.ps1

# Set ROCm paths using rocm-sdk
$ROCM_ROOT = (rocm-sdk path --root).Trim()
$ROCM_BIN = (rocm-sdk path --bin).Trim()
$env:ROCM_HOME = $ROCM_ROOT
$env:PATH = "$ROCM_ROOT\lib\llvm\bin;$ROCM_BIN;$env:PATH"

# Set compiler and build settings
$env:CC = "clang-cl"
$env:CXX = "clang-cl"
$env:DISTUTILS_USE_SDK = "1"

# install flash-attention
pip install --no-build-isolation -v .

@jammm
Copy link
Copy Markdown
Contributor Author

jammm commented Apr 29, 2026

@rocking5566 @tridao PTAL. This will fix a long-standing issue of compiling flash-attention with CK backend on Windows. Once distutils PR gets merged and percolates, we can revert this change. But that will take a long time, so this solution is best to be merged in the short-medium term.

@tridao tridao merged commit b995b24 into Dao-AILab:main Apr 29, 2026
ussoewwin pushed a commit to ussoewwin/flash-attention that referenced this pull request May 13, 2026
Use a temporary response file when setuptools emits an oversized link.exe command so Windows builds with many object files can complete.

Made-with: Cursor
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