Skip to content

"alwayslink=1" is broken on Windows and VS 2017 #3949

@snnn

Description

@snnn

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 '/'

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)platform: windowstype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions