-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Overview
We're aiming to support as much of the toolkit as possible on Windows.
- Our build target is "native" Windows (not WSL 1 or WSL 2), compiling using standard build tools (e.g. MSVC).
- We should support local builds, have regular CI builds (GitHub Actions), and eventually be able to distribute artifacts.
- We should also have any appropriate documentation, developer guides, etc. needed.
Current status
- Documentation for building and a list of currently supported subprojects is at https://github.com/ROCm/TheRock/blob/main/docs/development/windows_support.md.
- The 'base' and 'compiler' components build fully from public sources
- The 'core' component can build from public static libraries built from private sources (https://github.com/nod-ai/amdgpu-windows-interop).
- The 'math libraries' components all build. Some tests have been validated
- MIOpen builds
- The
build_windows_packages.yml
workflow runs as part ofci.yml
on every commit. The workflow builds some supported subprojects and publishes all built artifacts to S3. - The
release_windows_packages.yml
workflow runs nightly and publishes tarballs, rocm python packages, and torch packages to nightly releases. - PyTorch support is in preview: [Windows] Support building PyTorch with ROCm support #589
Initial experiments 2025-01-30
Expand to see details
Setup notes
- I'm on Windows 11 version 23H2, OS build 22631.4751
- I enabled Windows developer mode and granted my user account the ability to create symlinks
- I created a Dev Drive by following https://learn.microsoft.com/en-us/windows/dev-drive/ (500GB, shared with other projects)
- I installed standard software development tools and configured developer options:
-
git from https://git-scm.com/downloads (latest version
2.45.1
) then enabled symlinks withgit config --global core.symlinks true
-
Build Tools for Visual Studio 2022 from https://visualstudio.microsoft.com/downloads/ (latest version
17.12.4
) -
CMake from https://cmake.org/download/ (latest, version
3.31.5
) -
Ninja as a CMake generator from https://ninja-build.org/ (latest, version
1.12.1
) -
ccache from https://ccache.dev/ (latest, version
4.10.2
)
-
Fetching sources
After cloning TheRock, I tried to checkout sources using python ./build_tools/fetch_sources.py
. That needed the repo tool (https://gerrit.googlesource.com/git-repo/+/HEAD/README.md, docs at https://source.android.com/docs/setup/reference/repo), which is not distributed on Windows, so I downloaded the script manually. I did then have to edit build_tools/fetch_sources.py
to exec python D:/path/to/repo
instead of just repo
. We can teach that script how to download the file on its own and run it in a portable way.
Configure and build
After fetching sources, I tried configuring and building with CMake (under VSCode):
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DTHEROCK_ENABLE_RCCL=OFF -DTHEROCK_ENABLE_MATH_LIBS=OFF -DTHEROCK_ENABLE_ML_FRAMEWORKS=OFF -DTHEROCK_AMDGPU_FAMILIES=gfx110X-dgpu -UTHEROCK_AMDGPU_TARGETS -UTHEROCK_AMDGPU_DIST_BUNDLE_NAME -DLLVM_BUILD_LLVM_DYLIB=OFF --no-warn-unused-cli -SD:/projects/TheRock -Bd:/projects/TheRock/build -G Ninja
I found a few Windows issues specific to TheRock:
- Quote paths in toolchain to support spaces in paths on Windows. #34
- Skip dlopen test on Windows for now. #35
Next, I'm finding issues in the subprojects that TheRock includes. Sample logs: https://gist.github.com/ScottTodd/0a6625c4502169c5d54535bf122fc7fd. I'm not sure how deep these issues go, and if some of them are fixed on development branches. Here are a few I've found so far:
-
rocm-core
__attribute__
is not portable to all compilers (specifically MSVC) in https://github.com/ROCm/rocm-core/blob/master/rocm_version.h.in, do something like#if defined(_WIN32) || defined(__CYGWIN__) #define LIB_API_PUBLIC __declspec(dllexport) #else #define LIB_API_PUBLIC __attribute__((visibility("default"))) #endif
Need a similar fix for
__attribute__((nonnull))
, maybe_Ret_nonnull
(https://stackoverflow.com/a/78737973) -
rocm-core
link.h
anddlfcn.h
headers are Unix-only in https://github.com/ROCm/rocm-core/blob/master/rocm_getpath.cpp (use something likeLoadLibraryA()
on a.dll
instead ofdlopen()
on a.so
). The headers should also only be included ifBUILD_SHARED_LIBS
is defined (see next bullet)- Setting
-DBUILD_SHARED_LIBS=OFF
here helps a bit: https://github.com/nod-ai/TheRock/blob/96ebf46b5ca62add1307d9f03db6d04f31207ff0/base/CMakeLists.txt#L22
- Setting
-
rocm-core in the same file uses
PATH_MAX
which is nonstandard. There is aFILENAME_MAX
that is standard but https://stackoverflow.com/a/65174437 says it is not to be trusted for memory allocation. Could do something likemin(FILENAME_MAX, 4096)
(choosing some sensible value that is notINT_MAX
) -
llvm warns about
Generating libLLVM is not supported on MSVC
in https://github.com/ROCm/llvm-project/blob/amd-staging/llvm/tools/llvm-shlib/CMakeLists.txt so I set-DLLVM_BUILD_LLVM_DYLIB=OFF
in my CMake configure command. Not sure if that was load bearing for anything else yet. Could auto-detect and flip that off by default in TheRock or one of the subprojects that includes it. -
rocm_smi_lib sets
CMAKE_CXX_FLAGS
that assume gcc/clang: https://github.com/ROCm/rocm_smi_lib/blob/e5c5a1d5b7cba41ab801a987fb6c466503411804/CMakeLists.txt#L79-L85. It seems like https://github.com/ROCm/amdsmi is the successor to rocm_smi, but it has the same issue: https://github.com/ROCm/amdsmi/blob/9872083b491c9b136496fd493414aca5c6c144cb/CMakeLists.txt#L99-L104. Both projects also only claim to support Linux.