OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Runs 'ld -shared' and generates a .TOC file that's untouched when unchanged. | 6 """Runs 'ld -shared' and generates a .TOC file that's untouched when unchanged. |
7 | 7 |
8 This script exists to avoid using complex shell commands in | 8 This script exists to avoid using complex shell commands in |
9 gcc_toolchain.gni's tool("solink"), in case the host running the compiler | 9 gcc_toolchain.gni's tool("solink"), in case the host running the compiler |
10 does not have a POSIX-like shell (e.g. Windows). | 10 does not have a POSIX-like shell (e.g. Windows). |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 help='Output table-of-contents file', | 93 help='Output table-of-contents file', |
94 metavar='FILE') | 94 metavar='FILE') |
95 parser.add_argument('--output', | 95 parser.add_argument('--output', |
96 required=True, | 96 required=True, |
97 help='Final output shared object file', | 97 help='Final output shared object file', |
98 metavar='FILE') | 98 metavar='FILE') |
99 parser.add_argument('command', nargs='+', | 99 parser.add_argument('command', nargs='+', |
100 help='Linking command') | 100 help='Linking command') |
101 args = parser.parse_args() | 101 args = parser.parse_args() |
102 | 102 |
103 # Work-around for gold being slow-by-default. http://crbug.com/632230 | |
104 os.environ['LC_ALL'] = 'C' | |
pasko
2016/07/28 10:03:56
bring it back to the original after linking?
I am
agrieve
2016/07/28 14:14:39
Done.
| |
105 | |
103 # First, run the actual link. | 106 # First, run the actual link. |
104 result = subprocess.call(CommandToRun(args.command)) | 107 result = subprocess.call(CommandToRun(args.command)) |
105 if result != 0: | 108 if result != 0: |
106 return result | 109 return result |
107 | 110 |
108 # Next, generate the contents of the TOC file. | 111 # Next, generate the contents of the TOC file. |
109 result, toc = CollectTOC(args) | 112 result, toc = CollectTOC(args) |
110 if result != 0: | 113 if result != 0: |
111 return result | 114 return result |
112 | 115 |
113 # If there is an existing TOC file with identical contents, leave it alone. | 116 # If there is an existing TOC file with identical contents, leave it alone. |
114 # Otherwise, write out the TOC file. | 117 # Otherwise, write out the TOC file. |
115 UpdateTOC(args.tocfile, toc) | 118 UpdateTOC(args.tocfile, toc) |
116 | 119 |
117 # Finally, strip the linked shared object file (if desired). | 120 # Finally, strip the linked shared object file (if desired). |
118 if args.strip: | 121 if args.strip: |
119 result = subprocess.call(CommandToRun([args.strip, '--strip-unneeded', | 122 result = subprocess.call(CommandToRun([args.strip, '--strip-unneeded', |
120 '-o', args.output, args.sofile])) | 123 '-o', args.output, args.sofile])) |
121 | 124 |
122 return result | 125 return result |
123 | 126 |
124 | 127 |
125 if __name__ == "__main__": | 128 if __name__ == "__main__": |
126 sys.exit(main()) | 129 sys.exit(main()) |
OLD | NEW |