Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build/toolchain/win/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ if (target_cpu == "arm64") {
win_toolchains("arm64") {
toolchain_arch = "arm64"
}
win_toolchains(host_cpu) {
toolchain_arch = host_cpu
# Cross-compilation support for x64 hosts.
if (host_cpu != "arm64") {
win_toolchains(host_cpu) {
toolchain_arch = host_cpu
}
}
}
7 changes: 6 additions & 1 deletion build/toolchain/win/setup_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ def _SetupScript(target_cpu, sdk_dir):
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
'/' + target_cpu]
else:
vcvars_arch = {
'x86': 'amd64_x86',
'x64': 'amd64',
'arm64': 'amd64_arm64',
}
# We only support x64-hosted tools.
# TODO(scottmg|dpranke): Non-depot_tools toolchain: need to get Visual
# Studio install location from registry.
return [os.path.normpath(os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
'VC/Auxiliary/Build/vcvarsall.bat')),
'amd64_x86' if target_cpu == 'x86' else 'amd64']
vcvars_arch[target_cpu]]


def _FormatAsEnvironmentBlock(envvar_dict):
Expand Down
16 changes: 13 additions & 3 deletions build/vs_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
('2022', '17.0'),
])

VC_VERSIONS = {
'2017': 'VC141',
'2019': 'VC142',
'2022': 'VC143',
}


def SetEnvironmentAndGetRuntimeDllDirs():
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and
Expand Down Expand Up @@ -247,15 +253,19 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
"""Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
exist, but the target directory does exist."""
if target_cpu == 'arm64':
env_version = GetVisualStudioVersion()
vc_version = VC_VERSIONS[env_version]
prefix = 'Microsoft.' + vc_version

# Windows ARM64 VCRuntime is located at {toolchain_root}/VC/Redist/MSVC/
# {x.y.z}/[debug_nonredist/]arm64/Microsoft.VC141.CRT/.
# {x.y.z}/[debug_nonredist/]arm64/Microsoft.VC14{1,2,3}.CRT/.
vc_redist_root = FindVCRedistRoot()
if suffix.startswith('.'):
source_dir = os.path.join(vc_redist_root,
'arm64', 'Microsoft.VC141.CRT')
'arm64', prefix + '.CRT')
else:
source_dir = os.path.join(vc_redist_root, 'debug_nonredist',
'arm64', 'Microsoft.VC141.DebugCRT')
'arm64', prefix + '.DebugCRT')
for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
dll = dll_pattern % file_part
target = os.path.join(target_dir, dll)
Expand Down