bazelbuild / bazelbuild/bazel

cc_common Starlark examples don't work with layering_check feature

Open
#16,243 0 comments 0 reactions 0 assignees View on GitHub
help wanted P3 team-Documentation team-Rules-CPP type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

It looks like the common flow of using `cc_common.configure_features`, `cc_common.create_compile_variables` and `cc_common.get_memory_inefficient_command_line` does not work when `layering_check` feature is enabled for the package.

An indication that this is a known but undocumented issue is the line in the example in the rules_cc repo:
https://github.com/bazelbuild/rules_cc/blob/807a87190a117d5798f9f2c69427e9037e9891d3/examples/my_c_compile/my_c_compile.bzl#L23

Because `layering_check` feature is enabled only for clang on unix, this is only observed when compiling with clang on unix systems (not osx, which is a special case).

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

```
touch hello.cc
touch WORKSPACE

cat >BUILD <aspects.bzl <

Contributor guide

Open the contributing guide

Research direction

Start with the linked rules_cc example at examples/my_c_compile/my_c_compile.bzl and the reproduced aspects.bzl flow using cc_common.configure_features, create_compile_variables, and get_memory_inefficient_command_line. Run the Ubuntu 20.04 reproduction with clang and layering_check enabled, then verify that the Starlark example works without the reported failure.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.