Commit f7d47b7e authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

Do not use tool-wrapper for lld link

When building chrome on windows, tool-wrapper for linking is called 794 times.
And I found that calling python wrapper is relatively slow than calling link via ninja.

This CL replaces python wrapper to ninja wrapper to remove such overhead when we use lld.

I compared time of wrapper invocation using following powershell script.

for ($i = 0; $i -lt 100; $i++) {
    # ninja -t msvc -e environment.x64 -- C:/src/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe -c ' '
    # python.exe ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False C:/src/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe -c ' ' # code for FlushFileBuffers is commented out.
}

* ninja wrapper, 7.451s for 100 invocation
* python wrapper, 17.803s for 100 invocation
Using ninja as env wrapper is more than 2 times faster.

Bug: 787903
Change-Id: I6531b59a6c43085782b0138a264ecfc9a6f65833
Reviewed-on: https://chromium-review.googlesource.com/1107678
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568836}
parent 3f5f5357
...@@ -133,6 +133,18 @@ template("msvc_toolchain") { ...@@ -133,6 +133,18 @@ template("msvc_toolchain") {
sys_include_flags = "" sys_include_flags = ""
} }
if (use_lld) {
# Invoke ninja as wrapper instead of tool wrapper, because python
# invocation requires higher cpu usage compared to ninja invocation, and
# the python wrapper is only needed to work around link.exe problems.
# TODO(thakis): Remove wrapper once lld-link can merge manifests without
# relying on mt.exe being in %PATH% on Windows.
linker_wrapper = "ninja -t msvc -e $env -- " # Note trailing space.
} else {
linker_wrapper =
"$python_path $tool_wrapper_path link-wrapper $env False " # Note trailing space.
}
clflags = "" clflags = ""
# Pass /FC flag to the compiler if needed. # Pass /FC flag to the compiler if needed.
...@@ -196,7 +208,8 @@ template("msvc_toolchain") { ...@@ -196,7 +208,8 @@ template("msvc_toolchain") {
tool("alink") { tool("alink") {
rspfile = "{{output}}.rsp" rspfile = "{{output}}.rsp"
command = "$python_path $tool_wrapper_path link-wrapper $env False $lib /nologo {{arflags}} /OUT:{{output}} @$rspfile" command =
"$linker_wrapper$lib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
description = "LIB {{output}}" description = "LIB {{output}}"
outputs = [ outputs = [
# Ignore {{output_extension}} and always use .lib, there's no reason to # Ignore {{output_extension}} and always use .lib, there's no reason to
...@@ -218,7 +231,7 @@ template("msvc_toolchain") { ...@@ -218,7 +231,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp" rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" command = "$linker_wrapper$link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll" default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}" default_output_dir = "{{root_out_dir}}"
...@@ -251,7 +264,7 @@ template("msvc_toolchain") { ...@@ -251,7 +264,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp" rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" command = "$linker_wrapper$link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll" default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}" default_output_dir = "{{root_out_dir}}"
...@@ -275,7 +288,8 @@ template("msvc_toolchain") { ...@@ -275,7 +288,8 @@ template("msvc_toolchain") {
rspfile = "$exename.rsp" rspfile = "$exename.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$python_path $tool_wrapper_path link-wrapper $env False $link /nologo /OUT:$exename /PDB:$pdbname @$rspfile" command =
"$linker_wrapper$link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
if (host_os == "win") { if (host_os == "win") {
shellprefix = "cmd /c" shellprefix = "cmd /c"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment