bazelbuild / bazelbuild/bazel

Request improvement for "target does not provide the DeclaredToolchainInfo provider" error message.

Open
#13,556 1 comment 0 reactions 0 assignees View on GitHub
P2 team-Configurability team-Documentation type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

> ATTENTION! Please read and follow:

### Description of the problem / feature request:
From discussion here:
https://groups.google.com/g/bazel-discuss/c/Q5onIjX2Sjo

As a part of my adventures in Toolchain land, I took the bazel clang toolchain tutorial and modified for my own needs. Unfortunately, I'm now running into an error message of:

ERROR: While resolving toolchains for target //thing/to:build: invalid registered toolchain '//tools/build/product-build:my_toolchain': target does not provide the DeclaredToolchainInfo provider.

This error message provides little guidance about what is missing. If my supposition below is correct, detecting this situation and providing a suggestion such as "Did you pass in a toolchain rather than toolchain_suite?" might help other users.

In my case, I believe that the error was caused by passing in a cc_toolchain rather than cc_toolchain_suite to register_toolchain()

### Feature requests: what underlying problem are you trying to solve with this feature?

I am attempting to add a specific pre-compiled instance of a cross-compiler to my environment setup so that I can build cc_library and cc_binary targets concurrently for the host as well as target platforms as outlined in BUILD files.

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Passing in a cc_toolchain rather than cc_toolchain_suite to register_toolchain() should cause the error message.

### What operating system are you running Bazel on?

"Ubuntu 18.04.5 LTS"

### What's the output of `bazel info release`?

release 4.1.0

### If `bazel info release` returns "development version" or "(@non-git)", tell us how you built Bazel.

N/A

### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ?

fatal: not a git repository (or any of the parent directories): .git

### Have you found anything relevant by searching the web?

A few people asking similar questions, but no useful found.

### Any other information, logs, or outputs that you want to share?

Nothing at this time.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the error with a cc_toolchain passed to register_toolchain(), then trace how Bazel validates the registered target and reports the missing DeclaredToolchainInfo provider. Done means the diagnostic explains the likely toolchain-versus-toolchain_suite mistake and has coverage for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.