Skip to content

Commit ef21831

Browse files
committed
[bolt][bazel] Port e235fcb.
1 parent cd10c01 commit ef21831

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

utils/bazel/configure.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,19 @@ def _llvm_configure_impl(repository_ctx):
172172
)
173173

174174
# Create a starlark file with the requested LLVM targets.
175-
targets = repository_ctx.attr.targets
175+
llvm_targets = repository_ctx.attr.targets
176176
repository_ctx.file(
177177
"llvm/targets.bzl",
178-
content = "llvm_targets = " + str(targets),
178+
content = "llvm_targets = " + str(llvm_targets),
179+
executable = False,
180+
)
181+
182+
# Create a starlark file with the requested BOLT targets.
183+
bolt_targets = ["AArch64","X86","RISCV"] # Supported targets.
184+
bolt_targets = [t for t in llvm_targets if t in bolt_targets]
185+
repository_ctx.file(
186+
"bolt/targets.bzl",
187+
content = "bolt_targets = " + str(bolt_targets),
179188
executable = False,
180189
)
181190

utils/bazel/llvm-project-overlay/bolt/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

55
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
6+
load(":targets.bzl", "bolt_targets")
67

78
package(
89
default_visibility = ["//visibility:public"],
@@ -16,6 +17,20 @@ genrule(
1617
cmd = "echo '#undef BOLT_REVISION' >> $@\n",
1718
)
1819

20+
expand_template(
21+
name = "target_config_def_gen",
22+
out = "include/bolt/Core/TargetConfig.def",
23+
substitutions = {"@BOLT_ENUM_TARGETS@": "\n".join(
24+
["BOLT_TARGET({})".format(target) for target in bolt_targets],
25+
)},
26+
template = "include/bolt/Core/TargetConfig.def.in",
27+
)
28+
29+
cc_library(
30+
name = "TargetConfig",
31+
textual_hdrs = [":target_config_def_gen"],
32+
)
33+
1934
cc_binary(
2035
name = "llvm-bolt-heatmap",
2136
srcs = glob([
@@ -24,6 +39,7 @@ cc_binary(
2439
deps = [
2540
":Profile",
2641
":Rewrite",
42+
":TargetConfig",
2743
":Utils",
2844
"//llvm:AllTargetsAsmParsers",
2945
"//llvm:AllTargetsDisassemblers",
@@ -54,6 +70,7 @@ cc_binary(
5470
":Profile",
5571
":Rewrite",
5672
":RuntimeLibs",
73+
":TargetConfig",
5774
":TargetAArch64",
5875
":TargetX86",
5976
":Utils",

0 commit comments

Comments
 (0)