Skip to content

Commit

Permalink
Use objcopy instead of dump for symbols
Browse files Browse the repository at this point in the history
We keep the file name as `objdump` to not break customers consuming
these symbols.
  • Loading branch information
Reflejo committed Oct 30, 2024
1 parent f99fb64 commit 6cbe95e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ android_debug_info(
genrule(
name = "capture_symbols",
srcs = [
":capture_aar_objdump_collector",
":capture_aar_symbols_collector",
],
outs = ["symbols.tar"],
cmd = """
Expand Down
4 changes: 2 additions & 2 deletions bazel/android/artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def android_artifacts(name, android_library, manifest, archive_name, native_deps
aar_output = _create_aar(name, classes_jar, jni_archive, proguard_rules, manifest, visibility)

native.filegroup(
name = name + "_objdump_collector",
name = name + "_symbols_collector",
srcs = native_deps,
output_group = "objdump",
output_group = "objcopy",
visibility = ["//visibility:public"],
)

Expand Down
14 changes: 7 additions & 7 deletions bazel/android_debug_info.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Rule to create objdump debug info from a native dynamic library built for
Rule to create objcopy debug info from a native dynamic library built for
Android.
This is a workaround for generally not being able to produce dwp files for
Expand All @@ -11,7 +11,7 @@ somehow, this rule provides a separate --output_group for this

def _impl(ctx):
library_outputs = []
objdump_outputs = []
objcopy_outputs = []
for platform, dep in ctx.split_attr.dep.items():
# When --fat_apk_cpu isn't set, the platform is None
if len(dep.files.to_list()) != 1:
Expand All @@ -20,12 +20,12 @@ def _impl(ctx):
cc_toolchain = ctx.split_attr._cc_toolchain[platform][cc_common.CcToolchainInfo]
lib = dep.files.to_list()[0]
platform_name = platform or ctx.fragments.android.android_cpu
objdump_output = ctx.actions.declare_file(platform_name + "/" + platform_name + ".objdump.gz")
objcopy_output = ctx.actions.declare_file(platform_name + "/" + platform_name + ".debug.gz")

ctx.actions.run_shell(
inputs = [lib],
outputs = [objdump_output],
command = cc_toolchain.objdump_executable + " --syms " + lib.path + "| gzip -c >" + objdump_output.path,
outputs = [objcopy_output],
command = cc_toolchain.objcopy_executable + " --compress-debug-sections=zlib --only-keep-debug " + lib.path + " - | gzip -c >" + objcopy_output.path,
tools = [cc_toolchain.all_files],
progress_message = "Generating symbol map " + platform_name,
)
Expand All @@ -40,11 +40,11 @@ def _impl(ctx):
)

library_outputs.append(strip_output)
objdump_outputs.append(objdump_output)
objcopy_outputs.append(objcopy_output)

return [
DefaultInfo(files = depset(library_outputs)),
OutputGroupInfo(objdump = objdump_outputs),
OutputGroupInfo(objcopy = objcopy_outputs),
]

android_debug_info = rule(
Expand Down

0 comments on commit 6cbe95e

Please sign in to comment.