My (kinda works) fix to cross-compile android-llvm for Windows on Linux using MSVCConfig

41 views
Skip to first unread message

Naville Zhang

unread,
Jul 30, 2025, 6:42:00 AMJul 30
to android-llvm
Hi:
As title suggested, 
I attempted to fix up enough of llvm_android, thought it would be a good idea to show the initial work, get some code-review comments and attempt to submit my patches to AOSP.

Naville Zhang

unread,
Jul 30, 2025, 6:43:50 AMJul 30
to android-llvm
As to why MingW is not enough, please reference to https://github.com/msys2/MINGW-packages/issues/9771
Basically MingW's exception handling is very broken, and in our downstream build we build LLVM with Z3, a project with exception semantics everywhere and thus breaks

Naville Zhang

unread,
Jul 31, 2025, 4:51:09 AMJul 31
to android-llvm

I've successfully built everything on Linux using MSVC SDK using the attached patch.

Main changes include:
# win_sdk
- Fix broken path handling, now we require win_sdk's path to point to the root of the sdk package packed by aosp depot_tools
- Fix the algorithm used to expand environment variables in SetEnv.json
- Remove the half-ass baked broken Windows SDK Case Fixing component, and instead rely on the SDK being stored in a case-insensitive filesystem

# MSVCConfig
- Fix typo in code that results in  llvm_triple returning a triple instead of a string
- Use Host Stage2 toolchain to avoid building LLVM Host Tools in WindowsBuilder, which is broken without MinGW and too much work to fix.
- Add llvm-rc.exe and llvm-ml.exe

# LLVM
- Disable LLVM's InlineAsm BLAKE3 Implementation, which last time I check is broken on ClangCL, resulting in runtime crash.


It seems to me that I can't upload this patch to AOSP for a review directly.

Zhang
FixNDKWindowsSDK.diff

Naville Zhang

unread,
Jul 31, 2025, 4:57:46 AMJul 31
to android-llvm
What does't work yet:
- I didn't check if MinGW build still works with this patch.
- LLVM on Windows is not able to detect the prebuilt Python, probably some code is still broken.
- Packaging the final zip for Windows is broken, because the packaging component code still expects static library to have .a extension instead of .lib extension. 

As I was saying, I'd love to get some feedback and maybe get the initial patch merged into NDK upstream before attempting to fix the remaining problems

Reply all
Reply to author
Forward
0 new messages