Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 2272713004: Reland of Enable whitelist generation for official builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/gcc_solink_wrapper.py ('k') | build/toolchain/wrapper_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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("//tools/grit/grit_rule.gni")
12 13
13 # This template defines a toolchain for something that works like gcc 14 # This template defines a toolchain for something that works like gcc
14 # (including clang). 15 # (including clang).
15 # 16 #
16 # It requires the following variables specifying the executables to run: 17 # It requires the following variables specifying the executables to run:
17 # - ar 18 # - ar
18 # - cc 19 # - cc
19 # - cxx 20 # - cxx
20 # - ld 21 # - ld
21 # 22 #
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 214 }
214 215
215 # These library switches can apply to all tools below. 216 # These library switches can apply to all tools below.
216 lib_switch = "-l" 217 lib_switch = "-l"
217 lib_dir_switch = "-L" 218 lib_dir_switch = "-L"
218 219
219 # Object files go in this directory. 220 # Object files go in this directory.
220 object_subdir = "{{target_out_dir}}/{{label_name}}" 221 object_subdir = "{{target_out_dir}}/{{label_name}}"
221 222
222 tool("cc") { 223 tool("cc") {
224 whitelist_flag = " "
225 if (enable_resource_whitelist_generation) {
226 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
227 }
223 depfile = "{{output}}.d" 228 depfile = "{{output}}.d"
224 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" 229 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}"
225 depsformat = "gcc" 230 depsformat = "gcc"
226 description = "CC {{output}}" 231 description = "CC {{output}}"
227 outputs = [ 232 outputs = [
233 # The whitelist file is also an output, but ninja does not
234 # currently support multiple outputs for tool("cc").
228 "$object_subdir/{{source_name_part}}.o", 235 "$object_subdir/{{source_name_part}}.o",
229 ] 236 ]
237 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
238 root_build_dir)
239 command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
230 } 240 }
231 241
232 tool("cxx") { 242 tool("cxx") {
243 whitelist_flag = " "
244 if (enable_resource_whitelist_generation) {
245 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
246 }
233 depfile = "{{output}}.d" 247 depfile = "{{output}}.d"
234 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" 248 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}"
235 depsformat = "gcc" 249 depsformat = "gcc"
236 description = "CXX {{output}}" 250 description = "CXX {{output}}"
237 outputs = [ 251 outputs = [
252 # The whitelist file is also an output, but ninja does not
253 # currently support multiple outputs for tool("cxx").
238 "$object_subdir/{{source_name_part}}.o", 254 "$object_subdir/{{source_name_part}}.o",
239 ] 255 ]
256 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
257 root_build_dir)
258 command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
240 } 259 }
241 260
242 tool("asm") { 261 tool("asm") {
243 # For GCC we can just use the C compiler to compile assembly. 262 # For GCC we can just use the C compiler to compile assembly.
244 depfile = "{{output}}.d" 263 depfile = "{{output}}.d"
245 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" 264 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}"
246 depsformat = "gcc" 265 depsformat = "gcc"
247 description = "ASM {{output}}" 266 description = "ASM {{output}}"
248 outputs = [ 267 outputs = [
249 "$object_subdir/{{source_name_part}}.o", 268 "$object_subdir/{{source_name_part}}.o",
250 ] 269 ]
251 } 270 }
252 271
253 tool("alink") { 272 tool("alink") {
254 rspfile = "{{output}}.rsp" 273 rspfile = "{{output}}.rsp"
274 whitelist_flag = " "
275 if (enable_resource_whitelist_generation) {
276 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
277 }
255 278
256 # This needs a Python script to avoid using simple sh features in this 279 # This needs a Python script to avoid using simple sh features in this
257 # command, in case the host does not use a POSIX shell (e.g. compiling 280 # command, in case the host does not use a POSIX shell (e.g. compiling
258 # POSIX-like toolchains such as NaCl on Windows). 281 # POSIX-like toolchains such as NaCl on Windows).
259 ar_wrapper = 282 ar_wrapper =
260 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) 283 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir)
261 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" { {arflags}} rcsD @\"$rspfile\"" 284 command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\""
262 description = "AR {{output}}" 285 description = "AR {{output}}"
263 rspfile_content = "{{inputs}}" 286 rspfile_content = "{{inputs}}"
264 outputs = [ 287 outputs = [
265 "{{output_dir}}/{{target_output_name}}{{output_extension}}", 288 "{{output_dir}}/{{target_output_name}}{{output_extension}}",
266 ] 289 ]
267 290
268 # Shared libraries go in the target out directory by default so we can 291 # Shared libraries go in the target out directory by default so we can
269 # generate different targets with the same name and not have them collide. 292 # generate different targets with the same name and not have them collide.
270 default_output_dir = "{{target_out_dir}}" 293 default_output_dir = "{{target_out_dir}}"
271 default_output_extension = ".a" 294 default_output_extension = ".a"
272 output_prefix = "lib" 295 output_prefix = "lib"
273 } 296 }
274 297
275 tool("solink") { 298 tool("solink") {
276 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 299 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
277 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. 300 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
278 rspfile = sofile + ".rsp" 301 rspfile = sofile + ".rsp"
279 pool = "//build/toolchain:link_pool($default_toolchain)" 302 pool = "//build/toolchain:link_pool($default_toolchain)"
303 whitelist_flag = " "
304 if (enable_resource_whitelist_generation) {
305 whitelist_file = "$sofile.whitelist"
306 whitelist_flag = " --resource-whitelist=\"$whitelist_file\""
307 }
280 308
281 if (defined(invoker.strip)) { 309 if (defined(invoker.strip)) {
282 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" 310 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
283 } else { 311 } else {
284 unstripped_sofile = sofile 312 unstripped_sofile = sofile
285 } 313 }
286 314
287 # These variables are not built into GN but are helpers that 315 # These variables are not built into GN but are helpers that
288 # implement (1) linking to produce a .so, (2) extracting the symbols 316 # implement (1) linking to produce a .so, (2) extracting the symbols
289 # from that file (3) if the extracted list differs from the existing 317 # from that file (3) if the extracted list differs from the existing
290 # .TOC file, overwrite it, otherwise, don't change it. 318 # .TOC file, overwrite it, otherwise, don't change it.
291 tocfile = sofile + ".TOC" 319 tocfile = sofile + ".TOC"
292 320
293 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" 321 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
294 322
295 assert(defined(readelf), "to solink you must have a readelf") 323 assert(defined(readelf), "to solink you must have a readelf")
296 assert(defined(nm), "to solink you must have an nm") 324 assert(defined(nm), "to solink you must have an nm")
297 strip_switch = "" 325 strip_switch = ""
298 if (defined(invoker.strip)) { 326 if (defined(invoker.strip)) {
299 strip_switch = "--strip=${invoker.strip}" 327 strip_switch = "--strip=${invoker.strip}"
300 } 328 }
301 329
302 # This needs a Python script to avoid using a complex shell command 330 # This needs a Python script to avoid using a complex shell command
303 # requiring sh control structures, pipelines, and POSIX utilities. 331 # requiring sh control structures, pipelines, and POSIX utilities.
304 # The host might not have a POSIX shell and utilities (e.g. Windows). 332 # The host might not have a POSIX shell and utilities (e.g. Windows).
305 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") 333 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py")
306 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" -- $link_command" 334 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\"$whitelist_flag -- $link_command"
307 335
308 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" 336 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
309 337
310 description = "SOLINK $sofile" 338 description = "SOLINK $sofile"
311 339
312 # Use this for {{output_extension}} expansions unless a target manually 340 # Use this for {{output_extension}} expansions unless a target manually
313 # 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
314 # specifies). 342 # specifies).
315 default_output_extension = default_shlib_extension 343 default_output_extension = default_shlib_extension
316 344
317 default_output_dir = "{{root_out_dir}}" 345 default_output_dir = "{{root_out_dir}}"
318 if (shlib_subdir != ".") { 346 if (shlib_subdir != ".") {
319 default_output_dir += "/$shlib_subdir" 347 default_output_dir += "/$shlib_subdir"
320 } 348 }
321 349
322 output_prefix = "lib" 350 output_prefix = "lib"
323 351
324 # Since the above commands only updates the .TOC file when it changes, ask 352 # Since the above commands only updates the .TOC file when it changes, ask
325 # Ninja to check if the timestamp actually changed to know if downstream 353 # Ninja to check if the timestamp actually changed to know if downstream
326 # dependencies should be recompiled. 354 # dependencies should be recompiled.
327 restat = true 355 restat = true
328 356
329 # Tell GN about the output files. It will link to the sofile but use the 357 # Tell GN about the output files. It will link to the sofile but use the
330 # tocfile for dependency management. 358 # tocfile for dependency management.
331 outputs = [ 359 outputs = [
332 sofile, 360 sofile,
333 tocfile, 361 tocfile,
334 ] 362 ]
363 if (enable_resource_whitelist_generation) {
364 outputs += [ whitelist_file ]
365 }
335 if (sofile != unstripped_sofile) { 366 if (sofile != unstripped_sofile) {
336 outputs += [ unstripped_sofile ] 367 outputs += [ unstripped_sofile ]
337 } 368 }
338 link_output = sofile 369 link_output = sofile
339 depend_output = tocfile 370 depend_output = tocfile
340 } 371 }
341 372
342 tool("solink_module") { 373 tool("solink_module") {
343 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 374 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
344 sofile = "{{output_dir}}/$soname" 375 sofile = "{{output_dir}}/$soname"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 forward_variables_from(invoker, [ "strip" ]) 496 forward_variables_from(invoker, [ "strip" ])
466 497
467 toolchain_args = { 498 toolchain_args = {
468 if (defined(invoker.toolchain_args)) { 499 if (defined(invoker.toolchain_args)) {
469 forward_variables_from(invoker.toolchain_args, "*") 500 forward_variables_from(invoker.toolchain_args, "*")
470 } 501 }
471 is_clang = true 502 is_clang = true
472 } 503 }
473 } 504 }
474 } 505 }
OLDNEW
« no previous file with comments | « build/toolchain/gcc_solink_wrapper.py ('k') | build/toolchain/wrapper_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698