Skip to content

Commit

Permalink
[Bazel] Fix build after ObjCopy move.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D120039
  • Loading branch information
akuegel committed Feb 17, 2022
1 parent e993b20 commit e7d65fc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
46 changes: 24 additions & 22 deletions utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
Expand Up @@ -786,6 +786,27 @@ cc_library(
],
)

cc_library(
name = "ObjCopy",
srcs = glob([
"lib/ObjCopy/**/*.cpp",
"lib/ObjCopy/**/*.h",
]),
hdrs = glob([
"include/llvm/ObjCopy/**/*.h",
]),
copts = llvm_copts,
includes = ["lib/ObjCopy"],
deps = [
":MC",
":Object",
":ObjectYAML",
":Support",
":Target",
":intrinsics_impl_gen",
],
)

cc_library(
name = "Object",
srcs = glob([
Expand Down Expand Up @@ -2432,22 +2453,6 @@ cc_library(
],
)

# FIXME: This library should use `textual_hdrs` instead of `hdrs` as we don't
# want to parse or build modules for them (and haven't duplicated the necessary
# dependencies), but unfortunately that doesn't work with
# `strip_include_prefix`: https://github.com/bazelbuild/bazel/issues/12424
#
# For now, we simply disable features that might rely on the headers parsing.
cc_library(
name = "llvm-objcopy-headers",
hdrs = glob(["tools/llvm-objcopy/**/*.h"]),
features = [
"-parse_headers",
"-header_modules",
],
strip_include_prefix = "tools/llvm-objcopy",
)

cc_library(
name = "MCA",
srcs = glob([
Expand Down Expand Up @@ -3337,25 +3342,22 @@ cc_binary(
cc_binary(
name = "llvm-objcopy",
srcs = glob([
"tools/llvm-objcopy/**/*.cpp",
# Note that we redundantly include the headers here to allow files to
# include same-directory headers in addition to including headers via
# the `llvm-objcopy-headers` rule's stripped include prefix.
"tools/llvm-objcopy/**/*.h",
"tools/llvm-objcopy/*.cpp",
"tools/llvm-objcopy/*.h",
]),
copts = llvm_copts,
stamp = 0,
deps = [
":BinaryFormat",
":MC",
":ObjCopy",
":Object",
":ObjectYAML",
":Option",
":Support",
":Target",
":llvm-bitcode-strip-opts",
":llvm-installnametool-opts",
":llvm-objcopy-headers",
":llvm-objcopy-opts",
":llvm-strip-opts",
],
Expand Down
16 changes: 16 additions & 0 deletions utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
Expand Up @@ -411,6 +411,22 @@ cc_test(
],
)

cc_test(
name = "objcopy_tests",
srcs = glob(
["ObjCopy/*.cpp"],
allow_empty = False,
),
deps = [
"//llvm:ObjCopy",
"//llvm:Object",
"//llvm:ObjectYAML",
"//llvm:TestingSupport",
"//llvm:gtest",
"//llvm:gtest_main",
],
)

cc_test(
name = "object_tests",
size = "small",
Expand Down

0 comments on commit e7d65fc

Please sign in to comment.