Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use objcopy instead of dump for symbols #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading