-
Notifications
You must be signed in to change notification settings - Fork 4k
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
"alwayslink=1" is broken on Windows and VS 2017 #3949
Comments
@snnn It does produce the correct output on my machine
Hmm,, |
Can you run the link command manually to see if it works
|
|
Hi @meteorcloudy |
I installed Visual C++ Build Tool 2015,
Interesting, I'll test this with Visual Studio 2017 |
I got the same result as you with VS 2015. |
I can also reproduce this with VS 2017, it's surprising that VS 2017 stopped supporting |
Will anything go wrong if we use bazel/src/main/java/com/google/devtools/build/lib/vfs/WindowsPathFragment.java Lines 53 to 58 in 755e176
|
Looks like so, after switching the two, I got:
|
@meteorcloudy : I believe that would break things, but I don't know. For the record I didn't add that TODO, @haxorz did so he may have more context. |
@meteorcloudy : Maybe update this logic to be Windows-aware? |
I found a temporary solution for me: diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index 6af0118e7..1cc913ae4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -1891,6 +1891,7 @@ public class CppLinkActionBuilder {
name = Link.FAKE_OBJECT_PREFIX + inputArtifact.getExecPathString();
} else {
name = inputArtifact.getExecPathString();
+ name = name.replace('/','\\');
}
librariesToLink.addValue( |
I feel somewhat strongly that this should be a P1 issue. I'm not fully aware of how your priorities are assigned, but Visual Studio 2017 is the latest version and has been out for awhile. I think it should be fully supported if Bazel advertises full Windows support for C++. Is there any way to apply @snnn's fix for only Windows? It may be a hack, but it gets this working for now! |
Hi @tmandry Could you should me your Visual Studio version? with the minor version numbers. |
@snnn To be clear, I'm not suffering from this problem yet. I'm commenting because I'm in the process of transitioning our dev team to bazel, and some of them use Visual Studio. I wrote lavender for this purpose. It makes it harder to build up support for a change like this when the docs say the latest version of Visual Studio isn't supported. This issue actually seems like really low-hanging fruit, which is why I commented. That said, I know the team has a lot of work to do! |
Hi @tmandry I have reported this problem to VS team, they should have done some fix in their side. So, if you are using the latest visual studio 2017, it should be ok. They said they had fixed it, I haven't verified. |
@snnn Thanks for the reporting! I can confirm alwayslink now works with the latest VS 2017. |
I'll still try to make Bazel emit paths with |
Yes, exactly. That is the toolset version number. You may install multiple VS toolsets inside the same VS installation. Version number of VS is something like "15.6.6". |
Worked in minrepro, but it's completely unclear why. I found a few bugs related to the MSVC v14 linker that could be related to why the alwayslink = True alternatives weren't working. bazelbuild/bazel#3949.
Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.
Description of the problem / feature request / question:
"alwayslink=1" doesn't work anymore.
If possible, provide a minimal example to reproduce the problem:
Build file:
main.cpp
a1.cpp
When you run "h.exe", the expected output should be
hello
main
Environment info
Operating System:
Windows 10, Visual Studio 2017(15.4.1)
Bazel version (output of
bazel info release
):0.7.0
Have you found anything relevant by searching the web?
no
Anything else, information or logs or outputs that would be helpful?
I've found the root cause: In "h.exe-2.params", the file path after "/WHOLEARCHIVE:" should use '\' as path separator, not '/'
The text was updated successfully, but these errors were encountered: