diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-12-05 15:04:29 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-09 10:49:28 +0100 |
commit | af6588f8d723931a298c995fa97259bb7f7deb55 (patch) | |
tree | 060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/build/toolchain | |
parent | 2fff84d821cc7b1c785f6404e0f8091333283e74 (diff) | |
download | qtwebengine-chromium-af6588f8d723931a298c995fa97259bb7f7deb55.tar.gz |
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/build/toolchain')
-rw-r--r-- | chromium/build/toolchain/android/BUILD.gn | 37 | ||||
-rw-r--r-- | chromium/build/toolchain/android/find_android_compiler.py | 41 | ||||
-rw-r--r-- | chromium/build/toolchain/cros/BUILD.gn | 35 | ||||
-rw-r--r-- | chromium/build/toolchain/gcc_toolchain.gni | 170 | ||||
-rw-r--r-- | chromium/build/toolchain/get_concurrent_links.py | 64 | ||||
-rw-r--r-- | chromium/build/toolchain/goma.gni | 9 | ||||
-rw-r--r-- | chromium/build/toolchain/linux/BUILD.gn | 81 | ||||
-rw-r--r-- | chromium/build/toolchain/mac/BUILD.gn | 160 | ||||
-rw-r--r-- | chromium/build/toolchain/nacl/BUILD.gn | 4 | ||||
-rw-r--r-- | chromium/build/toolchain/win/BUILD.gn | 276 | ||||
-rw-r--r-- | chromium/build/toolchain/win/midl.gni | 8 |
11 files changed, 596 insertions, 289 deletions
diff --git a/chromium/build/toolchain/android/BUILD.gn b/chromium/build/toolchain/android/BUILD.gn index dc3bfeddab7..9ae22183407 100644 --- a/chromium/build/toolchain/android/BUILD.gn +++ b/chromium/build/toolchain/android/BUILD.gn @@ -29,16 +29,49 @@ template("android_gcc_toolchain") { libs_section_prefix = "$android_ndk_lib/crtbegin_dynamic.o" libs_section_postfix = "$android_ndk_lib/crtend_android.o" + solink_libs_section_prefix = "$android_ndk_lib/crtbegin_so.o" + solink_libs_section_postfix = "$android_ndk_lib/crtend_so.o" + # The tools should be run relative to the build dir. tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) - cc = tool_prefix + "gcc" - cxx = tool_prefix + "g++" + if (use_goma) { + goma_prefix = "$goma_dir/gomacc " + } else { + goma_prefix = "" + } + + cc = goma_prefix + tool_prefix + "gcc" + cxx = goma_prefix + tool_prefix + "g++" ar = tool_prefix + "ar" ld = cxx toolchain_os = "android" toolchain_cpu_arch = invoker.toolchain_cpu_arch + + # We make the assumption that the gcc_toolchain will produce a soname with + # the following definition. + soname = "{{target_output_name}}{{output_extension}}" + + stripped_soname = "lib.stripped/${soname}" + temp_stripped_soname = "${stripped_soname}.tmp" + + android_strip = "${tool_prefix}strip" + + mkdir_command = "mkdir -p lib.stripped" + strip_command = "$android_strip --strip-unneeded -o $temp_stripped_soname $soname" + replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_stripped_soname $stripped_soname; fi" + postsolink = "$mkdir_command && $strip_command && $replace_command" + solink_outputs = [ stripped_soname ] + + # We make the assumption that the gcc_toolchain will produce an exe with + # the following definition. + exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" + stripped_exe = "exe.stripped/$exe" + mkdir_command = "mkdir -p exe.stripped" + strip_command = "$android_strip --strip-unneeded -o $stripped_exe $exe" + postlink = "$mkdir_command && $strip_command" + link_outputs = [ stripped_exe ] } } diff --git a/chromium/build/toolchain/android/find_android_compiler.py b/chromium/build/toolchain/android/find_android_compiler.py deleted file mode 100644 index d806ead80d5..00000000000 --- a/chromium/build/toolchain/android/find_android_compiler.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# This script locates the Android compilers given the bin directory of the -# android toolchain. - -import glob -import subprocess -import sys - -if len(sys.argv) != 2: - print "Error: expecting one argument of the android toolchain dir." - sys.exit(1) - -# TODO(brettw) this logic seems like a bad idea. It was copied from -# common.gypi. It seems like the toolchain should just know the name given the -# current platform rather than having to rely on glob. -android_toolchain = sys.argv[1] -cc = glob.glob(android_toolchain + "/*-gcc") -cxx = glob.glob(android_toolchain + "/*-g++") - -# We tolerate "no matches." In the Android AOSP WebView build, it runs this -# logic and the directory doesn't exist, giving no matches. But that build runs -# GYP to generate Android Makefiles which specify the compiler separately. So -# all we need to do in this case is ignore the error and continue with empty -# target compilers. -if len(cc) == 0: - cc = [""] -if len(cxx) == 0: - cxx = [""] -if len(cc) != 1 or len(cxx) != 1: - print "More than one matching compiler." - sys.exit(1) - -# Get the host compilers from the current path. -which_gcc = subprocess.check_output(["which gcc"], shell=True).strip() -which_gxx = subprocess.check_output(["which g++"], shell=True).strip() - -print ('["' + cc[0] + '","' + cxx[0] + '","' + which_gcc + '","' + - which_gxx + '"]') diff --git a/chromium/build/toolchain/cros/BUILD.gn b/chromium/build/toolchain/cros/BUILD.gn new file mode 100644 index 00000000000..d360f72572e --- /dev/null +++ b/chromium/build/toolchain/cros/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/toolchain/clang.gni") +import("//build/toolchain/gcc_toolchain.gni") + +declare_args() { + # The CrOS build system supports many different kinds of targets across + # many different architectures. Bringing your own toolchain is also supported, + # so it's actually impossible to enumerate all toolchains for all targets + # as GN toolchain specifications. + # These arguments provide a mechanism for specifying your CC, CXX and AR at + # buildfile-generation time, allowing the CrOS build system to always use + # the right tools for the current target. + cros_target_cc = "" + cros_target_cxx = "" + cros_target_ar = "" +} + +gcc_toolchain("target") { + assert(cros_target_cc != "", "Must provide target CC.") + assert(cros_target_cxx != "", "Must provide target CXX.") + assert(cros_target_ar != "", "Must provide target AR.") + + cc = "${cros_target_cc}" + cxx = "${cros_target_cxx}" + + ar = "${cros_target_ar}" + ld = cxx + + toolchain_cpu_arch = "${cpu_arch}" + toolchain_os = "linux" + is_clang = is_clang +} diff --git a/chromium/build/toolchain/gcc_toolchain.gni b/chromium/build/toolchain/gcc_toolchain.gni index bc5288300fa..e415459eb09 100644 --- a/chromium/build/toolchain/gcc_toolchain.gni +++ b/chromium/build/toolchain/gcc_toolchain.gni @@ -2,7 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# This template defines a GCC toolchain. +# This value will be inherited in the toolchain below. +concurrent_links = exec_script("get_concurrent_links.py", [], "value") + +# This template defines a toolchain for something that works like gcc +# (including clang). # # It requires the following variables specifying the executables to run: # - cc @@ -21,6 +25,15 @@ # The contents of these strings, if specified, will be placed around # the libs section of the linker line. It allows one to inject libraries # at the beginning and end for all targets in a toolchain. +# - solink_libs_section_prefix +# - solink_libs_section_postfix +# Same as libs_section_{pre,post}fix except used for solink instead of link. +# - post_solink +# The content of this string, if specified, will be appended to the solink +# command. +# - deps +# Just forwarded to the toolchain definition. +# - is_clang template("gcc_toolchain") { toolchain(target_name) { assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") @@ -53,52 +66,136 @@ template("gcc_toolchain") { libs_section_postfix = "" } - # Make these apply to all tools below. - lib_prefix = "-l" - lib_dir_prefix="-L" + if (defined(invoker.solink_libs_section_prefix)) { + solink_libs_section_prefix = invoker.solink_libs_section_prefix + } else { + solink_libs_section_prefix = "" + } + + if (defined(invoker.solink_libs_section_postfix)) { + solink_libs_section_postfix = invoker.solink_libs_section_postfix + } else { + solink_libs_section_postfix = "" + } + + # These library switches can apply to all tools below. + lib_switch = "-l" + lib_dir_switch = "-L" tool("cc") { - # cflags_pch_c - command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" - description = "CC \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CC {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("cxx") { - # cflags_pch_cc - command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" - description = "CXX \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CXX {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] + } + + tool("asm") { + # For GCC we can just use the C compiler to compile assembly. + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "ASM {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("alink") { - command = "rm -f \$out && $ar rcs \$out @\$rspfile" - description = "AR \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in" + rspfile = "{{output}}.rsp" + command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" + description = "AR {{output}}" + rspfile_content = "{{inputs}}" + outputs = [ + "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" + ] + default_output_extension = ".a" + output_prefix = "lib" } + tool("solink") { - command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname @\$rspfile && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive $libs_section_prefix \$libs $libs_section_postfix && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" - description = "SOLINK \$lib" - rspfile = "\$out.rsp" - rspfile_content = "-Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs" - #pool = "link_pool" - restat = "1" + soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". + sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. + rspfile = sofile + ".rsp" + + # These variables are not built into GN but are helpers that implement + # (1) linking to produce a .so, (2) extracting the symbols from that file + # to a temporary file, (3) if the temporary file has differences from the + # existing .TOC file, overwrite it, otherwise, don't change it. + tocfile = sofile + ".TOC" + temporary_tocname = sofile + ".tmp" + link_command = "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" + toc_command = "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname | cut -f1-2 -d' '; } > $temporary_tocname" + replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi" + + command = "$link_command && $toc_command && $replace_command" + if (defined(invoker.postsolink)) { + command += " && " + invoker.postsolink + } + rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" + + description = "SOLINK $sofile" + + # Use this for {{output_extension}} expansions unless a target manually + # overrides it (in which case {{output_extension}} will be what the target + # specifies). + default_output_extension = ".so" + + output_prefix = "lib" + + # Since the above commands only updates the .TOC file when it changes, ask + # Ninja to check if the timestamp actually changed to know if downstream + # dependencies should be recompiled. + restat = true + + # Tell GN about the output files. It will link to the sofile but use the + # tocfile for dependency management. + outputs = [ + sofile, + tocfile, + ] + if (defined(invoker.solink_outputs)) { + outputs += invoker.solink_outputs + } + link_output = sofile + depend_output = tocfile } + tool("link") { - command = "$ld \$ldflags -o \$out -Wl,--start-group @\$rspfile \$solibs -Wl,--end-group $libs_section_prefix \$libs $libs_section_postfix" - description = "LINK \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in" - #pool = "link_pool" + outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" + rspfile = "$outfile.rsp" + command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" + if (defined(invoker.postlink)) { + command += " && " + invoker.postlink + } + description = "LINK $outfile" + rspfile_content = "{{inputs}}" + outputs = [ outfile ] + if (defined(invoker.link_outputs)) { + outputs += invoker.link_outputs + } } + tool("stamp") { - command = "\${postbuilds}touch \$out" - description = "STAMP \$out" + command = "touch {{output}}" + description = "STAMP {{output}}" } + tool("copy") { - command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)" - description = "COPY \$in \$out" + command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" + description = "COPY {{source}} {{output}}" } # When invoking this toolchain not as the default one, these args will be @@ -106,6 +203,13 @@ template("gcc_toolchain") { toolchain_args() { cpu_arch = invoker.toolchain_cpu_arch os = invoker.toolchain_os + if (defined(invoker.is_clang)) { + is_clang = invoker.is_clang + } + } + + if (defined(invoker.deps)) { + deps = invoker.deps } } } diff --git a/chromium/build/toolchain/get_concurrent_links.py b/chromium/build/toolchain/get_concurrent_links.py new file mode 100644 index 00000000000..629d67d5030 --- /dev/null +++ b/chromium/build/toolchain/get_concurrent_links.py @@ -0,0 +1,64 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script computs the number of concurrent links we want to run in the build +# as a function of machine spec. It's based on GetDefaultConcurrentLinks in GYP. + +import os +import re +import sys + +def GetDefaultConcurrentLinks(): + # Inherit the legacy environment variable for people that have set it in GYP. + pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) + if pool_size: + return pool_size + + if sys.platform in ('win32', 'cygwin'): + import ctypes + + class MEMORYSTATUSEX(ctypes.Structure): + _fields_ = [ + ("dwLength", ctypes.c_ulong), + ("dwMemoryLoad", ctypes.c_ulong), + ("ullTotalPhys", ctypes.c_ulonglong), + ("ullAvailPhys", ctypes.c_ulonglong), + ("ullTotalPageFile", ctypes.c_ulonglong), + ("ullAvailPageFile", ctypes.c_ulonglong), + ("ullTotalVirtual", ctypes.c_ulonglong), + ("ullAvailVirtual", ctypes.c_ulonglong), + ("sullAvailExtendedVirtual", ctypes.c_ulonglong), + ] + + stat = MEMORYSTATUSEX() + stat.dwLength = ctypes.sizeof(stat) + ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) + + mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB + hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) + return min(mem_limit, hard_cap) + elif sys.platform.startswith('linux'): + if os.path.exists("/proc/meminfo"): + with open("/proc/meminfo") as meminfo: + memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') + for line in meminfo: + match = memtotal_re.match(line) + if not match: + continue + # Allow 8Gb per link on Linux because Gold is quite memory hungry + return max(1, int(match.group(1)) / (8 * (2 ** 20))) + return 1 + elif sys.platform == 'darwin': + try: + avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) + # A static library debug build of Chromium's unit_tests takes ~2.7GB, so + # 4GB per ld process allows for some more bloat. + return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB + except: + return 1 + else: + # TODO(scottmg): Implement this for other platforms. + return 1 + +print GetDefaultConcurrentLinks() diff --git a/chromium/build/toolchain/goma.gni b/chromium/build/toolchain/goma.gni index 1f34723ad42..c0f4cf28252 100644 --- a/chromium/build/toolchain/goma.gni +++ b/chromium/build/toolchain/goma.gni @@ -20,12 +20,3 @@ declare_args() { goma_dir = getenv("HOME") + "/goma" } } - -if (use_goma) { - # Define the toolchain for the GYP build when using goma. - make_goma_global_settings = - "['CC_wrapper', '$goma_dir/gomacc']," + - "['CXX_wrapper', '$goma_dir/gomacc']," + - "['CC.host_wrapper', '$goma_dir/gomacc']," + - "['CXX.host_wrapper', '$goma_dir/gomacc']," -} diff --git a/chromium/build/toolchain/linux/BUILD.gn b/chromium/build/toolchain/linux/BUILD.gn index dd98cb4e0e3..a98ea53c95c 100644 --- a/chromium/build/toolchain/linux/BUILD.gn +++ b/chromium/build/toolchain/linux/BUILD.gn @@ -7,60 +7,84 @@ import("//build/toolchain/clang.gni") import("//build/toolchain/gcc_toolchain.gni") import("//build/toolchain/goma.gni") +if (use_goma) { + goma_prefix = "$goma_dir/gomacc " +} else { + goma_prefix = "" +} + gcc_toolchain("arm") { - cc = "arm-linux-gnueabi-gcc" - cxx = "arm-linux-gnueabi-g++" + cc = "${goma_prefix}arm-linux-gnueabi-gcc" + cxx = "${goma_prefix}arm-linux-gnueabi-g++" + ar = "arm-linux-gnueabi-ar" ld = cxx toolchain_cpu_arch = "arm" toolchain_os = "linux" + is_clang = false } -gcc_toolchain("x86") { - if (is_clang) { - if (use_clang_type_profiler) { - prefix = rebase_path("//third_party/llvm-allocated-type/Linux_ia32/bin", - root_build_dir) - } else { - prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", - root_build_dir) - } - cc = "$prefix/clang" - cxx = "$prefix/clang++" +gcc_toolchain("clang_x86") { + if (use_clang_type_profiler) { + prefix = rebase_path("//third_party/llvm-allocated-type/Linux_ia32/bin", + root_build_dir) } else { - cc = "gcc" - cxx = "g++" + prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", + root_build_dir) } + cc = "${goma_prefix}$prefix/clang" + cxx = "${goma_prefix}$prefix/clang++" ar = "ar" ld = cxx toolchain_cpu_arch = "x86" toolchain_os = "linux" + is_clang = true } -gcc_toolchain("x64") { - if (is_clang) { - if (use_clang_type_profiler) { - prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin", - root_build_dir) - } else { - prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", - root_build_dir) - } - cc = "$prefix/clang" - cxx = "$prefix/clang++" +gcc_toolchain("x86") { + cc = "${goma_prefix}gcc" + cxx = "$goma_prefix}g++" + + ar = "ar" + ld = cxx + + toolchain_cpu_arch = "x86" + toolchain_os = "linux" + is_clang = false +} + +gcc_toolchain("clang_x64") { + if (use_clang_type_profiler) { + prefix = rebase_path("//third_party/llvm-allocated-type/Linux_x64/bin", + root_build_dir) } else { - cc = "gcc" - cxx = "g++" + prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", + root_build_dir) } + cc = "${goma_prefix}$prefix/clang" + cxx = "${goma_prefix}$prefix/clang++" + + ar = "ar" + ld = cxx + + toolchain_cpu_arch = "x64" + toolchain_os = "linux" + is_clang = true +} + +gcc_toolchain("x64") { + cc = "${goma_prefix}gcc" + cxx = "${goma_prefix}g++" ar = "ar" ld = cxx toolchain_cpu_arch = "x64" toolchain_os = "linux" + is_clang = false } gcc_toolchain("mipsel") { @@ -71,4 +95,5 @@ gcc_toolchain("mipsel") { toolchain_cpu_arch = "mipsel" toolchain_os = "linux" + is_clang = false } diff --git a/chromium/build/toolchain/mac/BUILD.gn b/chromium/build/toolchain/mac/BUILD.gn index e95e540b384..b1cd36bef4a 100644 --- a/chromium/build/toolchain/mac/BUILD.gn +++ b/chromium/build/toolchain/mac/BUILD.gn @@ -29,7 +29,7 @@ ld = cxx # file of the win tool. gyp_mac_tool_source = rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", root_build_dir) -exec_script("setup_toolchain.py", [ gyp_mac_tool_source ], "value") +exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) # Shared toolchain definition. Invocations should set toolchain_os to set the # build args in this definition. @@ -52,71 +52,135 @@ template("mac_clang_toolchain") { ld = invoker.ld # Make these apply to all tools below. - lib_prefix = "-l" - lib_dir_prefix="-L" + lib_switch = "-l" + lib_dir_switch = "-L" tool("cc") { - command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_pch_c -c \$in -o \$out" - description = "CC \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CC {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("cxx") { - command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_pch_cc -c \$in -o \$out" - description = "CXX \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CXX {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] + } + + tool("asm") { + # For GCC we can just use the C compiler to compile assembly. + depfile = "{{output}}.d" + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "ASM {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("objc") { - command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_objc \$cflags_pch_objc -c \$in -o \$out" - description = "OBJC \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "OBJC {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("objcxx") { - command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_objcc \$cflags_pch_objcc -c \$in -o \$out" - description = "OBJCXX \$out" - depfile = "\$out.d" - deps = "gcc" + depfile = "{{output}}.d" + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "OBJCXX {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", + ] } + tool("alink") { - command = "rm -f \$out && ./gyp-mac-tool filter-libtool libtool \$libtool_flags -static -o \$out \$in \$postbuilds" - description = "LIBTOOL-STATIC \$out" + command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -static -o {{output}} {{inputs}}" + description = "LIBTOOL-STATIC {{output}}" + outputs = [ + "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" + ] + default_output_extension = ".a" + output_prefix = "lib" } + tool("solink") { - command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ] || otool -l \$lib | grep -q LC_REEXPORT_DYLIB ; then $ld -shared \$ldflags -o \$lib -Wl,-filelist,\$rspfile \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib \$in \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" - description = "SOLINK \$lib" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline" - #pool = "link_pool" - restat = "1" + dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.dylib" + rspfile = dylib + ".rsp" + + # These variables are not build into GN but are helpers that implement + # (1) linking to produce a .so, (2) extracting the symbols from that file + # to a temporary file, (3) if the temporary file has differences from the + # existing .TOC file, overwrite it, oterwise, don't change it. + # + # As a special case, if the library reexports symbols from other dynamic + # libraries, we always update the .TOC and skip the temporary file and + # diffing steps, since that library always needs to be re-linked. + tocname = dylib + ".TOC" + temporary_tocname = dylib + ".tmp" + + does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dylib | grep -q LC_REEXPORT_DYLIB" + link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile {{solibs}} {{libs}}" + replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $temporary_tocname $tocname" + extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }" + + command = "if $does_reexport_command ; then $link_command && $extract_toc_command > $tocname; else $link_command && $extract_toc_command > $temporary_tocname && $replace_command ; fi; fi" + + rspfile_content = "{{inputs_newline}}" + + description = "SOLINK {{output}}" + + # Use this for {{output_extension}} expansions unless a target manually + # overrides it (in which case {{output_extension}} will be what the target + # specifies). + default_output_extension = ".dylib" + + output_prefix = "lib" + + # Since the above commands only updates the .TOC file when it changes, ask + # Ninja to check if the timestamp actually changed to know if downstream + # dependencies should be recompiled. + restat = true + + # Tell GN about the output files. It will link to the dylib but use the + # tocname for dependency management. + outputs = [ + dylib, + tocname, + ] + link_output = dylib + depend_output = tocname } + tool("link") { - command = "$ld \$ldflags -o \$out -Wl,-filelist,\$rspfile \$solibs \$libs \$postbuilds" - description = "LINK \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline" - #pool = "link_pool" + outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" + rspfile = "$outfile.rsp" + command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}}" + description = "LINK $outfile" + rspfile_content = "{{inputs_newline}}" + outputs = [ outfile ] } - #tool("infoplist") { - # command = "$cc -E -P -Wno-trigraphs -x c \$defines \$in -o \$out && plutil -convert xml1 \$out \$out" - # description = "INFOPLIST \$out" - #} - #tool("mac_tool") { - # command = "\$env ./gyp-mac-tool \$mactool_cmd \$in \$out" - # description = "MACTOOL \$mactool_cmd \$in" - #} - #tool("package_framework") { - # command = "./gyp-mac-tool package-framework \$out \$version \$postbuilds && touch \$out" - # description = "PACKAGE FRAMEWORK \$out, POSTBUILDS" - #} + tool("stamp") { - command = "\${postbuilds}touch \$out" - description = "STAMP \$out" + command = "touch {{output}}" + description = "STAMP {{output}}" } + tool("copy") { - command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)" - description = "COPY \$in \$out" + command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" + description = "COPY {{source}} {{output}}" } toolchain_args() { diff --git a/chromium/build/toolchain/nacl/BUILD.gn b/chromium/build/toolchain/nacl/BUILD.gn index 362e9124ae9..8c76f5a9697 100644 --- a/chromium/build/toolchain/nacl/BUILD.gn +++ b/chromium/build/toolchain/nacl/BUILD.gn @@ -12,14 +12,14 @@ toolchain("x86_newlib") { command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out" description = "CC(NaCl x86 Newlib) \$out" depfile = "\$out.d" - deps = "gcc" + depsformat = "gcc" } tool("cxx") { # cflags_pch_cc command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" description = "CXX(NaCl x86 Newlib) \$out" depfile = "\$out.d" - deps = "gcc" + depsformat = "gcc" } tool("alink") { command = "rm -f \$out && ${toolprefix}ar rcs \$out \$in" diff --git a/chromium/build/toolchain/win/BUILD.gn b/chromium/build/toolchain/win/BUILD.gn index 11ff2f25d26..a9fab7c4c03 100644 --- a/chromium/build/toolchain/win/BUILD.gn +++ b/chromium/build/toolchain/win/BUILD.gn @@ -16,135 +16,161 @@ assert(is_win) gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) exec_script("setup_toolchain.py", - [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ], - "string") - -stamp_command = "$python_path gyp-win-tool stamp \$out" -copy_command = "$python_path gyp-win-tool recursive-mirror \$in \$out" - -# 32-bit toolchain ------------------------------------------------------------- - -toolchain("32") { - # Make these apply to all tools below. - lib_prefix = "" - lib_dir_prefix="/LIBPATH:" - - cc_command = "ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname" - tool("cc") { - command = cc_command - description = "CC \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$defines \$includes \$cflags \$cflags_c" - deps = "msvc" - } - tool("cxx") { - command = cc_command # Same as above - description = "CXX \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" - deps = "msvc" - } - tool("rc") { - command = "$python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" - description = "RC \$in" - } - tool("asm") { - command = "$python_path gyp-win-tool asm-wrapper environment.x86 ml.exe \$defines \$includes /c /Fo \$out \$in" - description = "ASM \$in" - } - tool("alink") { - command = "$python_path gyp-win-tool link-wrapper environment.x86 False lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" - description = "LIB \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline \$libflags" - } - tool("solink") { - command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 False link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" - description = "LINK(DLL) \$dll" - restat = "1" - rspfile = "\$dll.rsp" - rspfile_content = "\$libs \$in_newline \$ldflags" - } - tool("link") { - command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 False link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" - description = "LINK \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline \$libs \$ldflags" - } - tool("stamp") { - command = stamp_command - description = "STAMP \$out" - } - tool("copy") { - command = copy_command - description = "COPY \$in \$out" + [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ]) + +# This value will be inherited in the toolchain below. +concurrent_links = exec_script("../get_concurrent_links.py", [], "value") + +# Parameters: +# cpu_arch: cpu_arch to pass as a build arg +# environment: File name of environment file. +# force_win64 (optional): value for this build arg. +template("msvc_toolchain") { + if (defined(invoker.concurrent_links)) { + concurrent_links = invoker.concurrent_links } -} -# 64-bit toolchain ------------------------------------------------------------- + env = invoker.environment -toolchain("64") { - # Make these apply to all tools below. - lib_prefix = "" - lib_dir_prefix="/LIBPATH:" + toolchain(target_name) { + # Make these apply to all tools below. + lib_switch = "" + lib_dir_switch="/LIBPATH:" - cc_command = "ninja -t msvc -e environment.x64 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname" - tool("cc") { - command = cc_command - description = "CC \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$defines \$includes \$cflags \$cflags_c" - deps = "msvc" - } - tool("cxx") { - command = cc_command # Same as above - description = "CXX \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" - deps = "msvc" - } - tool("rc") { - command = "$python_path gyp-win-tool rc-wrapper environment.x64 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" - description = "RC \$in" - } - tool("asm") { - command = "$python_path gyp-win-tool asm-wrapper environment.x64 ml.exe \$defines \$includes /c /Fo \$out \$in" - description = "ASM \$in" - } - tool("alink") { - command = "$python_path gyp-win-tool link-wrapper environment.x64 False lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" - description = "LIB \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline \$libflags" - } - tool("solink") { - command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 False link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" - description = "LINK(DLL) \$dll" - restat = "1" - rspfile = "\$dll.rsp" - rspfile_content = "\$libs \$in_newline \$ldflags" - } - tool("link") { - command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 False link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" - description = "LINK \$out" - rspfile = "\$out.rsp" - rspfile_content = "\$in_newline \$libs \$ldflags" - } - tool("stamp") { - command = stamp_command - description = "STAMP \$out" - } - tool("copy") { - command = copy_command - description = "COPY \$in \$out" - } + tool("cc") { + rspfile = "{{output}}.rsp" + pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" + command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" + depsformat = "msvc" + description = "CC {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", + ] + rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" + } - # When invoking this toolchain not as the default one, these args will be - # passed to the build. They are ignored when this is the default toolchain. - toolchain_args() { - cpu_arch = "x64" - # Normally the build config resets the CPU architecture to 32-bits. Setting - # this flag overrides that behavior. - force_win64 = true + tool("cxx") { + rspfile = "{{output}}.rsp" + # The PDB name needs to be different between C and C++ compiled files. + pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" + command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" + depsformat = "msvc" + description = "CXX {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", + ] + rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" + } + + tool("rc") { + command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{include_dirs}} /fo{{output}} {{source}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.res", + ] + description = "RC {{output}}" + } + + tool("asm") { + # TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract + # assembler flags to a variable like cflags. crbug.com/418613 + command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {{include_dirs}} /safeseh /c /Fo {{output}} {{source}}" + description = "ASM {{output}}" + outputs = [ + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", + ] + } + + tool("alink") { + rspfile = "{{output}}.rsp" + command = "$python_path gyp-win-tool link-wrapper $env False lib.exe /nologo /ignore:4221 /OUT:{{output}} @$rspfile" + description = "LIB {{output}}" + outputs = [ + # Ignore {{output_extension}} and always use .lib, there's no reason to + # allow targets to override this extension on Windows. + "{{target_out_dir}}/{{target_output_name}}.lib", + ] + default_output_extension = ".lib" + # The use of inputs_newline is to work around a fixed per-line buffer + # size in the linker. + rspfile_content = "{{inputs_newline}}" + } + + tool("solink") { + dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e.g. foo.dll + libname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e.g. foo.dll.lib + rspfile = "${dllname}.rsp" + + link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" + + # TODO(brettw) support manifests + #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:${dllname}.manifest" + #command = "cmd /c $link_command && $manifest_command" + command = link_command + + default_output_extension = ".dll" + description = "LINK(DLL) {{output}}" + outputs = [ + dllname, + libname, + ] + link_output = libname + depend_output = libname + # The use of inputs_newline is to work around a fixed per-line buffer + # size in the linker. + rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" + } + + tool("link") { + rspfile = "{{output}}.rsp" + + link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /OUT:{{output}} /PDB:{{output}}.pdb @$rspfile" + + # TODO(brettw) support manifests + #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:{{output}}.manifest" + #command = "cmd /c $link_command && $manifest_command" + command = link_command + + default_output_extension = ".exe" + description = "LINK {{output}}" + outputs = [ + "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", + ] + # The use of inputs_newline is to work around a fixed per-line buffer + # size in the linker. + rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" + } + + tool("stamp") { + command = "$python_path gyp-win-tool stamp {{output}}" + description = "STAMP {{output}}" + } + + tool("copy") { + command = "$python_path gyp-win-tool recursive-mirror {{source}} {{output}}" + description = "COPY {{source}} {{output}}" + } + + # When invoking this toolchain not as the default one, these args will be + # passed to the build. They are ignored when this is the default toolchain. + toolchain_args() { + cpu_arch = invoker.cpu_arch + + # Normally the build config resets the CPU architecture to 32-bits. Setting + # this flag overrides that behavior. + if (defined(invoker.force_win64)) { + force_win64 = invoker.force_win64 + } + } } } + +msvc_toolchain("32") { + environment = "environment.x86" + cpu_arch = "x64" +} + +msvc_toolchain("64") { + environment = "environment.x64" + cpu_arch = "x64" + force_win64 = true +} diff --git a/chromium/build/toolchain/win/midl.gni b/chromium/build/toolchain/win/midl.gni index a8cf4ffdc3b..7f068d01b12 100644 --- a/chromium/build/toolchain/win/midl.gni +++ b/chromium/build/toolchain/win/midl.gni @@ -4,6 +4,8 @@ assert(is_win) +import("//build/config/win/visual_studio_version.gni") + # This template defines a rule to invoke the MS IDL compiler. # # Parameters @@ -35,7 +37,7 @@ template("midl") { type_library_file = "{{source_name_part}}.tlb" action_foreach(action_name) { - visibility = ":$source_set_name" + visibility = [ ":$source_set_name" ] # This functionality is handled by the win-tool because the GYP build has # MIDL support built-in. @@ -77,6 +79,10 @@ template("midl") { "/env", idl_target_platform, "/Oicf", ] + + foreach(include, system_include_dirs) { + args += [ "/I", include ] + } } source_set(target_name) { |