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/clang/clang.gni") | 5 import("//build/config/clang/clang.gni") |
6 import("//build/config/nacl/config.gni") | 6 import("//build/config/nacl/config.gni") |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
8 import("//build/config/v8_target_cpu.gni") | 8 import("//build/config/v8_target_cpu.gni") |
9 import("//build/toolchain/cc_wrapper.gni") | 9 import("//build/toolchain/cc_wrapper.gni") |
10 import("//build/toolchain/goma.gni") | 10 import("//build/toolchain/goma.gni") |
11 import("//build/toolchain/toolchain.gni") | 11 import("//build/toolchain/toolchain.gni") |
12 import("//build/toolchain/concurrent_links.gni") | 12 import("//build/toolchain/concurrent_links.gni") |
13 import("//tools/grit/grit_rule.gni") | |
14 | |
15 # This flag is used to let the compilation and linking steps know that | |
16 # resource whitelisting should be done. | |
17 if (enable_resource_whitelist_generation) { | |
18 _whitelist_flag = "--whitelist" | |
agrieve
2016/07/27 01:42:27
nit: move this to be closer to where it is used.
estevenson
2016/07/28 21:56:45
Done.
| |
19 } else { | |
20 _whitelist_flag = "" | |
21 } | |
13 | 22 |
14 # This template defines a toolchain for something that works like gcc | 23 # This template defines a toolchain for something that works like gcc |
15 # (including clang). | 24 # (including clang). |
16 # | 25 # |
17 # It requires the following variables specifying the executables to run: | 26 # It requires the following variables specifying the executables to run: |
18 # - ar | 27 # - ar |
19 # - cc | 28 # - cc |
20 # - cxx | 29 # - cxx |
21 # - ld | 30 # - ld |
22 # and the following which is used in the toolchain_args | 31 # and the following which is used in the toolchain_args |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 lib_dir_switch = "-L" | 229 lib_dir_switch = "-L" |
221 | 230 |
222 # Object files go in this directory. | 231 # Object files go in this directory. |
223 object_subdir = "{{target_out_dir}}/{{label_name}}" | 232 object_subdir = "{{target_out_dir}}/{{label_name}}" |
224 | 233 |
225 tool("cc") { | 234 tool("cc") { |
226 depfile = "{{output}}.d" | 235 depfile = "{{output}}.d" |
227 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" | 236 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" |
228 depsformat = "gcc" | 237 depsformat = "gcc" |
229 description = "CC {{output}}" | 238 description = "CC {{output}}" |
230 outputs = [ | 239 outputs = [ |
agrieve
2016/07/27 01:42:27
nit: add a comment here that ninja doesn't support
estevenson
2016/07/28 21:56:45
Done.
| |
231 "$object_subdir/{{source_name_part}}.o", | 240 "$object_subdir/{{source_name_part}}.o", |
232 ] | 241 ] |
242 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", | |
243 root_build_dir) | |
244 command = "$python_path \"$compile_wrapper\" $_whitelist_flag --whitelist- file={{output}}.whitelist $command" | |
agrieve
2016/07/27 01:42:27
nit: this will result in a double space when white
estevenson
2016/07/28 21:56:45
Done.
| |
233 } | 245 } |
234 | 246 |
235 tool("cxx") { | 247 tool("cxx") { |
236 depfile = "{{output}}.d" | 248 depfile = "{{output}}.d" |
237 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" | 249 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" |
238 depsformat = "gcc" | 250 depsformat = "gcc" |
239 description = "CXX {{output}}" | 251 description = "CXX {{output}}" |
240 outputs = [ | 252 outputs = [ |
241 "$object_subdir/{{source_name_part}}.o", | 253 "$object_subdir/{{source_name_part}}.o", |
242 ] | 254 ] |
255 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", | |
256 root_build_dir) | |
257 command = "$python_path \"$compile_wrapper\" $_whitelist_flag --whitelist- file={{output}}.whitelist $command" | |
243 } | 258 } |
244 | 259 |
245 tool("asm") { | 260 tool("asm") { |
246 # For GCC we can just use the C compiler to compile assembly. | 261 # For GCC we can just use the C compiler to compile assembly. |
247 depfile = "{{output}}.d" | 262 depfile = "{{output}}.d" |
248 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" | 263 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" |
249 depsformat = "gcc" | 264 depsformat = "gcc" |
250 description = "ASM {{output}}" | 265 description = "ASM {{output}}" |
251 outputs = [ | 266 outputs = [ |
252 "$object_subdir/{{source_name_part}}.o", | 267 "$object_subdir/{{source_name_part}}.o", |
253 ] | 268 ] |
254 } | 269 } |
255 | 270 |
256 tool("alink") { | 271 tool("alink") { |
257 rspfile = "{{output}}.rsp" | 272 rspfile = "{{output}}.rsp" |
258 | 273 |
259 # This needs a Python script to avoid using simple sh features in this | 274 # This needs a Python script to avoid using simple sh features in this |
260 # command, in case the host does not use a POSIX shell (e.g. compiling | 275 # command, in case the host does not use a POSIX shell (e.g. compiling |
261 # POSIX-like toolchains such as NaCl on Windows). | 276 # POSIX-like toolchains such as NaCl on Windows). |
262 ar_wrapper = | 277 ar_wrapper = |
263 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) | 278 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
264 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" { {arflags}} rcsD @\"$rspfile\"" | 279 command = "$python_path \"$ar_wrapper\" $_whitelist_flag --rspfile=\"$rspf ile\" --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\"" |
265 description = "AR {{output}}" | 280 description = "AR {{output}}" |
266 rspfile_content = "{{inputs}}" | 281 rspfile_content = "{{inputs}}" |
267 outputs = [ | 282 outputs = [ |
268 "{{output_dir}}/{{target_output_name}}{{output_extension}}", | 283 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
269 ] | 284 ] |
270 | 285 |
271 # Shared libraries go in the target out directory by default so we can | 286 # Shared libraries go in the target out directory by default so we can |
272 # generate different targets with the same name and not have them collide. | 287 # generate different targets with the same name and not have them collide. |
273 default_output_dir = "{{target_out_dir}}" | 288 default_output_dir = "{{target_out_dir}}" |
274 default_output_extension = ".a" | 289 default_output_extension = ".a" |
275 output_prefix = "lib" | 290 output_prefix = "lib" |
276 } | 291 } |
277 | 292 |
278 tool("solink") { | 293 tool("solink") { |
279 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 294 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
280 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. | 295 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. |
281 rspfile = sofile + ".rsp" | 296 rspfile = sofile + ".rsp" |
297 whitelistfile = "{{output_dir}}/$soname.whitelist" | |
282 | 298 |
283 if (defined(invoker.strip)) { | 299 if (defined(invoker.strip)) { |
284 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 300 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
285 } else { | 301 } else { |
286 unstripped_sofile = sofile | 302 unstripped_sofile = sofile |
287 } | 303 } |
288 | 304 |
289 # These variables are not built into GN but are helpers that | 305 # These variables are not built into GN but are helpers that |
290 # implement (1) linking to produce a .so, (2) extracting the symbols | 306 # implement (1) linking to produce a .so, (2) extracting the symbols |
291 # from that file (3) if the extracted list differs from the existing | 307 # from that file (3) if the extracted list differs from the existing |
292 # .TOC file, overwrite it, otherwise, don't change it. | 308 # .TOC file, overwrite it, otherwise, don't change it. |
293 tocfile = sofile + ".TOC" | 309 tocfile = sofile + ".TOC" |
294 | 310 |
295 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" | 311 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
296 | 312 |
297 assert(defined(readelf), "to solink you must have a readelf") | 313 assert(defined(readelf), "to solink you must have a readelf") |
298 assert(defined(nm), "to solink you must have an nm") | 314 assert(defined(nm), "to solink you must have an nm") |
299 strip_switch = "" | 315 strip_switch = "" |
300 if (defined(invoker.strip)) { | 316 if (defined(invoker.strip)) { |
301 strip_switch = "--strip=${invoker.strip}" | 317 strip_switch = "--strip=${invoker.strip}" |
302 } | 318 } |
303 | 319 |
304 # This needs a Python script to avoid using a complex shell command | 320 # This needs a Python script to avoid using a complex shell command |
305 # requiring sh control structures, pipelines, and POSIX utilities. | 321 # requiring sh control structures, pipelines, and POSIX utilities. |
306 # The host might not have a POSIX shell and utilities (e.g. Windows). | 322 # The host might not have a POSIX shell and utilities (e.g. Windows). |
307 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") | 323 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") |
308 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" -- $link_command" | 324 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" $_whitelist_flag --rspfile=\"$rspfile\" -- $link_command" |
309 | 325 |
310 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 326 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
311 | 327 |
312 description = "SOLINK $sofile" | 328 description = "SOLINK $sofile" |
313 | 329 |
314 # Use this for {{output_extension}} expansions unless a target manually | 330 # Use this for {{output_extension}} expansions unless a target manually |
315 # overrides it (in which case {{output_extension}} will be what the target | 331 # overrides it (in which case {{output_extension}} will be what the target |
316 # specifies). | 332 # specifies). |
317 default_output_extension = default_shlib_extension | 333 default_output_extension = default_shlib_extension |
318 | 334 |
319 default_output_dir = "{{root_out_dir}}" | 335 default_output_dir = "{{root_out_dir}}" |
320 if (shlib_subdir != ".") { | 336 if (shlib_subdir != ".") { |
321 default_output_dir += "/$shlib_subdir" | 337 default_output_dir += "/$shlib_subdir" |
322 } | 338 } |
323 | 339 |
324 output_prefix = "lib" | 340 output_prefix = "lib" |
325 | 341 |
326 # Since the above commands only updates the .TOC file when it changes, ask | 342 # Since the above commands only updates the .TOC file when it changes, ask |
327 # Ninja to check if the timestamp actually changed to know if downstream | 343 # Ninja to check if the timestamp actually changed to know if downstream |
328 # dependencies should be recompiled. | 344 # dependencies should be recompiled. |
329 restat = true | 345 restat = true |
330 | 346 |
331 # Tell GN about the output files. It will link to the sofile but use the | 347 # Tell GN about the output files. It will link to the sofile but use the |
332 # tocfile for dependency management. | 348 # tocfile for dependency management. |
333 outputs = [ | 349 outputs = [ |
334 sofile, | 350 sofile, |
335 tocfile, | 351 tocfile, |
352 whitelistfile, | |
336 ] | 353 ] |
337 if (sofile != unstripped_sofile) { | 354 if (sofile != unstripped_sofile) { |
338 outputs += [ unstripped_sofile ] | 355 outputs += [ unstripped_sofile ] |
339 } | 356 } |
340 link_output = sofile | 357 link_output = sofile |
341 depend_output = tocfile | 358 depend_output = tocfile |
342 } | 359 } |
343 | 360 |
344 tool("solink_module") { | 361 tool("solink_module") { |
345 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 362 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 "toolchain_os", | 555 "toolchain_os", |
539 "use_gold", | 556 "use_gold", |
540 "v8_toolchain_cpu", | 557 "v8_toolchain_cpu", |
541 ]) | 558 ]) |
542 | 559 |
543 if (defined(invoker.use_debug_fission)) { | 560 if (defined(invoker.use_debug_fission)) { |
544 use_debug_fission = invoker.use_debug_fission | 561 use_debug_fission = invoker.use_debug_fission |
545 } | 562 } |
546 } | 563 } |
547 } | 564 } |
OLD | NEW |