[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
[llvm-project.git] / libcxx / utils / generate_abi_list.py
blob670300ba0f1b1659c59fa5e2f0f408a7c7993936
1 #!/usr/bin/env python
2 #===----------------------------------------------------------------------===##
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===----------------------------------------------------------------------===##
10 import argparse
11 import io
12 import libcxx.sym_check.extract
13 import libcxx.sym_check.util
14 import pprint
15 import sys
17 def OutputFile(file):
18 if isinstance(file, io.IOBase):
19 return file
20 assert isinstance(file, str), "Got object {} which is not a str".format(file)
21 return open(file, 'w', newline='\n')
23 def main(argv):
24 parser = argparse.ArgumentParser(
25 description='Extract a list of symbols from a shared library.')
26 parser.add_argument('library', metavar='LIB', type=str,
27 help='The library to extract symbols from.')
28 parser.add_argument('-o', '--output', dest='output', type=OutputFile, default=sys.stdout,
29 help='The output file to write the symbols to. It is overwritten if it already exists. '
30 'If no file is specified, the results are written to standard output.')
31 args = parser.parse_args(argv)
33 symbols = libcxx.sym_check.extract.extract_symbols(args.library)
34 symbols, _ = libcxx.sym_check.util.filter_stdlib_symbols(symbols)
36 lines = [pprint.pformat(sym, width=99999) for sym in symbols]
37 args.output.writelines('\n'.join(sorted(lines)))
39 if __name__ == '__main__':
40 main(sys.argv[1:])