[PATCH] D106606: [Bazel] Change external_zlib attribute to string
Michael McLoughlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 22 15:12:47 PDT 2021
mmcloughlin created this revision.
mmcloughlin added a reviewer: GMNGeoffrey.
mmcloughlin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When using `llvm_zlib_external` rule with `external_zlib` attribute set to a
label referring to the main repository, like `@//third_party/zlib`, it will be
replaced with `//third_party/zlib` after template substitution. This will then
attempt to find `//third_party/zlib` within the local repository
`@llvm_zlib//third_party/zlib`, which does not exist, rather than the intended
reference back to the main repository. The issue appears to be that the
conversion of `Label` type to string with
`str(repository_ctx.attr.external_zlib)`, which is causing the main repository
qualifier to be lost.
This diff fixes the issue by changing the `external_zlib` attribute to
`attr.string` type rather than `attr.label`.
In future a more elegant solution may be possible that preserves use of the
`Label` type, depending on resolution of the issue
https://github.com/bazelbuild/bazel/issues/13731.
Ported from Github PR https://github.com/google/llvm-bazel/pull/236.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106606
Files:
utils/bazel/zlib.bzl
Index: utils/bazel/zlib.bzl
===================================================================
--- utils/bazel/zlib.bzl
+++ utils/bazel/zlib.bzl
@@ -24,7 +24,7 @@
"BUILD",
repository_ctx.attr._external_build_template,
substitutions = {
- "@external_zlib_repo//:zlib_rule": str(repository_ctx.attr.external_zlib),
+ "@external_zlib_repo//:zlib_rule": repository_ctx.attr.external_zlib,
},
executable = False,
)
@@ -36,7 +36,7 @@
default = Label("//deps_impl:zlib_external.BUILD"),
allow_single_file = True,
),
- "external_zlib": attr.label(
+ "external_zlib": attr.string(
doc = "The dependency that should be used for the external zlib library.",
mandatory = True,
),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106606.360994.patch
Type: text/x-patch
Size: 825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/39be1fd7/attachment.bin>
More information about the llvm-commits
mailing list