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 a linking command and optionally a strip command. | 6 """Runs a linking command and optionally a strip command. |
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("link"), in case the host running the compiler | 9 gcc_toolchain.gni's tool("link"), 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). |
11 """ | 11 """ |
12 | 12 |
13 import argparse | 13 import argparse |
| 14 import os |
14 import subprocess | 15 import subprocess |
15 import sys | 16 import sys |
16 | 17 |
17 | 18 |
18 # When running on a Windows host and using a toolchain whose tools are | 19 # When running on a Windows host and using a toolchain whose tools are |
19 # actually wrapper scripts (i.e. .bat files on Windows) rather than binary | 20 # actually wrapper scripts (i.e. .bat files on Windows) rather than binary |
20 # executables, the "command" to run has to be prefixed with this magic. | 21 # executables, the "command" to run has to be prefixed with this magic. |
21 # The GN toolchain definitions take care of that for when GN/Ninja is | 22 # The GN toolchain definitions take care of that for when GN/Ninja is |
22 # running the tool directly. When that command is passed in to this | 23 # running the tool directly. When that command is passed in to this |
23 # script, it appears as a unitary string but needs to be split up so that | 24 # script, it appears as a unitary string but needs to be split up so that |
(...skipping 16 matching lines...) Expand all Loading... |
40 help='Executable file produced by linking command', | 41 help='Executable file produced by linking command', |
41 metavar='FILE') | 42 metavar='FILE') |
42 parser.add_argument('--output', | 43 parser.add_argument('--output', |
43 required=True, | 44 required=True, |
44 help='Final output executable file', | 45 help='Final output executable file', |
45 metavar='FILE') | 46 metavar='FILE') |
46 parser.add_argument('command', nargs='+', | 47 parser.add_argument('command', nargs='+', |
47 help='Linking command') | 48 help='Linking command') |
48 args = parser.parse_args() | 49 args = parser.parse_args() |
49 | 50 |
50 # First, run the actual link. | 51 # Work-around for gold being slow-by-default. http://crbug.com/632230 |
51 result = subprocess.call(CommandToRun(args.command)) | 52 fast_env = dict(os.environ) |
| 53 fast_env['LC_ALL'] = 'C' |
| 54 result = subprocess.call(CommandToRun(args.command), env=fast_env) |
52 if result != 0: | 55 if result != 0: |
53 return result | 56 return result |
54 | 57 |
55 # Finally, strip the linked executable (if desired). | 58 # Finally, strip the linked executable (if desired). |
56 if args.strip: | 59 if args.strip: |
57 result = subprocess.call(CommandToRun([ | 60 result = subprocess.call(CommandToRun([ |
58 args.strip, '--strip-unneeded', '-o', args.output, args.unstripped_file | 61 args.strip, '--strip-unneeded', '-o', args.output, args.unstripped_file |
59 ])) | 62 ])) |
60 | 63 |
61 return result | 64 return result |
62 | 65 |
63 | 66 |
64 if __name__ == "__main__": | 67 if __name__ == "__main__": |
65 sys.exit(main()) | 68 sys.exit(main()) |
OLD | NEW |