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 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 # - ar | 27 # - ar |
28 # - ld | 28 # - ld |
29 # and the following which is used in the toolchain_args | 29 # and the following which is used in the toolchain_args |
30 # - toolchain_cpu (What "current_cpu" should be set to when invoking a | 30 # - toolchain_cpu (What "current_cpu" should be set to when invoking a |
31 # build using this toolchain.) | 31 # build using this toolchain.) |
32 # - toolchain_os (What "current_os" should be set to when invoking a | 32 # - toolchain_os (What "current_os" should be set to when invoking a |
33 # build using this toolchain.) | 33 # build using this toolchain.) |
34 # | 34 # |
35 # Optional parameters that control the tools: | 35 # Optional parameters that control the tools: |
36 # | 36 # |
37 # - extra_cflags | |
38 # Extra flags to be appended when compiling C files | |
39 # - extra_cppflags | |
hashimoto
2016/05/17 06:26:31
nit: It'd be nice to make it clear the difference
Dirk Pranke
2016/05/17 21:37:45
Will add comments.
| |
40 # Extra flags to be appended when compiling C or C++ files | |
41 # - extra_cxxflags | |
42 # Extra flags to be appended when compiling C or C++ files | |
hashimoto
2016/05/17 06:26:31
nit: Not when compiling C?
Dirk Pranke
2016/05/17 21:37:45
Whoops. Will fix.
| |
43 # - extra_ldflags | |
44 # Extra flags to be appended when linking | |
45 # | |
37 # - libs_section_prefix | 46 # - libs_section_prefix |
38 # - libs_section_postfix | 47 # - libs_section_postfix |
39 # The contents of these strings, if specified, will be placed around | 48 # The contents of these strings, if specified, will be placed around |
40 # the libs section of the linker line. It allows one to inject libraries | 49 # the libs section of the linker line. It allows one to inject libraries |
41 # at the beginning and end for all targets in a toolchain. | 50 # at the beginning and end for all targets in a toolchain. |
42 # - solink_libs_section_prefix | 51 # - solink_libs_section_prefix |
43 # - solink_libs_section_postfix | 52 # - solink_libs_section_postfix |
44 # Same as libs_section_{pre,post}fix except used for solink instead of link . | 53 # Same as libs_section_{pre,post}fix except used for solink instead of link . |
45 # - link_outputs | 54 # - link_outputs |
46 # The content of this array, if specified, will be added to the list of | 55 # The content of this array, if specified, will be added to the list of |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 } else { | 182 } else { |
174 solink_libs_section_prefix = "" | 183 solink_libs_section_prefix = "" |
175 } | 184 } |
176 | 185 |
177 if (defined(invoker.solink_libs_section_postfix)) { | 186 if (defined(invoker.solink_libs_section_postfix)) { |
178 solink_libs_section_postfix = invoker.solink_libs_section_postfix | 187 solink_libs_section_postfix = invoker.solink_libs_section_postfix |
179 } else { | 188 } else { |
180 solink_libs_section_postfix = "" | 189 solink_libs_section_postfix = "" |
181 } | 190 } |
182 | 191 |
192 if (defined(invoker.extra_cflags) && invoker.extra_cflags != "") { | |
193 extra_cflags = " " + invoker.extra_cflags | |
194 } else { | |
195 extra_cflags = "" | |
196 } | |
197 | |
198 if (defined(invoker.extra_cppflags) && invoker.extra_cppflags != "") { | |
199 extra_cppflags = " " + invoker.extra_cppflags | |
200 } else { | |
201 extra_cppflags = "" | |
202 } | |
203 | |
204 if (defined(invoker.extra_cxxflags) && invoker.extra_cxxflags != "") { | |
205 extra_cxxflags = " " + invoker.extra_cxxflags | |
206 } else { | |
207 extra_cxxflags = "" | |
208 } | |
209 | |
210 if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") { | |
211 extra_ldflags = " " + invoker.extra_ldflags | |
212 } else { | |
213 extra_ldflags = "" | |
214 } | |
215 | |
183 # These library switches can apply to all tools below. | 216 # These library switches can apply to all tools below. |
184 lib_switch = "-l" | 217 lib_switch = "-l" |
185 lib_dir_switch = "-L" | 218 lib_dir_switch = "-L" |
186 | 219 |
187 # Object files go in this directory. | 220 # Object files go in this directory. |
188 object_subdir = "{{target_out_dir}}/{{label_name}}" | 221 object_subdir = "{{target_out_dir}}/{{label_name}}" |
189 | 222 |
190 tool("cc") { | 223 tool("cc") { |
191 depfile = "{{output}}.d" | 224 depfile = "{{output}}.d" |
192 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" | 225 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" |
193 depsformat = "gcc" | 226 depsformat = "gcc" |
194 description = "CC {{output}}" | 227 description = "CC {{output}}" |
195 outputs = [ | 228 outputs = [ |
196 "$object_subdir/{{source_name_part}}.o", | 229 "$object_subdir/{{source_name_part}}.o", |
197 ] | 230 ] |
198 } | 231 } |
199 | 232 |
200 tool("cxx") { | 233 tool("cxx") { |
201 depfile = "{{output}}.d" | 234 depfile = "{{output}}.d" |
202 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" | 235 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" |
203 depsformat = "gcc" | 236 depsformat = "gcc" |
204 description = "CXX {{output}}" | 237 description = "CXX {{output}}" |
205 outputs = [ | 238 outputs = [ |
206 "$object_subdir/{{source_name_part}}.o", | 239 "$object_subdir/{{source_name_part}}.o", |
207 ] | 240 ] |
208 } | 241 } |
209 | 242 |
210 tool("asm") { | 243 tool("asm") { |
211 # For GCC we can just use the C compiler to compile assembly. | 244 # For GCC we can just use the C compiler to compile assembly. |
212 depfile = "{{output}}.d" | 245 depfile = "{{output}}.d" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 } else { | 283 } else { |
251 unstripped_sofile = sofile | 284 unstripped_sofile = sofile |
252 } | 285 } |
253 | 286 |
254 # These variables are not built into GN but are helpers that | 287 # These variables are not built into GN but are helpers that |
255 # implement (1) linking to produce a .so, (2) extracting the symbols | 288 # implement (1) linking to produce a .so, (2) extracting the symbols |
256 # from that file (3) if the extracted list differs from the existing | 289 # from that file (3) if the extracted list differs from the existing |
257 # .TOC file, overwrite it, otherwise, don't change it. | 290 # .TOC file, overwrite it, otherwise, don't change it. |
258 tocfile = sofile + ".TOC" | 291 tocfile = sofile + ".TOC" |
259 | 292 |
260 link_command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-son ame=\"$soname\" @\"$rspfile\"" | 293 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
261 | 294 |
262 assert(defined(readelf), "to solink you must have a readelf") | 295 assert(defined(readelf), "to solink you must have a readelf") |
263 assert(defined(nm), "to solink you must have an nm") | 296 assert(defined(nm), "to solink you must have an nm") |
264 strip_switch = "" | 297 strip_switch = "" |
265 if (defined(invoker.strip)) { | 298 if (defined(invoker.strip)) { |
266 strip_switch = "--strip=${invoker.strip}" | 299 strip_switch = "--strip=${invoker.strip}" |
267 } | 300 } |
268 | 301 |
269 # This needs a Python script to avoid using a complex shell command | 302 # This needs a Python script to avoid using a complex shell command |
270 # requiring sh control structures, pipelines, and POSIX utilities. | 303 # requiring sh control structures, pipelines, and POSIX utilities. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 343 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
311 sofile = "{{output_dir}}/$soname" | 344 sofile = "{{output_dir}}/$soname" |
312 rspfile = sofile + ".rsp" | 345 rspfile = sofile + ".rsp" |
313 | 346 |
314 if (defined(invoker.strip)) { | 347 if (defined(invoker.strip)) { |
315 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 348 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
316 } else { | 349 } else { |
317 unstripped_sofile = sofile | 350 unstripped_sofile = sofile |
318 } | 351 } |
319 | 352 |
320 command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\ "$soname\" @\"$rspfile\"" | 353 command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile \" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
321 | 354 |
322 if (defined(invoker.strip)) { | 355 if (defined(invoker.strip)) { |
323 strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$uns tripped_sofile\"" | 356 strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$uns tripped_sofile\"" |
324 command += " && " + strip_command | 357 command += " && " + strip_command |
325 } | 358 } |
326 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 359 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
327 | 360 |
328 description = "SOLINK_MODULE $sofile" | 361 description = "SOLINK_MODULE $sofile" |
329 | 362 |
330 # Use this for {{output_extension}} expansions unless a target manually | 363 # Use this for {{output_extension}} expansions unless a target manually |
(...skipping 30 matching lines...) Expand all Loading... | |
361 # overrides it (in which case {{output_extension}} will be what the target | 394 # overrides it (in which case {{output_extension}} will be what the target |
362 # specifies). | 395 # specifies). |
363 default_output_extension = default_executable_extension | 396 default_output_extension = default_executable_extension |
364 | 397 |
365 default_output_dir = "{{root_out_dir}}" | 398 default_output_dir = "{{root_out_dir}}" |
366 | 399 |
367 if (defined(invoker.strip)) { | 400 if (defined(invoker.strip)) { |
368 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" | 401 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" |
369 } | 402 } |
370 | 403 |
371 command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--start-group @\ "$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_secti on_postfix" | 404 command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl, --start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{li bs}} $libs_section_postfix" |
372 if (defined(invoker.strip)) { | 405 if (defined(invoker.strip)) { |
373 link_wrapper = | 406 link_wrapper = |
374 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) | 407 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) |
375 command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" - -unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command" | 408 command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" - -unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command" |
376 } | 409 } |
377 description = "LINK $outfile" | 410 description = "LINK $outfile" |
378 rspfile_content = "{{inputs}}" | 411 rspfile_content = "{{inputs}}" |
379 outputs = [ | 412 outputs = [ |
380 outfile, | 413 outfile, |
381 ] | 414 ] |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 } | 454 } |
422 if (defined(invoker.symbol_level)) { | 455 if (defined(invoker.symbol_level)) { |
423 symbol_level = invoker.symbol_level | 456 symbol_level = invoker.symbol_level |
424 } | 457 } |
425 if (defined(invoker.use_allocator)) { | 458 if (defined(invoker.use_allocator)) { |
426 use_allocator = invoker.use_allocator | 459 use_allocator = invoker.use_allocator |
427 } | 460 } |
428 if (defined(invoker.use_gold)) { | 461 if (defined(invoker.use_gold)) { |
429 use_gold = invoker.use_gold | 462 use_gold = invoker.use_gold |
430 } | 463 } |
464 if (defined(invoker.use_sysroot)) { | |
465 use_sysroot = invoker.use_sysroot | |
hashimoto
2016/05/17 06:26:31
Sorry, I'm not familiar enough with GN to understa
Dirk Pranke
2016/05/17 21:37:45
Yes, exactly.
See https://chromium.googlesource.
| |
466 } | |
431 | 467 |
432 if (defined(invoker.clear_sanitizers) && invoker.clear_sanitizers) { | 468 if (defined(invoker.clear_sanitizers) && invoker.clear_sanitizers) { |
433 is_asan = false | 469 is_asan = false |
434 is_cfi = false | 470 is_cfi = false |
435 is_lsan = false | 471 is_lsan = false |
436 is_msan = false | 472 is_msan = false |
437 is_syzyasan = false | 473 is_syzyasan = false |
438 is_tsan = false | 474 is_tsan = false |
439 is_ubsan = false | 475 is_ubsan = false |
440 is_ubsan_vptr = false | 476 is_ubsan_vptr = false |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 | 513 |
478 forward_variables_from(invoker, | 514 forward_variables_from(invoker, |
479 [ | 515 [ |
480 "toolchain_cpu", | 516 "toolchain_cpu", |
481 "toolchain_os", | 517 "toolchain_os", |
482 "use_gold", | 518 "use_gold", |
483 "strip", | 519 "strip", |
484 ]) | 520 ]) |
485 } | 521 } |
486 } | 522 } |
OLD | NEW |