lavender icon indicating copy to clipboard operation
lavender copied to clipboard

Error: Information about the C++ toolchain API is not accessible anymore through ctx.fragments.cpp

Open plule opened this issue 6 years ago • 4 comments

Hello and first, thanks for making this!

It seems that a bazel change broke Lavender. When trying to convert a project, I get:

Information about the C++ toolchain API is not accessible anymore through ctx.fragments.cpp (see --incompatible_disable_legacy_cpp_toolchain_skylark_api on http://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disable-legacy-c-configuration-api for migration notes). Use CcToolchainInfo instead.

The link provides instructions for migration, but I just started learning Bazel so I did not manage to fix it myself. Removing the + ctx.fragments.cpp.compiler_options([]) + ctx.fragments.cpp.cxx_options([]) parts from msbuild.bzl allows the script to complete.

plule avatar Dec 14 '18 16:12 plule

Hey, thanks for your report! I'm not actively maintaining this anymore, unfortunately (and don't have a codebase to test it with), but willing to help guide you through fixing it.

The before/after example from the documentation you linked is more or less what needs to be done. You need to add a load statement to the top of the file:

load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

Then, at the top of this function:

https://github.com/tmandry/lavender/blob/d867ab536e36a4764c0f7108450b25b3d5cbc411/bazel/bazel-msbuild/msbuild.bzl#L1-L10

add the line cc_toolchain = find_cpp_toolchain(ctx), and you should be able to replace those expressions you removed with their counterparts, listed in the table on the doc page you linked to. Looks like you can remove the unused [] arguments in each of them.

tmandry avatar Dec 14 '18 22:12 tmandry

Let me know if you have any issues. If you get it working, please submit a PR and I'll get it merged. Thanks!

tmandry avatar Dec 14 '18 22:12 tmandry

Thanks for the guidance, I'll take a look at it!

plule avatar Dec 15 '18 12:12 plule

https://github.com/lummax/lavender/commit/623e18c2324f07f2a47c6134679d81b3befe7df8 was my attempt at this. Inspired by https://github.com/grailbio/bazel-compilation-database

Edit: And https://github.com/xforce/lavender/commit/01609c4e8675f7f75d86e3699fb0373b18ecb42a is another one.

lummax avatar Apr 13 '21 09:04 lummax