Skip to content

Commit 426db91

Browse files
authored
build: use local llvm-objcopy when use_local_llvm is true (#44903)
Signed-off-by: Eric Bishop <ericbish.dev@gmail.com>
1 parent 7e0f0c9 commit 426db91

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

source/extensions/dynamic_modules/dynamic_modules.bzl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Bazel rules for building Envoy dynamic modules."""
22

3+
load("@envoy_repo//:compiler.bzl", "LLVM_PATH")
34
load("@rules_cc//cc:defs.bzl", "cc_import")
45

56
def envoy_dynamic_module_prefix_symbols(name, module_name, archive, tags = [], **kwargs):
@@ -61,19 +62,30 @@ def envoy_dynamic_module_prefix_symbols(name, module_name, archive, tags = [], *
6162
# NOTE: The case statement is kept outside $() command substitution for
6263
# compatibility with bash 3.2 (macOS default), which cannot parse case
6364
# pattern delimiters inside $().
65+
archive_select_cmd = (
66+
"ARCH=\"\"; " +
67+
"for f in $(SRCS); do case $$f in *.pic.a) continue;; *.a) ARCH=$$f; break;; esac; done; " +
68+
"[ -z \"$$ARCH\" ] && " +
69+
"for f in $(SRCS); do case $$f in *.a) ARCH=$$f; break;; esac; done; "
70+
)
6471
native.genrule(
6572
name = renamed_name,
6673
srcs = [archive, ":" + redefine_syms_name],
6774
outs = [name + "_renamed.a"],
68-
cmd = (
69-
"ARCH=\"\"; " +
70-
"for f in $(SRCS); do case $$f in *.pic.a) continue;; *.a) ARCH=$$f; break;; esac; done; " +
71-
"[ -z \"$$ARCH\" ] && " +
72-
"for f in $(SRCS); do case $$f in *.a) ARCH=$$f; break;; esac; done; " +
73-
"$(location @llvm_toolchain_llvm//:objcopy) " +
74-
"--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@"
75-
),
76-
tools = ["@llvm_toolchain_llvm//:objcopy"],
75+
cmd = archive_select_cmd + select({
76+
"@envoy_repo//:use_local_llvm": (
77+
"%s/bin/llvm-objcopy " % LLVM_PATH +
78+
"--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@"
79+
),
80+
"//conditions:default": (
81+
"$(location @llvm_toolchain_llvm//:objcopy) " +
82+
"--redefine-syms=$(location :" + redefine_syms_name + ") $$ARCH $@"
83+
),
84+
}),
85+
tools = select({
86+
"@envoy_repo//:use_local_llvm": [],
87+
"//conditions:default": ["@llvm_toolchain_llvm//:objcopy"],
88+
}),
7789
tags = tags,
7890
)
7991

0 commit comments

Comments
 (0)