OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/nacl/config.gni") | 5 import("//build/config/nacl/config.gni") |
6 import("//build/config/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
7 import("//build/toolchain/ccache.gni") | 7 import("//build/toolchain/ccache.gni") |
8 import("//build/toolchain/goma.gni") | 8 import("//build/toolchain/goma.gni") |
9 import("//build/toolchain/toolchain.gni") | 9 import("//build/toolchain/toolchain.gni") |
10 | 10 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 tool("alink") { | 208 tool("alink") { |
209 rspfile = "{{output}}.rsp" | 209 rspfile = "{{output}}.rsp" |
210 arflags = "" | 210 arflags = "" |
211 if (is_cfi && invoker.toolchain_os != "nacl") { | 211 if (is_cfi && invoker.toolchain_os != "nacl") { |
212 gold_plugin_path = rebase_path( | 212 gold_plugin_path = rebase_path( |
213 "//third_party/llvm-build/Release+Asserts/lib/LLVMgold.so", | 213 "//third_party/llvm-build/Release+Asserts/lib/LLVMgold.so", |
214 root_build_dir) | 214 root_build_dir) |
215 arflags = "--plugin $gold_plugin_path" | 215 arflags = "--plugin $gold_plugin_path" |
216 } | 216 } |
217 command = "rm -f {{output}} && $ar rcs $arflags {{output}} @$rspfile" | 217 |
| 218 # This needs a Python script to avoid using simple sh features in this |
| 219 # command, in case the host does not use a POSIX shell (e.g. Windows). |
| 220 ar_wrapper = rebase_path("//build/toolchain/gcc_ar_wrapper.py") |
| 221 command = "$python_path $ar_wrapper --output={{output}} --ar=$ar $arflags
rcs @$rspfile" |
218 description = "AR {{output}}" | 222 description = "AR {{output}}" |
219 rspfile_content = "{{inputs}}" | 223 rspfile_content = "{{inputs}}" |
220 outputs = [ | 224 outputs = [ |
221 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", | 225 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
222 ] | 226 ] |
223 default_output_extension = ".a" | 227 default_output_extension = ".a" |
224 output_prefix = "lib" | 228 output_prefix = "lib" |
225 } | 229 } |
226 | 230 |
227 tool("solink") { | 231 tool("solink") { |
228 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 232 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
229 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 233 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. |
230 if (shlib_subdir != ".") { | 234 if (shlib_subdir != ".") { |
231 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" | 235 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" |
232 } | 236 } |
233 rspfile = sofile + ".rsp" | 237 rspfile = sofile + ".rsp" |
234 | 238 |
235 unstripped_sofile = sofile | 239 unstripped_sofile = sofile |
236 if (defined(invoker.strip)) { | 240 if (defined(invoker.strip)) { |
237 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 241 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
238 } | 242 } |
239 | 243 |
240 # These variables are not built into GN but are helpers that implement | 244 # These variables are not built into GN but are helpers that |
241 # (1) linking to produce a .so, (2) extracting the symbols from that file | 245 # implement (1) linking to produce a .so, (2) extracting the symbols |
242 # to a temporary file, (3) if the temporary file has differences from the | 246 # from that file (3) if the extracted list differs from the existing |
243 # existing .TOC file, overwrite it, otherwise, don't change it. | 247 # .TOC file, overwrite it, otherwise, don't change it. |
244 tocfile = sofile + ".TOC" | 248 tocfile = sofile + ".TOC" |
245 temporary_tocname = sofile + ".tmp" | |
246 | 249 |
247 link_command = "$ld -shared {{ldflags}} -o $unstripped_sofile -Wl,-soname=
$soname @$rspfile" | 250 link_command = "$ld -shared {{ldflags}} -o $unstripped_sofile -Wl,-soname=
$soname @$rspfile" |
| 251 |
248 assert(defined(readelf), "to solink you must have a readelf") | 252 assert(defined(readelf), "to solink you must have a readelf") |
249 assert(defined(nm), "to solink you must have an nm") | 253 assert(defined(nm), "to solink you must have an nm") |
250 toc_command = "{ $readelf -d $unstripped_sofile | grep SONAME ; $nm -gD -f
p $unstripped_sofile | cut -f1-2 -d' '; } > $temporary_tocname" | 254 strip_switch = "" |
251 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo
rary_tocname $tocfile; fi" | 255 if (defined(invoker.strip)) { |
| 256 strip_switch = "--strip=${invoker.strip}" |
| 257 } |
252 | 258 |
253 command = "$link_command && $toc_command && $replace_command" | 259 # This needs a Python script to avoid using a complex shell command |
254 if (defined(invoker.strip)) { | 260 # requiring sh control structures, pipelines, and POSIX utilities. |
255 strip_command = | 261 # The host might not have a POSIX shell and utilities (e.g. Windows). |
256 "${invoker.strip} --strip-unneeded -o $sofile $unstripped_sofile" | 262 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") |
257 command += " && " + strip_command | 263 command = "$python_path $solink_wrapper --readelf=$readelf --nm=$nm $strip
_switch --sofile=$unstripped_sofile --tocfile=$tocfile --output=$sofile -- $link
_command" |
258 } | 264 |
259 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 265 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
260 | 266 |
261 description = "SOLINK $sofile" | 267 description = "SOLINK $sofile" |
262 | 268 |
263 # Use this for {{output_extension}} expansions unless a target manually | 269 # Use this for {{output_extension}} expansions unless a target manually |
264 # overrides it (in which case {{output_extension}} will be what the target | 270 # overrides it (in which case {{output_extension}} will be what the target |
265 # specifies). | 271 # specifies). |
266 default_output_extension = default_shlib_extension | 272 default_output_extension = default_shlib_extension |
267 | 273 |
268 output_prefix = "lib" | 274 output_prefix = "lib" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 nm = "${toolprefix}nm" | 445 nm = "${toolprefix}nm" |
440 | 446 |
441 forward_variables_from(invoker, | 447 forward_variables_from(invoker, |
442 [ | 448 [ |
443 "toolchain_cpu", | 449 "toolchain_cpu", |
444 "toolchain_os", | 450 "toolchain_os", |
445 "use_gold", | 451 "use_gold", |
446 ]) | 452 ]) |
447 } | 453 } |
448 } | 454 } |
OLD | NEW |