OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2016 The Dart Authors. All rights reserved. | 3 # Copyright (c) 2016 The Dart Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 This script performs the final link step for Fuchsia NDK executables. | 8 This script performs the final link step for Fuchsia NDK executables. |
9 Usage: | 9 Usage: |
10 ./fuchsia_link {arm,arm64,ia32} {executable,library,shared_library} | 10 ./fuchsia_link {arm,arm64,ia32} {executable,library,shared_library} |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 # Fuchsia specific system includes and libraries. | 98 # Fuchsia specific system includes and libraries. |
99 fuchsia_sysroot = os.path.join(fuchsia_tools, 'sysroot', 'x86_64') | 99 fuchsia_sysroot = os.path.join(fuchsia_tools, 'sysroot', 'x86_64') |
100 if target_arch == 'arm64': | 100 if target_arch == 'arm64': |
101 fuchsia_sysroot = os.path.join(fuchsia_tools, 'sysroot', 'arm64') | 101 fuchsia_sysroot = os.path.join(fuchsia_tools, 'sysroot', 'arm64') |
102 CheckDirExists(fuchsia_sysroot, 'Fuchsia sysroot') | 102 CheckDirExists(fuchsia_sysroot, 'Fuchsia sysroot') |
103 fuchsia_lib = os.path.join(fuchsia_sysroot, 'usr', 'lib') | 103 fuchsia_lib = os.path.join(fuchsia_sysroot, 'usr', 'lib') |
104 crtn_fuchsia = os.path.join(fuchsia_lib, 'crtn.o') | 104 crtn_fuchsia = os.path.join(fuchsia_lib, 'crtn.o') |
105 | 105 |
106 if link_target == 'target': | 106 if link_target == 'target': |
107 # Add and remove libraries as listed in configurations_fuchsia.gypi | 107 # Add and remove libraries as listed in configurations_fuchsia.gypi |
108 libs_to_rm = ['-lrt', '-lpthread', '-ldl'] | 108 libs_to_rm = ['-lrt', '-lpthread'] |
109 libs_to_add = [fuchsia_libgcc, '-lc',] | 109 libs_to_add = [fuchsia_libgcc, '-lc', '-ldl', '-lm'] |
110 | 110 |
111 # Add crtn_fuchsia to end if we are linking an executable. | 111 # Add crtn_fuchsia to end if we are linking an executable. |
112 if link_type == 'executable': | 112 if link_type == 'executable': |
113 libs_to_add.extend([crtn_fuchsia]) | 113 libs_to_add.extend([crtn_fuchsia]) |
114 | 114 |
115 link_args = [i for i in link_args if i not in libs_to_rm] | 115 link_args = [i for i in link_args if i not in libs_to_rm] |
116 link_args.extend(libs_to_add) | 116 link_args.extend(libs_to_add) |
117 | 117 |
118 link_args.insert(0, fuchsia_linker) | 118 link_args.insert(0, fuchsia_linker) |
119 else: | 119 else: |
120 link_args.extend(['-ldl', '-lrt']) | 120 link_args.extend(['-ldl', '-lrt']) |
121 link_args.insert(0, 'g++') | 121 link_args.insert(0, 'g++') |
122 | 122 |
123 print ' '.join(link_args) | 123 print ' '.join(link_args) |
124 sys.exit(execute(link_args)) | 124 sys.exit(execute(link_args)) |
125 | 125 |
126 if __name__ == '__main__': | 126 if __name__ == '__main__': |
127 main() | 127 main() |
OLD | NEW |