-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "prefer to use clang instead of MSVC" API that can automatically find Microsoft-provided clang #882
Comments
This sounds like a job for |
I'd take patches to support this, but have no strong feeling on the implementation strategy (calling out to something like vswhere is certainly acceptable if it works well though). The API name |
How does using vswhere.exe differ from what cc-rs currently does to find MSVC itself? I wonder it might be better for cc-rs to adapt what it currently does for finding MSVC to find clang directly without shelling out to vswhere? |
Sure. If we did this though I'd personally prefer we adapt |
This would be awesome. I don't have time to write the implementation myself, but I am happy to commit to helping in every other way though, especially testing. I can also help review the design and code though I'm not authoritative in any way regarding cc-rs. |
Hm, the hard part of this does tend to be testing. I no longer have access to a windows machine I can use for development though, so I can't help either. |
Unfortunately I don't have much time myself atm (I'm already not keeping up with a lot of stuff). But if someone wants to give it a try I can offer help if they get stuck or need questions answered. If nobody picks this up I'll be happy to work on it when I have more time but that might be awhile. You'd possibly want to start by looking at how msbuild is handled in https://github.com/rust-lang/cc-rs/blob/main/src/windows_registry.rs. Fair warning that quite a bit of the code is quite old and could really do with a cleanup/refactoring. But that's beyond the scope of this issue. |
@awakecoding did a lot of work in this area and shared the link to microsoft/vswhere#242 where he tried to get
|
So it should just need to probe the visual studio directories for e.g. |
I think that's right. And I think if you had to limit it to 2022+, it would not be bad. |
My question is does it have to be that "selfish"? What I'm referring to is suggestion to make it exclusively about msvc. Why not On a tangential note. Using |
@dot-asm I am so happy to hear from you. Note that I need this just for aarch64-pc-windows-msvc where I'm inheriting code from BoringSSL that is NOT written using PerlAsm but rather just straight gas syntax .S files. Also, in this build configuration, LINK.EXE still does the linking. |
Well, formally speaking it doesn't qualify for making things less usable for everybody. I mean no overly specific and non-common case should. Well, at least not in my book, as I don't speak for maintainers and don't know what they will choose to do :-)
I'm aware of that. Linking problems stem from the fact that |
But all the straight .S files you have don't target Windows, let alone Windows on ARM. Wouldn't it be more reasonable to simply not attempt to compile them? Or what am I missing? |
Alternatively one can put is as following. If user tries to compile |
It was pointed out that it is problematic to force the use of clang when the build is set up to use MSVC because CFLAGS, etc. will be set for MSVC and not clang. It was suggested instead that we switch to use clang-cl, which is more (but not completely) compatible with CFLAGS, etc. Note that we still need to be able to differentiate clang-cl vs. MSVC because clang-cl does need some different flags compared to MSVC, e.g. |
The relevant issue and PR on the |
I would love to be able in my build.rs to instead just say
b.prefer_clang_over_msvc()
to get cc-rs to automatically discover Microsoft-provided clang's and use it if/when it is available, when it would otherwise choose MSVC.Some projects, such as ring, require clang when building for Windows AArch64.
Some projects, such as ring would prefer to build with clang if it were available, when building for Windows X86-64, because the C code is optimized for clang in various ways (because Google uses clang for everything, and the C code we have comes from Google, and Google's preferences are unlikely to change any time soon).
Currently I am recommending people to do this:
to get ring to build for aarch64-pc-windows-msvc using the clang that Microsoft provides with the build tools. Unfortunately, this advice is problematic:
The text was updated successfully, but these errors were encountered: