Refactor the symbol checking tools, making them more generic and using llvm-ifs to check the symbols instead of manual tooling.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
@ldionne This is a prototype for a complete refactor of the symbol checker. There's a lot I don't know about other platforms and what we should expect to support, so please share your thoughts.
runtimes/utils/sym_check/extract.py | ||
---|---|---|
10 | magic and yaml are external modules. While we can likely get away without magic, since llvm-ifs requires us to output to a YAML file, I think it's best to read said file with yaml.safe_load() |
Using a simple C file:
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
Compiled with: clang testfile.c -shared -fPIC -o testlib.so
generate_abi_list.py will output the following JSON (whether to stdout or a file):
[ { "Name": "_ITM_deregisterTMCloneTable", "Type": "NoType", "Undefined": true, "Weak": true }, { "Name": "_ITM_registerTMCloneTable", "Type": "NoType", "Undefined": true, "Weak": true }, { "Name": "__cxa_finalize", "Type": "Func", "Undefined": true, "Weak": true }, { "Name": "__gmon_start__", "Type": "NoType", "Undefined": true, "Weak": true }, { "Name": "main", "Type": "Func" }, { "Name": "printf", "Type": "Func", "Undefined": true } ]
Saving this output to a file (sample.json) and giving both the file and the library to get_sym_diff.py outputs:
Symbols unchanged
In sample.json, I changed the name of the first symbol to Test_ITM_deregisterTMCloneTable and changed the visibility of the second symbol from "Weak": true to "Weak: false". I passed the original library and this altered symbol table to get_sym_diff.py as so:
python3 get_sym_diff.py testlib.so sample.json
The output is below:
Symbols Added: 1 Added {'Name': 'Test_ITM_deregisterTMCloneTable', 'Type': 'NoType', 'Undefined': True, 'Weak': True} Symbols Removed: 1 Removed {'Name': '_ITM_deregisterTMCloneTable', 'Type': 'NoType', 'Undefined': True, 'Weak': True} Symbols Changed: 1 _ITM_registerTMCloneTable: {'Name': '_ITM_registerTMCloneTable', 'Type': 'NoType', 'Undefined': True, 'Weak': True} -> {'Name': '_ITM_registerTMCloneTable', 'Type': 'NoType', 'Undefined': True, 'Weak': False} ABI BREAKAGE!: 1 added, 1 removed, 1 changed.
magic and yaml are external modules. While we can likely get away without magic, since llvm-ifs requires us to output to a YAML file, I think it's best to read said file with yaml.safe_load()