-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Update windows VS detection code to account for new directory #18608
Conversation
Windows VS 2022 version 17.6 introduced a new `vspkg` directory underneath `VC` that is throwing off the toolchain autodetection code. The checks now got renamed to a more approriate `_is_vs_2017_or_newer` and takes into account the possible presence of this `vspkg` directory.
2f4ed3b
to
75334d1
Compare
Tested this successfully on a recent VS 2022 Community install |
Should you also change bazel/tools/cpp/windows_cc_configure.bzl Lines 232 to 244 in 75334d1
ps: I'm using "Microsoft Visual Studio\2022\Preview\VC" (2022 Community preview 17.7.0) |
Good catch @Mizux, but now it is kinda surprising me that even though |
Ah, I see now, that is a kind of last resort hard-coded path check, following many other ways of finding out the VC path, which probably usually already work. But yes, then it makes sense to add 2022 to the mix there. |
tools/cpp/windows_cc_configure.bzl
Outdated
"Microsoft Visual Studio 14.0\\VC", | ||
"Microsoft Visual Studio\\2019\\Preview\\VC", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Currently we need
2022\Preview\VC
to build google/or-tools ^^;
or you could add it to the below comprehension list ? - Also order may matter imho i.e. prefer "Preview" before "Enterprise" before "Community" etc...
as well as for date 2022 > 2019 > 2017
ref:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in previous code the order was "Preview", "BuildTools", "Community", "Professional", "Enterprise". Should I keep that, or reverse it after "Preview" (i.e. "Preview", "Enterprise", "Professional", "Community", "BuildTools")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I guess adding "Microsoft Visual Studio\\2017\\Preview\\VC"
is harmless even though that did not exist AFAIK, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(for the moment I preserved the order prior to this patch wrt editions, and added the 2017\Preview one, but that can still be tweaked)
This change makes |
@redsun82 can u publish an release binary file for bazel of your branch ? just in you repo's release and name it bazel-vs2022.exe is ok. i'need it for some special work. thank u very much |
Can we work around this issue by setting the |
I did not find one after long hours of debugging. There is no way around the failure other than:
|
this will not work on vs2022 |
As already noted, setting
load("//tools/cpp:cc_configure.bzl", "cc_configure")
cc_configure() This will replace the built-in autodetection with the patched one. |
@Mizux what do you think about the change to the hardcoded VS paths that makes that one test fail? As I mentioned I cannot unfortunately devote much time to that currently, so either someone could take over trying to figure out that test failure, or for the moment we revert that change to quickly get something out that still works most of the time? Before this issue I don't think anyone has yet complained about VS 2022 detection not working, even though it's missing from that hard-coded list. |
thank you very much! so kind of u! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing it, sorry for the late reply!
Let's me check if I can help with the test failure |
vc_path_contents = [d.basename.lower() for d in repository_ctx.path(vc_path).readdir()] | ||
vc_path_contents = sorted(vc_path_contents) | ||
return vc_path_contents == vc_2017_or_2019_contents | ||
vc_path_contents = sorted([d for d in vc_path_contents if d in vc_2017_or_newer_contents]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can simplify the logic here:
vc_2017_or_newer_expected_dirs = ["auxiliary", "redist", "tools"]
for dir in vc_2017_or_newer_expected_dirs:
if not repository_ctx.path(vc_path).get_child(dir).exists:
return False
return True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a comment above, VS2015 has this directory structure
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\VC
├───bin
├───crt
├───include
├───lib
└───redist
So I think anything that checks for tools
and auxiliary
will work to differentiate VS2017+ from VS2015. The check for tools
is the important one, since that is where the binaries are found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, then this could be further simplified to
return repository_ctx.path(vc_path).get_child("tools").exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@redsun82 Can you overtake the suggested change - would be nice if we could soon merge this in bring it to Bazel 6.3.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fork this and add @meteorcloudy suggestion if @redsun82 does not have time/resources to work on this further...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I create a PR with this change -> #18945 @meteorcloudy, @redsun82
Maybe we can also remove support for VS2015 and prior to simplify the code? |
@bazel-io fork 6.3.0 |
That kind of change is beyond my paygrade, but I think it might be too disruptive on the 5.4 branch. Maybe there are some people using really old VS versions? |
Yeah, that's a breaking change, we probably shouldn't do that if we plan to cherry pick the fix back to 6.x branches. |
I think the test failure is a bug with the version of VC 2022 build tools we have on CI, I cannot reproduce with the latest VC 2022 build tool locally. We should update the VC 2022 version in the Windows VM. In the mean time I have a workaround to use older VC version in integration tests to unblock this. |
To work around [test failure](https://buildkite.com/bazel/bazel-bazel-github-presubmit/builds/16353#018901e5-b0f1-41be-a6f4-e12878711ad3) on #18608. This PR enables Bazel to detect the latest VC build tools installed, but apparently there is a test case which is failing with the new toolchain. Setting --test_env=BAZEL_VC ensures the integrations tests also uses the older VC build tools for now. PiperOrigin-RevId: 544037250 Change-Id: I4625da17ff2168acbe63813aa7a01e49e0cb459a
When it comes to building Tensorflow from source with VC 2022 here is the result of my debugging: Although, Bazel does not account for VS2022 yet but the if condition for VS2017 and VS2019 can still do the trick. The solution here is either to edit ../Hostx64/.. label (https://github.com/bazelbuild/bazel/blob/9c96529fca4a135c162e35ce2882834b879438fb/tools/cpp/windows_cc_configure.bzl#L325C1-L326C1) and change the lines to
or you rename \bin\Hostx64\ to \bin\HostX64\ also it is vital that these environment variables point to the right paths: BAZEL_SH=C:\msys64\usr\bin\bash.exe Hopefully this helps. |
Is this really necessary? File name is supposed to be case insensitive on Windows. |
This is the same PR as #18608 but extended by the modification proposed by @meteorcloudy This should fix #18592 Should also be picked to 6.3.0 -> #18799 Closes #18945. PiperOrigin-RevId: 548725707 Change-Id: Iff0f972c9fc23491c8070ee2b12ec600a3d1ead9
This is the same PR as bazelbuild#18608 but extended by the modification proposed by @meteorcloudy This should fix bazelbuild#18592 Should also be picked to 6.3.0 -> bazelbuild#18799 Closes bazelbuild#18945. PiperOrigin-RevId: 548725707 Change-Id: Iff0f972c9fc23491c8070ee2b12ec600a3d1ead9
To work around [test failure](https://buildkite.com/bazel/bazel-bazel-github-presubmit/builds/16353#018901e5-b0f1-41be-a6f4-e12878711ad3) on bazelbuild#18608. This PR enables Bazel to detect the latest VC build tools installed, but apparently there is a test case which is failing with the new toolchain. Setting --test_env=BAZEL_VC ensures the integrations tests also uses the older VC build tools for now. PiperOrigin-RevId: 544037250 Change-Id: I4625da17ff2168acbe63813aa7a01e49e0cb459a
Idk, as I opted for editing the path in the code to avoid messing any other dependencies. |
This is the same PR as #18608 but extended by the modification proposed by @meteorcloudy This should fix #18592 Should also be picked to 6.3.0 -> #18799 Closes #18945. PiperOrigin-RevId: 548725707 Change-Id: Iff0f972c9fc23491c8070ee2b12ec600a3d1ead9 Co-authored-by: Vertexwahn <julian.amann@tum.de>
#18945 has been merged and cherry picked back to 6.3.0, so we can close this one. |
Windows VS 2022 version 17.6 introduced a new
vcpkg
directory underneathVC
that is throwing off the toolchain autodetection code.The checks now got renamed to a more approriate
_is_vs_2017_or_newer
and takes into account the possible presence of thisvcpkg
directory.Closes #18592