Skip to content

DRAFT: Add MSVC target support#187

Draft
ArchangelX360 wants to merge 8 commits intocerisier:mainfrom
ArchangelX360:ArchangelX360/msvc_support
Draft

DRAFT: Add MSVC target support#187
ArchangelX360 wants to merge 8 commits intocerisier:mainfrom
ArchangelX360:ArchangelX360/msvc_support

Conversation

@ArchangelX360
Copy link
Copy Markdown
Contributor

Closes #156

".",
"runtimes/musl",
],
target_compatible_with = [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should probably run buildifier over the repo and check it in to minimize this PR (and also add a CI pass haha cc @cerisier )

"@glibc//:gnu_libc_headers",
],
"@platforms//os:windows": [
"@toolchains_llvm_bootstrapped//platforms/config:abi_gnu": [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i don't have a great suggestion, but I do think it's very confusing to have config:gnu and config:abi_gnu that are very different things :) perhaps windows_gnu and windows_msvc? Or windows_mingw and windows_msvc? not sure :/

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'll have a think of what defines this best.
Neither libc or abi is good here. But we lack something else for now.
Most probably we'll need to develop those constraints a bit more as a prerequisite. I'll tackle that this week.

@ArchangelX360
Copy link
Copy Markdown
Contributor Author

Just a note, I did not abandon that work, I just am short in time at the moment, but I will return ASAP.
I'm also waiting on bazelbuild/rules_cc#561 (comment), but this is not a blocker.

Copy link
Copy Markdown
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.

Oops realized I had some review comments that were stuck in pending state for a while ..

name = prefix + "/bin/clang-cl",
platform = prefix + "_platform",
actual = "@llvm-project//clang:clang.stripped",
# TODO: is it also the case for clang-cl?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i guess it depends how clang-cl locates the linker; i don't know if it accepts the -fuse-ld=lld-style flag. do you know?

cc_toolchain(
name = msvc_cc_toolchain_name,
tool_map = ":{}_{}/tools_for_msvc".format(exec_os, exec_cpu),
compiler = "clang", # FIXME: should we change to clang-cl?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

now that i'm looking at this more, i'm wondering if it's actually necessary to use clang-cl vs normal clang with an msvc target? I guess it depends on how build targets in the ecosystem pass their args? In any case, I do think this this should be clang-cl if the underlying binary is clang-cl, otherwise well-intentioned code that selects on clang-cl instead of @platforms//os:windows (trying to handle mingw properly) will break here, right?

"//conditions:default": "//runtimes:dynamic_runtime_lib",
}),
compiler = "clang",
compiler = compiler, # TODO: actually, I'm not sure `rules_cc` supports `clang-cl` yet, so I'm not sure what it would do (https://github.com/bazelbuild/rules_cc/pull/561)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah i think it's a little half-baked upstream, we might need that to land before this becomes functional, though you could patch it here for experimenting

@dzbarsky
Copy link
Copy Markdown
Collaborator

Quick heads up, while this PR was pending we switched to building a single llvm binary in the multicall/BusyBox style (@llvm-project//llvm) and making all the tools symlinks, so you'll want to make some adjustments as you rebase. The advantage is a much cheaper build (fewer links) and overall smaller size

@sluongng
Copy link
Copy Markdown

sluongng commented Feb 4, 2026

Oh hey, it's Titouan 👋
Long time no see!

I am very excited about this PR. We have a user who is interested in using this.

@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch from 6cc43d9 to 0bdc368 Compare March 23, 2026 17:12
}),
compiler = "clang",
compiler = select({
"@llvm//constraints/abi:msvc": "clang-cl",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This requires bazelbuild/rules_cc#561

@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch 4 times, most recently from 3607d8b to dd571e6 Compare March 23, 2026 17:34
return []

tag = repository_ctx.attr.winsysroot_version
repo_base = "https://github.com/ArchangelX360/winsysroot/releases/download/{}".format(tag)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

move that winsysroot tool to hermeticbuild org

"integrity": attr.string(
doc = "Optional SRI integrity for the downloaded winsysroot binary.",
),
"visual_studio_release": attr.string(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably should be the MSVC version directly, as I'm pretty sure this will not be reproducible

@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch from dd571e6 to 952f484 Compare March 24, 2026 16:50
@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch from bc1464d to cb05f18 Compare March 25, 2026 02:09
@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch from 142573b to ab7f703 Compare March 27, 2026 18:44
@ArchangelX360 ArchangelX360 force-pushed the ArchangelX360/msvc_support branch from 449518d to b5d3f96 Compare March 29, 2026 01:19
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.

Support Native MSVC ABI targets (*-windows-msvc)

4 participants