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.

Workspace rules don't have the access to the bazel's toolchains

See original GitHub issue

There is a group of workspace rules that invoke package managers for various languages. Workspace rules currently don’t have an access to bazel’s toolchains for corresponding languages. As a result, package manager is invoked with the incorrect toolchain information, or project owners have to use multiple workspace rules (one for each toolchain) and select the right one in their BUILD files. In the second case, the toolchain information has to be duplicated in the WORKSPACE file, as there is currently no way to reuse toolchain information.

As a more concrete example: pip_import python workspace rule invokes pip package manager, but since it doesn’t have access to the C++ toolchain, it compiles native code for the host system. When someone needs to target a different platform, they would need to have multiple pip_import rules in their WORKSPACE and use select in their deps. The workspace rules would have to provide environment variables specifying the compiler, linker, and the corresponding flags. This information is already present in the CROSSTOOL file, but cannot be easily reused.

In addition, if the project uses hermetic C++ toolchain (toolchain files are part of the project, as opposed by being installed on the host system), then it’s even more complicated, since to get the C++ compiler one would have to execute bazel.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hlopkocommented, May 11, 2018

I understand that this issue goes against many principles of Bazel. But it’s good to be aware of this problem and evaluate the possibilities, even when the “fix” is to document best practices when writing workspace rules integrating with language specific package managers.

I’d assume that it’s not easy to persuade pip, npm, rubygems, cargo and many other language specific package managers not to build the package, but to provide sources only. But I know at least of https://github.com/pinterest/PodToBUILD (@jerrymarino) that pulls this off for cocoa pods.

0reactions
hlopkocommented, Jan 10, 2019

Closing as invalid (wont fix).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toolchains | Bazel
Aspects have access to the same toolchain API as rules: you can define required toolchain types, access toolchains via the context, and use...
Read more >
Writing Bazel rules: platforms and toolchains - jayconrod.com
This article is part of the series "Writing Bazel rules". ... Before we get to the actual code, let's go over some platform...
Read more >
Using toolchains in custom Bazel C++ rules - Technical notes
The rule does not need any attributes and it returns the provider with a key-value list that can be accessed from the rules...
Read more >
Bazel School: Toolchains - John Millikin
It's easy for rule implementations to get access to the ToolchainInfo for any registered toolchain, so be clear in your docs which attributes ......
Read more >
How do I setup/configure custom toolchain that is not external?
We are evaluating Bazel to replace a legacy build framework. It is using a system that have been customized from Perforce JAM. The...
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