question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 ‘/’

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
snnncommented, Apr 11, 2018

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.

0reactions
snnncommented, Apr 12, 2018

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”.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found