Commit 054eb914 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

Do not use wrapper for link in win cross build

This is follow up of
https://chromium.googlesource.com/chromium/src/+/f7d47b7e8c03400343d4b6753ff79ade9d09ca68

This CL specifies libpath explicitly for LIB directories.

Bug: 854849, 787903
Change-Id: I9b65b0c0980af1f7eb4ece2ffbb31d8bde44e7ce
Reviewed-on: https://chromium-review.googlesource.com/1109452
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569486}
parent 5b0cf18c
......@@ -133,16 +133,23 @@ template("msvc_toolchain") {
sys_include_flags = ""
}
if (use_lld) {
# ninja does not have -t msvc other than windows, and lld doesn't depend on
# mt.exe in PATH on non-Windows, so it's not needed there anyways.
if (defined(invoker.sys_lib_flags)) {
linker_wrapper = ""
sys_lib_flags = "${invoker.sys_lib_flags} " # Note trailing space
} else 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.
sys_lib_flags = ""
} else {
linker_wrapper =
"$python_path $tool_wrapper_path link-wrapper $env False " # Note trailing space.
sys_lib_flags = ""
}
clflags = ""
......@@ -208,8 +215,7 @@ template("msvc_toolchain") {
tool("alink") {
rspfile = "{{output}}.rsp"
command =
"$linker_wrapper$lib /nologo {{arflags}} /OUT:{{output}} @$rspfile"
command = "$linker_wrapper$lib /nologo ${sys_lib_flags}{{arflags}} /OUT:{{output}} @$rspfile"
description = "LIB {{output}}"
outputs = [
# Ignore {{output_extension}} and always use .lib, there's no reason to
......@@ -231,7 +237,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$linker_wrapper$link /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
command = "$linker_wrapper$link /nologo ${sys_lib_flags}/IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}"
......@@ -264,7 +270,7 @@ template("msvc_toolchain") {
rspfile = "${dllname}.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command = "$linker_wrapper$link /nologo /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
command = "$linker_wrapper$link /nologo ${sys_lib_flags}/DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
default_output_extension = ".dll"
default_output_dir = "{{root_out_dir}}"
......@@ -288,8 +294,7 @@ template("msvc_toolchain") {
rspfile = "$exename.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
command =
"$linker_wrapper$link /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
command = "$linker_wrapper$link /nologo ${sys_lib_flags}/OUT:$exename /PDB:$pdbname @$rspfile"
if (host_os == "win") {
shellprefix = "cmd /c"
......@@ -373,6 +378,10 @@ if (win_build_host_cpu != "x64") {
msvc_toolchain(win_build_host_cpu) {
environment = "environment." + win_build_host_cpu
cl = "${goma_prefix}\"${build_cpu_toolchain_data.vc_bin_dir}/cl.exe\""
if (host_os != "win") {
# For win cross build.
sys_lib_flags = "${build_cpu_toolchain_data.libpath_flags}"
}
toolchain_args = {
current_os = "win"
current_cpu = win_build_host_cpu
......@@ -385,6 +394,10 @@ if (win_build_host_cpu != "x64") {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
cl = "${goma_prefix}$prefix/${clang_cl}"
sys_include_flags = "${build_cpu_toolchain_data.include_flags_imsvc}"
if (host_os != "win") {
# For win cross build.
sys_lib_flags = "${build_cpu_toolchain_data.libpath_flags}"
}
toolchain_args = {
current_os = "win"
......@@ -410,6 +423,10 @@ template("win_x64_toolchains") {
msvc_toolchain(target_name) {
environment = "environment.x64"
cl = "${goma_prefix}\"${x64_toolchain_data.vc_bin_dir}/cl.exe\""
if (host_os != "win") {
# For win cross build
sys_lib_flags = "${x64_toolchain_data.libpath_flags}"
}
toolchain_args = {
if (defined(invoker.toolchain_args)) {
......@@ -426,6 +443,10 @@ template("win_x64_toolchains") {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
cl = "${goma_prefix}$prefix/${clang_cl}"
sys_include_flags = "${x64_toolchain_data.include_flags_imsvc}"
if (host_os != "win") {
# For win cross build
sys_lib_flags = "${x64_toolchain_data.libpath_flags}"
}
toolchain_args = {
if (defined(invoker.toolchain_args)) {
......
......@@ -207,6 +207,7 @@ def main():
vc_lib_atlmfc_path = ''
vc_lib_um_path = ''
include = ''
lib = ''
# TODO(scottmg|goma): Do we need an equivalent of
# ninja_use_custom_environment_files?
......@@ -247,10 +248,18 @@ def main():
except ValueError:
pass
lib = [p.replace('"', r'\"') for p in env['LIB'].split(';') if p]
# Make lib path relative to builddir when cwd and sdk in same drive.
try:
lib = map(os.path.relpath, lib)
except ValueError:
pass
def q(s): # Quote s if it contains spaces or other weird characters.
return s if re.match(r'^[a-zA-Z0-9._/\\:-]*$', s) else '"' + s + '"'
include_I = ' '.join([q('/I' + i) for i in include])
include_imsvc = ' '.join([q('-imsvc' + i) for i in include])
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
if (environment_block_name != ''):
env_block = _FormatAsEnvironmentBlock(env)
......@@ -275,6 +284,9 @@ def main():
assert vc_lib_um_path
print 'vc_lib_um_path = ' + gn_helpers.ToGNString(vc_lib_um_path)
print 'paths = ' + gn_helpers.ToGNString(env['PATH'])
assert libpath_flags
print 'libpath_flags = ' + gn_helpers.ToGNString(libpath_flags)
if __name__ == '__main__':
main()
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