Allow sym_diff.py to report non-zero for non-breaking ABI changes

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-01-18 00:05:01 +00:00
parent 1b30568b31
commit 08305aaf6e
3 changed files with 14 additions and 7 deletions

View File

@@ -22,7 +22,8 @@ if (LIBCXX_HAS_ABILIST_CONFIGURATION)
set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist") set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist")
set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py") set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py")
add_custom_target(check-cxx-abilist add_custom_target(check-cxx-abilist
${SYMDIFF_EXE} --only-stdlib-symbols ${ABILIST_FILE} $<TARGET_SONAME_FILE:cxx_shared> ${SYMDIFF_EXE} --only-stdlib-symbols --strict ${ABILIST_FILE}
$<TARGET_SONAME_FILE:cxx_shared>
DEPENDS cxx_shared DEPENDS cxx_shared
COMMENT "Testing ABI compatibility...") COMMENT "Testing ABI compatibility...")
endif() endif()

View File

@@ -98,4 +98,6 @@ def report_diff(added_syms, removed_syms, changed_syms, names_only=False,
report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!' report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!'
else: else:
report += 'Symbols match.' report += 'Symbols match.'
return report, int(abi_break) is_different = abi_break or bool(len(added_syms)) \
or bool(len(changed_syms))
return report, abi_break, is_different

View File

@@ -30,6 +30,10 @@ def main():
parser.add_argument('--only-stdlib-symbols', dest='only_stdlib', parser.add_argument('--only-stdlib-symbols', dest='only_stdlib',
help="Filter all symbols not related to the stdlib", help="Filter all symbols not related to the stdlib",
action='store_true', default=False) action='store_true', default=False)
parser.add_argument('--strict', dest='strict',
help="Exit with a non-zero status if any symbols "
"differ",
action='store_true', default=False)
parser.add_argument( parser.add_argument(
'-o', '--output', dest='output', '-o', '--output', dest='output',
help='The output file. stdout is used if not given', help='The output file. stdout is used if not given',
@@ -54,16 +58,16 @@ def main():
added, removed, changed = diff.diff(old_syms_list, new_syms_list) added, removed, changed = diff.diff(old_syms_list, new_syms_list)
if args.removed_only: if args.removed_only:
added = {} added = {}
report, is_break = diff.report_diff(added, removed, changed, report, is_break, is_different = diff.report_diff(
names_only=args.names_only, added, removed, changed, names_only=args.names_only,
demangle=args.demangle) demangle=args.demangle)
if args.output is None: if args.output is None:
print(report) print(report)
else: else:
with open(args.output, 'w') as f: with open(args.output, 'w') as f:
f.write(report + '\n') f.write(report + '\n')
sys.exit(is_break) exit_code = 1 if is_break or (args.strict and is_different) else 0
sys.exit(exit_code)
if __name__ == '__main__': if __name__ == '__main__':
main() main()