bazel: "alwayslink=1" is broken on Windows and VS 2017
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:
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 ‘/’
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (17 by maintainers)
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.