diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -786,6 +786,27 @@ ], ) +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([ @@ -2432,22 +2453,6 @@ ], ) -# 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([ @@ -3337,17 +3342,15 @@ 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", @@ -3355,7 +3358,6 @@ ":Target", ":llvm-bitcode-strip-opts", ":llvm-installnametool-opts", - ":llvm-objcopy-headers", ":llvm-objcopy-opts", ":llvm-strip-opts", ], diff --git a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel @@ -411,6 +411,22 @@ ], ) +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",