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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ] | 205 ] |
206 } | 206 } |
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 | 217 |
218 # This needs a Python script to avoid using simple sh features in this | 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). | 219 # command, in case the host does not use a POSIX shell (e.g. compiling |
220 ar_wrapper = rebase_path("//build/toolchain/gcc_ar_wrapper.py") | 220 # POSIX-like toolchains such as NaCl on Windows). |
221 command = "$python_path $ar_wrapper --output={{output}} --ar=$ar $arflags
rcs @$rspfile" | 221 ar_wrapper = |
| 222 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
| 223 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=$ar $arfl
ags rcs @\"$rspfile\"" |
222 description = "AR {{output}}" | 224 description = "AR {{output}}" |
223 rspfile_content = "{{inputs}}" | 225 rspfile_content = "{{inputs}}" |
224 outputs = [ | 226 outputs = [ |
225 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", | 227 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
226 ] | 228 ] |
227 default_output_extension = ".a" | 229 default_output_extension = ".a" |
228 output_prefix = "lib" | 230 output_prefix = "lib" |
229 } | 231 } |
230 | 232 |
231 tool("solink") { | 233 tool("solink") { |
232 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 234 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
233 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 235 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. |
234 if (shlib_subdir != ".") { | 236 if (shlib_subdir != ".") { |
235 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" | 237 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" |
236 } | 238 } |
237 rspfile = sofile + ".rsp" | 239 rspfile = sofile + ".rsp" |
238 | 240 |
239 unstripped_sofile = sofile | 241 unstripped_sofile = sofile |
240 if (defined(invoker.strip)) { | 242 if (defined(invoker.strip)) { |
241 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 243 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
242 } | 244 } |
243 | 245 |
244 # These variables are not built into GN but are helpers that | 246 # These variables are not built into GN but are helpers that |
245 # implement (1) linking to produce a .so, (2) extracting the symbols | 247 # implement (1) linking to produce a .so, (2) extracting the symbols |
246 # from that file (3) if the extracted list differs from the existing | 248 # from that file (3) if the extracted list differs from the existing |
247 # .TOC file, overwrite it, otherwise, don't change it. | 249 # .TOC file, overwrite it, otherwise, don't change it. |
248 tocfile = sofile + ".TOC" | 250 tocfile = sofile + ".TOC" |
249 | 251 |
250 link_command = "$ld -shared {{ldflags}} -o $unstripped_sofile -Wl,-soname=
$soname @$rspfile" | 252 link_command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-son
ame=\"$soname\" @\"$rspfile\"" |
251 | 253 |
252 assert(defined(readelf), "to solink you must have a readelf") | 254 assert(defined(readelf), "to solink you must have a readelf") |
253 assert(defined(nm), "to solink you must have an nm") | 255 assert(defined(nm), "to solink you must have an nm") |
254 strip_switch = "" | 256 strip_switch = "" |
255 if (defined(invoker.strip)) { | 257 if (defined(invoker.strip)) { |
256 strip_switch = "--strip=${invoker.strip}" | 258 strip_switch = "--strip=${invoker.strip}" |
257 } | 259 } |
258 | 260 |
259 # This needs a Python script to avoid using a complex shell command | 261 # This needs a Python script to avoid using a complex shell command |
260 # requiring sh control structures, pipelines, and POSIX utilities. | 262 # requiring sh control structures, pipelines, and POSIX utilities. |
261 # The host might not have a POSIX shell and utilities (e.g. Windows). | 263 # The host might not have a POSIX shell and utilities (e.g. Windows). |
262 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") | 264 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") |
263 command = "$python_path $solink_wrapper --readelf=$readelf --nm=$nm $strip
_switch --sofile=$unstripped_sofile --tocfile=$tocfile --output=$sofile -- $link
_command" | 265 command = "$python_path $solink_wrapper --readelf=$readelf --nm=$nm $strip
_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --output=\"$sofil
e\" -- $link_command" |
264 | 266 |
265 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 267 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
266 | 268 |
267 description = "SOLINK $sofile" | 269 description = "SOLINK $sofile" |
268 | 270 |
269 # Use this for {{output_extension}} expansions unless a target manually | 271 # Use this for {{output_extension}} expansions unless a target manually |
270 # overrides it (in which case {{output_extension}} will be what the target | 272 # overrides it (in which case {{output_extension}} will be what the target |
271 # specifies). | 273 # specifies). |
272 default_output_extension = default_shlib_extension | 274 default_output_extension = default_shlib_extension |
273 | 275 |
(...skipping 23 matching lines...) Expand all Loading... |
297 if (shlib_subdir != ".") { | 299 if (shlib_subdir != ".") { |
298 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" | 300 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" |
299 } | 301 } |
300 rspfile = sofile + ".rsp" | 302 rspfile = sofile + ".rsp" |
301 | 303 |
302 unstripped_sofile = sofile | 304 unstripped_sofile = sofile |
303 if (defined(invoker.strip)) { | 305 if (defined(invoker.strip)) { |
304 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 306 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
305 } | 307 } |
306 | 308 |
307 command = "$ld -shared {{ldflags}} -o $unstripped_sofile -Wl,-soname=$sona
me @$rspfile" | 309 command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\
"$soname\" @\"$rspfile\"" |
308 | 310 |
309 if (defined(invoker.strip)) { | 311 if (defined(invoker.strip)) { |
310 strip_command = | 312 strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$uns
tripped_sofile\"" |
311 "${invoker.strip} --strip-unneeded -o $sofile $unstripped_sofile" | |
312 command += " && " + strip_command | 313 command += " && " + strip_command |
313 } | 314 } |
314 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 315 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
315 | 316 |
316 description = "SOLINK_MODULE $sofile" | 317 description = "SOLINK_MODULE $sofile" |
317 | 318 |
318 # Use this for {{output_extension}} expansions unless a target manually | 319 # Use this for {{output_extension}} expansions unless a target manually |
319 # overrides it (in which case {{output_extension}} will be what the target | 320 # overrides it (in which case {{output_extension}} will be what the target |
320 # specifies). | 321 # specifies). |
321 default_output_extension = default_shlib_extension | 322 default_output_extension = default_shlib_extension |
(...skipping 16 matching lines...) Expand all Loading... |
338 | 339 |
339 # Use this for {{output_extension}} expansions unless a target manually | 340 # Use this for {{output_extension}} expansions unless a target manually |
340 # overrides it (in which case {{output_extension}} will be what the target | 341 # overrides it (in which case {{output_extension}} will be what the target |
341 # specifies). | 342 # specifies). |
342 default_output_extension = default_executable_extension | 343 default_output_extension = default_executable_extension |
343 | 344 |
344 if (defined(invoker.strip)) { | 345 if (defined(invoker.strip)) { |
345 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" | 346 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" |
346 } | 347 } |
347 | 348 |
348 command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspf
ile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postf
ix" | 349 command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--start-group @\
"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_secti
on_postfix" |
349 if (defined(invoker.strip)) { | 350 if (defined(invoker.strip)) { |
350 link_wrapper = rebase_path("//build/toolchain/gcc_link_wrapper.py") | 351 link_wrapper = |
351 command = "$python_path $link_wrapper --strip=${invoker.strip} --unstrip
ped-file=$unstripped_outfile --output=$outfile -- $command" | 352 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) |
| 353 command = "$python_path \"$link_wrapper\" --strip=${invoker.strip} --uns
tripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command" |
352 } | 354 } |
353 description = "LINK $outfile" | 355 description = "LINK $outfile" |
354 rspfile_content = "{{inputs}}" | 356 rspfile_content = "{{inputs}}" |
355 outputs = [ | 357 outputs = [ |
356 outfile, | 358 outfile, |
357 ] | 359 ] |
358 if (outfile != unstripped_outfile) { | 360 if (outfile != unstripped_outfile) { |
359 outputs += [ unstripped_outfile ] | 361 outputs += [ unstripped_outfile ] |
360 } | 362 } |
361 if (defined(invoker.link_outputs)) { | 363 if (defined(invoker.link_outputs)) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 nm = "${toolprefix}nm" | 443 nm = "${toolprefix}nm" |
442 | 444 |
443 forward_variables_from(invoker, | 445 forward_variables_from(invoker, |
444 [ | 446 [ |
445 "toolchain_cpu", | 447 "toolchain_cpu", |
446 "toolchain_os", | 448 "toolchain_os", |
447 "use_gold", | 449 "use_gold", |
448 ]) | 450 ]) |
449 } | 451 } |
450 } | 452 } |
OLD | NEW |