diff options
author | Giuliano Procida <gprocida@google.com> | 2021-10-08 14:52:12 +0100 |
---|---|---|
committer | Giuliano Procida <gprocida@google.com> | 2021-11-25 13:35:10 +0000 |
commit | 41bc4aa8229843ee4295ccd6f3f20d873f72eb6c (patch) | |
tree | 0317303622050b6ecbb8c90097b8e43bd3a05a53 | |
parent | 35417fc53f2000d75a2a0730093b3ed2acb7b42a (diff) | |
download | build-41bc4aa8229843ee4295ccd6f3f20d873f72eb6c.tar.gz |
build: ABI: add stgdiff reporting
This change adds stgdiff reports alongside the existing abidiff
reports.
Bug: 201642997
Change-Id: I43191ac60d68712aafcdeed317e9936517d5598b
Signed-off-by: Giuliano Procida <gprocida@google.com>
-rw-r--r-- | abi/abitool.py | 38 | ||||
l--------- | build-tools/path/linux-x86/stgdiff | 1 | ||||
-rwxr-xr-x | build_abi.sh | 14 |
3 files changed, 51 insertions, 2 deletions
diff --git a/abi/abitool.py b/abi/abitool.py index bf933fb0..a787a8f3 100644 --- a/abi/abitool.py +++ b/abi/abitool.py @@ -146,7 +146,8 @@ class AbiTool(object): vmlinux_path=None): raise NotImplementedError() - def diff_abi(self, old_dump, new_dump, diff_report, short_report, symbol_list): + def diff_abi(self, old_dump, new_dump, diff_report, short_report, + symbol_list, full_report): raise NotImplementedError() def name(self): @@ -233,9 +234,42 @@ class Libabigail(AbiTool): return abi_changed +class Stg(AbiTool): + DIFF_ERROR = (1<<0) + DIFF_ABI_CHANGE = (1<<2) + + """" Concrete AbiTool implementation for STG """ + def dump_kernel_abi(self, linux_tree, dump_path, symbol_list, + vmlinux_path=None): + raise + + def diff_abi(self, old_dump, new_dump, diff_report, short_report=None, + symbol_list=None, full_report=None): + # shoehorn the interface + basename = diff_report + + log.info(f"stgdiff {old_dump} {new_dump} at {basename}.*") + command = ["stgdiff", "--abi", old_dump, new_dump] + for f in ["plain", "flat", "small", "viz"]: + command.extend(["--format", f, "--output", f"{basename}.{f}"]) + + abi_changed = False + + with open(f"{basename}.errors", "w") as out: + try: + subprocess.check_call(command, stdout=out, stderr=out) + except subprocess.CalledProcessError as e: + if e.returncode & self.DIFF_ERROR: + raise + abi_changed = True + + return abi_changed + def get_abi_tool(abi_tool = "libabigail"): + log.info(f"using {abi_tool} for abi analysis") if abi_tool == "libabigail": - log.info("using libabigail for abi analysis") return Libabigail() + if abi_tool == "STG": + return Stg() raise ValueError("not a valid abi_tool: %s" % abi_tool) diff --git a/build-tools/path/linux-x86/stgdiff b/build-tools/path/linux-x86/stgdiff new file mode 120000 index 00000000..d50da5b6 --- /dev/null +++ b/build-tools/path/linux-x86/stgdiff @@ -0,0 +1 @@ +../../../../prebuilts/kernel-build-tools/linux-x86/bin/stgdiff
\ No newline at end of file diff --git a/build_abi.sh b/build_abi.sh index c5887878..cb3bcd5d 100755 --- a/build_abi.sh +++ b/build_abi.sh @@ -343,6 +343,20 @@ if [ -n "$ABI_DEFINITION" ]; then echo "========================================================" 1>&2 cat ${abi_report}.short 1>&2 fi + + set +e + ${ROOT_DIR}/build/abi/diff_abi --abi-tool STG \ + --baseline $KERNEL_DIR/$ABI_DEFINITION \ + --new ${DIST_DIR}/${abi_out_file} \ + --report ${abi_report}.stg + rc=$? + set -e + echo "========================================================" + echo " stgdiff reports have been created at ${abi_report}.stg.*" + + if [ $rc -ne 0 ]; then + echo " stgdiff has reported ABI differences" 1>&2 + fi fi if [ $UPDATE -eq 1 ] ; then echo "========================================================" |