This is an archive of the discontinued LLVM Phabricator instance.

[bazel] Add layering-check
ClosedPublic

Authored by gchatelet on Feb 9 2023, 1:40 PM.

Details

Summary

In the same vein as https://reviews.llvm.org/D141553
Enable the feature globally to ensure layering and catch circular dependencies
(https://llvm.org/docs/CodingStandards.html#library-layering).

Diff Detail

Event Timeline

gchatelet created this revision.Feb 9 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2023, 1:40 PM
gchatelet requested review of this revision.Feb 9 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2023, 1:40 PM

layering_check has already been turned on at the package level for the packages that are layering clean (e.g. https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel#L15). You could add more

layering_check has already been turned on at the package level for the packages that are layering clean (e.g. https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel#L15). You could add more

I did it originally for libc but got bitten by not setting it in the subfolders BUILD.bazel files.
Subfolder BUILD.bazel files create a new package that also needs to receive the feature.
@aeubanks suggested to add it to the .blazerc file instead to be more thorough.

gchatelet abandoned this revision.Feb 9 2023, 2:07 PM

I just looked at the premerge checks and I can see how this will be hard to fix globally (if at all possible).
I'll use the package feature instead.

I just looked at the premerge checks and I can see how this will be hard to fix globally (if at all possible).
I'll use the package feature instead.

IMO we should try to clean those up, and then once we do so, remove the package-level annotations and have the feature globally enabled -- but as build --features=layering_check, not build:ci --features=layering_check.

If there are any that are really problematic, we can add a feature to disable layering check for that rule (or package)

gchatelet reclaimed this revision.Feb 10 2023, 3:44 AM

I just looked at the premerge checks and I can see how this will be hard to fix globally (if at all possible).
I'll use the package feature instead.

IMO we should try to clean those up, and then once we do so, remove the package-level annotations and have the feature globally enabled -- but as build --features=layering_check, not build:ci --features=layering_check.

If there are any that are really problematic, we can add a feature to disable layering check for that rule (or package)

I've fixed all layering checks in https://github.com/llvm/llvm-project/commit/1842b5885baa1e002b3fa8b6ac1bae9cf4d39610
I'm reviving this patch to add build --features=layering_check as you suggests.

gchatelet updated this revision to Diff 496413.Feb 10 2023, 3:48 AM

rebase and move layering check as a global option

gchatelet retitled this revision from [bazel] Add layering-check on CI to [bazel] Add layering-check.Feb 10 2023, 3:48 AM
gchatelet edited the summary of this revision. (Show Details)
aeubanks accepted this revision.Feb 10 2023, 9:56 AM

lg if bazel precommit ci lg

This revision is now accepted and ready to land.Feb 10 2023, 9:56 AM
MaskRay accepted this revision.Feb 10 2023, 9:59 AM
MaskRay added inline comments.
utils/bazel/.bazelrc
25

Add

Looks like there's still an issue with mpfr. One advantage to adding at the package level is that it will also apply for downstream projects using LLVM. So if someone is building via their own project and editing an LLVM submodule or something then they would still have layering enforced. Just a thought

gchatelet added a reviewer: Restricted Project.Feb 13 2023, 1:21 AM
gchatelet updated this revision to Diff 496865.Feb 13 2023, 1:23 AM
  • Fix typo
gchatelet marked an inline comment as done.Feb 13 2023, 1:34 AM

One advantage to adding at the package level is that it will also apply for downstream projects using LLVM. So if someone is building via their own project and editing an LLVM submodule or something then they would still have layering enforced. Just a thought

I've added bazel-group as a reviewer to get input from other people.

gchatelet added a comment.EditedFeb 13 2023, 1:37 AM

Looks like there's still an issue with mpfr.

It runs just fine locally with bazelisk-linux-amd64 test --config=ci --sandbox_base=/dev/shm @llvm-project//... and bazelisk-linux-amd64 query //... + @llvm-project//... | xargs bazelisk-linux-amd64 test --config=ci, could it be a caching issue?

This revision was landed with ongoing or failed builds.Mar 7 2023, 5:24 AM
This revision was automatically updated to reflect the committed changes.
gchatelet reopened this revision.Mar 7 2023, 5:48 AM
This revision is now accepted and ready to land.Mar 7 2023, 5:48 AM
gchatelet updated this revision to Diff 503011.Mar 7 2023, 5:49 AM
  • Disable layering check when using mpfr_system
gchatelet updated this revision to Diff 503328.Mar 8 2023, 5:00 AM
  • Disable layering check when using mpfr_system
  • Remove layering_check on MPRFUtils instead
This revision was automatically updated to reflect the committed changes.