[RFC] Bringing up new tool llvm-tapi-diff


I am a proposing a new tool, llvm-tapi-diff (https://reviews.llvm.org/D101835), that would compare two files and return the differences based on attributes that are specific to linking. The initial patch only supports TBD files. Text-based Dynamic Library Stubs (TBDs) are a representation of the information in dynamic libraries needed for the static linker in Apple’s SDK’s. LLVM already has support for reading and writing TBD files. Although the current patch only supports TBD files, we hope to have support for Mach-O dylib binaries in the future. This tool could also be extended to provide the same functionality for other formats. This tool emits a human readable output to easily see the differences in the two input files. Since the initial support for this tool is focused on TBD files, one of its major purposes is helping in finding regressions in tools that emit tbd files like TAPI or the swift compiler. With the future expansion of file formats that this tool could support, it could serve a variety of purposes including tracking when clang emits more exported symbols between compiler versions.

The introduction of an entirely new tool brings forth some questions.

Why not use llvm-nm?

llvm-nm lists the contents of symbol tables from the files but it does not list all of the additional attributes necessary for linking in TBD files. Adding this amount of functionality and restructuring didn’t seem as good of an option over creating a new tool for this functionality.

Why not use llvm-diff?

llvm-diff has a very different objective in comparison to llvm-tapi-diff as llvm-diff checks the structural differences between llvm modules focusing on function definitions and control flow. llvm-tapi-diff checks for differences that can be captured using other binary inspection tools like nm and otool.

For more resources on TAPI and TBD files, please refer to the RFC for the introduction of TAPI in LLVM by Jürgen Ributzka (https://lists.llvm.org/pipermail/llvm-dev/2017-September/117264.html) and this presentation from the 2018 LLVM Developers’ Meeting by Steven Wu (https://www.youtube.com/watch?v=B9li6EkD5zA).

Thank you,

Sam Powell