[bolt][bazel] Port e235fcb582.

This commit is contained in:
Christian Sigg 2025-02-18 11:24:15 +01:00
parent cd10c01767
commit ef218317d7
2 changed files with 28 additions and 2 deletions

View File

@ -172,10 +172,19 @@ def _llvm_configure_impl(repository_ctx):
)
# Create a starlark file with the requested LLVM targets.
targets = repository_ctx.attr.targets
llvm_targets = repository_ctx.attr.targets
repository_ctx.file(
"llvm/targets.bzl",
content = "llvm_targets = " + str(targets),
content = "llvm_targets = " + str(llvm_targets),
executable = False,
)
# Create a starlark file with the requested BOLT targets.
bolt_targets = ["AArch64","X86","RISCV"] # Supported targets.
bolt_targets = [t for t in llvm_targets if t in bolt_targets]
repository_ctx.file(
"bolt/targets.bzl",
content = "bolt_targets = " + str(bolt_targets),
executable = False,
)

View File

@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load(":targets.bzl", "bolt_targets")
package(
default_visibility = ["//visibility:public"],
@ -16,6 +17,20 @@ genrule(
cmd = "echo '#undef BOLT_REVISION' >> $@\n",
)
expand_template(
name = "target_config_def_gen",
out = "include/bolt/Core/TargetConfig.def",
substitutions = {"@BOLT_ENUM_TARGETS@": "\n".join(
["BOLT_TARGET({})".format(target) for target in bolt_targets],
)},
template = "include/bolt/Core/TargetConfig.def.in",
)
cc_library(
name = "TargetConfig",
textual_hdrs = [":target_config_def_gen"],
)
cc_binary(
name = "llvm-bolt-heatmap",
srcs = glob([
@ -24,6 +39,7 @@ cc_binary(
deps = [
":Profile",
":Rewrite",
":TargetConfig",
":Utils",
"//llvm:AllTargetsAsmParsers",
"//llvm:AllTargetsDisassemblers",
@ -54,6 +70,7 @@ cc_binary(
":Profile",
":Rewrite",
":RuntimeLibs",
":TargetConfig",
":TargetAArch64",
":TargetX86",
":Utils",