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/cc_wrapper.gni") | 7 import("//build/toolchain/cc_wrapper.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 |
11 # This value will be inherited in the toolchain below. | 11 # "concurrent_links" is a toolchain variable. By computing it here rather than |
| 12 # inside the toolchain, the exec_script will only get run once rather than |
| 13 # each time the toolchain template is invoked. |
12 if (allow_posix_link_time_opt || is_cfi) { | 14 if (allow_posix_link_time_opt || is_cfi) { |
13 concurrent_links = | 15 concurrent_links_ = |
14 exec_script("get_concurrent_links.py", [ "--lto" ], "value") | 16 exec_script("get_concurrent_links.py", [ "--lto" ], "value") |
15 } else { | 17 } else { |
16 concurrent_links = exec_script("get_concurrent_links.py", [], "value") | 18 concurrent_links_ = exec_script("get_concurrent_links.py", [], "value") |
17 } | 19 } |
18 | 20 |
19 # This template defines a toolchain for something that works like gcc | 21 # This template defines a toolchain for something that works like gcc |
20 # (including clang). | 22 # (including clang). |
21 # | 23 # |
22 # It requires the following variables specifying the executables to run: | 24 # It requires the following variables specifying the executables to run: |
23 # - cc | 25 # - cc |
24 # - cxx | 26 # - cxx |
25 # - ar | 27 # - ar |
26 # - ld | 28 # - ld |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 toolchain(target_name) { | 96 toolchain(target_name) { |
95 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") | 97 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") |
96 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") | 98 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") |
97 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") | 99 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") |
98 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") | 100 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") |
99 assert(defined(invoker.toolchain_cpu), | 101 assert(defined(invoker.toolchain_cpu), |
100 "gcc_toolchain() must specify a \"toolchain_cpu\"") | 102 "gcc_toolchain() must specify a \"toolchain_cpu\"") |
101 assert(defined(invoker.toolchain_os), | 103 assert(defined(invoker.toolchain_os), |
102 "gcc_toolchain() must specify a \"toolchain_os\"") | 104 "gcc_toolchain() must specify a \"toolchain_os\"") |
103 | 105 |
| 106 concurrent_links = concurrent_links_ |
| 107 |
104 if (defined(invoker.cc_wrapper)) { | 108 if (defined(invoker.cc_wrapper)) { |
105 cc_wrapper = invoker.cc_wrapper | 109 cc_wrapper = invoker.cc_wrapper |
106 } | 110 } |
107 if (defined(invoker.use_goma)) { | 111 if (defined(invoker.use_goma)) { |
108 use_goma = invoker.use_goma | 112 use_goma = invoker.use_goma |
109 } | 113 } |
110 if (use_goma) { | 114 if (use_goma) { |
111 assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.") | 115 assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.") |
112 compiler_prefix = "$goma_dir/gomacc " | 116 compiler_prefix = "$goma_dir/gomacc " |
113 } else if (cc_wrapper != "") { | 117 } else if (cc_wrapper != "") { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di
rs}} {{asmflags}} -c {{source}} -o {{output}}" | 213 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di
rs}} {{asmflags}} -c {{source}} -o {{output}}" |
210 depsformat = "gcc" | 214 depsformat = "gcc" |
211 description = "ASM {{output}}" | 215 description = "ASM {{output}}" |
212 outputs = [ | 216 outputs = [ |
213 "$object_subdir/{{source_name_part}}.o", | 217 "$object_subdir/{{source_name_part}}.o", |
214 ] | 218 ] |
215 } | 219 } |
216 | 220 |
217 tool("alink") { | 221 tool("alink") { |
218 rspfile = "{{output}}.rsp" | 222 rspfile = "{{output}}.rsp" |
219 arflags = "" | |
220 if ((allow_posix_link_time_opt || is_cfi) && | |
221 invoker.toolchain_os != "nacl") { | |
222 gold_plugin_path = rebase_path( | |
223 "//third_party/llvm-build/Release+Asserts/lib/LLVMgold.so", | |
224 root_build_dir) | |
225 arflags = "--plugin \"$gold_plugin_path\"" | |
226 } | |
227 | 223 |
228 # This needs a Python script to avoid using simple sh features in this | 224 # This needs a Python script to avoid using simple sh features in this |
229 # command, in case the host does not use a POSIX shell (e.g. compiling | 225 # command, in case the host does not use a POSIX shell (e.g. compiling |
230 # POSIX-like toolchains such as NaCl on Windows). | 226 # POSIX-like toolchains such as NaCl on Windows). |
231 ar_wrapper = | 227 ar_wrapper = |
232 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) | 228 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
233 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" $
arflags rcsD @\"$rspfile\"" | 229 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" {
{arflags}} rcsD @\"$rspfile\"" |
234 description = "AR {{output}}" | 230 description = "AR {{output}}" |
235 rspfile_content = "{{inputs}}" | 231 rspfile_content = "{{inputs}}" |
236 outputs = [ | 232 outputs = [ |
237 "{{output_dir}}/{{target_output_name}}{{output_extension}}", | 233 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
238 ] | 234 ] |
239 | 235 |
240 # Shared libraries go in the target out directory by default so we can | 236 # Shared libraries go in the target out directory by default so we can |
241 # generate different targets with the same name and not have them collide. | 237 # generate different targets with the same name and not have them collide. |
242 default_output_dir = "{{target_out_dir}}" | 238 default_output_dir = "{{target_out_dir}}" |
243 default_output_extension = ".a" | 239 default_output_extension = ".a" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 468 |
473 forward_variables_from(invoker, | 469 forward_variables_from(invoker, |
474 [ | 470 [ |
475 "toolchain_cpu", | 471 "toolchain_cpu", |
476 "toolchain_os", | 472 "toolchain_os", |
477 "use_gold", | 473 "use_gold", |
478 "strip", | 474 "strip", |
479 ]) | 475 ]) |
480 } | 476 } |
481 } | 477 } |
OLD | NEW |