Skip to content

Commit c70c47f

Browse files
authored
Merge pull request SCons#4534 from jcbrill/jbrill-msvc-detect
MSVC: detection fixes
2 parents 65b6268 + 5000a65 commit c70c47f

35 files changed

+3307
-733
lines changed

CHANGES.txt

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,64 @@ NOTE: Python 3.6 support is deprecated and will be dropped in a future reease.
1212

1313
RELEASE VERSION/DATE TO BE FILLED IN LATER
1414

15+
From Joseph Brill:
16+
- For msvc version specifications without an 'Exp' suffix, an express installation
17+
is used when no other edition is detected for the msvc version. Similarly, an
18+
express installation of the IDE binary is used when no other IDE edition is
19+
detected.
20+
- VS2015 Express (14.0Exp) does not support the sdk version argument. VS2015 Express
21+
does not support the store argument for target architectures other than x86.
22+
Script argument validation now takes into account these restrictions.
23+
- VS2015 BuildTools (14.0) does not support the sdk version argument and does not
24+
support the store argument. Script argument validation now takes into account
25+
these restrictions.
26+
- The Windows SDK for Windows 7 and .NET Framework 4" (SDK 7.1) populates the
27+
registry keys in a manner in which the msvc detection would report that VS2010
28+
(10.0) is installed when only the SDK was installed. The installed files are
29+
intended to be used via the sdk batch file setenv.cmd. The installed msvc
30+
batch files will fail. The msvc detection logic now ignores SDK-only VS2010
31+
installations. Similar protection is implemented for the sdk-only installs that
32+
populate the installation folder and registry keys for VS2008 (9.0), if necessary.
33+
- For VS2005 (8.0) to VS2015 (14.0), vsvarsall.bat is employed to dispatch to a
34+
dependent batch file when configuring the msvc environment. Previously, only the
35+
existence of the compiler executable was verified. In certain installations, the
36+
dependent batch file (e.g., vcvars64.bat) may not exist while the compiler
37+
executable does exist resulting in build failures. The existence of vcvarsall.bat,
38+
the dependent batch file, and the compiler executable are now validated.
39+
- MSVC configuration data specific to versions VS2005 (8.0) to VS2008 (9.0) was added
40+
as the dependent batch files have different names than the batch file names used
41+
for VS2010 (10.0) and later. The VS2008 (9.0) Visual C++ For Python installation
42+
is handled as a special case as the dependent batch files are: (a) not used and (b)
43+
in different locations.
44+
- When VS2008 (9.0) Visual C++ For Python is installed using the ALLUSERS=1 option
45+
(i.e., msiexec /i VCForPython27.msi ALLUSERS=1), the registry keys are written to
46+
HKEY_LOCAL_MACHINE rather than HKEY_CURRENT_USER. An entry was added to query the
47+
Visual C++ For Python keys in HKLM following the HKCU query, if necessary.
48+
- For VS2008, a full development edition (e.g., Professional) is now selected before
49+
a Visual C++ For Python edition. Prior to this change, Visual C++ For Python was
50+
selected before a full development edition when both editions are installed.
51+
- The registry detection of VS2015 (14.0), and earlier, is now cached at runtime and
52+
is only evaluated once for each msvc version.
53+
- The vswhere executable is frozen upon initial detection. Specifying a different
54+
vswhere executable via the construction variable VSWHERE after the initial
55+
detection now results in an exception. Multiple bugs in the implementation of
56+
specifying a vswhere executable via the construction variable VSWHERE have been
57+
fixed. Previously, when a user specified vswhere executable detects new msvc
58+
installations after the initial detection, the internal msvc installation cache
59+
and the default msvc version based on the initial detection are no longer valid.
60+
For example, when no vswhere executable is found for the initial detection
61+
and then later an environment is constructed with a user specified vswhere
62+
executable that detects new msvc installations.
63+
- The vswhere detection of VS2017 (14.1), and later, is now cached at runtime and is
64+
only evaluated once using a single vswhere invocation for all msvc versions.
65+
Previously, the vswhere executable was invoked for each supported msvc version.
66+
- The vswhere executable locations for the WinGet and Scoop package managers were
67+
added to the default vswhere executable search list after the Chocolatey
68+
installation location.
69+
- Fix issue #4543: add support for msvc toolset versions 14.4X installed as the
70+
latest msvc toolset versions for msvc buildtools v143. The v143 msvc buildtools
71+
may contain msvc toolset versions from 14.30 to 14.4X.
72+
1573
From Thaddeus Crews:
1674
- GetSConsVersion() to grab the latest SCons version without needing to
1775
access SCons internals.
@@ -1490,7 +1548,7 @@ RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000
14901548
in the case where a child process is spawned while a Python action has a
14911549
file open. Original author: Ryan Beasley.
14921550
- Added memoization support for calls to Environment.Value() in order to
1493-
improve performance of repeated calls.
1551+
improve performance of repeated calls.
14941552

14951553

14961554
From Jason Kenny

RELEASE.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
4444
of CCFLAGS; the latter variable could cause a compiler warning.
4545
- The implementation of Variables was slightly refactored, there should
4646
not be user-visible changes.
47+
- MSVC: For msvc version specifications without an 'Exp' suffix, an express
48+
installation is used when no other edition is detected for the msvc version.
49+
This was the behavior for Visual Studio 2008 (9.0) through Visual Studio 2015
50+
(14.0). This behavior was extended to Visual Studio 2017 (14.1) and Visual
51+
Studio 2008 (8.0). An express installation of the IDE binary is used when no
52+
other IDE edition is detected.
53+
- The vswhere executable locations for the WinGet and Scoop package managers were
54+
added to the default vswhere executable search list after the Chocolatey
55+
installation location.
4756
- SCons.Environment.is_valid_construction_var() now returns a boolean to
4857
match the convention that functions beginning with "is" have yes/no
4958
answers (previously returned either None or an re.match object).
@@ -73,6 +82,37 @@ FIXES
7382
- Improved the conversion of a "foreign" exception from an action
7483
into BuildError by making sure our defaults get applied even in
7584
corner cases. Fixes Issue #4530
85+
- MSVC: Visual Studio 2010 (10.0) could be inadvertently detected due to an
86+
sdk-only install of Windows SDK 7.1. An sdk-only install of Visual Studio
87+
2010 is ignored as the msvc batch files will fail. The installed files are
88+
intended to be used in conjunction with the SDK batch file. Similar protection
89+
was added for Visual Studio 2008 (9.0).
90+
- MSVC: For Visual Studio 2005 (8.0) to Visual Studio 2015 (14.0), detection of
91+
installed files was expanded to include the primary msvc batch file, dependent
92+
msvc batch file, and compiler executable. In certain installations, the
93+
dependent msvc batch file may not exist while the compiler executable does exist
94+
resulting in a build failure.
95+
- MSVC: Visual Studio 2008 (9.0) Visual C++ For Python was not detected when
96+
installed using the ALLUSERS command-line option:
97+
msiexec /i VCForPython27.msi ALLUSERS=1
98+
When installed for all users, Visual Studio 2008 (9.0) Visual C++ For Python is
99+
now correctly detected.
100+
- MSVC: For Visual Studio 2008 (9.0), a full development edition (e.g., Professional)
101+
is now selected before a Visual C++ For Python edition. Prior to this change,
102+
Visual C++ For Python was selected before a full development edition when both
103+
editions are installed.
104+
- The vswhere executable is frozen upon initial detection. Specifying a different
105+
vswhere executable via the construction variable VSWHERE after the initial
106+
detection now results in an exception. Multiple bugs in the implementation of
107+
specifying a vswhere executable via the construction variable VSWHERE have been
108+
fixed. Previously, when a user specified vswhere executable detects new msvc
109+
installations after the initial detection, the internal msvc installation cache
110+
and the default msvc version based on the initial detection are no longer valid.
111+
For example, when no vswhere executable is found for the initial detection
112+
and then later an environment is constructed with a user specified vswhere
113+
executable that detects new msvc installations.
114+
- MSVC: Visual Studio 2022 v143 BuildTools now supports msvc toolset versions from
115+
14.30 to 14.4X. Fixes Issue #4543.
76116
- The Clone() method now respects the variables argument (fixes #3590)
77117

78118
IMPROVEMENTS
@@ -84,6 +124,17 @@ IMPROVEMENTS
84124
- Performance tweak: the __setitem__ method of an Environment, used for
85125
setting construction variables, now uses the string method isidentifier
86126
to validate the name (updated from microbenchmark results).
127+
- MSVC: Visual Studio 2015 Express (14.0Exp) does not support the sdk version
128+
argument. Visual Studio 2015 Express does not support the store argument for
129+
target architectures other than x86. Script argument validation now takes into
130+
account these restrictions.
131+
- MSVC: Visual Studio 2015 BuildTools (14.0) does not support the sdk version
132+
argument and does not support the store argument. Script argument validation now
133+
takes into account these restrictions.
134+
- MSVC: The registry detection of VS2015 (14.0), and earlier, is now cached at runtime
135+
and is only evaluated once for each msvc version.
136+
- MSVC: The vswhere detection of VS2017 (14.1), and later, is now cached at runtime and
137+
is only evaluated once using a single vswhere invocation for all msvc versions.
87138

88139
PACKAGING
89140
---------

SCons/Tool/MSCommon/MSVC/Config.py

Lines changed: 100 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -118,59 +118,126 @@
118118
for vc_runtime_alias in vc_runtime_alias_list:
119119
MSVC_RUNTIME_EXTERNAL[vc_runtime_alias] = vc_runtime_def
120120

121-
MSVC_BUILDTOOLS_DEFINITION = namedtuple('MSVCBuildtools', [
122-
'vc_buildtools',
123-
'vc_buildtools_numeric',
121+
MSVC_BUILDSERIES_DEFINITION = namedtuple('MSVCBuildSeries', [
122+
'vc_buildseries',
123+
'vc_buildseries_numeric',
124124
'vc_version',
125125
'vc_version_numeric',
126126
'cl_version',
127127
'cl_version_numeric',
128+
])
129+
130+
MSVC_BUILDSERIES_DEFINITION_LIST = []
131+
132+
MSVC_BUILDSERIES_INTERNAL = {}
133+
MSVC_BUILDSERIES_EXTERNAL = {}
134+
135+
VC_BUILDTOOLS_MAP = {}
136+
137+
VC_VERSION_MAP = {}
138+
CL_VERSION_MAP = {}
139+
140+
for (vc_buildseries, vc_version, cl_version) in [
141+
('144', '14.4', '19.4'),
142+
('143', '14.3', '19.3'),
143+
('142', '14.2', '19.2'),
144+
('141', '14.1', '19.1'),
145+
('140', '14.0', '19.0'),
146+
('120', '12.0', '18.0'),
147+
('110', '11.0', '17.0'),
148+
('100', '10.0', '16.0'),
149+
('90', '9.0', '15.0'),
150+
('80', '8.0', '14.0'),
151+
('71', '7.1', '13.1'),
152+
('70', '7.0', '13.0'),
153+
('60', '6.0', '12.0'),
154+
]:
155+
156+
vc_buildseries_def = MSVC_BUILDSERIES_DEFINITION(
157+
vc_buildseries=vc_buildseries,
158+
vc_buildseries_numeric=int(vc_buildseries),
159+
vc_version=vc_version,
160+
vc_version_numeric=float(vc_version),
161+
cl_version=cl_version,
162+
cl_version_numeric=float(cl_version),
163+
)
164+
165+
MSVC_BUILDSERIES_DEFINITION_LIST.append(vc_buildseries_def)
166+
167+
MSVC_BUILDSERIES_INTERNAL[vc_buildseries] = vc_buildseries_def
168+
MSVC_BUILDSERIES_EXTERNAL[vc_buildseries] = vc_buildseries_def
169+
MSVC_BUILDSERIES_EXTERNAL[vc_version] = vc_buildseries_def
170+
171+
VC_VERSION_MAP[vc_version] = vc_buildseries_def
172+
CL_VERSION_MAP[cl_version] = vc_buildseries_def
173+
174+
MSVC_BUILDTOOLS_DEFINITION = namedtuple('MSVCBuildtools', [
175+
'vc_buildtools',
176+
'vc_buildtools_numeric',
177+
'vc_buildseries_list',
128178
'vc_runtime_def',
129179
'vc_istoolset',
180+
'msvc_version',
181+
'msvc_version_numeric',
130182
])
131183

132184
MSVC_BUILDTOOLS_DEFINITION_LIST = []
133185

134186
MSVC_BUILDTOOLS_INTERNAL = {}
135187
MSVC_BUILDTOOLS_EXTERNAL = {}
136188

137-
VC_VERSION_MAP = {}
138-
139-
for vc_buildtools, vc_version, cl_version, vc_runtime, vc_istoolset in [
140-
('v143', '14.3', '19.3', '140', True),
141-
('v142', '14.2', '19.2', '140', True),
142-
('v141', '14.1', '19.1', '140', True),
143-
('v140', '14.0', '19.0', '140', True),
144-
('v120', '12.0', '18.0', '120', False),
145-
('v110', '11.0', '17.0', '110', False),
146-
('v100', '10.0', '16.0', '100', False),
147-
('v90', '9.0', '15.0', '90', False),
148-
('v80', '8.0', '14.0', '80', False),
149-
('v71', '7.1', '13.1', '71', False),
150-
('v70', '7.0', '13.0', '70', False),
151-
('v60', '6.0', '12.0', '60', False),
189+
MSVC_VERSION_NEWEST = None
190+
MSVC_VERSION_NEWEST_NUMERIC = 0.0
191+
192+
for vc_buildtools, vc_buildseries_list, vc_runtime, vc_istoolset in [
193+
('v143', ['144', '143'], '140', True),
194+
('v142', ['142'], '140', True),
195+
('v141', ['141'], '140', True),
196+
('v140', ['140'], '140', True),
197+
('v120', ['120'], '120', False),
198+
('v110', ['110'], '110', False),
199+
('v100', ['100'], '100', False),
200+
('v90', ['90'], '90', False),
201+
('v80', ['80'], '80', False),
202+
('v71', ['71'], '71', False),
203+
('v70', ['70'], '70', False),
204+
('v60', ['60'], '60', False),
152205
]:
153206

154207
vc_runtime_def = MSVC_RUNTIME_INTERNAL[vc_runtime]
155208

209+
vc_buildseries_list = tuple(
210+
MSVC_BUILDSERIES_INTERNAL[vc_buildseries]
211+
for vc_buildseries in vc_buildseries_list
212+
)
213+
214+
vc_buildtools_numstr = vc_buildtools[1:]
215+
216+
msvc_version = vc_buildtools_numstr[:-1] + '.' + vc_buildtools_numstr[-1]
217+
msvc_version_numeric = float(msvc_version)
218+
156219
vc_buildtools_def = MSVC_BUILDTOOLS_DEFINITION(
157220
vc_buildtools = vc_buildtools,
158221
vc_buildtools_numeric = int(vc_buildtools[1:]),
159-
vc_version = vc_version,
160-
vc_version_numeric = float(vc_version),
161-
cl_version = cl_version,
162-
cl_version_numeric = float(cl_version),
222+
vc_buildseries_list = vc_buildseries_list,
163223
vc_runtime_def = vc_runtime_def,
164224
vc_istoolset = vc_istoolset,
225+
msvc_version = msvc_version,
226+
msvc_version_numeric = msvc_version_numeric,
165227
)
166228

167229
MSVC_BUILDTOOLS_DEFINITION_LIST.append(vc_buildtools_def)
168230

169231
MSVC_BUILDTOOLS_INTERNAL[vc_buildtools] = vc_buildtools_def
170232
MSVC_BUILDTOOLS_EXTERNAL[vc_buildtools] = vc_buildtools_def
171-
MSVC_BUILDTOOLS_EXTERNAL[vc_version] = vc_buildtools_def
233+
MSVC_BUILDTOOLS_EXTERNAL[msvc_version] = vc_buildtools_def
234+
235+
for vc_buildseries_def in vc_buildseries_list:
236+
VC_BUILDTOOLS_MAP[vc_buildseries_def.vc_buildseries] = vc_buildtools_def
172237

173-
VC_VERSION_MAP[vc_version] = vc_buildtools_def
238+
if vc_buildtools_def.msvc_version_numeric > MSVC_VERSION_NEWEST_NUMERIC:
239+
MSVC_VERSION_NEWEST_NUMERIC = vc_buildtools_def.msvc_version_numeric
240+
MSVC_VERSION_NEWEST = vc_buildtools_def.msvc_version
174241

175242
MSVS_VERSION_INTERNAL = {}
176243
MSVS_VERSION_EXTERNAL = {}
@@ -181,8 +248,6 @@
181248

182249
MSVS_VERSION_MAJOR_MAP = {}
183250

184-
CL_VERSION_MAP = {}
185-
186251
MSVC_SDK_VERSIONS = set()
187252

188253
VISUALSTUDIO_DEFINITION = namedtuple('VisualStudioDefinition', [
@@ -247,15 +312,15 @@
247312

248313
vc_buildtools_def.vc_runtime_def.vc_runtime_vsdef_list.append(vs_def)
249314

250-
vc_version = vc_buildtools_def.vc_version
315+
msvc_version = vc_buildtools_def.msvc_version
251316

252317
MSVS_VERSION_INTERNAL[vs_product] = vs_def
253318
MSVS_VERSION_EXTERNAL[vs_product] = vs_def
254319
MSVS_VERSION_EXTERNAL[vs_version] = vs_def
255320

256-
MSVC_VERSION_INTERNAL[vc_version] = vs_def
321+
MSVC_VERSION_INTERNAL[msvc_version] = vs_def
257322
MSVC_VERSION_EXTERNAL[vs_product] = vs_def
258-
MSVC_VERSION_EXTERNAL[vc_version] = vs_def
323+
MSVC_VERSION_EXTERNAL[msvc_version] = vs_def
259324
MSVC_VERSION_EXTERNAL[vc_buildtools_def.vc_buildtools] = vs_def
260325

261326
if vs_product in VS_PRODUCT_ALIAS:
@@ -264,14 +329,12 @@
264329
MSVS_VERSION_EXTERNAL[vs_product_alias] = vs_def
265330
MSVC_VERSION_EXTERNAL[vs_product_alias] = vs_def
266331

267-
MSVC_VERSION_SUFFIX[vc_version] = vs_def
332+
MSVC_VERSION_SUFFIX[msvc_version] = vs_def
268333
if vs_express:
269-
MSVC_VERSION_SUFFIX[vc_version + 'Exp'] = vs_def
334+
MSVC_VERSION_SUFFIX[msvc_version + 'Exp'] = vs_def
270335

271336
MSVS_VERSION_MAJOR_MAP[vs_version_major] = vs_def
272337

273-
CL_VERSION_MAP[vc_buildtools_def.cl_version] = vs_def
274-
275338
if vc_sdk:
276339
MSVC_SDK_VERSIONS.update(vc_sdk)
277340

@@ -292,7 +355,7 @@
292355
for vs_def in VISUALSTUDIO_DEFINITION_LIST:
293356
if not vs_def.vc_buildtools_def.vc_istoolset:
294357
continue
295-
version_key = vs_def.vc_buildtools_def.vc_version
358+
version_key = vs_def.vc_buildtools_def.msvc_version
296359
MSVC_VERSION_TOOLSET_DEFAULTS_MAP[version_key] = [version_key]
297360
MSVC_VERSION_TOOLSET_SEARCH_MAP[version_key] = []
298361
if vs_def.vs_express:
@@ -305,11 +368,11 @@
305368
for vs_def in VISUALSTUDIO_DEFINITION_LIST:
306369
if not vs_def.vc_buildtools_def.vc_istoolset:
307370
continue
308-
version_key = vs_def.vc_buildtools_def.vc_version
371+
version_key = vs_def.vc_buildtools_def.msvc_version
309372
for vc_buildtools in vs_def.vc_buildtools_all:
310373
toolset_buildtools_def = MSVC_BUILDTOOLS_INTERNAL[vc_buildtools]
311-
toolset_vs_def = MSVC_VERSION_INTERNAL[toolset_buildtools_def.vc_version]
312-
buildtools_key = toolset_buildtools_def.vc_version
374+
toolset_vs_def = MSVC_VERSION_INTERNAL[toolset_buildtools_def.msvc_version]
375+
buildtools_key = toolset_buildtools_def.msvc_version
313376
MSVC_VERSION_TOOLSET_SEARCH_MAP[buildtools_key].extend(MSVC_VERSION_TOOLSET_DEFAULTS_MAP[version_key])
314377

315378
# convert string version set to string version list ranked in descending order

0 commit comments

Comments
 (0)