Skip to content

Conversation

@ArchangelX360
Copy link

@ArchangelX360 ArchangelX360 commented Dec 17, 2025

The following PR adds Windows support for both usage on Windows host (ARM64 and x86_64) and to compile Windows targets (ARM64 and x86_64).

This work is based on the awesome work of both:

It has been tested internally at JetBrains (not in production yet) for our rules_rust, we tested so far:

  • aarch64-pc-windows-msvc from a Windows ARM64 host (Parallels VM) machine: ✅
  • aarch64-pc-windows-msvc from a macOS aarch64 host machine (using a wired MSVC+SDK sysroot): ✅
  • x86_64-pc-windows-msvc from a macOS aarch64 machine: 🔴 did not work, due to what appears to be Rust related and not toolchain related

Known issues

  • use_absolute_paths_llvm is forced to True when using a Windows host as a mitigation to symlink issues (see comment in the PR's code)
  • some uncertainty on the default flags to use, I would love some advices from maintainers if possible
  • just like @peakschris I do not know how to merge both Windows and Unix template files, when using select it does not really do what we need, that's why it's written as a separate file

@dzbarsky
Copy link
Collaborator

It's going to take me a bit of time to digest this. In the meantime, you might be curious to take a look at https://github.com/cerisier/toolchains_llvm_bootstrapped which also provides windows support out of the box with no config :) (At the very least, I'd appreciate you giving it a spin and reporting any bugs you find)

@ArchangelX360 ArchangelX360 force-pushed the archangelx360/llvm_windows_host_target branch from a1d8eab to b2f7dd3 Compare December 17, 2025 15:21
@f0rmiga
Copy link
Member

f0rmiga commented Dec 17, 2025

Thank you for continuing the work I started!

@ArchangelX360
Copy link
Author

@dzbarsky Seems like the README must be updated, Windows support is still written under roadmap.
I'll give it a shot when I'll have some spare time, at least to tell you if/where it falls short for us 😄!

Of course, despite that, I believe that repository should still have a decent Windows support for our beloved Windows developers wanting to build something 😄.

@dzbarsky
Copy link
Collaborator

Yes we will need to update README! We should support windows here as well, I will find some time to review this one soon

@ArchangelX360
Copy link
Author

@dzbarsky FYI: I commented on cerisier/toolchains_llvm_bootstrapped#24 and opened cerisier/toolchains_llvm_bootstrapped#141 which blocked me almost immediately.
So far, https://github.com/cerisier/toolchains_llvm_bootstrapped is not usable for us, but it looks super promising!

Copy link
Collaborator

@dzbarsky dzbarsky left a comment

Choose a reason for hiding this comment

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

It seems like the changes are all behind windows conditionals so existing functionality is hopefully unaffected. From that POV I'm ok landing this with some disclaimers that it's experimental/incomplete/possibly-broken/etc.

It does seem like there are still some issues to work through and errors that aren't understood yet - do we want to get a better understanding of those before landing?


# This filegroup should only have source directories, not individual files.
# We rely on this assumption in system_module_map.bzl.
filegroup(
Copy link
Collaborator

Choose a reason for hiding this comment

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

@fmeum any FUD around source directories on windows?

# not be available at runtime to allow sanitizers to work locally.
# Any library linked from the toolchain to be released should be linked statically.
"lib/clang/{LLVM_VERSION}/lib/**",
"lib/**/libc++*.a",
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm are you sure about these? First of all I thought clang-cl would use .lib instead of .a, also I didn't think it uses llvm runtime libs?

Copy link
Author

Choose a reason for hiding this comment

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

No indeed, libc++*.a have nothing to do here, I removed it.

For lib/clang/{LLVM_VERSION}/lib/**, we do have:

./lib/clang/20/lib/windows/clang_rt.builtins-aarch64.lib
./lib/clang/20/lib/windows/clang_rt.profile-aarch64.lib

but where they should be in lib and lib_legacy I'm not sure.
What is the exact use of it in the UNIX side? It seems to be something only for darwin, but I don't get exactly the use-case to arbiter whether it makes sense on Windows or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's darwin-only; this is the compiler-rt lib that provides the builtins (as well as as sanitizer libs, which are less relevant on Windows, although from a bit of research it does seem like ubsan at least might be workable on windows?)

As for lib/lib_legacy, those are mutually exclusive and which one is used depends on Bazel version, newer versions use non-legacy one which is more efficient. Since you're the only user right now if your Bazel is relatively recent you can probably just skip the legacy bits?

# $ bazelisk.exe build //fleet/native/launcher:fleet # WORKS
# $ dir C:/temp/k7ozco62/external/toolchains_llvm++llvm+llvm_toolchain/bin # shows `-a----` file modes on binaries
#
use_absolute_paths_llvm = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this break caching?

Copy link
Author

Choose a reason for hiding this comment

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

It most probably does, I would need help investigated the original issue for which that mitigation is in place.

Bazel (or our repo rules, I don't know) does something quite odd.
Depending on the command that is run, (and in which order!) the symlinked files are changing.
I don't understand yet what is exactly happening, so I had to force use_absolute_paths_llvm to have something reliably working, for now.
It's most probably related to symlinks, as symlinks on Windows is particularly finicky, but I have no idea what is happening. Any lead or idea is welcomed, see the comment for the behaviour observed.

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