[AMDGPU] prevent shrinking udiv/urem if either operand is in (SignedMax,UnsignedMax...
[llvm-project.git] / llvm / utils / gn / build / symbol_exports.py
blob708e2edd889b4946113731072454854f6ba9e0b7
1 #!/usr/bin/env python3
3 """Converts a .exports file to a format consumable by linkers.
5 An .exports file is a file with one exported symbol per line.
6 This script converts a .exports file into a format that linkers
7 can understand:
8 - It prepends a `_` to each line for use with -exported_symbols_list for Darwin
9 - It writes a .def file for use with /DEF: for Windows
10 - It writes a linker script for use with --version-script elsewhere
11 """
13 import argparse
14 import sys
17 def main():
18 parser = argparse.ArgumentParser(
19 description=__doc__,
20 formatter_class=argparse.RawDescriptionHelpFormatter)
21 parser.add_argument("--format", required=True, choices=("linux", "mac", "win"))
22 parser.add_argument("source")
23 parser.add_argument("output")
24 args = parser.parse_args()
26 symbols = open(args.source).readlines()
28 if args.format == "linux":
29 output_lines = (
31 "LLVM_0 {\n",
32 " global:\n",
34 + [" %s;\n" % s.rstrip() for s in symbols]
35 + [" local:\n", " *;\n", "};\n"]
37 elif args.format == "mac":
38 output_lines = ["_" + s for s in symbols]
39 else:
40 assert args.format == "win"
41 output_lines = ["EXPORTS\n"] + [" " + s for s in symbols]
43 open(args.output, "w").writelines(output_lines)
46 if __name__ == "__main__":
47 sys.exit(main())