Skip to content

Fail build on Kconfig warning #77530

@rettichschnidi

Description

@rettichschnidi

Introduction

There are many tests/samples, which issue a Kconfig warning when getting built (with certain boards). This also applies to combinations which are built in CI, as Twister currently can not fail builds on Kconfig warnings.

Problem description

Not enforcing the absence of Kconfig warnings causes them to pile up, make the devs blind to them.

For example, this makes it hard to catch the relevant (new) warnings when upgrading to a new Zephyr release downstream.

Even when running Twister for well-supported platforms such as nrf52840dk/nrf52840, and for upstream code, many build.log files contain warnings like those:

-- Including generated dts.cmake file: twister-out/nrf52840dk_nrf52840/samples/subsys/profiling/perf/sample.perf/zephyr/dts.cmake

warning: PROFILING_PERF (defined at subsys/profiling/perf/Kconfig:5) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: PROFILING_PERF_HAS_BACKEND (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_PROFILING_PERF and/or look up
PROFILING_PERF in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.


warning: PROFILING_PERF_BUFFER_SIZE (defined at subsys/profiling/perf/Kconfig:15) was assigned the
value '128' but got the value ''. Check these unsatisfied dependencies: PROFILING_PERF (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_PROFILING_PERF_BUFFER_SIZE and/or look up
PROFILING_PERF_BUFFER_SIZE in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.

Proposed change

Introduce a KCONFIG_WARNINGS_AS_ERRORS option and enabled it per default in Twister, similar to ?COMPILER_WARNINGS_AS_ERRORS.

Detailed RFC

Proposed change (Detailed)

  1. Introduce KCONFIG_WARNINGS_AS_ERRORS: kconfig: Add option to fail build on warning #77529. This allows developers to opt-in, ensure their applications-of-concern build warning free.
  2. Start enabling KCONFIG_WARNINGS_AS_ERRORS for certain key samples/tests to enforce warning free builds in CI
  3. Add KCONFIG_WARNINGS_AS_ERRORS to twister per default, allow opt-out using the existing (and to be extended) parameter --disable-warnings-as-errors
  4. Clean up opt-ins from point 2.

Dependencies

  • None?

Concerns and Unresolved Questions

  • When a build fails due to a Kconfig warning, the dev needs to run cmake -DCONFIG_KCONFIG_WARNINGS_AS_ERRORS=n . in the build directory before being able to running west build -t menuconfig to investigate the dependency issue.

Alternatives

  • Add some kind of post-build hook to grep for ^warning: messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest For Comments: want input from the communityarea: Kconfig

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions