Skip to content

Commit 73295d5

Browse files
StefanStojanovicaduh95
authored andcommitted
build,win: fix VS2022 arm64 PGO build
Refs: #62761 Signed-off-by: StefanStojanovic <stefan.stojanovic@janeasystems.com> PR-URL: #63413 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
1 parent fc2c6c9 commit 73295d5

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

configure.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,18 +1749,29 @@ def configure_node(o):
17491749
msvc_dir = target_arch # 'x64' or 'arm64'
17501750

17511751
vc_tools_dir = os.environ.get('VCToolsInstallDir', '')
1752-
if vc_tools_dir:
1753-
clang_profile_lib = os.path.join(vc_tools_dir, 'lib', msvc_dir, lib_name)
1754-
if os.path.isfile(clang_profile_lib):
1755-
o['variables']['clang_profile_lib'] = clang_profile_lib
1756-
else:
1757-
raise Exception(
1758-
f'PGO profile runtime library not found at {clang_profile_lib}. '
1759-
'Ensure the ClangCL toolset is installed.')
1760-
else:
1752+
if not vc_tools_dir:
17611753
raise Exception(
17621754
'VCToolsInstallDir not set. Run from a Visual Studio command prompt.')
17631755

1756+
# Primary location: VS2026 and VS2022 x64
1757+
candidates = [os.path.join(vc_tools_dir, 'lib', msvc_dir, lib_name)]
1758+
1759+
# Secondary location: VS2022 arm64 fallback
1760+
clang_major = options.clang_cl.split('.', 1)[0]
1761+
candidates.append(os.path.normpath(os.path.join(
1762+
vc_tools_dir, '..', '..', 'Llvm', msvc_dir,
1763+
'lib', 'clang', clang_major, 'lib', 'windows', lib_name)))
1764+
1765+
clang_profile_lib = next(
1766+
(p for p in candidates if os.path.isfile(p)), None)
1767+
if clang_profile_lib:
1768+
o['variables']['clang_profile_lib'] = clang_profile_lib
1769+
else:
1770+
raise Exception(
1771+
f'PGO profile runtime library {lib_name} not found. Searched:\n ' +
1772+
'\n '.join(candidates) +
1773+
'\nEnsure the ClangCL toolset is installed.')
1774+
17641775
if flavor != 'win' and options.enable_thin_lto:
17651776
raise Exception(
17661777
'Use --enable-lto instead.')

0 commit comments

Comments
 (0)