"alwayslink=1" is broken on Windows and VS 2017
See original GitHub issuePlease 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:
cc_binary(
name = "h",
srcs = ["main.cpp"],
deps = [":a1"]
)
cc_library(
name="a1",
srcs=["a1.cpp"],
visibility=["//visibility:public"],
alwayslink=1,
linkstatic=1
)
main.cpp
#include <stdio.h>
int main(){
printf("main\n");
return 0;
}
a1.cpp
#include <stdlib.h>
#include <stdio.h>
class Hello{
public:
Hello(){
printf("hello\n");
}
};
static Hello h;
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 ‘/’
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (17 by maintainers)
Top Results From Across the Web
Repair Visual Studio | Microsoft Learn
Sometimes your Visual Studio installation becomes damaged or corrupted. A repair is useful for fixing a wide variety of install-time issues, ...
Read more >link.exe should not search %PATH% for 64-bit version during ...
Starting with Visual Studio 2017 the toolchain paths are no longer added to the global environment's %PATH% variable and are instead inserted into...
Read more >Updating to Visual Studio 2017 15.8.6, now completely broken
Looks like I found the solution. Ran the following from a VS Developer Command Prompt: gacutil /u Microsoft.Build.
Read more >Install Path not found - VS 2017, 2019, and any workloads or ...
Launch the Installer from Windows or Console (w admin priv) · Attempt to install any workloads, or modify/repair any installation of VSStudio ...
Read more >Why does Visual Studio run in "Always on top" mode?
Fixed the issue with VS2017 on Windows 10 by giving focus to another application and pressing Windows+Home (to minimize all windows apart from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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”.