[PATCH] D136496: [bazel] Make labels to third-party dependencies explicit

Aaron Siddhartha Mondal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 29 09:08:42 PDT 2022


aaronmondal added a comment.

Ok I tried a bunch of combinations. Apart from the current one, none seem to work.

I believe what is happening is that when we call `configure` from a module extension, the `repository_ctx` effectively becomes a `module_ctx`. If the labels are relative, e.g. `//utils/bazel/deps_impl:zlib_disable.BUILD`, this will be interpreted as `@llvm-raw//utils/bazeldeps_impl:zlib.BUILD` with the WORKSPACE build, which is correct, but when using bzlmod with an in-tree build, it will incorrectly resolve to `@llvm-project-overlay//utils/bazel`, which is the nonexistent `llvm-project/utils/bazel/utils/bazel`, since `@llvm-project-overlay` refers to the `utils/bazel` subdirectory already. So then using bzlmod we need the explicit `@llvm-raw` workspace since it is in fact an external workspace in that case.

Regarding the `Label("//:WORKSPACE")`, this doesn't work for the same reason. With the WORKSPACE build, It resolves to the correct `@llvm-raw//:WORKSPACE`. With bzlmod we want `@llvm-raw//:WORKSPACE` as well, but if this is relative we get the incorrect `@llvm-project-overlay//:WORKSPACE` (aka `@llvm-raw//utils/bazel:WORKSPACE`).

I don't think there is a way to implement this differently without significant changes to the entire overlay logic. The explicit labels in this case actually do what they are supposed to do - explicitly reference targets as if they are coming from an external workspace.

A case where the opposite is actually desirable is https://reviews.llvm.org/D137007, where we need to be able to use the workspace `@llvm-project` and the bzlmod `@llvm-project-overlay.16.0.0-bcr.0.llvm_project_overlay.llvm-project` interchangeably.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136496/new/

https://reviews.llvm.org/D136496



More information about the llvm-commits mailing list